summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-06-13 09:05:52 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-06-13 15:29:49 +0200
commitf281b70282bcead3fca9c5a783e4584144d92a51 (patch)
tree520eac535ea41d1c7ed8ad45b91b430ab7e90d68 /vcl
parent96f22f5e5302e030fcbc939ef94b7c1fd2748df2 (diff)
tdf#160462 qt a11y: Open menu bar on F10
F10 is used as a shortcut to open the menu bar (or main menu) on various platforms and toolkits, and KDE adapted that for KF 6 as well, see [1]. Do the same for the Qt-based VCL plugins: Connect a slot to the F10 shortcut that opens the first menu item. [1] https://wordsmith.social/felix-ernst/f10-for-accessibility-in-kf6 Change-Id: I27e34f87a115b89e047b08aed334207c64b0b9e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168765 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/qt5/QtMenu.hxx1
-rw-r--r--vcl/qt5/QtMenu.cxx14
2 files changed, 15 insertions, 0 deletions
diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 28e5ac57146b..24d56333a067 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -113,6 +113,7 @@ private slots:
static void slotMenuAboutToHide(QtMenuItem* pQItem);
void slotCloseDocument();
void slotMenuBarButtonClicked(QAbstractButton*);
+ void slotShortcutF10();
};
class QtMenuItem : public SalMenuItem
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index e3494356fc8b..5b76706f22b3 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -457,6 +457,11 @@ void QtMenu::SetFrame(const SalFrame* pFrame)
mpQMenuBar = new QMenuBar();
pMainWindow->setMenuBar(mpQMenuBar);
+ // open menu bar on F10, as is common in KF 6 and other toolkits:
+ // https://wordsmith.social/felix-ernst/f10-for-accessibility-in-kf6
+ QShortcut* pQShortcut = new QShortcut(QKeySequence(Qt::Key_F10), mpQMenuBar->window());
+ connect(pQShortcut, &QShortcut::activated, this, &QtMenu::slotShortcutF10);
+
QWidget* pWidget = mpQMenuBar->cornerWidget(Qt::TopRightCorner);
if (pWidget)
{
@@ -697,6 +702,15 @@ void QtMenu::slotMenuBarButtonClicked(QAbstractButton* pButton)
}
}
+void QtMenu::slotShortcutF10()
+{
+ SolarMutexGuard aGuard;
+
+ // focus menu bar and select first item
+ if (mpQMenuBar && !mpQMenuBar->actions().empty())
+ mpQMenuBar->setActiveAction(mpQMenuBar->actions().at(0));
+}
+
QPushButton* QtMenu::ImplAddMenuBarButton(const QIcon& rIcon, const QString& rToolTip, int nId)
{
if (!validateQMenuBar())