diff --git a/src/ProfileManager.h b/src/ProfileManager.h --- a/src/ProfileManager.h +++ b/src/ProfileManager.h @@ -284,6 +284,10 @@ QString profilePath; }; QMap _shortcuts; // shortcut keys -> profile path + + // finds out if it's a internal profile or an external one, + // fixing the path to point to the correct location for the profile. + QString normalizePath(const QString& path) const; }; /** diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -569,6 +569,14 @@ _shortcuts.insert(shortcut, data); } } + +QString ProfileManager::normalizePath(const QString& path) const { + QFileInfo fileInfo(path); + const QString location = QStandardPaths::locate( + QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + fileInfo.fileName()); + return (!fileInfo.isAbsolute()) || location.isEmpty() ? path : fileInfo.fileName(); +} + void ProfileManager::saveShortcuts() { KSharedConfigPtr appConfig = KSharedConfig::openConfig(); @@ -578,30 +586,27 @@ QMapIterator iter(_shortcuts); while (iter.hasNext()) { iter.next(); - QString shortcutString = iter.key().toString(); + QString profileName = normalizePath(iter.value().profilePath); + shortcutGroup.writeEntry(shortcutString, profileName); + } +} - // if the profile path in "Profile Shortcuts" is an absolute path, - // take the profile name - QFileInfo fileInfo(iter.value().profilePath); - QString profileName; - if (fileInfo.isAbsolute()) { - // Check to see if file is under KDE's data locations. If not, - // store full path. - const QString location = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("konsole/") + fileInfo.fileName()); - if (location.isEmpty()) { - profileName = iter.value().profilePath; - } else { - profileName = fileInfo.fileName(); - } - } else { - profileName = iter.value().profilePath; - } - shortcutGroup.writeEntry(shortcutString, profileName); +void ProfileManager::saveFavorites() +{ + KSharedConfigPtr appConfig = KSharedConfig::openConfig(); + KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles"); + + QStringList paths; + foreach(const Profile::Ptr& profile, _favorites) { + Q_ASSERT(_profiles.contains(profile) && profile); + paths << normalizePath(profile->path()); } + favoriteGroup.writeEntry("Favorites", paths); } + + void ProfileManager::setShortcut(Profile::Ptr profile , const QKeySequence& keySequence) { @@ -655,37 +660,6 @@ _loadedFavorites = true; } -void ProfileManager::saveFavorites() -{ - KSharedConfigPtr appConfig = KSharedConfig::openConfig(); - KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles"); - - QStringList paths; - foreach(const Profile::Ptr& profile, _favorites) { - Q_ASSERT(_profiles.contains(profile) && profile); - - QFileInfo fileInfo(profile->path()); - QString profileName; - - if (fileInfo.isAbsolute()) { - // Check to see if file is under KDE's data locations. If not, - // store full path. - const QString location = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + fileInfo.fileName()); - - if (location.isEmpty()) { - profileName = profile->path(); - } else { - profileName = fileInfo.fileName(); - } - } else { - profileName = profile->path(); - } - - paths << profileName; - } - - favoriteGroup.writeEntry("Favorites", paths); -} QList ProfileManager::shortcuts() {