Commit e805f086 authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg
Browse files

Change EditProfileDialog window title when creating a new profile

Now when creating a new profile, the title will be "Create new profile",
this is less confusing when the user tries to edit e.g. the Fallback profile,
which in effect will create a new profile as the Fallback one is immutable.
parent ba81c56a
......@@ -899,6 +899,7 @@ void SessionController::changeCodec(QTextCodec* codec)
void SessionController::editCurrentProfile()
{
auto profile = SessionManager::instance()->sessionProfile(session());
auto state = EditProfileDialog::ExistingProfile;
// Don't edit the Fallback profile, instead create a new one
if (profile->isFallback()) {
auto newProfile = Profile::Ptr(new Profile(profile));
......@@ -908,12 +909,13 @@ void SessionController::editCurrentProfile()
newProfile->setProperty(Profile::UntranslatedName, uniqueName);
profile = newProfile;
SessionManager::instance()->setSessionProfile(session(), profile);
state = EditProfileDialog::NewProfile;
}
auto *dialog = new EditProfileDialog(QApplication::activeWindow());
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setModal(true);
dialog->setProfile(profile);
dialog->setProfile(profile, state);
connect(dialog, &QDialog::accepted, this, [profile]() {
ProfileManager::instance()->addProfile(profile);
......
......@@ -148,7 +148,7 @@ void ProfileSettings::createProfile()
auto *dialog = new EditProfileDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setModal(true);
dialog->setProfile(newProfile);
dialog->setProfile(newProfile, EditProfileDialog::NewProfile);
dialog->selectProfileName();
connect(dialog, &QDialog::accepted, this, [newProfile]() {
......
......@@ -348,7 +348,7 @@ QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr &group, int
return caption;
}
void EditProfileDialog::updateCaption(const Profile::Ptr &profile)
void EditProfileDialog::updateCaption(const Profile::Ptr &profile, EditProfileDialog::InitialProfileState state)
{
const int MAX_GROUP_CAPTION_LENGTH = 25;
ProfileGroup::Ptr group = profile->asGroup();
......@@ -359,18 +359,22 @@ void EditProfileDialog::updateCaption(const Profile::Ptr &profile)
group->profiles().count(),
caption));
} else {
setWindowTitle(i18n("Edit Profile \"%1\"", profile->name()));
if (state == EditProfileDialog::NewProfile) {
setWindowTitle(i18n("Create New Profile"));
} else {
setWindowTitle(i18n("Edit Profile \"%1\"", profile->name()));
}
}
}
void EditProfileDialog::setProfile(const Konsole::Profile::Ptr &profile)
void EditProfileDialog::setProfile(const Konsole::Profile::Ptr &profile, EditProfileDialog::InitialProfileState state)
{
Q_ASSERT(profile);
_profile = profile;
// update caption
updateCaption(profile);
updateCaption(profile, state);
// mark each page of the dialog as out of date
// and force an update of the currently visible page
......
......@@ -61,6 +61,11 @@ public:
explicit EditProfileDialog(QWidget *parent = nullptr);
~EditProfileDialog() override;
enum InitialProfileState {
ExistingProfile,
NewProfile,
};
/**
* Initializes the dialog with the settings for the specified session
* type.
......@@ -69,8 +74,10 @@ public:
* with the altered settings.
*
* @param profile The profile to be edited
* @param state Indicates whether @p profile is an already existing profile
* or a new one being created
*/
void setProfile(const Profile::Ptr &profile);
void setProfile(const Profile::Ptr &profile, InitialProfileState state = EditProfileDialog::ExistingProfile);
/**
* Selects the text in the profile name edit area.
......@@ -263,7 +270,7 @@ private:
void unpreviewAll();
void enableIfNonEmptySelection(QWidget *widget, QItemSelectionModel *selectionModel);
void updateCaption(const Profile::Ptr &profile);
void updateCaption(const Profile::Ptr &profile, InitialProfileState state = EditProfileDialog::ExistingProfile);
void updateTransparencyWarning();
void updateFontPreview(QFont font);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment