Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show access key underline (mnemonics) of menu items on focus #11679

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5561,10 +5561,6 @@ Are you sure you want to continue with this file?</source>
<source>&amp;Tools</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>View</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Theme</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -6230,6 +6226,10 @@ Expect some bugs and minor issues, this version is meant for testing purposes.</
<source>E&amp;xpire Entry…</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;View</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
<string>&amp;View</string>
</property>
<widget class="QMenu" name="menuTheme">
<property name="title">
Expand Down
20 changes: 19 additions & 1 deletion src/gui/styles/base/BaseStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QFile>
#include <QHeaderView>
#include <QListView>
#include <QMenuBar>
#include <QPainter>
#include <QPainterPath>
#include <QPoint>
Expand Down Expand Up @@ -4680,7 +4681,24 @@ int BaseStyle::styleHint(StyleHint hint,
case SH_WindowFrame_Mask:
return 0;
case SH_UnderlineShortcut: {
return false;
#if defined(Q_OS_WIN) or defined(Q_OS_LINUX)
// Only show underline shortcuts if the user focused with ALT (Win/Linux only)
auto menu = qobject_cast<const QMenu*>(widget);
if (menu) {
auto p = menu->parentWidget();
while (p) {
auto mb = qobject_cast<QMenuBar*>(p);
if (mb && mb->hasFocus()) {
return 1;
}
p = p->parentWidget();
}
}
auto mb = qobject_cast<const QMenuBar*>(widget);
return (mb && mb->hasFocus()) ? 1 : 0;
#else
return 0;
#endif
}
case SH_Widget_Animate:
return 1;
Expand Down
Loading