mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Split out some code to a separate method
The goal is to make the code slightly more readable. GIT_SILENT
This commit is contained in:
@@ -359,26 +359,9 @@ void ProfileManager::changeProfile(Profile::Ptr profile, QHash<Profile::Property
|
||||
if (persistent && !profile->isHidden()) {
|
||||
profile->setProperty(Profile::Path, saveProfile(profile));
|
||||
|
||||
// if the profile was renamed, after saving the new profile
|
||||
// delete the old/redundant profile.
|
||||
// only do this if origPath is not empty, because it's empty
|
||||
// when creating a new profile, this works around a bug where
|
||||
// the newly created profile appears twice in the ProfileSettings
|
||||
// dialog
|
||||
// origPath is empty when creating a new profile (i.e. no renaming)
|
||||
if (!origPath.isEmpty() && profile->path() != origPath) {
|
||||
// this is needed to include the old profile too
|
||||
_loadedAllProfiles = false;
|
||||
const QList<Profile::Ptr> availableProfiles = ProfileManager::instance()->allProfiles();
|
||||
for (const Profile::Ptr &oldProfile : availableProfiles) {
|
||||
if (oldProfile->path() == origPath) {
|
||||
// assign the same shortcut of the old profile to
|
||||
// the newly renamed profile
|
||||
const auto oldShortcut = shortcut(oldProfile);
|
||||
if (deleteProfile(oldProfile)) {
|
||||
setShortcut(profile, oldShortcut);
|
||||
}
|
||||
}
|
||||
}
|
||||
processProfileRenaming(profile, origPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +373,22 @@ void ProfileManager::changeProfile(Profile::Ptr profile, QHash<Profile::Property
|
||||
Q_EMIT profileChanged(profile);
|
||||
}
|
||||
|
||||
void ProfileManager::processProfileRenaming(Profile::Ptr profile, const QString &origPath)
|
||||
{
|
||||
// We need all profiles here, including the old profile too
|
||||
_loadedAllProfiles = false;
|
||||
const QList<Profile::Ptr> availableProfiles = allProfiles();
|
||||
|
||||
for (const Profile::Ptr &oldProfile : availableProfiles) {
|
||||
if (oldProfile->path() == origPath) {
|
||||
const auto oldShortcut = shortcut(oldProfile);
|
||||
if (deleteProfile(oldProfile)) {
|
||||
setShortcut(profile, oldShortcut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileManager::addProfile(const Profile::Ptr &profile)
|
||||
{
|
||||
if (_profiles.empty()) {
|
||||
|
||||
@@ -224,6 +224,12 @@ private:
|
||||
// A list of all loaded profiles, sorted by profile name
|
||||
std::vector<Profile::Ptr> _profiles;
|
||||
|
||||
// This is called after renaming a profile, and saving it to the new
|
||||
// .profile on disk; this method will then delete the old profile (i.e.
|
||||
// remove the old .profile from disk ...etc), and assign the keyboard
|
||||
// shortcut (if any) of the old profile to the newly created one.
|
||||
void processProfileRenaming(Profile::Ptr profile, const QString &origPath);
|
||||
|
||||
Profile::Ptr _defaultProfile;
|
||||
Profile::Ptr _fallbackProfile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user