| 1 | /* |
| 2 | * configdialog.cpp |
| 3 | * |
| 4 | * SPDX-FileCopyrightText: 2004 Zack Rusin <zack@kde.org> |
| 5 | * |
| 6 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 7 | */ |
| 8 | #include "configdialog.h" |
| 9 | #include "configwidget.h" |
| 10 | |
| 11 | #include <QDialogButtonBox> |
| 12 | #include <QVBoxLayout> |
| 13 | |
| 14 | using namespace Sonnet; |
| 15 | |
| 16 | class Sonnet::ConfigDialogPrivate |
| 17 | { |
| 18 | public: |
| 19 | ConfigDialogPrivate(ConfigDialog *parent) |
| 20 | : q(parent) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | ConfigWidget *ui = nullptr; |
| 25 | ConfigDialog *const q; |
| 26 | void slotConfigChanged(); |
| 27 | }; |
| 28 | |
| 29 | void ConfigDialogPrivate::slotConfigChanged() |
| 30 | { |
| 31 | Q_EMIT q->languageChanged(language: ui->language()); |
| 32 | } |
| 33 | |
| 34 | ConfigDialog::ConfigDialog(QWidget *parent) |
| 35 | : QDialog(parent) |
| 36 | , d(new ConfigDialogPrivate(this)) |
| 37 | { |
| 38 | setObjectName(QStringLiteral("SonnetConfigDialog" )); |
| 39 | setModal(true); |
| 40 | setWindowTitle(tr(s: "Spell Checking Configuration" )); |
| 41 | |
| 42 | QVBoxLayout *layout = new QVBoxLayout(this); |
| 43 | |
| 44 | d->ui = new ConfigWidget(this); |
| 45 | layout->addWidget(d->ui); |
| 46 | |
| 47 | QDialogButtonBox *buttonBox = new QDialogButtonBox(this); |
| 48 | buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 49 | layout->addWidget(buttonBox); |
| 50 | |
| 51 | connect(sender: buttonBox, signal: &QDialogButtonBox::accepted, context: this, slot: &ConfigDialog::slotOk); |
| 52 | connect(sender: buttonBox, signal: &QDialogButtonBox::rejected, context: this, slot: &QDialog::reject); |
| 53 | connect(sender: d->ui, SIGNAL(configChanged()), receiver: this, SLOT(slotConfigChanged())); |
| 54 | |
| 55 | connect(sender: d->ui, signal: &ConfigWidget::configChanged, context: this, slot: &ConfigDialog::configChanged); |
| 56 | } |
| 57 | |
| 58 | ConfigDialog::~ConfigDialog() = default; |
| 59 | |
| 60 | void ConfigDialog::slotOk() |
| 61 | { |
| 62 | d->ui->save(); |
| 63 | accept(); |
| 64 | } |
| 65 | |
| 66 | void ConfigDialog::slotApply() |
| 67 | { |
| 68 | d->ui->save(); |
| 69 | } |
| 70 | |
| 71 | void ConfigDialog::setLanguage(const QString &language) |
| 72 | { |
| 73 | d->ui->setLanguage(language); |
| 74 | } |
| 75 | |
| 76 | QString ConfigDialog::language() const |
| 77 | { |
| 78 | return d->ui->language(); |
| 79 | } |
| 80 | |
| 81 | #include "moc_configdialog.cpp" |
| 82 | |