Changeset View
Changeset View
Standalone View
Standalone View
src/EditProfileDialog.cpp
Context not available. | |||||
280 | return _profile; | 280 | return _profile; | ||
---|---|---|---|---|---|
281 | } | 281 | } | ||
282 | 282 | | |||
283 | const QString EditProfileDialog::currentColorSchemeName() const | ||||
284 | { | ||||
285 | const QString ¤tColorSchemeName = lookupProfile()->colorScheme(); | ||||
286 | return currentColorSchemeName; | ||||
287 | } | ||||
288 | | ||||
283 | void EditProfileDialog::preparePage(int page) | 289 | void EditProfileDialog::preparePage(int page) | ||
284 | { | 290 | { | ||
285 | const Profile::Ptr profile = lookupProfile(); | 291 | const Profile::Ptr profile = lookupProfile(); | ||
Context not available. | |||||
536 | _ui->resetColorSchemeButton->setEnabled(false); | 542 | _ui->resetColorSchemeButton->setEnabled(false); | ||
537 | 543 | | |||
538 | // setup color list | 544 | // setup color list | ||
539 | updateColorSchemeList(true); | 545 | // select the colorScheme used in the current profile | ||
546 | updateColorSchemeList(currentColorSchemeName()); | ||||
540 | 547 | | |||
541 | _ui->colorSchemeList->setMouseTracking(true); | 548 | _ui->colorSchemeList->setMouseTracking(true); | ||
542 | _ui->colorSchemeList->installEventFilter(this); | 549 | _ui->colorSchemeList->installEventFilter(this); | ||
Context not available. | |||||
636 | updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable); | 643 | updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable); | ||
637 | } | 644 | } | ||
638 | 645 | | |||
639 | void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme) | 646 | void EditProfileDialog::updateColorSchemeList(const QString &selectedColorSchemeName) | ||
640 | { | 647 | { | ||
641 | if (_ui->colorSchemeList->model() == nullptr) { | 648 | if (_ui->colorSchemeList->model() == nullptr) { | ||
642 | _ui->colorSchemeList->setModel(new QStandardItemModel(this)); | 649 | _ui->colorSchemeList->setModel(new QStandardItemModel(this)); | ||
643 | } | 650 | } | ||
644 | 651 | | |||
645 | const QString &name = lookupProfile()->colorScheme(); | 652 | const ColorScheme *selectedColorScheme = ColorSchemeManager::instance()->findColorScheme(selectedColorSchemeName); | ||
646 | const ColorScheme *currentScheme = ColorSchemeManager::instance()->findColorScheme(name); | | |||
647 | 653 | | |||
648 | QStandardItemModel *model = qobject_cast<QStandardItemModel *>(_ui->colorSchemeList->model()); | 654 | QStandardItemModel *model = qobject_cast<QStandardItemModel *>(_ui->colorSchemeList->model()); | ||
649 | 655 | | |||
Context not available. | |||||
661 | item->setData(QVariant::fromValue(_profile->font()), Qt::UserRole + 2); | 667 | item->setData(QVariant::fromValue(_profile->font()), Qt::UserRole + 2); | ||
662 | item->setFlags(item->flags()); | 668 | item->setFlags(item->flags()); | ||
663 | 669 | | |||
664 | if (currentScheme == scheme) { | 670 | // if selectedColorSchemeName is not empty then select that scheme | ||
671 | // after saving the changes in the colorScheme editor | ||||
672 | if (selectedColorScheme == scheme) { | ||||
665 | selectedItem = item; | 673 | selectedItem = item; | ||
666 | } | 674 | } | ||
667 | 675 | | |||
Context not available. | |||||
670 | 678 | | |||
671 | model->sort(0); | 679 | model->sort(0); | ||
672 | 680 | | |||
673 | if (selectCurrentScheme && (selectedItem != nullptr)) { | 681 | if (selectedItem != nullptr) { | ||
674 | _ui->colorSchemeList->updateGeometry(); | 682 | _ui->colorSchemeList->updateGeometry(); | ||
675 | _ui->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->index(), | 683 | _ui->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->index(), | ||
676 | QItemSelectionModel::Select); | 684 | QItemSelectionModel::Select); | ||
Context not available. | |||||
847 | void EditProfileDialog::resetColorScheme() | 855 | void EditProfileDialog::resetColorScheme() | ||
848 | { | 856 | { | ||
849 | removeColorScheme(); | 857 | removeColorScheme(); | ||
850 | updateColorSchemeList(true); | 858 | // select the colorScheme used in the current profile | ||
859 | updateColorSchemeList(currentColorSchemeName()); | ||||
851 | } | 860 | } | ||
852 | 861 | | |||
853 | void EditProfileDialog::showColorSchemeEditor(bool isNewScheme) | 862 | void EditProfileDialog::showColorSchemeEditor(bool isNewScheme) | ||
Context not available. | |||||
907 | 916 | | |||
908 | ColorSchemeManager::instance()->addColorScheme(newScheme); | 917 | ColorSchemeManager::instance()->addColorScheme(newScheme); | ||
909 | 918 | | |||
910 | updateColorSchemeList(true); | 919 | const QString &selectedColorSchemeName = newScheme->name(); | ||
920 | | ||||
921 | // select the edited or the new colorScheme after saving the changes | ||||
922 | updateColorSchemeList(selectedColorSchemeName); | ||||
911 | 923 | | |||
912 | preview(Profile::ColorScheme, newScheme->name()); | 924 | preview(Profile::ColorScheme, newScheme->name()); | ||
913 | } | 925 | } | ||
Context not available. |