summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-09-09 16:50:16 +0200
committerEike Ziller <eike.ziller@qt.io>2019-09-11 08:15:16 +0000
commitb34102ceeadbceb9fab4c0c24e764c3f10698bbb (patch)
treee05d3656aee17c2cce3c112d25ad6ebd74c47085 /src/plugins/coreplugin
parentf0a37795131133e0b5acbeb355e90fbad1af3b5b (diff)
downloadqt-creator-b34102ceeadbceb9fab4c0c24e764c3f10698bbb.tar.gz
Add option for shortcut visibility in context menus
Fixes: QTCREATORBUG-22502 Change-Id: I49587a6a8b575a3a1453104a829cd91ad3566d7e Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'src/plugins/coreplugin')
-rw-r--r--src/plugins/coreplugin/generalsettings.cpp33
-rw-r--r--src/plugins/coreplugin/generalsettings.h5
-rw-r--r--src/plugins/coreplugin/generalsettings.ui87
-rw-r--r--src/plugins/coreplugin/mainwindow.cpp2
4 files changed, 74 insertions, 53 deletions
diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp
index 27788d5711..f0db3135e9 100644
--- a/src/plugins/coreplugin/generalsettings.cpp
+++ b/src/plugins/coreplugin/generalsettings.cpp
@@ -37,6 +37,7 @@
#include <QLibraryInfo>
#include <QMessageBox>
#include <QSettings>
+#include <QStyleHints>
#include "ui_generalsettings.h"
@@ -46,6 +47,7 @@ namespace Core {
namespace Internal {
const char settingsKeyDPI[] = "Core/EnableHighDpiScaling";
+const char settingsKeyShortcutsInContextMenu[] = "General/ShowShortcutsInContextMenu";
GeneralSettings::GeneralSettings()
: m_page(nullptr), m_dialog(nullptr)
@@ -56,6 +58,8 @@ GeneralSettings::GeneralSettings()
setDisplayCategory(QCoreApplication::translate("Core", "Environment"));
setCategoryIcon(Utils::Icon({{":/core/images/settingscategory_core.png",
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
+ m_defaultShowShortcutsInContextMenu = QGuiApplication::styleHints()
+ ->showShortcutsInContextMenus();
}
static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrPath)
@@ -107,8 +111,15 @@ QWidget *GeneralSettings::widget()
m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
m_page->resetWarningsButton->setEnabled(canResetWarnings());
+ m_page->showShortcutsInContextMenus->setText(
+ tr("Show keyboard shortcuts in context menus (default: %1)")
+ .arg(QLatin1String(m_defaultShowShortcutsInContextMenu ? "on" : "off")));
+ m_page->showShortcutsInContextMenus->setChecked(showShortcutsInContextMenu());
+#if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
+ m_page->showShortcutsInContextMenus->setVisible(false);
+#endif
+
if (Utils::HostOsInfo().isMacHost()) {
- m_page->dpiLabel->setVisible(false);
m_page->dpiCheckbox->setVisible(false);
} else {
const bool defaultValue = Utils::HostOsInfo().isWindowsHost();
@@ -134,6 +145,7 @@ void GeneralSettings::apply()
return;
int currentIndex = m_page->languageBox->currentIndex();
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
+ setShowShortcutsInContextMenu(m_page->showShortcutsInContextMenus->isChecked());
// Apply the new base color if accepted
StyleHelper::setBaseColor(m_page->colorButton->color());
m_page->themeChooser->apply();
@@ -146,6 +158,14 @@ void GeneralSettings::finish()
m_page = nullptr;
}
+bool GeneralSettings::showShortcutsInContextMenu() const
+{
+ return ICore::settings()
+ ->value(settingsKeyShortcutsInContextMenu,
+ QGuiApplication::styleHints()->showShortcutsInContextMenus())
+ .toBool();
+}
+
void GeneralSettings::resetInterfaceColor()
{
m_page->colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
@@ -189,5 +209,16 @@ void GeneralSettings::setLanguage(const QString &locale)
settings->setValue(QLatin1String("General/OverrideLanguage"), locale);
}
+void GeneralSettings::setShowShortcutsInContextMenu(bool show)
+{
+ if (show == m_defaultShowShortcutsInContextMenu)
+ ICore::settings()->remove(settingsKeyShortcutsInContextMenu);
+ else
+ ICore::settings()->setValue(settingsKeyShortcutsInContextMenu, show);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
+ QGuiApplication::styleHints()->setShowShortcutsInContextMenus(show);
+#endif
+}
+
} // namespace Internal
} // namespace Core
diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h
index ed0f177532..bdd6597755 100644
--- a/src/plugins/coreplugin/generalsettings.h
+++ b/src/plugins/coreplugin/generalsettings.h
@@ -48,6 +48,9 @@ public:
void apply() override;
void finish() override;
+ bool showShortcutsInContextMenu() const;
+ void setShowShortcutsInContextMenu(bool show);
+
private:
void resetInterfaceColor();
void resetWarnings();
@@ -57,9 +60,11 @@ private:
void fillLanguageBox() const;
QString language() const;
void setLanguage(const QString&);
+
Ui::GeneralSettings *m_page;
QPointer<QMessageBox> m_dialog;
QPointer<QWidget> m_widget;
+ bool m_defaultShowShortcutsInContextMenu;
};
} // namespace Internal
diff --git a/src/plugins/coreplugin/generalsettings.ui b/src/plugins/coreplugin/generalsettings.ui
index 0302314d64..93edf24536 100644
--- a/src/plugins/coreplugin/generalsettings.ui
+++ b/src/plugins/coreplugin/generalsettings.ui
@@ -16,21 +16,7 @@
<property name="title">
<string>User Interface</string>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="colorLabel">
- <property name="text">
- <string>Color:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="languageLabel">
- <property name="text">
- <string>Language:</string>
- </property>
- </widget>
- </item>
+ <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="themeLabel">
<property name="text">
@@ -38,6 +24,9 @@
</property>
</widget>
</item>
+ <item row="1" column="1">
+ <widget class="Core::Internal::ThemeChooser" name="themeChooser" native="true"/>
+ </item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -84,16 +73,6 @@
</item>
</layout>
</item>
- <item row="4" column="0">
- <widget class="QPushButton" name="resetWarningsButton">
- <property name="toolTip">
- <string>Re-enable warnings that were suppressed by selecting &quot;Do Not Show Again&quot; (for example, missing highlighter).</string>
- </property>
- <property name="text">
- <string comment="Button text">Reset Warnings</string>
- </property>
- </widget>
- </item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@@ -121,37 +100,41 @@
</item>
</layout>
</item>
- <item row="1" column="1">
- <widget class="Core::Internal::ThemeChooser" name="themeChooser" native="true"/>
+ <item row="0" column="0">
+ <widget class="QLabel" name="colorLabel">
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QPushButton" name="resetWarningsButton">
+ <property name="toolTip">
+ <string>Re-enable warnings that were suppressed by selecting &quot;Do Not Show Again&quot; (for example, missing highlighter).</string>
+ </property>
+ <property name="text">
+ <string comment="Button text">Reset Warnings</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="languageLabel">
+ <property name="text">
+ <string>Language:</string>
+ </property>
+ </widget>
</item>
<item row="3" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QCheckBox" name="dpiCheckbox">
- <property name="text">
- <string>Enable high DPI scaling</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>285</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="QCheckBox" name="dpiCheckbox">
+ <property name="text">
+ <string>Enable high DPI scaling</string>
+ </property>
+ </widget>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="dpiLabel">
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="showShortcutsInContextMenus">
<property name="text">
- <string>High DPI scaling:</string>
+ <string/>
</property>
</widget>
</item>
diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp
index c55411d5ec..732f485824 100644
--- a/src/plugins/coreplugin/mainwindow.cpp
+++ b/src/plugins/coreplugin/mainwindow.cpp
@@ -149,6 +149,8 @@ MainWindow::MainWindow()
}
QApplication::setStyle(new ManhattanStyle(baseName));
+ m_generalSettings->setShowShortcutsInContextMenu(
+ m_generalSettings->showShortcutsInContextMenu());
setDockNestingEnabled(true);