Changeset View
Changeset View
Standalone View
Standalone View
src/EditProfileDialog.cpp
Context not available. | |||||
83 | 83 | | |||
---|---|---|---|---|---|
84 | connect(mButtonBox->button(QDialogButtonBox::Apply), | 84 | connect(mButtonBox->button(QDialogButtonBox::Apply), | ||
85 | &QPushButton::clicked, this, | 85 | &QPushButton::clicked, this, | ||
86 | &Konsole::EditProfileDialog::save); | 86 | &Konsole::EditProfileDialog::apply); | ||
87 | 87 | | |||
88 | connect(_delayedPreviewTimer, &QTimer::timeout, this, | 88 | connect(_delayedPreviewTimer, &QTimer::timeout, this, | ||
89 | &Konsole::EditProfileDialog::delayedPreviewActivate); | 89 | &Konsole::EditProfileDialog::delayedPreviewActivate); | ||
Context not available. | |||||
142 | } | 142 | } | ||
143 | 143 | | |||
144 | void EditProfileDialog::accept() | 144 | void EditProfileDialog::accept() | ||
145 | { | ||||
146 | if (!checkProfileName()) { | ||||
147 | return; | ||||
148 | } | ||||
149 | save(); | ||||
150 | unpreviewAll(); | ||||
151 | QDialog::accept(); | ||||
152 | } | ||||
153 | | ||||
154 | void EditProfileDialog::apply() | ||||
155 | { | ||||
156 | if (!checkProfileName()) { | ||||
157 | return; | ||||
158 | } | ||||
159 | save(); | ||||
160 | } | ||||
161 | | ||||
162 | bool EditProfileDialog::checkProfileName() | ||||
145 | { | 163 | { | ||
146 | Q_ASSERT(_profile); | 164 | Q_ASSERT(_profile); | ||
147 | Q_ASSERT(_tempProfile); | 165 | Q_ASSERT(_tempProfile); | ||
148 | 166 | | |||
167 | Profile::Ptr existingProfile; | ||||
168 | QList<Profile::Ptr> existingProfiles = ProfileManager::instance()->allProfiles(); | ||||
169 | QStringList otherExistingProfileNames; | ||||
170 | | ||||
171 | foreach(existingProfile, existingProfiles) { | ||||
172 | if (existingProfile->name() != _profile->name()) { | ||||
173 | otherExistingProfileNames.append(existingProfile->name()); | ||||
174 | } | ||||
175 | } | ||||
176 | | ||||
149 | if ((_tempProfile->isPropertySet(Profile::Name) | 177 | if ((_tempProfile->isPropertySet(Profile::Name) | ||
150 | && _tempProfile->name().isEmpty()) | 178 | && _tempProfile->name().isEmpty()) | ||
151 | || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) { | 179 | || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) { | ||
152 | KMessageBox::sorry(this, | 180 | KMessageBox::sorry(this, | ||
153 | i18n("<p>Each profile must have a name before it can be saved " | 181 | i18n("<p>Each profile must have a name before it can be saved " | ||
154 | "into disk.</p>")); | 182 | "into disk.</p>")); | ||
155 | return; | 183 | // revert the name in the dialog | ||
184 | _ui->profileNameEdit->setText(_profile->name()); | ||||
185 | selectProfileName(); | ||||
186 | return false; | ||||
187 | } else if (!_tempProfile->name().isEmpty() && otherExistingProfileNames.contains(_tempProfile->name())) { | ||||
188 | KMessageBox::sorry(this, | ||||
189 | i18n("<p>A profile with this name already exists.</p>")); | ||||
190 | // revert the name in the dialog | ||||
191 | _ui->profileNameEdit->setText(_profile->name()); | ||||
192 | selectProfileName(); | ||||
193 | return false; | ||||
194 | } else { | ||||
195 | return true; | ||||
156 | } | 196 | } | ||
157 | save(); | | |||
158 | unpreviewAll(); | | |||
159 | QDialog::accept(); | | |||
160 | } | 197 | } | ||
161 | 198 | | |||
162 | QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr group, int maxLength) | 199 | QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr group, int maxLength) | ||
Context not available. |