forked from qt-creator/qt-creator
Core: Inline generalsettings.ui
Change-Id: I8811728543cd7fb161b6df21dacc0fc23c6165a4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -116,7 +116,7 @@ public:
|
||||
class QTCREATOR_UTILS_EXPORT Space : public LayoutItem
|
||||
{
|
||||
public:
|
||||
explicit Space(int space);
|
||||
explicit Space(int space = 0);
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT Span : public LayoutItem
|
||||
|
@@ -87,7 +87,7 @@ add_qtc_plugin(Core
|
||||
findplaceholder.cpp findplaceholder.h
|
||||
foldernavigationwidget.cpp
|
||||
foldernavigationwidget.h
|
||||
generalsettings.cpp generalsettings.h generalsettings.ui
|
||||
generalsettings.cpp generalsettings.h
|
||||
generatedfile.cpp generatedfile.h
|
||||
helpitem.cpp helpitem.h
|
||||
helpmanager.cpp helpmanager.h helpmanager_implementation.h
|
||||
|
@@ -77,7 +77,6 @@ Project {
|
||||
"foldernavigationwidget.h",
|
||||
"generalsettings.cpp",
|
||||
"generalsettings.h",
|
||||
"generalsettings.ui",
|
||||
"generatedfile.cpp",
|
||||
"generatedfile.h",
|
||||
"helpitem.cpp",
|
||||
|
@@ -27,8 +27,7 @@
|
||||
#include "coreconstants.h"
|
||||
#include "coreplugintr.h"
|
||||
#include "icore.h"
|
||||
|
||||
#include "ui_generalsettings.h"
|
||||
#include "themechooser.h"
|
||||
|
||||
#include <coreplugin/dialogs/restartdialog.h>
|
||||
|
||||
@@ -36,17 +35,24 @@
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/infobar.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcolorbutton.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QGuiApplication>
|
||||
#include <QLibraryInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QStyleHints>
|
||||
#include <QTextCodec>
|
||||
|
||||
using namespace Utils;
|
||||
using namespace Layouting;
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
@@ -58,7 +64,6 @@ const char settingsKeyCodecForLocale[] = "General/OverrideCodecForLocale";
|
||||
class GeneralSettingsWidget final : public IOptionsPageWidget
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Core::Internal::GeneralSettings)
|
||||
|
||||
public:
|
||||
explicit GeneralSettingsWidget(GeneralSettings *q);
|
||||
|
||||
@@ -77,31 +82,52 @@ public:
|
||||
static void setCodecForLocale(const QByteArray&);
|
||||
|
||||
GeneralSettings *q;
|
||||
Ui::GeneralSettings m_ui;
|
||||
QComboBox *m_languageBox;
|
||||
QComboBox *m_codecBox;
|
||||
QCheckBox *m_showShortcutsInContextMenus;
|
||||
QtColorButton *m_colorButton;
|
||||
ThemeChooser *m_themeChooser;
|
||||
QPushButton *m_resetWarningsButton;
|
||||
};
|
||||
|
||||
GeneralSettingsWidget::GeneralSettingsWidget(GeneralSettings *q)
|
||||
: q(q)
|
||||
, m_languageBox(new QComboBox)
|
||||
, m_codecBox(new QComboBox)
|
||||
, m_showShortcutsInContextMenus(new QCheckBox)
|
||||
, m_colorButton(new QtColorButton)
|
||||
, m_themeChooser(new ThemeChooser)
|
||||
, m_resetWarningsButton(new QPushButton)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_languageBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
m_languageBox->setMinimumContentsLength(20);
|
||||
|
||||
fillLanguageBox();
|
||||
fillCodecBox();
|
||||
m_codecBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||
m_codecBox->setMinimumContentsLength(20);
|
||||
|
||||
m_ui.colorButton->setColor(StyleHelper::requestedBaseColor());
|
||||
m_ui.resetWarningsButton->setEnabled(canResetWarnings());
|
||||
m_colorButton->setMinimumSize(QSize(64, 0));
|
||||
m_colorButton->setProperty("alphaAllowed", QVariant(false));
|
||||
|
||||
m_ui.showShortcutsInContextMenus->setText(
|
||||
tr("Show keyboard shortcuts in context menus (default: %1)")
|
||||
.arg(q->m_defaultShowShortcutsInContextMenu ? tr("on") : tr("off")));
|
||||
m_ui.showShortcutsInContextMenus->setChecked(GeneralSettings::showShortcutsInContextMenu());
|
||||
m_resetWarningsButton->setText(tr("Reset Warnings", "Button text"));
|
||||
m_resetWarningsButton->setToolTip(
|
||||
tr("Re-enable warnings that were suppressed by selecting \"Do Not "
|
||||
"Show Again\" (for example, missing highlighter).",
|
||||
nullptr));
|
||||
|
||||
if (Utils::HostOsInfo::isMacHost()) {
|
||||
m_ui.dpiCheckbox->setVisible(false);
|
||||
} else {
|
||||
auto resetColorButton = new QPushButton(tr("Reset"));
|
||||
resetColorButton->setToolTip(tr("Reset to default.", "Color"));
|
||||
|
||||
Form form;
|
||||
form.addRow({tr("Color:"), m_colorButton, resetColorButton, Stretch()});
|
||||
form.addRow({tr("Theme:"), m_themeChooser});
|
||||
form.addRow({tr("Language:"), m_languageBox, Stretch()});
|
||||
|
||||
if (!Utils::HostOsInfo::isMacHost()) {
|
||||
auto dpiCheckbox = new QCheckBox(tr("Enable high DPI scaling"));
|
||||
form.addRow({Space(), dpiCheckbox});
|
||||
const bool defaultValue = Utils::HostOsInfo::isWindowsHost();
|
||||
m_ui.dpiCheckbox->setChecked(ICore::settings()->value(settingsKeyDPI, defaultValue).toBool());
|
||||
connect(m_ui.dpiCheckbox, &QCheckBox::toggled, this, [defaultValue](bool checked) {
|
||||
dpiCheckbox->setChecked(ICore::settings()->value(settingsKeyDPI, defaultValue).toBool());
|
||||
connect(dpiCheckbox, &QCheckBox::toggled, this, [defaultValue](bool checked) {
|
||||
ICore::settings()->setValueWithDefault(settingsKeyDPI, checked, defaultValue);
|
||||
QMessageBox::information(ICore::dialogParent(),
|
||||
tr("Restart Required"),
|
||||
@@ -109,10 +135,30 @@ GeneralSettingsWidget::GeneralSettingsWidget(GeneralSettings *q)
|
||||
});
|
||||
}
|
||||
|
||||
connect(m_ui.resetColorButton, &QAbstractButton::clicked,
|
||||
this, &GeneralSettingsWidget::resetInterfaceColor);
|
||||
connect(m_ui.resetWarningsButton, &QAbstractButton::clicked,
|
||||
this, &GeneralSettingsWidget::resetWarnings);
|
||||
form.addRow({Space(), m_showShortcutsInContextMenus});
|
||||
form.addRow(Row{m_resetWarningsButton, Stretch()});
|
||||
form.addRow({tr("Text codec for tools:"), m_codecBox, Stretch()});
|
||||
Column{Group{Title(tr("User Interface")), form}}.attachTo(this);
|
||||
|
||||
fillLanguageBox();
|
||||
fillCodecBox();
|
||||
|
||||
m_colorButton->setColor(StyleHelper::requestedBaseColor());
|
||||
m_resetWarningsButton->setEnabled(canResetWarnings());
|
||||
|
||||
m_showShortcutsInContextMenus->setText(
|
||||
tr("Show keyboard shortcuts in context menus (default: %1)")
|
||||
.arg(q->m_defaultShowShortcutsInContextMenu ? Tr::tr("on") : Tr::tr("off")));
|
||||
m_showShortcutsInContextMenus->setChecked(GeneralSettings::showShortcutsInContextMenu());
|
||||
|
||||
connect(resetColorButton,
|
||||
&QAbstractButton::clicked,
|
||||
this,
|
||||
&GeneralSettingsWidget::resetInterfaceColor);
|
||||
connect(m_resetWarningsButton,
|
||||
&QAbstractButton::clicked,
|
||||
this,
|
||||
&GeneralSettingsWidget::resetWarnings);
|
||||
}
|
||||
|
||||
static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrPath)
|
||||
@@ -127,11 +173,11 @@ void GeneralSettingsWidget::fillLanguageBox() const
|
||||
{
|
||||
const QString currentLocale = language();
|
||||
|
||||
m_ui.languageBox->addItem(tr("<System Language>"), QString());
|
||||
m_languageBox->addItem(tr("<System Language>"), QString());
|
||||
// need to add this explicitly, since there is no qm file for English
|
||||
m_ui.languageBox->addItem(QLatin1String("English"), QLatin1String("C"));
|
||||
m_languageBox->addItem(QLatin1String("English"), QLatin1String("C"));
|
||||
if (currentLocale == QLatin1String("C"))
|
||||
m_ui.languageBox->setCurrentIndex(m_ui.languageBox->count() - 1);
|
||||
m_languageBox->setCurrentIndex(m_languageBox->count() - 1);
|
||||
|
||||
const FilePath creatorTrPath = ICore::resourcePath("translations");
|
||||
const QStringList languageFiles = creatorTrPath.toDir().entryList(
|
||||
@@ -146,23 +192,23 @@ void GeneralSettingsWidget::fillLanguageBox() const
|
||||
QLocale tmpLocale(locale);
|
||||
QString languageItem = QLocale::languageToString(tmpLocale.language()) + QLatin1String(" (")
|
||||
+ QLocale::countryToString(tmpLocale.country()) + QLatin1Char(')');
|
||||
m_ui.languageBox->addItem(languageItem, locale);
|
||||
m_languageBox->addItem(languageItem, locale);
|
||||
if (locale == currentLocale)
|
||||
m_ui.languageBox->setCurrentIndex(m_ui.languageBox->count() - 1);
|
||||
m_languageBox->setCurrentIndex(m_languageBox->count() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsWidget::apply()
|
||||
{
|
||||
int currentIndex = m_ui.languageBox->currentIndex();
|
||||
setLanguage(m_ui.languageBox->itemData(currentIndex, Qt::UserRole).toString());
|
||||
currentIndex = m_ui.codecBox->currentIndex();
|
||||
setCodecForLocale(m_ui.codecBox->itemText(currentIndex).toLocal8Bit());
|
||||
q->setShowShortcutsInContextMenu(m_ui.showShortcutsInContextMenus->isChecked());
|
||||
int currentIndex = m_languageBox->currentIndex();
|
||||
setLanguage(m_languageBox->itemData(currentIndex, Qt::UserRole).toString());
|
||||
currentIndex = m_codecBox->currentIndex();
|
||||
setCodecForLocale(m_codecBox->itemText(currentIndex).toLocal8Bit());
|
||||
q->setShowShortcutsInContextMenu(m_showShortcutsInContextMenus->isChecked());
|
||||
// Apply the new base color if accepted
|
||||
StyleHelper::setBaseColor(m_ui.colorButton->color());
|
||||
m_ui.themeChooser->apply();
|
||||
StyleHelper::setBaseColor(m_colorButton->color());
|
||||
m_themeChooser->apply();
|
||||
}
|
||||
|
||||
bool GeneralSettings::showShortcutsInContextMenu()
|
||||
@@ -175,14 +221,14 @@ bool GeneralSettings::showShortcutsInContextMenu()
|
||||
|
||||
void GeneralSettingsWidget::resetInterfaceColor()
|
||||
{
|
||||
m_ui.colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
|
||||
m_colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
|
||||
}
|
||||
|
||||
void GeneralSettingsWidget::resetWarnings()
|
||||
{
|
||||
InfoBar::clearGloballySuppressed();
|
||||
CheckableMessageBox::resetAllDoNotAskAgainQuestions(ICore::settings());
|
||||
m_ui.resetWarningsButton->setEnabled(false);
|
||||
m_resetWarningsButton->setEnabled(false);
|
||||
}
|
||||
|
||||
bool GeneralSettingsWidget::canResetWarnings()
|
||||
@@ -194,7 +240,7 @@ bool GeneralSettingsWidget::canResetWarnings()
|
||||
void GeneralSettingsWidget::resetLanguage()
|
||||
{
|
||||
// system language is default
|
||||
m_ui.languageBox->setCurrentIndex(0);
|
||||
m_languageBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
QString GeneralSettingsWidget::language()
|
||||
@@ -222,9 +268,9 @@ void GeneralSettingsWidget::fillCodecBox() const
|
||||
QByteArrayList codecs = QTextCodec::availableCodecs();
|
||||
Utils::sort(codecs);
|
||||
for (const QByteArray &codec : qAsConst(codecs)) {
|
||||
m_ui.codecBox->addItem(QString::fromLocal8Bit(codec));
|
||||
m_codecBox->addItem(QString::fromLocal8Bit(codec));
|
||||
if (codec == currentCodec)
|
||||
m_ui.codecBox->setCurrentIndex(m_ui.codecBox->count() - 1);
|
||||
m_codecBox->setCurrentIndex(m_codecBox->count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,214 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Core::Internal::GeneralSettings</class>
|
||||
<widget class="QWidget" name="Core::Internal::GeneralSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>527</width>
|
||||
<height>469</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="interfaceBox">
|
||||
<property name="title">
|
||||
<string>User Interface</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<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="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QComboBox" name="languageBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<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="1">
|
||||
<widget class="QCheckBox" name="dpiCheckbox">
|
||||
<property name="text">
|
||||
<string>Enable high DPI scaling</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Utils::QtColorButton" name="colorButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alphaAllowed" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetColorButton">
|
||||
<property name="toolTip">
|
||||
<string comment="Color">Reset to default.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<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="2" column="0">
|
||||
<widget class="QLabel" name="languageLabel">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="showShortcutsInContextMenus">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="themeLabel">
|
||||
<property name="text">
|
||||
<string>Theme:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Core::Internal::ThemeChooser" name="themeChooser" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="colorLabel">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="codecForLocale">
|
||||
<property name="text">
|
||||
<string>Text codec for tools:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QComboBox" name="codecBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::QtColorButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header location="global">utils/qtcolorbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Core::Internal::ThemeChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">coreplugin/themechooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>colorButton</tabstop>
|
||||
<tabstop>resetColorButton</tabstop>
|
||||
<tabstop>languageBox</tabstop>
|
||||
<tabstop>resetWarningsButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Reference in New Issue
Block a user