Warning, file /education/kwordquiz/src/kwqcleardialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2010 Peter Hedlund <peter.hedlund@kdemail.net>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 // Own
0007 #include "kwqcleardialog.h"
0008 
0009 // Qt
0010 #include <QPushButton>
0011 #include <QDialogButtonBox>
0012 
0013 // Kwq
0014 #include "prefs.h"
0015 
0016 KWQClearDialog::KWQClearDialog(QWidget* parent): QDialog(parent)
0017 {
0018     setWindowTitle(i18nc("@title:window", "Clear Contents"));
0019     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
0020     QWidget *mainWidget = new QWidget(this);
0021     QVBoxLayout *mainLayout = new QVBoxLayout;
0022     setLayout(mainLayout);
0023     mainLayout->addWidget(mainWidget);
0024     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0025     okButton->setDefault(true);
0026     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0027     connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
0028     connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
0029     mainLayout->addWidget(buttonBox);
0030     setupUi(mainWidget);
0031 
0032     connect(clearButtonGroup, &QGroupBox::clicked, this, &KWQClearDialog::buttonGroupChanged);
0033 
0034     updateCheckBoxes();
0035 }
0036 
0037 void KWQClearDialog::buttonGroupChanged(int id)
0038 {
0039     Q_UNUSED(id);
0040     Prefs::setClearAll(clearAllCheckBox->isChecked());
0041     Prefs::setClearText(clearTextCheckBox->isChecked());
0042     Prefs::setClearImageLink(clearImageCheckBox->isChecked());
0043     Prefs::setClearSoundLink(clearSoundCheckBox->isChecked());
0044     updateCheckBoxes();
0045 }
0046 
0047 void KWQClearDialog::updateCheckBoxes()
0048 {
0049     bool all = Prefs::clearAll();
0050     clearAllCheckBox->setChecked(all);
0051     clearTextCheckBox->setChecked(Prefs::clearText());
0052     clearImageCheckBox->setChecked(Prefs::clearImageLink());
0053     clearSoundCheckBox->setChecked(Prefs::clearSoundLink());
0054 
0055     clearTextCheckBox->setEnabled(!all);
0056     clearImageCheckBox->setEnabled(!all);
0057     clearSoundCheckBox->setEnabled(!all);
0058 }
0059 
0060 void KWQClearDialog::accept()
0061 {
0062   Prefs::setClearAll(clearAllCheckBox->isChecked());
0063   Prefs::setClearText(clearTextCheckBox->isChecked());
0064   Prefs::setClearImageLink(clearImageCheckBox->isChecked());
0065   Prefs::setClearSoundLink(clearSoundCheckBox->isChecked());
0066   QDialog::accept();
0067 }