Add Reset, Default and Apply button to config dialog
Makes it more like when starting KCMShell. REVIEW: 117110
This commit is contained in:
parent
b14cae83a0
commit
388cd21adf
1 changed files with 17 additions and 3 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
@ -72,13 +73,26 @@ void EffectConfig::openConfig(const QString &serviceName, bool scripted)
|
||||||
|
|
||||||
connect(&dialog, &QDialog::accepted, kcm, &KCModule::save);
|
connect(&dialog, &QDialog::accepted, kcm, &KCModule::save);
|
||||||
|
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dialog);
|
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok |
|
||||||
|
QDialogButtonBox::Cancel |
|
||||||
buttons->setCenterButtons(true);
|
QDialogButtonBox::Apply |
|
||||||
|
QDialogButtonBox::RestoreDefaults |
|
||||||
|
QDialogButtonBox::Reset,
|
||||||
|
&dialog);
|
||||||
|
|
||||||
|
QPushButton *apply = buttons->button(QDialogButtonBox::Apply);
|
||||||
|
QPushButton *reset = buttons->button(QDialogButtonBox::Reset);
|
||||||
|
apply->setEnabled(false);
|
||||||
|
reset->setEnabled(false);
|
||||||
//Here we connect our buttons with the dialog
|
//Here we connect our buttons with the dialog
|
||||||
connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||||
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||||
|
connect(apply, &QPushButton::clicked, kcm, &KCModule::save);
|
||||||
|
connect(reset, &QPushButton::clicked, kcm, &KCModule::load);
|
||||||
|
auto changedSignal = static_cast<void(KCModule::*)(bool)>(&KCModule::changed);
|
||||||
|
connect(kcm, changedSignal, apply, &QPushButton::setEnabled);
|
||||||
|
connect(kcm, changedSignal, reset, &QPushButton::setEnabled);
|
||||||
|
connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(&dialog);
|
QVBoxLayout *layout = new QVBoxLayout(&dialog);
|
||||||
layout->addWidget(kcm);
|
layout->addWidget(kcm);
|
||||||
|
|
Loading…
Reference in a new issue