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

New commits:
commit f0a0dbb9907c4b125175c8c578302ceea6303ee7
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Sun Jun 23 00:10:25 2019 +0200
Commit:     Jan-Marek Glogowski <glo...@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.wegh...@posteo.de>
    Reviewed-by: Jan-Marek Glogowski <glo...@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);
     }
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to