From 0f2edfdb4e4b6bc2e941733e9ceba45799b2ed50 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 28 Apr 2021 22:06:42 +0100 Subject: [PATCH] Fix hidding the pin/auto-hide icon when side-by-side in floating An else {} branch was missing. Also just simplify the code, and call supportsAutoHideButton() which wasn't being used. Also removed some bogus updateAutoHideButton() calls from the CTOR, needs to use singleShot() since the method is virtual, the derived class isn't constructed yet --- src/private/TitleBar.cpp | 6 ++---- src/private/widgets/TitleBarWidget.cpp | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/private/TitleBar.cpp b/src/private/TitleBar.cpp index 3fd1a8cd..bc067df6 100644 --- a/src/private/TitleBar.cpp +++ b/src/private/TitleBar.cpp @@ -39,9 +39,6 @@ TitleBar::TitleBar(Frame *parent) if (Config::self().flags() & Config::Flag_TitleBarIsFocusable) setFocusPolicy(Qt::StrongFocus); - - QTimer::singleShot(0, this, &TitleBar::updateAutoHideButton); // have to wait after the frame is constructed - updateAutoHideButton(); } TitleBar::TitleBar(FloatingWindow *parent) @@ -55,7 +52,6 @@ TitleBar::TitleBar(FloatingWindow *parent) connect(m_floatingWindow, &FloatingWindow::windowStateChanged, this, &TitleBar::updateMaximizeButton); connect(m_floatingWindow, &FloatingWindow::activatedChanged , this, &TitleBar::isFocusedChanged); init(); - updateAutoHideButton(); // always hidden when we're in a FloatingWindow. } void TitleBar::init() @@ -68,6 +64,8 @@ void TitleBar::init() }); updateButtons(); + QTimer::singleShot(0, this, &TitleBar::updateAutoHideButton); // have to wait after the frame is + // constructed } TitleBar::~TitleBar() diff --git a/src/private/widgets/TitleBarWidget.cpp b/src/private/widgets/TitleBarWidget.cpp index 87b39ad2..0aa92cd0 100644 --- a/src/private/widgets/TitleBarWidget.cpp +++ b/src/private/widgets/TitleBarWidget.cpp @@ -171,14 +171,10 @@ void TitleBarWidget::updateAutoHideButton() m_autoHideButton->setIcon(factory->iconForButtonType(TitleBarButtonType::UnautoHide, devicePixelRatioF())); m_autoHideButton->setToolTip(tr("Disable auto-hide")); } - - m_autoHideButton->setVisible(true); - } else { - m_autoHideButton->setVisible(false); } - } else { - m_autoHideButton->setVisible(false); } + + m_autoHideButton->setVisible(supportsAutoHideButton()); } void TitleBarWidget::updateMaximizeButton()