diff --git a/src/profile/ProfileManager.cpp b/src/profile/ProfileManager.cpp index 44601aa2..956febd4 100644 --- a/src/profile/ProfileManager.cpp +++ b/src/profile/ProfileManager.cpp @@ -53,6 +53,7 @@ ProfileManager::ProfileManager() { // load fallback profile initFallbackProfile(); + _defaultProfile = _fallbackProfile; // lookup the default profile specified in rc // for stand-alone Konsole, appConfig is just konsolerc @@ -69,18 +70,7 @@ ProfileManager::ProfileManager() defaultProfileFileName = group.readEntry("DefaultProfile", ""); } - _defaultProfile = _fallbackProfile; - if (!defaultProfileFileName.isEmpty()) { - // load the default profile - const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + defaultProfileFileName); - - if (!path.isEmpty()) { - Profile::Ptr profile = loadProfile(path); - if (profile) { - _defaultProfile = profile; - } - } - } + loadAllProfiles(defaultProfileFileName); Q_ASSERT(_profiles.size() > 0); Q_ASSERT(_defaultProfile); @@ -216,18 +206,15 @@ QStringList ProfileManager::availableProfileNames() const return names; } -void ProfileManager::loadAllProfiles() +void ProfileManager::loadAllProfiles(const QString &defaultProfileFileName) { - if (_loadedAllProfiles) { - return; - } - const QStringList &paths = availableProfilePaths(); for (const QString &path : paths) { - loadProfile(path); + Profile::Ptr profile = loadProfile(path); + if (profile && !defaultProfileFileName.isEmpty() && path.endsWith(defaultProfileFileName)) { + _defaultProfile = profile; + } } - - _loadedAllProfiles = true; } void ProfileManager::saveSettings() @@ -363,7 +350,7 @@ void ProfileManager::changeProfile(Profile::Ptr profile, QHashpath() != origPath) { // this is needed to include the old profile too - _loadedAllProfiles = false; + loadAllProfiles(); const QList availableProfiles = ProfileManager::instance()->allProfiles(); for (const Profile::Ptr &oldProfile : availableProfiles) { if (oldProfile->path() == origPath) { diff --git a/src/profile/ProfileManager.h b/src/profile/ProfileManager.h index de6cee23..8b231982 100644 --- a/src/profile/ProfileManager.h +++ b/src/profile/ProfileManager.h @@ -72,7 +72,7 @@ public: * profile configuration file from disk and parsing it. * Therefore it should only be done when necessary. */ - void loadAllProfiles(); + void loadAllProfiles(const QString &defaultProfileFileName = {}); /** * Loads a profile from the specified path and registers @@ -227,8 +227,6 @@ private: Profile::Ptr _defaultProfile; Profile::Ptr _fallbackProfile; - bool _loadedAllProfiles = false; // set to true after loadAllProfiles has been called - struct ShortcutData { Profile::Ptr profileKey; QString profilePath;