summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-05-06 17:18:56 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2019-05-15 23:25:37 +0200
commita348806baf31b4072f02886d142ac6c3e1bba665 (patch)
tree518056488ca8e75b0229f465aa2d52189cc9c70c /vcl
parent6dcc1e233f248696165fc976513cdf3f09dac2bd (diff)
Qt5 don't unconditionally disconnect close button
Change-Id: Ibfa4d493ed752a03554020c6ab06bfc38745d97d Reviewed-on: https://gerrit.libreoffice.org/71871 Tested-by: Jenkins Reviewed-by: Aleksei Nikiforov <darktemplar@basealt.ru> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/qt5/Qt5Menu.hxx3
-rw-r--r--vcl/qt5/Qt5Menu.cxx23
2 files changed, 17 insertions, 9 deletions
diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index 76d865b263ff..cf60ee2c0bb7 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -18,6 +18,7 @@
class MenuItemList;
class QAction;
class QActionGroup;
+class QPushButton;
class QMenu;
class QMenuBar;
class Qt5MenuItem;
@@ -34,6 +35,8 @@ private:
bool mbMenuBar;
QMenuBar* mpQMenuBar;
QMenu* mpQMenu;
+ QPushButton* mpCloseButton;
+ QMetaObject::Connection maCloseButtonConnection;
void DoFullMenuUpdate(Menu* pMenuBar);
static void NativeItemText(OUString& rItemText);
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 5bfaefa9b931..733b1505b49c 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -30,6 +30,7 @@ Qt5Menu::Qt5Menu(bool bMenuBar)
, mbMenuBar(bMenuBar)
, mpQMenuBar(nullptr)
, mpQMenu(nullptr)
+ , mpCloseButton(nullptr)
{
}
@@ -411,7 +412,17 @@ void Qt5Menu::SetFrame(const SalFrame* pFrame)
{
mpQMenuBar = pMainWindow->menuBar();
if (mpQMenuBar)
+ {
mpQMenuBar->clear();
+ QPushButton* pButton
+ = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
+ if (pButton && ((mpCloseButton != pButton) || !maCloseButtonConnection))
+ {
+ maCloseButtonConnection
+ = connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument);
+ mpCloseButton = pButton;
+ }
+ }
mpQMenu = nullptr;
@@ -622,19 +633,13 @@ void Qt5Menu::ShowCloseButton(bool bShow)
pButton->setFlat(true);
pButton->setToolTip(toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)));
mpQMenuBar->setCornerWidget(pButton, Qt::TopRightCorner);
+ maCloseButtonConnection
+ = connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument);
+ mpCloseButton = pButton;
}
if (bShow)
- {
- // The mpQMenuBar is used in multiple Qt5Menu. If one Qt5Menu is deleted, the clicked button
- // connection is severed. The reconnect could be handled in SetFrame, but ShowCloseButton is
- // called so seldomly, that I decided to keep the reconnect in this function in one place. As
- // we don't know the connection state, we unconditionally remove it, so slotCloseDocument
- // isn't called multiple times on click.
- pButton->disconnect(SIGNAL(clicked(bool)));
- connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument);
pButton->show();
- }
else
pButton->hide();
}