diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp index 9030ecd9e2..2d2830e60a 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp @@ -329,8 +329,9 @@ void DlgSettingsGeneral::loadSettings() } QAbstractItemModel* model = ui->Languages->model(); - if (model) + if (model) { model->sort(0); + } addIconSizes(getCurrentIconSize()); @@ -425,18 +426,44 @@ void DlgSettingsGeneral::loadThemes() { ui->themesCombobox->clear(); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/MainWindow"); QString currentTheme = QString::fromLatin1(hGrp->GetASCII("Theme", "").c_str()); Application::Instance->prefPackManager()->rescan(); auto packs = Application::Instance->prefPackManager()->preferencePacks(); + QString currentStyleSheet = QString::fromLatin1(hGrp->GetASCII("StyleSheet", "").c_str()); + QFileInfo fi(currentStyleSheet); + currentStyleSheet = fi.baseName(); + QString themeClassic = QStringLiteral("classic"); // handle the upcoming name change + QString similarTheme; + QString packName; for (const auto& pack : packs) { if (pack.second.metadata().type() == "Theme") { + packName = QString::fromStdString(pack.first); + if (packName.contains(themeClassic, Qt::CaseInsensitive)) { + themeClassic = QString::fromStdString(pack.first); + } + if (packName.contains(currentStyleSheet, Qt::CaseInsensitive)) { + similarTheme = QString::fromStdString(pack.first); + } ui->themesCombobox->addItem(QString::fromStdString(pack.first)); } } + if (currentTheme.isEmpty()) { + if (!currentStyleSheet.isEmpty() + && !similarTheme.isEmpty()) { // a user upgrading from 0.21 or earlier + hGrp->SetASCII("Theme", similarTheme.toStdString()); + currentTheme = QString::fromLatin1(hGrp->GetASCII("Theme", "").c_str()); + } + else { // a brand new user + hGrp->SetASCII("Theme", themeClassic.toStdString()); + currentTheme = QString::fromLatin1(hGrp->GetASCII("Theme", "").c_str()); + } + } + int index = ui->themesCombobox->findText(currentTheme); if (index >= 0 && index < ui->themesCombobox->count()) { ui->themesCombobox->setCurrentIndex(index);