forked from qt-creator/qt-creator
Core: Refactor argument handling
Split up getting the data from the arguments list and actually applying the values, and move the details of theme creation and application to better places. This gets rid of ugly control flow details like that CorePlugin::initialize created the action manager before calling parseArguments, because that is needed to apply the presentation mode argument setting, and parseArguments created the main window because that needs to be created _after_ setting the theme (which can be overridden by command line argument), but _before_ applying the override color argument setting. Change-Id: I9c99305b6efbfcc4b37cea9e5c70d816a621963b Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -171,8 +171,7 @@ void ThemeChooser::apply()
|
||||
return;
|
||||
const QString themeId = d->m_themeListModel->themeAt(index).id().toString();
|
||||
QSettings *settings = ICore::settings();
|
||||
const QString currentThemeId = settings->value(QLatin1String(Constants::SETTINGS_THEME),
|
||||
QLatin1String(Constants::DEFAULT_THEME)).toString();
|
||||
const QString currentThemeId = ThemeEntry::themeSetting().toString();
|
||||
if (currentThemeId != themeId) {
|
||||
QMessageBox::information(ICore::mainWindow(), tr("Restart Required"),
|
||||
tr("The theme change will take effect after a restart of Qt Creator."));
|
||||
@@ -215,5 +214,25 @@ QList<ThemeEntry> ThemeEntry::availableThemes()
|
||||
return themes;
|
||||
}
|
||||
|
||||
Id ThemeEntry::themeSetting()
|
||||
{
|
||||
return Id::fromSetting(ICore::settings()->value(QLatin1String(Constants::SETTINGS_THEME),
|
||||
QLatin1String(Constants::DEFAULT_THEME)));
|
||||
}
|
||||
|
||||
Theme *ThemeEntry::createTheme(Id id)
|
||||
{
|
||||
if (!id.isValid())
|
||||
return nullptr;
|
||||
const ThemeEntry entry = Utils::findOrDefault(availableThemes(),
|
||||
Utils::equal(&ThemeEntry::id, id));
|
||||
if (!entry.id().isValid())
|
||||
return nullptr;
|
||||
QSettings themeSettings(entry.filePath(), QSettings::IniFormat);
|
||||
Theme *theme = new Theme(entry.id().toString());
|
||||
theme->readSettings(themeSettings);
|
||||
return theme;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
Reference in New Issue
Block a user