Changeset View
Changeset View
Standalone View
Standalone View
src/EditProfileDialog.cpp
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Line(s) | 306 | KMessageBox::sorry(this, | |||
---|---|---|---|---|---|
307 | i18n("<p>Konsole does not have permission to save this profile to:<br /> \"%1\"</p>" | 307 | i18n("<p>Konsole does not have permission to save this profile to:<br /> \"%1\"</p>" | ||
308 | "<p>To be able to save settings you can either change the permissions " | 308 | "<p>To be able to save settings you can either change the permissions " | ||
309 | "of the profile configuration file or change the profile name to save " | 309 | "of the profile configuration file or change the profile name to save " | ||
310 | "the settings to a new profile.</p>", _profile->path())); | 310 | "the settings to a new profile.</p>", _profile->path())); | ||
311 | return false; | 311 | return false; | ||
312 | } | 312 | } | ||
313 | } | 313 | } | ||
314 | 314 | | |||
315 | const QList<Profile::Ptr> existingProfiles = ProfileManager::instance()->allProfiles(); | | |||
316 | QStringList otherExistingProfileNames; | 315 | QStringList otherExistingProfileNames; | ||
317 | 316 | | |||
318 | foreach(auto existingProfile, existingProfiles) { | 317 | for (const auto& existingProfile : ProfileManager::instance()->allProfiles()) { | ||
319 | if (existingProfile->name() != _profile->name()) { | 318 | if (existingProfile->name() != _profile->name()) { | ||
320 | otherExistingProfileNames.append(existingProfile->name()); | 319 | otherExistingProfileNames.append(existingProfile->name()); | ||
321 | } | 320 | } | ||
322 | } | 321 | } | ||
323 | 322 | | |||
324 | if ((_tempProfile->isPropertySet(Profile::Name) | 323 | if ((_tempProfile->isPropertySet(Profile::Name) | ||
325 | && _tempProfile->name().isEmpty()) | 324 | && _tempProfile->name().isEmpty()) | ||
326 | || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) { | 325 | || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) { | ||
327 | KMessageBox::sorry(this, | 326 | KMessageBox::sorry(this, | ||
328 | i18n("<p>Each profile must have a name before it can be saved " | 327 | i18n("<p>Each profile must have a name before it can be saved " | ||
329 | "into disk.</p>")); | 328 | "into disk.</p>")); | ||
330 | // revert the name in the dialog | 329 | // revert the name in the dialog | ||
331 | _generalUi->profileNameEdit->setText(_profile->name()); | 330 | _generalUi->profileNameEdit->setText(_profile->name()); | ||
332 | selectProfileName(); | 331 | selectProfileName(); | ||
333 | return false; | 332 | return false; | ||
334 | } else if (!_tempProfile->name().isEmpty() && otherExistingProfileNames.contains(_tempProfile->name())) { | 333 | } | ||
334 | if (!_tempProfile->name().isEmpty() && otherExistingProfileNames.contains(_tempProfile->name())) { | ||||
335 | KMessageBox::sorry(this, | 335 | KMessageBox::sorry(this, | ||
336 | i18n("<p>A profile with this name already exists.</p>")); | 336 | i18n("<p>A profile with this name already exists.</p>")); | ||
337 | // revert the name in the dialog | 337 | // revert the name in the dialog | ||
338 | _generalUi->profileNameEdit->setText(_profile->name()); | 338 | _generalUi->profileNameEdit->setText(_profile->name()); | ||
339 | selectProfileName(); | 339 | selectProfileName(); | ||
340 | return false; | 340 | return false; | ||
341 | } else { | | |||
342 | return true; | | |||
343 | } | 341 | } | ||
342 | return true; | ||||
344 | } | 343 | } | ||
345 | 344 | | |||
346 | QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr &group, int maxLength) | 345 | QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr &group, int maxLength) | ||
347 | { | 346 | { | ||
348 | QString caption; | 347 | QString caption; | ||
349 | int count = group->profiles().count(); | 348 | int count = group->profiles().count(); | ||
350 | for (int i = 0; i < count; i++) { | 349 | for (int i = 0; i < count; i++) { | ||
351 | caption += group->profiles()[i]->name(); | 350 | caption += group->profiles()[i]->name(); | ||
▲ Show 20 Lines • Show All 517 Lines • ▼ Show 20 Line(s) | 861 | { | |||
869 | auto *model = qobject_cast<QStandardItemModel *>(_appearanceUi->colorSchemeList->model()); | 868 | auto *model = qobject_cast<QStandardItemModel *>(_appearanceUi->colorSchemeList->model()); | ||
870 | 869 | | |||
871 | Q_ASSERT(model); | 870 | Q_ASSERT(model); | ||
872 | 871 | | |||
873 | model->clear(); | 872 | model->clear(); | ||
874 | 873 | | |||
875 | QStandardItem *selectedItem = nullptr; | 874 | QStandardItem *selectedItem = nullptr; | ||
876 | 875 | | |||
877 | QList<const ColorScheme *> schemeList = ColorSchemeManager::instance()->allColorSchemes(); | 876 | for (auto *scheme : ColorSchemeManager::instance()->allColorSchemes()) { | ||
878 | | ||||
879 | foreach (const ColorScheme *scheme, schemeList) { | | |||
880 | QStandardItem *item = new QStandardItem(scheme->description()); | 877 | QStandardItem *item = new QStandardItem(scheme->description()); | ||
881 | item->setData(QVariant::fromValue(scheme), Qt::UserRole + 1); | 878 | item->setData(QVariant::fromValue(scheme), Qt::UserRole + 1); | ||
882 | item->setData(QVariant::fromValue(_profile->font()), Qt::UserRole + 2); | 879 | item->setData(QVariant::fromValue(_profile->font()), Qt::UserRole + 2); | ||
883 | item->setFlags(item->flags()); | 880 | item->setFlags(item->flags()); | ||
884 | 881 | | |||
885 | // if selectedColorSchemeName is not empty then select that scheme | 882 | // if selectedColorSchemeName is not empty then select that scheme | ||
886 | // after saving the changes in the colorScheme editor | 883 | // after saving the changes in the colorScheme editor | ||
887 | if (selectedColorScheme == scheme) { | 884 | if (selectedColorScheme == scheme) { | ||
▲ Show 20 Lines • Show All 440 Lines • ▼ Show 20 Line(s) | |||||
1328 | void EditProfileDialog::enableIfNonEmptySelection(QWidget *widget, QItemSelectionModel *selectionModel) | 1325 | void EditProfileDialog::enableIfNonEmptySelection(QWidget *widget, QItemSelectionModel *selectionModel) | ||
1329 | { | 1326 | { | ||
1330 | widget->setEnabled(selectionModel->hasSelection()); | 1327 | widget->setEnabled(selectionModel->hasSelection()); | ||
1331 | } | 1328 | } | ||
1332 | 1329 | | |||
1333 | void EditProfileDialog::updateTransparencyWarning() | 1330 | void EditProfileDialog::updateTransparencyWarning() | ||
1334 | { | 1331 | { | ||
1335 | // zero or one indexes can be selected | 1332 | // zero or one indexes can be selected | ||
1336 | foreach (const QModelIndex &index, _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes()) { | 1333 | for (const auto &index : _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes()) { | ||
1337 | bool needTransparency = index.data(Qt::UserRole + 1).value<const ColorScheme *>()->opacity() < 1.0; | 1334 | bool needTransparency = index.data(Qt::UserRole + 1).value<const ColorScheme *>()->opacity() < 1.0; | ||
1338 | 1335 | | |||
1339 | if (!needTransparency) { | 1336 | if (!needTransparency) { | ||
1340 | _appearanceUi->transparencyWarningWidget->setHidden(true); | 1337 | _appearanceUi->transparencyWarningWidget->setHidden(true); | ||
1341 | } else if (!KWindowSystem::compositingActive()) { | 1338 | } else if (!KWindowSystem::compositingActive()) { | ||
1342 | _appearanceUi->transparencyWarningWidget->setText(i18n( | 1339 | _appearanceUi->transparencyWarningWidget->setText(i18n( | ||
1343 | "This color scheme uses a transparent background" | 1340 | "This color scheme uses a transparent background" | ||
1344 | " which does not appear to be supported on your" | 1341 | " which does not appear to be supported on your" | ||
▲ Show 20 Lines • Show All 611 Lines • Show Last 20 Lines |