Commit 295d42a4 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Reuse the same _tempProfile in Edit dialog and clear its properties

Also in save() just clear _previewedProperties; logically it wouldn't be
holding any properties that weren't set on _tempProfile, since all those
properties have been saved by the changeProfile() call, clear() makes
sense.
parent 2bff3717
Pipeline #218439 passed with stage
in 2 minutes and 41 seconds
......@@ -58,7 +58,10 @@ using namespace Konsole;
EditProfileDialog::EditProfileDialog(QWidget *parent)
: KPageDialog(parent)
, _tempProfile(new Profile{})
{
_tempProfile->setHidden(true);
setWindowTitle(i18n("Edit Profile"));
setFaceType(KPageDialog::List);
......@@ -192,8 +195,6 @@ EditProfileDialog::EditProfileDialog(QWidget *parent)
// not been updated since the last profile change and will need
// to be refreshed when the user switches to them
connect(this, &KPageDialog::currentPageChanged, this, &Konsole::EditProfileDialog::preparePage);
createTempProfile();
}
EditProfileDialog::~EditProfileDialog()
......@@ -231,10 +232,7 @@ void EditProfileDialog::save()
// ensure that these settings are not undone by a call
// to unpreview()
const Profile::PropertyMap &map = _tempProfile->properties();
for (const auto &[property, _] : map) {
_previewedProperties.erase(property);
}
_previewedProperties.clear();
// Update the default profile if needed
if (defaultChanged) {
......@@ -246,7 +244,7 @@ void EditProfileDialog::save()
_isDefault = defaultChecked;
}
createTempProfile();
resetTempProfile();
_buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
}
......@@ -373,9 +371,7 @@ void EditProfileDialog::setProfile(const Konsole::Profile::Ptr &profile, EditPro
}
preparePage(currentPage());
if (_tempProfile) {
createTempProfile();
}
resetTempProfile();
}
const QString EditProfileDialog::currentColorSchemeName() const
......@@ -1317,9 +1313,9 @@ void EditProfileDialog::updateTransparencyWarning()
}
}
void EditProfileDialog::createTempProfile()
void EditProfileDialog::resetTempProfile()
{
_tempProfile = Profile::Ptr(new Profile);
_tempProfile->clear();
_tempProfile->setHidden(true);
}
......
......@@ -286,9 +286,8 @@ private:
// always come after the preview operation.
void updateTempProfileProperty(Profile::Property, const QVariant &value);
// helper method for creating an empty & hidden profile and assigning
// it to _tempProfile.
void createTempProfile();
// helper method for clearing all _tempProfile properies and marking it hidden
void resetTempProfile();
// Enable or disable apply button, used only within
// updateTempProfileProperty() or when toggling the default profile.
......
Supports Markdown
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