Kaydet (Commit) a348806b authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Qt5 don't unconditionally disconnect close button

Change-Id: Ibfa4d493ed752a03554020c6ab06bfc38745d97d
Reviewed-on: https://gerrit.libreoffice.org/71871
Tested-by: Jenkins
Reviewed-by: 's avatarAleksei Nikiforov <darktemplar@basealt.ru>
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 6dcc1e23
......@@ -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);
......
......@@ -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();
}
......
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