configdialog.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2003 Jonathan Singer <jsinger@leeta.net> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 #include "configdialog.h" 00020 #include "configdialog.moc" 00021 #include <klocale.h> 00022 #include <tqlayout.h> 00023 #include <kapplication.h> 00024 #include <kglobal.h> 00025 #include <kconfig.h> 00026 #include <kstandarddirs.h> 00027 #include <ksimpleconfig.h> 00028 00029 ConfigDialog::ConfigDialog(TQWidget * parent):KDialogBase(Plain, i18n("Configure Holidays"), Ok|Cancel, Ok, 00030 parent) 00031 { 00032 TQFrame *topFrame = plainPage(); 00033 TQVBoxLayout *topLayout = 00034 new TQVBoxLayout(topFrame, 0, spacingHint()); 00035 00036 israel_box = new TQCheckBox(topFrame); 00037 israel_box->setText(i18n("Use Israeli holidays")); 00038 topLayout->addWidget(israel_box); 00039 00040 parsha_box = new TQCheckBox(topFrame); 00041 parsha_box->setText(i18n("Show weekly parsha")); 00042 topLayout->addWidget(parsha_box); 00043 00044 omer_box = new TQCheckBox(topFrame); 00045 omer_box->setText(i18n("Show day of Omer")); 00046 topLayout->addWidget(omer_box); 00047 00048 chol_box = new TQCheckBox(topFrame); 00049 chol_box->setText(i18n("Show Chol HaMoed")); 00050 topLayout->addWidget(chol_box); 00051 00052 load(); 00053 } 00054 00055 ConfigDialog::~ConfigDialog() 00056 { 00057 } 00058 00059 void ConfigDialog::load() 00060 { 00061 KConfig config("korganizerrc", true, false); // Open read-only, no kdeglobals 00062 00063 config.setGroup("Calendar/Hebrew Calendar Plugin"); 00064 israel_box->setChecked(config. 00065 readBoolEntry("Israel", 00066 (KGlobal::locale()-> 00067 country() == ".il"))); 00068 parsha_box->setChecked(config.readBoolEntry("Parsha", true)); 00069 chol_box->setChecked(config.readBoolEntry("Chol_HaMoed", true)); 00070 omer_box->setChecked(config.readBoolEntry("Omer", true)); 00071 00072 } 00073 00074 void ConfigDialog::save() 00075 { 00076 KConfig config("korganizerrc", false, false); // Open read-write, no kdeglobals 00077 00078 config.setGroup("Calendar/Hebrew Calendar Plugin"); 00079 config.writeEntry("Israel", israel_box->isChecked()); 00080 config.writeEntry("Parsha", parsha_box->isChecked()); 00081 config.writeEntry("Chol_HaMoed", chol_box->isChecked()); 00082 config.writeEntry("Omer", omer_box->isChecked()); 00083 config.sync(); 00084 } 00085 00086 void ConfigDialog::slotOk() 00087 { 00088 save(); 00089 00090 accept(); 00091 }