summaryrefslogtreecommitdiff
path: root/vcl/qt5/Qt5Menu.cxx
AgeCommit message (Collapse)Author
2020-08-04loplugin:flatten in vclNoel Grandin
Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-02-12tdf#128921 tdf#130341 tdf#122053 qt5: Native PopupMenusMichael Weghorn
This implements native PopupMenus for the qt5 VCL plugin, which not only gives them the native look and feel, but also makes context menus faster (tdf#128921), accessible (e.g. to the Orca screen reader, tdf#122053), and makes them work for a case in Base's relationship dialog where entries in the non-native context menu were not selectable/clickable (tdf#130341). For now, this always shows the popup menu at cursor position, which can be changed by taking the Rectangle passed to 'Qt5Menu::ShowNativePopupMenu' into account if there should be any need. Change-Id: Ie52cbc682acacb92716ff51e8bf7f1ab07d34cf0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88512 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2020-01-28New loplugin:unsignedcompareStephan Bergmann
"Find explicit casts from signed to unsigned integer in comparison against unsigned integer, where the cast is presumably used to avoid warnings about signed vs. unsigned comparisons, and could thus be replaced with o3tl::make_unsigned for clairty." (compilerplugins/clang/unsignedcompare.cxx) o3tl::make_unsigned requires its argument to be non-negative, and there is a chance that some original code like static_cast<sal_uInt32>(n) >= c used the explicit cast to actually force a (potentially negative) value of sal_Int32 to be interpreted as an unsigned sal_uInt32, rather than using the cast to avoid a false "signed vs. unsigned comparison" warning in a case where n is known to be non-negative. It appears that restricting this plugin to non- equality comparisons (<, >, <=, >=) and excluding equality comparisons (==, !=) is a useful heuristic to avoid such false positives. The only remainging false positive I found was 0288c8ffecff4956a52b9147d441979941e8b87f "Rephrase cast from sal_Int32 to sal_uInt32". But which of course does not mean that there were no further false positivies that I missed. So this commit may accidentally introduce some false hits of the assert in o3tl::make_unsigned. At least, it passed a full (Linux ASan+UBSan --enable-dbgutil) `make check && make screenshot`. It is by design that o3tl::make_unsigned only accepts signed integer parameter types (and is not defined as a nop for unsigned ones), to avoid unnecessary uses which would in general be suspicious. But the STATIC_ARRAY_SELECT macro in include/oox/helper/helper.hxx is used with both signed and unsigned types, so needs a little oox::detail::make_unsigned helper function for now. (The ultimate fix being to get rid of the macro in the first place.) Change-Id: Ia4adc9f44c70ad1dfd608784cac39ee922c32175 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87556 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-01-24loplugin:makeshared in svgio..writerperfectNoel Grandin
Change-Id: I0f8de0f78c7a8fb78d47ee5dfed09019b4eb5288 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87357 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-01-10use more std::make_sharedNoel Grandin
found using 'git grep', I tried using clang-tidy, but it only successfully found a tiny fraction of these Change-Id: I61c7d85105ff7a911722750e759d6641d578da33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86526 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-09-28loplugin:constmethod in vclNoel Grandin
Change-Id: I6a456979a6cfcd7920dc468baf9b23013cb701a4 Reviewed-on: https://gerrit.libreoffice.org/79783 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-06-25tdf#120873 Qt5 invert checked state on triggerJan-Marek Glogowski
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@posteo.de> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2019-06-13Qt5 correctly hide menu bar in tabbed modeJan-Marek Glogowski
Change-Id: I179780c2df5637b8a28c3a77b829319b1a64845b Reviewed-on: https://gerrit.libreoffice.org/73924 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2019-05-30tdf#125548 Qt5 no focus for the menu bar buttonJan-Marek Glogowski
You can't tab into the menu bar, but if you add a corner widget, it will be enlisted in the parent's focus chain! Interestingly the menu bar even is considered to have the focus, if the widget is focused, and will handle key events, but this can probably be considered consistent. So this just denies the button any focus, as this is a mouse-only widget, and clicking it will close the document window. Change-Id: I3c48d85ca56b6a54daf01f444dddc736e7ebb8e7 Reviewed-on: https://gerrit.libreoffice.org/73186 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2019-05-15Qt5 don't unconditionally disconnect close buttonJan-Marek Glogowski
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>
2019-05-07tdf#123549 Qt5 implement Qt5Menu::ShowCloseButtonJan-Marek Glogowski
This includes some not-so-nice lifetime handling of the button "clicked" connection handling. I decided to keep the code in one place, simply always forcing a disconnect on show, instead of a more "optimized" code version in SetFrame. First we try to get the icon from the system theme, but use LO's own icon theme as a fallback. Change-Id: Ic0459623ec907b9a54bef4670bf65cf587cd47ea Reviewed-on: https://gerrit.libreoffice.org/71784 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2019-05-06Qt5 remove unused Qt5Menu::setFrameSignalJan-Marek Glogowski
Change-Id: Iead091fee3b6c72d610f42598edb7cbb681d0cd4 Reviewed-on: https://gerrit.libreoffice.org/71870 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2019-03-19tdf#123379: implement native menu bar toggle on/offKatarina Behrens
qt5 didn't provide implementation of virtual SalMenu::ShowMenuBar so native menu bar was visible at all times. Hopefully notebookbar fans are happier now Change-Id: Ie581397521369160e16f40231bade40100dcd6f6 Reviewed-on: https://gerrit.libreoffice.org/69327 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2019-03-05tdf#119856 vcl: convert Qt5FilePicker and Qt5Menu to RunInMainThreadMichael Stahl
... and also convert KDE5FilePicker. And Qt5Frame. The UNO methods in Qt5FilePicker/KDE5FilePicker have to ensure that the thread actually owns SolarMutex, because if RunInMainThread() is called without that it will deadlock. Change-Id: Ie4d2f494ac81c799ec7c9a3acb3a9b0f77bb6361 Reviewed-on: https://gerrit.libreoffice.org/68357 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2019-02-27KDE5: set correct parent menu in functionAleksei Nikiforov
Set correct parent menu in function Qt5Menu::InsertMenuItem instead of just returning it and setting it later if needed. Change-Id: Id866987e91ec1d57c720735da6afc44109aa901a Reviewed-on: https://gerrit.libreoffice.org/68437 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-02-27tdf#121970 KDE5: Regenerate menu when it's set as submenuAleksei Nikiforov
Also add item bits change notification function for SalMenu to properly convert regenerated menu items to check or radiocheck items. Change-Id: I61f16a771b484644bbefd9afaf2776232d38a2f9 Reviewed-on: https://gerrit.libreoffice.org/68438 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-02-26tdf#120824 KDE5: fix visible/enabled state for menuAleksei Nikiforov
Change-Id: I003703f0bc2e1697124e068a68bfb2e24c33cd1a Reviewed-on: https://gerrit.libreoffice.org/68351 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2019-01-16KDE5: Fix radiocheck menu itemsAleksei Nikiforov
This change fixes displaying of elements of 'Styles' menu of Writer Change-Id: I455a4f1c37aa7bc6641ebdd15eec23f18a8430d9 Reviewed-on: https://gerrit.libreoffice.org/66387 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-01-16KDE5: minor Qt5Menu cleanupAleksei Nikiforov
Remove unnecessary destructor Move MenuBar clearing out of DoFullMenuUpdate function Change-Id: I0fb916c6935b2f8a675e75adf696d99203a2c016 Reviewed-on: https://gerrit.libreoffice.org/66386 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-01-11tdf#122253 KDE5: Correct parent menu before it's usedAleksei Nikiforov
Also correct action group of menu Change-Id: Ie7eddd3cdc9fa1c36fdeaa1e96eb5d50d7126c09 Reviewed-on: https://gerrit.libreoffice.org/66146 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-01-11Unregister action when menu item is removedAleksei Nikiforov
Change-Id: I9fc5e6630560f285eeb7ef4dbc5e39ccabd5f0df Reviewed-on: https://gerrit.libreoffice.org/66147 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2019-01-10tdf#120877: make menu items checkable as neededKatarina Behrens
Change-Id: I5a07526aa5187313977d6f7c244541be83b5edbc Reviewed-on: https://gerrit.libreoffice.org/65930 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2018-12-08tdf#121974 Convert Qt menu text as neededMichael Weghorn
Just as is already done in 'Qt5Menu::InsertMenuItem', the text needs to be converted in 'Qt5Menu::SetItemText' as well. Change-Id: I03c8f2e6fe0e926a3f7e4be5b7eac70f1bd9850f Reviewed-on: https://gerrit.libreoffice.org/64796 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2018-11-30KDE5: fix build with Qt-5.6Aleksei Nikiforov
Change-Id: Ic4aef6b22d5b9c7262a534e26363c8f8cef99859 Reviewed-on: https://gerrit.libreoffice.org/64321 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-11-29tdf#120814 KDE5: Assign images to menu items on first build of menuAleksei Nikiforov
Treat submenu items similarly to action items. Qt5MenuItem controls lifetime of menus and actions instead of QMenu or QMenuBar. Qt5MenuItem may need to remove menus, and thus it may need to delete it. But if QMenu or QMenuBar owns menu, then on application exit a crash may happen due to order of destruction of objects. Change-Id: I66138c5692bd4955e78a805cc774ff9fc8fefb99 Reviewed-on: https://gerrit.libreoffice.org/63886 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2018-11-26Fix menu insertion to specified positionAleksei Nikiforov
Change-Id: I61f870010003fae98d792f95d7fdac0e59d4305c Reviewed-on: https://gerrit.libreoffice.org/63885 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2018-11-23tdf#121417 Allow dynamic menu changes for Qt5 and KDE5 interfacesAleksei Nikiforov
Separate HandleMenuActivateEvent function call from HandleMenuCommandEvent function call since first one might update some of menus. Also add call to HandleMenuDeActivateEvent function. Delete action with Qt5MenuItem to reflect the change in actual menu. Also update underlying qt-based menu from Qt5Menu::InsertItem function. And update Qt5Menu::SetItemImage to work with different types of descendants of SalBitmap. This code is shared between Qt5 and KDE5 plugins, but KDE5 plugin uses SvpSalBitmap instead of Qt5Bitmap. New image conversion process is borrowed from GTK plugin code. This approach is used in order to properly process transparency channel if it's present, and it is present usually. This change also fixes tdf#120789. Change-Id: Ifdc64c3e5d80782955b52e2da8fcff4844d2dc25 Reviewed-on: https://gerrit.libreoffice.org/63862 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2018-11-23Move menu item insertion into separate functionAleksei Nikiforov
Change-Id: I721910bbbd558827e9a5de1f8763426b460f08fa Reviewed-on: https://gerrit.libreoffice.org/63861 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2018-11-16loplugin:staticmethodsStephan Bergmann
Change-Id: I8d26503d68ed3dcc37574e247de3eae02b4e0f53
2018-11-12tdf#119856: thread-proof creating frames and setting menusKatarina Behrens
This finally enables opening a new frame and setting its menu from an extension, but it is still far from stable, loads of threading landmines like this all over the code Change-Id: Icf4b67796b0669425ecb7c2c142c21e184024534 Reviewed-on: https://gerrit.libreoffice.org/62737 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-10-27tdf#120453 Preserve literal '&' in Qt menu textsMichael Weghorn
As described in the QMenuBar documentation, a single ampersand in a menu item text is used to set the shortcut for the menu, while "&&" is used to get a real ampersand character. Change-Id: Idf510641c8919ff8223114413851cb3ee7d7b4a2 Reviewed-on: https://gerrit.libreoffice.org/62405 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2018-10-24remove more rtl::OUString and OString prefixesNoel Grandin
which seem to have snuck back in since the great rounds of removals. Change-Id: I85f7f5f4801c0b48dae8b50f51f83595b286d6a1 Reviewed-on: https://gerrit.libreoffice.org/62229 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-24tdf#120450: Radiobuttons want to be checked tooKatarina Behrens
Change-Id: If9b67bf866ed9fe38f69d440deeb2eccb87301bc Reviewed-on: https://gerrit.libreoffice.org/62237 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2018-10-22tdf#119856: [Re-]activate menu before dispatching commandKatarina Behrens
Menu entry dispatchers may be cleared (after they've been initially set) when an extension comes with its own menu entries. Activating the entry sets the dispatcher again so that dispatching a command can proceed Change-Id: I3909fb5eb6e6e2fa7db0418aca17009e60f01372 Reviewed-on: https://gerrit.libreoffice.org/62180 Tested-by: Jenkins Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2018-09-05kde5: make disabled and hidden menu items workThorsten Behrens
Change-Id: I145a496bbc5b375bc309815b18f2c31fa4d50d6c Reviewed-on: https://gerrit.libreoffice.org/60012 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-09-05kde5: cleanup cargo-culted empty dtorsThorsten Behrens
Change-Id: I8f987e30b2a78e173fd8f3ebb9f33e4720f6588b Reviewed-on: https://gerrit.libreoffice.org/60011 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-08-12Finally remove non-native menu barKatarina Behrens
Change-Id: I4758bc5afa9f9eaced7763b9923250f27df14259 Reviewed-on: https://gerrit.libreoffice.org/58834 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-08-12Set Qt5Widget to be a central widget of QMainWindowKatarina Behrens
this is meant to solve the problem of native menu bar overlapping w/ non-native, as well as the inability to place an object or select text dragging the mouse cursor w/ LMB pressed Change-Id: I29f590ebf79d1ecc7e17b402125384cf13774bf3 Reviewed-on: https://gerrit.libreoffice.org/58171 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-07-31Add missing sal/log.hxx headersGabor Kelemen
rtl/string.hxx and rtl/ustring.hxx both unnecessarily #include <sal/log.hxx> (and don't make use of it themselves), but many other files happen to depend on it. This is a continuation of commit 6ff2d84ade299cb3d14d4110e4cf1a4b8070c030 to be able to remove those unneeded includes. This commit adds missing headers to every file found by: grep -FwL sal/log.hxx $(git grep -Elw 'SAL_INFO|SAL_INFO_IF|SAL_WARN|SAL_WARN_IF|SAL_DETAIL_LOG_STREAM|SAL_WHERE|SAL_STREAM|SAL_DEBUG') to directory vcl Change-Id: I205fe0f4e80a66cd9c3b19f7e9716411da1d1cf5 Reviewed-on: https://gerrit.libreoffice.org/58221 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-06-01Remove unused Qt5MenuItem::mpVCLMenuStephan Bergmann
Change-Id: Ia7f28a54f253f0263cc781feb5997bb51bb640b2 Reviewed-on: https://gerrit.libreoffice.org/55193 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-06-01Various trivial loplugin fixes in --enable-qt5Stephan Bergmann
Change-Id: I9539eb77f663e1174919ae801495801f81571710
2018-06-01Make clang-format happy, remove vcl/unx/kde5 from blacklistKatarina Behrens
just between us girls, I hate you clang-format Change-Id: I4cd041eff7a9fa01eb9192cf357e3f07a26fa6ad
2018-06-01Add radiobuttons to native menusKatarina Behrens
Change-Id: I015bbb0a337b917096ca6f542a73c24c79fbef7d
2018-06-01Add checkmark buttons to native menusKatarina Behrens
Change-Id: If64227af287006cb4f9b980dac97b2fb401eac88
2018-06-01Dispatch commands from menus for realKatarina Behrens
Change-Id: I01997caa22e14c1350bd83100edb74397ebab5d7
2018-06-01Basic structure of a slot to dispatch commands from menuKatarina Behrens
Change-Id: If3a134f67f59d3238c27eb0fef99bf49a8970433
2018-06-01Add shortcuts to native menu entriesKatarina Behrens
something's wrong though, they don't really show Change-Id: Id8559fd9b6a5d4b2b49442d179571d31a99b5b20
2018-06-01Insert separators into native menuKatarina Behrens
Change-Id: I88bb70b1e443821cc8d1904039f2a8fb52df1ff9
2018-06-01Native leaf menus and submenus are now visibleKatarina Behrens
Change-Id: Ieaac0966b167d82c8bdeb60f3ce4b9cc8589ec62
2018-06-01Clear menubar before opening a new appKatarina Behrens
Change-Id: Icab19e31f7aa737351460790d2028114b24284ad