forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user