Warning, file /graphics/krita/libs/ui/input/config/kis_edit_profiles_dialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * This file is part of the KDE project 0003 * SPDX-FileCopyrightText: 2013 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kis_edit_profiles_dialog.h" 0009 0010 #include <QPushButton> 0011 #include <QStringListModel> 0012 #include <KLocalizedString> 0013 #include <QMessageBox> 0014 0015 #include "kis_icon_utils.h" 0016 #include "input/kis_input_profile_manager.h" 0017 #include "kis_input_profile_model.h" 0018 0019 #include "ui_kis_edit_profiles_dialog.h" 0020 0021 class KisEditProfilesDialog::Private 0022 { 0023 public: 0024 Private() { } 0025 0026 Ui::KisEditProfilesDialog *ui {nullptr}; 0027 KisInputProfileModel *profileModel {nullptr}; 0028 }; 0029 0030 KisEditProfilesDialog::KisEditProfilesDialog(QWidget *parent, Qt::WindowFlags flags) 0031 : KoDialog(parent, flags), d(new Private()) 0032 { 0033 QWidget *mainWidget = new QWidget(this); 0034 d->ui = new Ui::KisEditProfilesDialog(); 0035 d->ui->setupUi(mainWidget); 0036 setMainWidget(mainWidget); 0037 0038 d->profileModel = new KisInputProfileModel(this); 0039 d->ui->profileList->setModel(d->profileModel); 0040 0041 d->ui->removeButton->setIcon(KisIconUtils::loadIcon("edit-delete")); 0042 d->ui->duplicateButton->setIcon(KisIconUtils::loadIcon("edit-copy")); 0043 d->ui->renameButton->setIcon(KisIconUtils::loadIcon("document-edit")); 0044 d->ui->resetButton->setIcon(KisIconUtils::loadIcon("view-refresh")); 0045 0046 connect(d->ui->removeButton, SIGNAL(clicked(bool)), SLOT(removeButtonClicked())); 0047 connect(d->ui->duplicateButton, SIGNAL(clicked(bool)), SLOT(duplicateButtonClicked())); 0048 connect(d->ui->renameButton, SIGNAL(clicked(bool)), SLOT(renameButtonClicked())); 0049 connect(d->ui->resetButton, SIGNAL(clicked(bool)), SLOT(resetButtonClicked())); 0050 0051 d->ui->removeButton->setEnabled(d->profileModel->rowCount() > 1); 0052 0053 setButtons(Close | Default); 0054 setWindowTitle(i18n("Edit Profiles")); 0055 } 0056 0057 KisEditProfilesDialog::~KisEditProfilesDialog() 0058 { 0059 delete d; 0060 } 0061 0062 void KisEditProfilesDialog::removeButtonClicked() 0063 { 0064 KisInputProfileManager::instance()->removeProfile(d->profileModel->profileName(d->ui->profileList->currentIndex())); 0065 d->ui->removeButton->setEnabled(d->profileModel->rowCount() > 1); 0066 } 0067 0068 void KisEditProfilesDialog::duplicateButtonClicked() 0069 { 0070 QString currentName = d->profileModel->profileName(d->ui->profileList->currentIndex()); 0071 QString newName = i18n("Copy of %1", currentName); 0072 KisInputProfileManager::instance()->duplicateProfile(currentName, newName); 0073 d->ui->removeButton->setEnabled(d->profileModel->rowCount() > 1); 0074 } 0075 0076 void KisEditProfilesDialog::renameButtonClicked() 0077 { 0078 d->ui->profileList->edit(d->ui->profileList->currentIndex()); 0079 } 0080 0081 void KisEditProfilesDialog::resetButtonClicked() 0082 { 0083 if(QMessageBox::question(this, 0084 i18nc("@title:window", "Reset All Profiles"), 0085 i18n("You will lose all changes to any input profiles. Do you wish to continue?"), 0086 QMessageBox::Yes | QMessageBox::No, 0087 QMessageBox::Yes) == QMessageBox::Yes) { 0088 KisInputProfileManager::instance()->resetAll(); 0089 } 0090 }