2 This file is part of KOrganizer.
4 Copyright (c) 2003 Jonathan Singer <jsinger@leeta.net>
5 Copyright (C) 2007 Loïc Corbasson <loic.corbasson@gmail.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "configdialog.h"
25 #include <KLocalizedString>
30 #include <QVBoxLayout>
31 #include <KConfigGroup>
32 #include <QDialogButtonBox>
33 #include <QPushButton>
35 ConfigDialog::ConfigDialog(QWidget
*parent
)
38 QFrame
*topFrame
= new QFrame(this);
40 setWindowTitle(i18n("Configure Holidays"));
41 QDialogButtonBox
*buttonBox
= new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
);
42 QVBoxLayout
*mainLayout
= new QVBoxLayout
;
43 setLayout(mainLayout
);
44 mainLayout
->addWidget(topFrame
);
45 QPushButton
*okButton
= buttonBox
->button(QDialogButtonBox::Ok
);
46 okButton
->setDefault(true);
47 okButton
->setShortcut(Qt::CTRL
| Qt::Key_Return
);
48 connect(buttonBox
, &QDialogButtonBox::rejected
, this, &ConfigDialog::reject
);
49 mainLayout
->addWidget(buttonBox
);
50 okButton
->setDefault(true);
52 QVBoxLayout
*topLayout
= new QVBoxLayout(topFrame
);
53 topLayout
->setMargin(0);
55 mIsraelBox
= new QCheckBox(topFrame
);
56 mIsraelBox
->setText(i18n("Use Israeli holidays"));
57 topLayout
->addWidget(mIsraelBox
);
59 mParshaBox
= new QCheckBox(topFrame
);
60 mParshaBox
->setText(i18n("Show weekly parsha"));
61 topLayout
->addWidget(mParshaBox
);
63 mOmerBox
= new QCheckBox(topFrame
);
64 mOmerBox
->setText(i18n("Show day of Omer"));
65 topLayout
->addWidget(mOmerBox
);
67 mCholBox
= new QCheckBox(topFrame
);
68 mCholBox
->setText(i18n("Show Chol HaMoed"));
69 topLayout
->addWidget(mCholBox
);
70 connect(okButton
, &QPushButton::clicked
, this, &ConfigDialog::slotOk
);
74 ConfigDialog::~ConfigDialog()
78 void ConfigDialog::load()
80 KConfig
config(QStringLiteral("korganizerrc"));
82 KConfigGroup
group(&config
, "Hebrew Calendar Plugin");
83 mIsraelBox
->setChecked(
84 group
.readEntry("UseIsraelSettings",
85 (KLocale::global()->country() == QLatin1String(".il"))));
86 mParshaBox
->setChecked(group
.readEntry("ShowParsha", true));
87 mCholBox
->setChecked(group
.readEntry("ShowChol_HaMoed", true));
88 mOmerBox
->setChecked(group
.readEntry("ShowOmer", true));
91 void ConfigDialog::save()
93 KConfig
config(QStringLiteral("korganizerrc"));
94 KConfigGroup
group(&config
, "Hebrew Calendar Plugin");
95 group
.writeEntry("UseIsraelSettings", mIsraelBox
->isChecked());
96 group
.writeEntry("ShowParsha", mParshaBox
->isChecked());
97 group
.writeEntry("ShowChol_HaMoed", mCholBox
->isChecked());
98 group
.writeEntry("ShowOmer", mOmerBox
->isChecked());
102 void ConfigDialog::slotOk()