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 <QLibraryInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QStyleHints>
|
||||||
|
|
||||||
#include "ui_generalsettings.h"
|
#include "ui_generalsettings.h"
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ namespace Core {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
const char settingsKeyDPI[] = "Core/EnableHighDpiScaling";
|
const char settingsKeyDPI[] = "Core/EnableHighDpiScaling";
|
||||||
|
const char settingsKeyShortcutsInContextMenu[] = "General/ShowShortcutsInContextMenu";
|
||||||
|
|
||||||
GeneralSettings::GeneralSettings()
|
GeneralSettings::GeneralSettings()
|
||||||
: m_page(nullptr), m_dialog(nullptr)
|
: m_page(nullptr), m_dialog(nullptr)
|
||||||
@@ -56,6 +58,8 @@ GeneralSettings::GeneralSettings()
|
|||||||
setDisplayCategory(QCoreApplication::translate("Core", "Environment"));
|
setDisplayCategory(QCoreApplication::translate("Core", "Environment"));
|
||||||
setCategoryIcon(Utils::Icon({{":/core/images/settingscategory_core.png",
|
setCategoryIcon(Utils::Icon({{":/core/images/settingscategory_core.png",
|
||||||
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
||||||
|
m_defaultShowShortcutsInContextMenu = QGuiApplication::styleHints()
|
||||||
|
->showShortcutsInContextMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrPath)
|
static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrPath)
|
||||||
@@ -107,8 +111,15 @@ QWidget *GeneralSettings::widget()
|
|||||||
m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
|
m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
|
||||||
m_page->resetWarningsButton->setEnabled(canResetWarnings());
|
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()) {
|
if (Utils::HostOsInfo().isMacHost()) {
|
||||||
m_page->dpiLabel->setVisible(false);
|
|
||||||
m_page->dpiCheckbox->setVisible(false);
|
m_page->dpiCheckbox->setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
const bool defaultValue = Utils::HostOsInfo().isWindowsHost();
|
const bool defaultValue = Utils::HostOsInfo().isWindowsHost();
|
||||||
@@ -134,6 +145,7 @@ void GeneralSettings::apply()
|
|||||||
return;
|
return;
|
||||||
int currentIndex = m_page->languageBox->currentIndex();
|
int currentIndex = m_page->languageBox->currentIndex();
|
||||||
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
|
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
|
||||||
|
setShowShortcutsInContextMenu(m_page->showShortcutsInContextMenus->isChecked());
|
||||||
// Apply the new base color if accepted
|
// Apply the new base color if accepted
|
||||||
StyleHelper::setBaseColor(m_page->colorButton->color());
|
StyleHelper::setBaseColor(m_page->colorButton->color());
|
||||||
m_page->themeChooser->apply();
|
m_page->themeChooser->apply();
|
||||||
@@ -146,6 +158,14 @@ void GeneralSettings::finish()
|
|||||||
m_page = nullptr;
|
m_page = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GeneralSettings::showShortcutsInContextMenu() const
|
||||||
|
{
|
||||||
|
return ICore::settings()
|
||||||
|
->value(settingsKeyShortcutsInContextMenu,
|
||||||
|
QGuiApplication::styleHints()->showShortcutsInContextMenus())
|
||||||
|
.toBool();
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralSettings::resetInterfaceColor()
|
void GeneralSettings::resetInterfaceColor()
|
||||||
{
|
{
|
||||||
m_page->colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
|
m_page->colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
|
||||||
@@ -189,5 +209,16 @@ void GeneralSettings::setLanguage(const QString &locale)
|
|||||||
settings->setValue(QLatin1String("General/OverrideLanguage"), 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 Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public:
|
|||||||
void apply() override;
|
void apply() override;
|
||||||
void finish() override;
|
void finish() override;
|
||||||
|
|
||||||
|
bool showShortcutsInContextMenu() const;
|
||||||
|
void setShowShortcutsInContextMenu(bool show);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetInterfaceColor();
|
void resetInterfaceColor();
|
||||||
void resetWarnings();
|
void resetWarnings();
|
||||||
@@ -57,9 +60,11 @@ private:
|
|||||||
void fillLanguageBox() const;
|
void fillLanguageBox() const;
|
||||||
QString language() const;
|
QString language() const;
|
||||||
void setLanguage(const QString&);
|
void setLanguage(const QString&);
|
||||||
|
|
||||||
Ui::GeneralSettings *m_page;
|
Ui::GeneralSettings *m_page;
|
||||||
QPointer<QMessageBox> m_dialog;
|
QPointer<QMessageBox> m_dialog;
|
||||||
QPointer<QWidget> m_widget;
|
QPointer<QWidget> m_widget;
|
||||||
|
bool m_defaultShowShortcutsInContextMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -16,21 +16,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>User Interface</string>
|
<string>User Interface</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<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>
|
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="themeLabel">
|
<widget class="QLabel" name="themeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -38,6 +24,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="Core::Internal::ThemeChooser" name="themeChooser" native="true"/>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@@ -84,16 +73,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QPushButton" name="resetWarningsButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Re-enable warnings that were suppressed by selecting "Do Not Show Again" (for example, missing highlighter).</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string comment="Button text">Reset Warnings</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
@@ -121,37 +100,41 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="0">
|
||||||
<widget class="Core::Internal::ThemeChooser" name="themeChooser" native="true"/>
|
<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 "Do Not Show Again" (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>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<widget class="QCheckBox" name="dpiCheckbox">
|
||||||
<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>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="dpiLabel">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>High DPI scaling:</string>
|
<string>Enable high DPI scaling</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QCheckBox" name="showShortcutsInContextMenus">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ MainWindow::MainWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QApplication::setStyle(new ManhattanStyle(baseName));
|
QApplication::setStyle(new ManhattanStyle(baseName));
|
||||||
|
m_generalSettings->setShowShortcutsInContextMenu(
|
||||||
|
m_generalSettings->showShortcutsInContextMenu());
|
||||||
|
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user