Do not propagate dark theme to widget designer

Fixes: QTCREATORBUG-23981
Change-Id: I63c362b2ec87e02e7d6828ee4c143f54d113bef2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2020-08-14 11:29:34 +02:00
parent e9f74df8cf
commit 84e2814ef0
2 changed files with 17 additions and 1 deletions

View File

@@ -242,9 +242,24 @@ void Theme::readSettings(QSettings &settings)
}
}
// If you copy QPalette, default values stay at default, even if that default is different
// within the context of different widgets. Create deep copy.
static QPalette copyPalette(const QPalette &p)
{
QPalette res;
for (int group = 0; group < QPalette::NColorGroups; ++group) {
for (int role = 0; role < QPalette::NColorRoles; ++role) {
res.setBrush(QPalette::ColorGroup(group),
QPalette::ColorRole(role),
p.brush(QPalette::ColorGroup(group), QPalette::ColorRole(role)));
}
}
return res;
}
QPalette Theme::initialPalette()
{
static QPalette palette = QApplication::palette();
static QPalette palette = copyPalette(QApplication::palette());
return palette;
}

View File

@@ -766,6 +766,7 @@ IEditor *FormEditorData::createEditor()
m_fwm->closeAllPreviews();
QDesignerFormWindowInterface *form = m_fwm->createFormWindow(nullptr);
QTC_ASSERT(form, return nullptr);
form->setPalette(Theme::initialPalette());
QObject::connect(form, &QDesignerFormWindowInterface::toolChanged, [this] (int i) { toolChanged(i); });
auto widgetHost = new SharedTools::WidgetHost( /* parent */ nullptr, form);