Browse Source

Merge pull request #11618 from jagannatharjun/align

Align Properties Tabbar in center
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
2c100feb35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/gui/properties/propertieswidget.cpp
  2. 1
      src/gui/properties/propertieswidget.h
  3. 3
      src/gui/properties/propertieswidget.ui

9
src/gui/properties/propertieswidget.cpp

@ -75,6 +75,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_ui(new Ui::PropertiesWidget()) , m_ui(new Ui::PropertiesWidget())
, m_torrent(nullptr) , m_torrent(nullptr)
, m_handleWidth(-1)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAutoFillBackground(true); setAutoFillBackground(true);
@ -143,7 +144,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent)
m_ui->vBoxLayoutPeerPage->addWidget(m_peerList); m_ui->vBoxLayoutPeerPage->addWidget(m_peerList);
// Tab bar // Tab bar
m_tabBar = new PropTabBar(nullptr); m_tabBar = new PropTabBar(nullptr);
m_tabBar->setContentsMargins(0, 5, 0, 0); m_tabBar->setContentsMargins(0, 5, 0, 5);
m_ui->verticalLayout->addLayout(m_tabBar); m_ui->verticalLayout->addLayout(m_tabBar);
connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex); connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex);
connect(m_tabBar, &PropTabBar::tabChanged, this, &PropertiesWidget::saveSettings); connect(m_tabBar, &PropTabBar::tabChanged, this, &PropertiesWidget::saveSettings);
@ -191,7 +192,7 @@ void PropertiesWidget::showPiecesDownloaded(bool show)
m_ui->lineBelowBars->setVisible(show); m_ui->lineBelowBars->setVisible(show);
} }
void PropertiesWidget::setVisibility(bool visible) void PropertiesWidget::setVisibility(const bool visible)
{ {
if (!visible && (m_state == VISIBLE)) { if (!visible && (m_state == VISIBLE)) {
const int tabBarHeight = m_tabBar->geometry().height(); // take height before hiding const int tabBarHeight = m_tabBar->geometry().height(); // take height before hiding
@ -200,6 +201,8 @@ void PropertiesWidget::setVisibility(bool visible)
m_slideSizes = hSplitter->sizes(); m_slideSizes = hSplitter->sizes();
hSplitter->handle(1)->setVisible(false); hSplitter->handle(1)->setVisible(false);
hSplitter->handle(1)->setDisabled(true); hSplitter->handle(1)->setDisabled(true);
m_handleWidth = hSplitter->handleWidth();
hSplitter->setHandleWidth(0);
const QList<int> sizes {(hSplitter->geometry().height() - tabBarHeight), tabBarHeight}; const QList<int> sizes {(hSplitter->geometry().height() - tabBarHeight), tabBarHeight};
hSplitter->setSizes(sizes); hSplitter->setSizes(sizes);
setMaximumSize(maximumSize().width(), tabBarHeight); setMaximumSize(maximumSize().width(), tabBarHeight);
@ -210,6 +213,8 @@ void PropertiesWidget::setVisibility(bool visible)
if (visible && (m_state == REDUCED)) { if (visible && (m_state == REDUCED)) {
m_ui->stackedProperties->setVisible(true); m_ui->stackedProperties->setVisible(true);
auto *hSplitter = static_cast<QSplitter *>(parentWidget()); auto *hSplitter = static_cast<QSplitter *>(parentWidget());
if (m_handleWidth != -1)
hSplitter->setHandleWidth(m_handleWidth);
hSplitter->handle(1)->setDisabled(false); hSplitter->handle(1)->setDisabled(false);
hSplitter->handle(1)->setVisible(true); hSplitter->handle(1)->setVisible(true);
hSplitter->setSizes(m_slideSizes); hSplitter->setSizes(m_slideSizes);

1
src/gui/properties/propertieswidget.h

@ -123,6 +123,7 @@ private:
PieceAvailabilityBar *m_piecesAvailability; PieceAvailabilityBar *m_piecesAvailability;
PropTabBar *m_tabBar; PropTabBar *m_tabBar;
LineEdit *m_contentFilterLine; LineEdit *m_contentFilterLine;
int m_handleWidth;
}; };
#endif // PROPERTIESWIDGET_H #endif // PROPERTIESWIDGET_H

3
src/gui/properties/propertieswidget.ui

@ -23,6 +23,9 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing">
<number>0</number>
</property>
<item> <item>
<widget class="QStackedWidget" name="stackedProperties"> <widget class="QStackedWidget" name="stackedProperties">
<property name="currentIndex"> <property name="currentIndex">

Loading…
Cancel
Save