Popup dialog if changes are made to read-only profiles

Add dialog to explain how to change a ro profile.

patch by ahmadsamir

Differential Revision: https://phabricator.kde.org/D9350
wilder-portage
Kurt Hindenburg 8 years ago
parent ef43caa9af
commit 1adc69e39a
  1. 25
      src/EditProfileDialog.cpp
  2. 7
      src/EditProfileDialog.h

@ -143,10 +143,15 @@ void EditProfileDialog::reject()
void EditProfileDialog::accept()
{
if (!isValidProfileName()) {
return;
// if the Apply button is disabled then no settings were changed
// or the changes have already been saved by apply()
if (mButtonBox->button(QDialogButtonBox::Apply)->isEnabled()) {
if (!isValidProfileName()) {
return;
}
save();
}
save();
unpreviewAll();
QDialog::accept();
}
@ -164,6 +169,20 @@ bool EditProfileDialog::isValidProfileName()
Q_ASSERT(_profile);
Q_ASSERT(_tempProfile);
// check whether the user has enough permissions to save the profile
QFileInfo fileInfo(_profile->path());
if (fileInfo.exists() && !fileInfo.isWritable()) {
if (!_tempProfile->isPropertySet(Profile::Name)
|| (_tempProfile->isPropertySet(Profile::Name) && _tempProfile->name() == _profile->name())) {
KMessageBox::sorry(this,
i18n("<p>Konsole does not have permission to save this profile to:<br /> \"%1\"</p>"
"<p>To be able to save settings you can either change the permissions "
"of the profile configuration file or change the profile name to save "
"the settings to a new profile.</p>", _profile->path()));
return false;
}
}
const QList<Profile::Ptr> existingProfiles = ProfileManager::instance()->allProfiles();
QStringList otherExistingProfileNames;

@ -242,8 +242,11 @@ private:
};
void setupCheckBoxes(BooleanOption *options, const Profile::Ptr profile);
// returns false if the profile name is empty or if the name matches
// the name of an already existing profile; otherwise return true.
// returns false if:
// - the profile name is empty
// - the name matches the name of an already existing profile
// - the existing profile config file is read-only
// otherwise returns true.
bool isValidProfileName();
Ui::EditProfileDialog *_ui;

Loading…
Cancel
Save