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
(cherry picked from commit f281b70282bcead3fca9c5a783e4584144d92a51)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168795
diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 28e5ac5..24d5633 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 e3494356..5b76706 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())