[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/qt5

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 25 18:50:01 UTC 2019


 vcl/qt5/Qt5Menu.cxx |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit f0a0dbb9907c4b125175c8c578302ceea6303ee7
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Sun Jun 23 00:10:25 2019 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Jun 25 20:49:25 2019 +0200

    tdf#120873 Qt5 invert checked state on trigger
    
    SalMenu's event handling is not really compatible with QAction.
    LO expects to get something like an activate event, which happens
    without any menu state update. The item handler will then update
    the item state, as expected by LO.
    
    I'm not sure how this could be implemented in a good way in Qt, so
    this patch is just a hack. If the item is checkable, we invert its
    state before handling it. This just works correctly for single items,
    not radio groups, but it does the trick for this bug. And since
    setChecked() just emits toggled(), triggered() won't run twice.
    
    Maybe someone can come up with a better way using event filters, if
    ever needed.
    
    Change-Id: Ic32d07525ce8f394b83d04f53689d1669ddc9d83
    Reviewed-on: https://gerrit.libreoffice.org/74590
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit 44250864a8252d29c87801a4530e3fe3efd01ba7)
    Reviewed-on: https://gerrit.libreoffice.org/74710

diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 9ca4d54d45a3..418bda56281f 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -568,6 +568,11 @@ void Qt5Menu::slotMenuTriggered(Qt5MenuItem* pQItem)
         Menu* pMenu = pSalMenu->GetMenu();
         auto mnId = pQItem->mnId;
 
+        // HACK to allow HandleMenuCommandEvent to "not-set" the checked button
+        // LO expects a signal before an item state change, so reset the check item
+        if (pQItem->mpAction->isCheckable()
+            && (!pQItem->mpActionGroup || pQItem->mpActionGroup->actions().size() <= 1))
+            pQItem->mpAction->setChecked(!pQItem->mpAction->isChecked());
         pTopLevel->GetMenu()->HandleMenuCommandEvent(pMenu, mnId);
     }
 }


More information about the Libreoffice-commits mailing list