Commit b5c741d2 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Fix unused empty space on tabbar if separate tab close button is disabled

BUG: 382056
FIXED-IN: 1.8.21121
parent 4e5f1ed4
Pipeline #116235 passed with stage
in 1 minute and 35 seconds
......@@ -222,11 +222,11 @@ void ViewContainer::setupTabWidget()
m_vbox->hide();
auto* closeBtn = new QToolButton(m_tabWidget);
closeBtn->setIcon(QIcon::fromTheme(QStringLiteral("tab-close")));
closeBtn->adjustSize();
m_tabWidget->setCornerWidget(closeBtn, Qt::BottomRightCorner);
connect(closeBtn, &QAbstractButton::clicked, this, &ViewContainer::closeCurrentView);
m_tabCloseButton = new QToolButton(m_tabWidget);
m_tabCloseButton->setIcon(QIcon::fromTheme(QStringLiteral("tab-close")));
m_tabCloseButton->adjustSize();
m_tabWidget->setCornerWidget(m_tabCloseButton, Qt::BottomRightCorner);
connect(m_tabCloseButton, &QAbstractButton::clicked, this, &ViewContainer::closeCurrentView);
connect(m_tabWidget, &QTabWidget::currentChanged, this, &ViewContainer::viewSwitched);
connect(m_tabWidget->tabBar(), &QTabBar::tabCloseRequested, this, QOverload<int>::of(&ViewContainer::closeView));
......@@ -695,10 +695,24 @@ void ViewContainer::updateTabWidgetAppearance()
m_tabWidget->setTabPosition((Preferences::self()->tabPlacement()==Preferences::Top) ?
QTabWidget::North : QTabWidget::South);
if (Preferences::self()->showTabBarCloseButton() && !noTabBar)
m_tabWidget->cornerWidget()->show();
else
m_tabWidget->cornerWidget()->hide();
// the corner widget has to be unset if not wanted,
// just hiding it will have the tabbar still reserving the space
const bool showTabBarCloseButton = Preferences::self()->showTabBarCloseButton() && !noTabBar;
const bool isTabBarCloseButtonVisible = (m_tabWidget->cornerWidget() != nullptr);
if (showTabBarCloseButton != isTabBarCloseButtonVisible)
{
if (showTabBarCloseButton)
{
m_tabWidget->setCornerWidget(m_tabCloseButton, Qt::BottomRightCorner);
m_tabCloseButton->show();
}
else
{
m_tabWidget->setCornerWidget(nullptr, Qt::BottomRightCorner);
m_tabCloseButton->hide();
}
}
m_tabWidget->tabBar()->setTabsClosable(Preferences::self()->closeButtons());
}
......
......@@ -16,6 +16,7 @@
#include <QTabWidget>
class QSplitter;
class QToolButton;
class KActionCollection;
......@@ -279,6 +280,7 @@ class ViewContainer : public QAbstractItemModel
QSplitter* m_viewTreeSplitter;
TabWidget* m_tabWidget;
QToolButton* m_tabCloseButton;
ViewTree* m_viewTree;
QWidget* m_vbox;
QueueTuner* m_queueTuner;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment