Changeset View
Changeset View
Standalone View
Standalone View
src/kjotsconfigdlg.cpp
Show All 11 Lines | 1 | /* | |||
---|---|---|---|---|---|
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | 15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "kjotsconfigdlg.h" | 19 | #include "kjotsconfigdlg.h" | ||
20 | #include "KJotsSettings.h" | ||||
20 | #include <QPushButton> | 21 | #include <QPushButton> | ||
21 | 22 | | |||
22 | #include <KConfig> | | |||
23 | #include <KConfigGroup> | | |||
24 | | ||||
25 | KJotsConfigDlg::KJotsConfigDlg(const QString &title, QWidget *parent) | | |||
26 | : KCMultiDialog(parent) | | |||
27 | { | | |||
28 | setWindowTitle(title); | | |||
29 | setFaceType(KPageDialog::List); | | |||
30 | setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); | | |||
31 | button(QDialogButtonBox::Ok)->setDefault(true); | | |||
32 | | ||||
33 | addModule(QStringLiteral("kjots_config_misc")); | | |||
34 | connect(button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &KJotsConfigDlg::slotOk); | | |||
35 | } | | |||
36 | | ||||
37 | void KJotsConfigDlg::slotOk() | | |||
38 | { | | |||
39 | } | | |||
40 | | ||||
41 | KJotsConfigMisc::KJotsConfigMisc(QWidget *parent, const QVariantList &args) | 23 | KJotsConfigMisc::KJotsConfigMisc(QWidget *parent, const QVariantList &args) | ||
42 | : KCModule(parent, args) | 24 | : KCModule(parent, args) | ||
25 | , ui(new Ui::confPageMisc) | ||||
43 | { | 26 | { | ||
44 | auto *lay = new QHBoxLayout(this); | 27 | auto *lay = new QHBoxLayout(this); | ||
45 | miscPage = new confPageMisc(nullptr); | 28 | auto miscPage = new QWidget(this); | ||
29 | ui->setupUi(miscPage); | ||||
46 | lay->addWidget(miscPage); | 30 | lay->addWidget(miscPage); | ||
47 | connect(miscPage->autoSaveInterval, qOverload<int>(&QSpinBox::valueChanged), this, &KJotsConfigMisc::modified); | 31 | addConfig(KJotsSettings::self(), miscPage); | ||
48 | connect(miscPage->autoSave, &QCheckBox::stateChanged, this, &KJotsConfigMisc::modified); | | |||
49 | load(); | 32 | load(); | ||
50 | } | 33 | } | ||
51 | 34 | | |||
52 | void KJotsConfigMisc::modified() | | |||
53 | { | | |||
54 | Q_EMIT changed(true); | | |||
55 | } | | |||
56 | | ||||
57 | void KJotsConfigMisc::load() | | |||
58 | { | | |||
59 | KConfig config(QStringLiteral("kjotsrc")); | | |||
60 | KConfigGroup group = config.group("kjots"); | | |||
61 | miscPage->autoSaveInterval->setValue(group.readEntry("AutoSaveInterval", 5)); | | |||
62 | miscPage->autoSave->setChecked(group.readEntry("AutoSave", true)); | | |||
63 | Q_EMIT changed(false); | | |||
64 | } | | |||
65 | | ||||
66 | void KJotsConfigMisc::save() | | |||
67 | { | | |||
68 | KConfig config(QStringLiteral("kjotsrc")); | | |||
69 | KConfigGroup group = config.group("kjots"); | | |||
70 | group.writeEntry("AutoSaveInterval", miscPage->autoSaveInterval->value()); | | |||
71 | group.writeEntry("AutoSave", miscPage->autoSave->isChecked()); | | |||
72 | group.sync(); | | |||
73 | Q_EMIT changed(false); | | |||
74 | } | | |||
75 | | ||||
76 | #include "moc_kjotsconfigdlg.cpp" | 35 | #include "moc_kjotsconfigdlg.cpp" |