forked from qt-creator/qt-creator
Theme: Force new start of Creator when changing the theme
Let's face it. "Live" theme change doesn't work reliably and there is currently no effort to make this work. This change removes the theme change during a Qt Creator run and shows "Restart required" message dialog which we know from the language settings. Change-Id: Ic9d300c5378841905260ff725aa3011717191de7 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -148,7 +148,6 @@ signals:
|
|||||||
void coreAboutToClose();
|
void coreAboutToClose();
|
||||||
void contextAboutToChange(const QList<Core::IContext *> &context);
|
void contextAboutToChange(const QList<Core::IContext *> &context);
|
||||||
void contextChanged(const Core::Context &context);
|
void contextChanged(const Core::Context &context);
|
||||||
void themeChanged();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* internal use */
|
/* internal use */
|
||||||
|
@@ -155,30 +155,15 @@ void ThemeSettingsWidget::apply()
|
|||||||
const int index = d->m_ui->themeComboBox->currentIndex();
|
const int index = d->m_ui->themeComboBox->currentIndex();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
ThemeEntry currentTheme = d->m_themeListModel->themeAt(index);
|
const QString themeId = d->m_themeListModel->themeAt(index).id().toString();
|
||||||
const QString themeId = currentTheme.id().toString();
|
|
||||||
Theme *newTheme = new Theme(themeId);
|
|
||||||
QSettings themeSettings(currentTheme.filePath(), QSettings::IniFormat);
|
|
||||||
newTheme->readSettings(themeSettings);
|
|
||||||
setCreatorTheme(newTheme);
|
|
||||||
emit ICore::instance()->themeChanged();
|
|
||||||
QPalette pal = newTheme->flag(Theme::ApplyThemePaletteGlobally) ? newTheme->palette()
|
|
||||||
: Theme::initialPalette();
|
|
||||||
QApplication::setPalette(pal);
|
|
||||||
if (ManhattanStyle *style = qobject_cast<ManhattanStyle *>(QApplication::style())) {
|
|
||||||
QStyle *baseStyle = 0;
|
|
||||||
foreach (const QString &s, creatorTheme()->preferredStyles()) {
|
|
||||||
if ((baseStyle = QStyleFactory::create(s)))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
style->setBaseStyle(baseStyle);
|
|
||||||
}
|
|
||||||
foreach (QWidget *w, QApplication::topLevelWidgets())
|
|
||||||
w->update();
|
|
||||||
|
|
||||||
// save filename of selected theme in global config
|
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->setValue(QLatin1String(Constants::SETTINGS_THEME), themeId);
|
if (settings->value(QLatin1String(Constants::SETTINGS_THEME)).toString() != themeId) {
|
||||||
|
QMessageBox::information(ICore::mainWindow(), tr("Restart Required"),
|
||||||
|
tr("The theme change will take effect after a restart of Qt Creator."));
|
||||||
|
|
||||||
|
// save filename of selected theme in global config
|
||||||
|
settings->setValue(QLatin1String(Constants::SETTINGS_THEME), themeId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -100,8 +100,6 @@ public:
|
|||||||
int activePlugin() const { return m_activePlugin; }
|
int activePlugin() const { return m_activePlugin; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onThemeChanged();
|
|
||||||
|
|
||||||
void setActivePlugin(int pos)
|
void setActivePlugin(int pos)
|
||||||
{
|
{
|
||||||
if (m_activePlugin != pos) {
|
if (m_activePlugin != pos) {
|
||||||
@@ -118,6 +116,7 @@ private:
|
|||||||
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
||||||
void facilitateQml(QQmlEngine *engine);
|
void facilitateQml(QQmlEngine *engine);
|
||||||
void addPages(const QList<IWelcomePage *> &pages);
|
void addPages(const QList<IWelcomePage *> &pages);
|
||||||
|
void applyTheme();
|
||||||
|
|
||||||
QWidget *m_modeWidget;
|
QWidget *m_modeWidget;
|
||||||
QuickContainer *m_welcomePage;
|
QuickContainer *m_welcomePage;
|
||||||
@@ -153,7 +152,7 @@ WelcomeMode::WelcomeMode()
|
|||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
|
|
||||||
m_welcomePage = new QuickContainer();
|
m_welcomePage = new QuickContainer();
|
||||||
onThemeChanged(); // initialize background color and theme properties
|
applyTheme(); // initialize background color and theme properties
|
||||||
m_welcomePage->setResizeMode(QuickContainer::SizeRootObjectToView);
|
m_welcomePage->setResizeMode(QuickContainer::SizeRootObjectToView);
|
||||||
|
|
||||||
m_welcomePage->setObjectName(QLatin1String("WelcomePage"));
|
m_welcomePage->setObjectName(QLatin1String("WelcomePage"));
|
||||||
@@ -175,12 +174,10 @@ WelcomeMode::WelcomeMode()
|
|||||||
layout->addWidget(container);
|
layout->addWidget(container);
|
||||||
#endif // USE_QUICK_WIDGET
|
#endif // USE_QUICK_WIDGET
|
||||||
|
|
||||||
connect(ICore::instance(), &ICore::themeChanged, this, &WelcomeMode::onThemeChanged);
|
|
||||||
|
|
||||||
setWidget(m_modeWidget);
|
setWidget(m_modeWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WelcomeMode::onThemeChanged()
|
void WelcomeMode::applyTheme()
|
||||||
{
|
{
|
||||||
const QVariantHash creatorTheme = Utils::creatorTheme()->values();
|
const QVariantHash creatorTheme = Utils::creatorTheme()->values();
|
||||||
for (auto it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
|
for (auto it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
|
||||||
|
Reference in New Issue
Block a user