Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
4d429f94
Commit
4d429f94
authored
Oct 09, 2021
by
Ahmad Samir
Committed by
Kurt Hindenburg
Oct 15, 2021
Browse files
Change how profile renaming is handled
parent
03badf5b
Pipeline
#88877
passed with stage
in 1 minute and 49 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/profile/ProfileManager.cpp
View file @
4d429f94
...
...
@@ -286,6 +286,8 @@ void ProfileManager::changeProfile(Profile::Ptr profile, QHash<Profile::Property
Q_ASSERT
(
profile
);
const
QString
origPath
=
profile
->
path
();
const
QKeySequence
origShortcut
=
shortcut
(
profile
);
const
bool
isDefaultProfile
=
profile
==
defaultProfile
();
const
QString
uniqueProfileName
=
generateUniqueName
();
...
...
@@ -340,30 +342,25 @@ void ProfileManager::changeProfile(Profile::Ptr profile, QHash<Profile::Property
// it has no file on disk
if
(
persistent
&&
!
profile
->
isHidden
())
{
profile
->
setProperty
(
Profile
::
Path
,
saveProfile
(
profile
));
}
if
(
isNameChanged
)
{
// Renamed?
// origPath is empty when saving a new profile
if
(
!
origPath
.
isEmpty
())
{
// Delete the old/redundant .profile from disk
QFile
::
remove
(
origPath
);
// 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
if
(
!
origPath
.
isEmpty
()
&&
profile
->
path
()
!=
origPath
)
{
// this is needed to include the old profile too
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
);
}
}
// Change the default profile name to the new one
if
(
isDefaultProfile
)
{
setDefaultProfile
(
profile
);
}
// If the profile had a shortcut, re-assign it to the profile
if
(
!
origShortcut
.
isEmpty
())
{
setShortcut
(
profile
,
origShortcut
);
}
}
}
if
(
isNameChanged
)
{
sortProfiles
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment