From 6f38a86d9ac0f576bd91d7ab04fc910a16bf21aa Mon Sep 17 00:00:00 2001 From: jagannatharjun Date: Fri, 1 May 2020 23:55:30 +0530 Subject: [PATCH] Align Properties Tabbar in center --- src/gui/properties/propertieswidget.cpp | 9 +++++++-- src/gui/properties/propertieswidget.h | 1 + src/gui/properties/propertieswidget.ui | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index e4e89680f..c8443de08 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -76,6 +76,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent) : QWidget(parent) , m_ui(new Ui::PropertiesWidget()) , m_torrent(nullptr) + , m_handleWidth(-1) { m_ui->setupUi(this); setAutoFillBackground(true); @@ -144,7 +145,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent) m_ui->vBoxLayoutPeerPage->addWidget(m_peerList); // Tab bar 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); connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex); connect(m_tabBar, &PropTabBar::tabChanged, this, &PropertiesWidget::saveSettings); @@ -192,7 +193,7 @@ void PropertiesWidget::showPiecesDownloaded(bool show) m_ui->lineBelowBars->setVisible(show); } -void PropertiesWidget::setVisibility(bool visible) +void PropertiesWidget::setVisibility(const bool visible) { if (!visible && (m_state == VISIBLE)) { const int tabBarHeight = m_tabBar->geometry().height(); // take height before hiding @@ -201,6 +202,8 @@ void PropertiesWidget::setVisibility(bool visible) m_slideSizes = hSplitter->sizes(); hSplitter->handle(1)->setVisible(false); hSplitter->handle(1)->setDisabled(true); + m_handleWidth = hSplitter->handleWidth(); + hSplitter->setHandleWidth(0); const QList sizes {(hSplitter->geometry().height() - tabBarHeight), tabBarHeight}; hSplitter->setSizes(sizes); setMaximumSize(maximumSize().width(), tabBarHeight); @@ -211,6 +214,8 @@ void PropertiesWidget::setVisibility(bool visible) if (visible && (m_state == REDUCED)) { m_ui->stackedProperties->setVisible(true); auto *hSplitter = static_cast(parentWidget()); + if (m_handleWidth != -1) + hSplitter->setHandleWidth(m_handleWidth); hSplitter->handle(1)->setDisabled(false); hSplitter->handle(1)->setVisible(true); hSplitter->setSizes(m_slideSizes); diff --git a/src/gui/properties/propertieswidget.h b/src/gui/properties/propertieswidget.h index 0e59b1124..673e8f718 100644 --- a/src/gui/properties/propertieswidget.h +++ b/src/gui/properties/propertieswidget.h @@ -123,6 +123,7 @@ private: PieceAvailabilityBar *m_piecesAvailability; PropTabBar *m_tabBar; LineEdit *m_contentFilterLine; + int m_handleWidth; }; #endif // PROPERTIESWIDGET_H diff --git a/src/gui/properties/propertieswidget.ui b/src/gui/properties/propertieswidget.ui index 4f8d46e4f..1918472a6 100644 --- a/src/gui/properties/propertieswidget.ui +++ b/src/gui/properties/propertieswidget.ui @@ -23,6 +23,9 @@ 0 + + 0 +