00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "kcmplanner.h"
00025
00026 #include <kaboutdata.h>
00027 #include <kacceleratormanager.h>
00028 #include <kcomponentdata.h>
00029 #include <kconfig.h>
00030 #include <kdebug.h>
00031 #include <klocale.h>
00032 #include <kdemacros.h>
00033
00034 #include <QCheckBox>
00035 #include <QLabel>
00036 #include <QLayout>
00037 #include <QRadioButton>
00038 #include <QSpinBox>
00039
00040 extern "C"
00041 {
00042 KDE_EXPORT KCModule *create_planner( QWidget *parent, const char * )
00043 {
00044 KComponentData inst( "kcmplanner" );
00045 return new KCMPlanner( inst, parent );
00046 }
00047 }
00048
00049 KCMPlanner::KCMPlanner( const KComponentData &inst, QWidget *parent )
00050 : KCModule( inst, parent )
00051 {
00052 setupUi( this );
00053
00054 customDaysChanged( 7 );
00055
00056 connect( mShowRecurrence, SIGNAL(stateChanged(int)), SLOT(modified()) );
00057 connect( mShowReminder, SIGNAL(stateChanged(int)), SLOT(modified()) );
00058 connect( mUnderline, SIGNAL(stateChanged(int)), SLOT(modified()) );
00059 connect( mTodo, SIGNAL(stateChanged(int)), SLOT(modified()) );
00060 connect( mSd, SIGNAL(stateChanged(int)), SLOT(modified()) );
00061
00062 connect( mDateTodayButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00063 connect( mDateMonthButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00064 connect( mDateRangeButton, SIGNAL(clicked(bool)), SLOT(modified()) );
00065
00066 connect( mHideCompletedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00067 connect( mHideOpenEndedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00068 connect( mHideUnstartedBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00069 connect( mHideInProgressBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00070 connect( mHideOverdueBox, SIGNAL(stateChanged(int)), SLOT(modified()) );
00071
00072 connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(modified()) );
00073 connect( mCustomDays, SIGNAL(valueChanged(int)), SLOT(customDaysChanged(int)) );
00074
00075
00076 connect( mBirthdayConList, SIGNAL(stateChanged(int)), SLOT(modified()) );
00077
00078 connect( mAnniversariesConList, SIGNAL(stateChanged(int)), SLOT(modified()) );
00079 connect( mHolidaysCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00080 connect( mSpecialOccasionsCal, SIGNAL(stateChanged(int)), SLOT(modified()) );
00081
00082 KAcceleratorManager::manage( this );
00083
00084 load();
00085 }
00086
00087 KCMPlanner::~KCMPlanner()
00088 {
00089 }
00090
00091 void KCMPlanner::modified()
00092 {
00093 emit changed( true );
00094 }
00095
00096 void KCMPlanner::customDaysChanged( int value )
00097 {
00098 mCustomDays->setSuffix( i18np( " day", " days", value ) );
00099 }
00100
00101 void KCMPlanner::buttonClicked( bool state )
00102 {
00103 mCustomDays->setEnabled( state );
00104 }
00105
00106 void KCMPlanner::load()
00107 {
00108 KConfig config( "plannerrc" );
00109
00110
00111 KConfigGroup general = config.group( "General" );
00112
00113 mShowRecurrence->setChecked( general.readEntry( "ShowRecurrence", true ) );
00114 mShowReminder->setChecked( general.readEntry( "ShowReminder", true ) );
00115 mUnderline->setChecked( general.readEntry( "underlineLink", true ) );
00116 mTodo->setChecked( general.readEntry( "ShowTodo", true ) );
00117 mSd->setChecked( general.readEntry( "ShowSd", true ) );
00118
00119
00120 KConfigGroup calendar = config.group( "Calendar" );
00121
00122
00123 int days = calendar.readEntry( "DaysToShow", 7 );
00124 if ( days == 1 ) {
00125 mDateTodayButton->setChecked( true );
00126 } else if( days == 31 ) {
00127 mDateMonthButton->setChecked( true );
00128 } else {
00129 mDateRangeButton->setChecked( true );
00130 mCustomDays->setValue( days );
00131 mCustomDays->setEnabled( true );
00132 }
00133
00134
00135 KConfigGroup hideGroup( &config, "Hide" );
00136 mHideInProgressBox->setChecked( hideGroup.readEntry( "InProgress", false ) );
00137 mHideOverdueBox->setChecked( hideGroup.readEntry( "Overdue", false ) );
00138 mHideCompletedBox->setChecked( hideGroup.readEntry( "Completed", true ) );
00139 mHideOpenEndedBox->setChecked( hideGroup.readEntry( "OpenEnded", false ) );
00140 mHideUnstartedBox->setChecked( hideGroup.readEntry( "NotStarted", false ) );
00141
00142 KConfigGroup sd = config.group( "SpecialDates" );
00143
00144
00145
00146 mBirthdayConList->setChecked( sd.readEntry( "BirthdayConList", true ) );
00147
00148 mAnniversariesConList->setChecked( sd.readEntry( "AnniversariesConList", true ) );
00149 mHolidaysCal->setChecked( sd.readEntry ( "HolidaysCal", true ) );
00150 mSpecialOccasionsCal->setChecked( sd.readEntry( "SpecialOccasionsCal", true ) );
00151
00152 emit changed( false );
00153 }
00154
00155 void KCMPlanner::save()
00156 {
00157 KConfig config( "plannerrc" );
00158
00159
00160 KConfigGroup general = config.group( "General" );
00161
00162 general.writeEntry( "ShowRecurrence", mShowRecurrence->isChecked() );
00163 general.writeEntry( "ShowReminder", mShowReminder->isChecked() );
00164 general.writeEntry( "underlineLink", mUnderline->isChecked() );
00165 general.writeEntry( "ShowTodo", mTodo->isChecked() );
00166 general.writeEntry( "ShowSd", mSd->isChecked() );
00167
00168
00169 KConfigGroup calendar = config.group( "Calendar" );
00170
00171 int days ;
00172 if ( mDateTodayButton->isChecked() ) {
00173 days = 1;
00174 } else if ( mDateMonthButton->isChecked() ) {
00175 days = 31;
00176 } else {
00177 days = mCustomDays->value();
00178 }
00179 calendar.writeEntry( "DaysToShow", days );
00180
00181
00182 KConfigGroup hideGroup( &config, "Hide" );
00183 hideGroup.writeEntry( "InProgress", mHideInProgressBox->isChecked() );
00184 hideGroup.writeEntry( "Overdue", mHideOverdueBox->isChecked() );
00185 hideGroup.writeEntry( "Completed", mHideCompletedBox->isChecked() );
00186 hideGroup.writeEntry( "OpenEnded", mHideOpenEndedBox->isChecked() );
00187 hideGroup.writeEntry( "NotStarted", mHideUnstartedBox->isChecked() );
00188
00189
00190 KConfigGroup sd = config.group( "SpecialDates" );
00191
00192
00193 sd.writeEntry( "BirthdayConList", mBirthdayConList->isChecked() );
00194
00195 sd.writeEntry( "AnniversariesConList", mAnniversariesConList->isChecked() );
00196 sd.writeEntry( "HolidaysCal", mHolidaysCal->isChecked() );
00197 sd.writeEntry( "SpecialOccasionsCal", mSpecialOccasionsCal->isChecked() );
00198
00199 config.sync();
00200
00201 emit changed( false );
00202 }
00203
00204 void KCMPlanner::defaults()
00205 {
00206 mShowRecurrence->setChecked( true );
00207 mShowReminder->setChecked( true );
00208 mUnderline->setChecked( true );
00209 mTodo->setChecked( true );
00210 mSd->setChecked( true );
00211
00212 mDateRangeButton->setChecked( true );
00213 mCustomDays->setValue( 7 );
00214 mCustomDays->setEnabled( true );
00215
00216 mHideInProgressBox->setChecked( false );
00217 mHideOverdueBox->setChecked( false );
00218 mHideCompletedBox->setChecked( true );
00219 mHideOpenEndedBox->setChecked( false );
00220 mHideUnstartedBox->setChecked( false );
00221
00222
00223 mBirthdayConList->setChecked( true );
00224
00225 mAnniversariesConList->setChecked( true );
00226 mHolidaysCal->setChecked( true );
00227 mSpecialOccasionsCal->setChecked( true );
00228
00229 emit changed( true );
00230 }
00231
00232 const KAboutData *KCMPlanner::aboutData() const
00233 {
00234 KAboutData *about = new KAboutData(
00235 I18N_NOOP( "kcmplanner" ), 0, ki18n( "Planner Summary Configuration Dialog" ),
00236 0, KLocalizedString(), KAboutData::License_GPL, ki18n( "(c) 2007-2008 Oral Timocin" ) );
00237
00238 about->addAuthor( ki18n( "Tobias Koenig" ), KLocalizedString(), "tokoe@kde.org" );
00239 about->addAuthor( ki18n( "Allen Winter" ), KLocalizedString(), "winter@kde.org" );
00240 about->addAuthor( ki18n( "Oral Timocin" ), KLocalizedString(), "o.timocin.kde@gmx.de" );
00241
00242 return about;
00243 }
00244
00245 #include "kcmplanner.moc"