24 #include <tqbuttongroup.h>
27 #include <tqradiobutton.h>
28 #include <tqspinbox.h>
30 #include <tdeaboutdata.h>
31 #include <tdeapplication.h>
32 #include <tdeaccelmanager.h>
33 #include <tdeconfig.h>
35 #include <kdialogbase.h>
36 #include <tdelocale.h>
38 #include "kcmkorgsummary.h"
40 #include <tdemacros.h>
44 TDE_EXPORT TDECModule *create_korgsummary( TQWidget *parent,
const char * )
46 return new KCMKOrgSummary( parent,
"kcmkorgsummary" );
50 KCMKOrgSummary::KCMKOrgSummary( TQWidget *parent,
const char *name )
51 : TDECModule( parent, name )
55 customDaysChanged( 1 );
57 connect( mCalendarGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( modified() ) );
58 connect( mCalendarGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( buttonClicked(
int ) ) );
59 connect( mTodoGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( modified() ) );
60 connect( mCustomDays, TQ_SIGNAL( valueChanged(
int ) ), TQ_SLOT( modified() ) );
61 connect( mCustomDays, TQ_SIGNAL( valueChanged(
int ) ), TQ_SLOT( customDaysChanged(
int ) ) );
63 TDEAcceleratorManager::manage(
this );
67 TDEAboutData *about =
new TDEAboutData( I18N_NOOP(
"kcmkorgsummary" ),
68 I18N_NOOP(
"Schedule Configuration Dialog" ),
69 0, 0, TDEAboutData::License_GPL,
70 I18N_NOOP(
"(c) 2003 - 2004 Tobias Koenig" ) );
72 about->addAuthor(
"Tobias Koenig", 0,
"tokoe@kde.org" );
73 setAboutData( about );
76 void KCMKOrgSummary::modified()
81 void KCMKOrgSummary::buttonClicked(
int id )
83 mCustomDays->setEnabled(
id == 4 );
86 void KCMKOrgSummary::customDaysChanged(
int value )
88 mCustomDays->setSuffix( i18n(
" day",
" days", value ) );
91 void KCMKOrgSummary::initGUI()
93 TQVBoxLayout *layout =
new TQVBoxLayout(
this, 0, KDialog::spacingHint() );
95 mCalendarGroup =
new TQButtonGroup( 0, TQt::Vertical, i18n(
"Appointments" ),
this );
96 TQVBoxLayout *boxLayout =
new TQVBoxLayout( mCalendarGroup->layout(),
97 KDialog::spacingHint() );
99 TQLabel *label =
new TQLabel( i18n(
"How many days should the calendar show at once?" ), mCalendarGroup );
100 boxLayout->addWidget( label );
102 TQRadioButton *button =
new TQRadioButton( i18n(
"One day" ), mCalendarGroup );
103 boxLayout->addWidget( button );
105 button =
new TQRadioButton( i18n(
"Five days" ), mCalendarGroup );
106 boxLayout->addWidget( button );
108 button =
new TQRadioButton( i18n(
"One week" ), mCalendarGroup );
109 boxLayout->addWidget( button );
111 button =
new TQRadioButton( i18n(
"One month" ), mCalendarGroup );
112 boxLayout->addWidget( button );
114 TQHBoxLayout *hbox =
new TQHBoxLayout( boxLayout, KDialog::spacingHint() );
116 button =
new TQRadioButton(
"", mCalendarGroup );
117 hbox->addWidget( button );
119 mCustomDays =
new TQSpinBox( 1, 365, 1, mCalendarGroup );
120 mCustomDays->setEnabled(
false );
121 hbox->addWidget( mCustomDays );
123 hbox->addStretch( 1 );
125 layout->addWidget( mCalendarGroup );
127 mTodoGroup =
new TQButtonGroup( 2, TQt::Horizontal, i18n(
"To-dos" ),
this );
128 new TQRadioButton( i18n(
"Show all to-dos" ), mTodoGroup );
129 new TQRadioButton( i18n(
"Show today's to-dos only" ), mTodoGroup );
131 layout->addWidget( mTodoGroup );
133 layout->addStretch();
136 void KCMKOrgSummary::load()
138 TDEConfig config(
"kcmkorgsummaryrc" );
140 config.setGroup(
"Calendar" );
141 int days = config.readNumEntry(
"DaysToShow", 1 );
143 mCalendarGroup->setButton( 0 );
144 else if ( days == 5 )
145 mCalendarGroup->setButton( 1 );
146 else if ( days == 7 )
147 mCalendarGroup->setButton( 2 );
148 else if ( days == 31 )
149 mCalendarGroup->setButton( 3 );
151 mCalendarGroup->setButton( 4 );
152 mCustomDays->setValue( days );
153 mCustomDays->setEnabled(
true );
156 config.setGroup(
"Todo" );
157 bool allTodos = config.readBoolEntry(
"ShowAllTodos",
false );
160 mTodoGroup->setButton( 0 );
162 mTodoGroup->setButton( 1 );
164 emit changed(
false );
167 void KCMKOrgSummary::save()
169 TDEConfig config(
"kcmkorgsummaryrc" );
171 config.setGroup(
"Calendar" );
174 switch ( mCalendarGroup->selectedId() ) {
175 case 0: days = 1;
break;
176 case 1: days = 5;
break;
177 case 2: days = 7;
break;
178 case 3: days = 31;
break;
180 default: days = mCustomDays->value();
break;
182 config.writeEntry(
"DaysToShow", days );
184 config.setGroup(
"Todo" );
185 config.writeEntry(
"ShowAllTodos", mTodoGroup->selectedId() == 0 );
189 emit changed(
false );
192 void KCMKOrgSummary::defaults()
194 mCalendarGroup->setButton( 0 );
195 mTodoGroup->setButton( 1 );
197 emit changed(
true );
200 #include "kcmkorgsummary.moc"