25 #include <tqbuttongroup.h>
26 #include <tqcheckbox.h>
29 #include <tqradiobutton.h>
30 #include <tqspinbox.h>
32 #include <tdeaboutdata.h>
33 #include <tdeapplication.h>
34 #include <tdeaccelmanager.h>
35 #include <tdeconfig.h>
37 #include <kdialogbase.h>
38 #include <tdelocale.h>
40 #include "kcmsdsummary.h"
42 #include <tdemacros.h>
46 TDE_EXPORT TDECModule *create_sdsummary( TQWidget *parent,
const char * )
48 return new KCMSDSummary( parent,
"kcmsdsummary" );
52 KCMSDSummary::KCMSDSummary( TQWidget *parent,
const char *name )
53 : TDECModule( parent, name )
57 customDaysChanged( 1 );
59 connect( mDaysGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( modified() ) );
60 connect( mDaysGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( buttonClicked(
int ) ) );
61 connect( mCalendarGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( modified() ) );
62 connect( mContactGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( modified() ) );
63 connect( mCustomDays, TQ_SIGNAL( valueChanged(
int ) ), TQ_SLOT( modified() ) );
64 connect( mCustomDays, TQ_SIGNAL( valueChanged(
int ) ), TQ_SLOT( customDaysChanged(
int ) ) );
66 TDEAcceleratorManager::manage(
this );
71 void KCMSDSummary::modified()
76 void KCMSDSummary::buttonClicked(
int id )
78 mCustomDays->setEnabled(
id == 4 );
81 void KCMSDSummary::customDaysChanged(
int value )
83 mCustomDays->setSuffix( i18n(
" day",
" days", value ) );
86 void KCMSDSummary::initGUI()
88 TQGridLayout *layout =
new TQGridLayout(
this, 3, 2, KDialog::spacingHint() );
90 mDaysGroup =
new TQButtonGroup( 0, TQt::Vertical, i18n(
"Special Dates Summary" ),
this );
91 TQVBoxLayout *boxLayout =
new TQVBoxLayout( mDaysGroup->layout(),
92 KDialog::spacingHint() );
94 TQLabel *label =
new TQLabel( i18n(
"How many days should the special dates summary show at once?" ), mDaysGroup );
95 boxLayout->addWidget( label );
97 TQRadioButton *button =
new TQRadioButton( i18n(
"One day" ), mDaysGroup );
98 boxLayout->addWidget( button );
100 button =
new TQRadioButton( i18n(
"Five days" ), mDaysGroup );
101 boxLayout->addWidget( button );
103 button =
new TQRadioButton( i18n(
"One week" ), mDaysGroup );
104 boxLayout->addWidget( button );
106 button =
new TQRadioButton( i18n(
"One month" ), mDaysGroup );
107 boxLayout->addWidget( button );
109 TQHBoxLayout *hbox =
new TQHBoxLayout( boxLayout, KDialog::spacingHint() );
111 button =
new TQRadioButton(
"", mDaysGroup );
112 hbox->addWidget( button );
114 mCustomDays =
new TQSpinBox( 1, 365, 1, mDaysGroup );
115 mCustomDays->setEnabled(
false );
116 hbox->addWidget( mCustomDays );
118 hbox->addStretch( 1 );
120 layout->addMultiCellWidget( mDaysGroup, 0, 0, 0, 1 );
122 mCalendarGroup =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Special Dates From Calendar" ),
this );
124 mShowBirthdaysFromCal =
new TQCheckBox( i18n(
"Show birthdays" ), mCalendarGroup );
125 mShowAnniversariesFromCal =
new TQCheckBox( i18n(
"Show anniversaries" ), mCalendarGroup );
126 mShowHolidays =
new TQCheckBox( i18n(
"Show holidays" ), mCalendarGroup );
128 mShowSpecialsFromCal =
new TQCheckBox( i18n(
"Show special occasions" ), mCalendarGroup );
130 mContactGroup =
new TQButtonGroup( 1, TQt::Horizontal, i18n(
"Special Dates From Contact List" ),
this );
132 mShowBirthdaysFromKAB =
new TQCheckBox( i18n(
"Show birthdays" ), mContactGroup );
133 mShowAnniversariesFromKAB =
new TQCheckBox( i18n(
"Show anniversaries" ), mContactGroup );
135 layout->addWidget( mCalendarGroup, 1, 0 );
136 layout->addWidget( mContactGroup, 1, 1 );
138 layout->setRowStretch( 2, 1 );
141 void KCMSDSummary::load()
143 TDEConfig config(
"kcmsdsummaryrc" );
145 config.setGroup(
"Days" );
146 int days = config.readNumEntry(
"DaysToShow", 7 );
148 mDaysGroup->setButton( 0 );
149 else if ( days == 5 )
150 mDaysGroup->setButton( 1 );
151 else if ( days == 7 )
152 mDaysGroup->setButton( 2 );
153 else if ( days == 31 )
154 mDaysGroup->setButton( 3 );
156 mDaysGroup->setButton( 4 );
157 mCustomDays->setValue( days );
158 mCustomDays->setEnabled(
true );
161 config.setGroup(
"EventTypes" );
163 mShowBirthdaysFromKAB->
164 setChecked( config.readBoolEntry(
"ShowBirthdaysFromContacts",
true ) );
165 mShowBirthdaysFromCal->
166 setChecked( config.readBoolEntry(
"ShowBirthdaysFromCalendar",
true ) );
168 mShowAnniversariesFromKAB->
169 setChecked( config.readBoolEntry(
"ShowAnniversariesFromContacts",
true ) );
170 mShowAnniversariesFromCal->
171 setChecked( config.readBoolEntry(
"ShowAnniversariesFromCalendar",
true ) );
174 setChecked( config.readBoolEntry(
"ShowHolidays",
true ) );
176 mShowSpecialsFromCal->
177 setChecked( config.readBoolEntry(
"ShowSpecialsFromCalendar",
true ) );
179 emit changed(
false );
182 void KCMSDSummary::save()
184 TDEConfig config(
"kcmsdsummaryrc" );
186 config.setGroup(
"Days" );
189 switch ( mDaysGroup->selectedId() ) {
190 case 0: days = 1;
break;
191 case 1: days = 5;
break;
192 case 2: days = 7;
break;
193 case 3: days = 31;
break;
195 default: days = mCustomDays->value();
break;
197 config.writeEntry(
"DaysToShow", days );
199 config.setGroup(
"EventTypes" );
201 config.writeEntry(
"ShowBirthdaysFromContacts",
202 mShowBirthdaysFromKAB->isChecked() );
203 config.writeEntry(
"ShowBirthdaysFromCalendar",
204 mShowBirthdaysFromCal->isChecked() );
206 config.writeEntry(
"ShowAnniversariesFromContacts",
207 mShowAnniversariesFromKAB->isChecked() );
208 config.writeEntry(
"ShowAnniversariesFromCalendar",
209 mShowAnniversariesFromCal->isChecked() );
211 config.writeEntry(
"ShowHolidays",
212 mShowHolidays->isChecked() );
214 config.writeEntry(
"ShowSpecialsFromCalendar",
215 mShowSpecialsFromCal->isChecked() );
219 emit changed(
false );
222 void KCMSDSummary::defaults()
224 mDaysGroup->setButton( 7 );
225 mShowBirthdaysFromKAB->setChecked(
true );
226 mShowBirthdaysFromCal->setChecked(
true );
227 mShowAnniversariesFromKAB->setChecked(
true );
228 mShowAnniversariesFromCal->setChecked(
true );
229 mShowHolidays->setChecked(
true );
230 mShowSpecialsFromCal->setChecked(
true );
232 emit changed(
true );
235 const TDEAboutData* KCMSDSummary::aboutData()
const
237 TDEAboutData *about =
new TDEAboutData( I18N_NOOP(
"kcmsdsummary" ),
238 I18N_NOOP(
"Special Dates Configuration Dialog" ),
239 0, 0, TDEAboutData::License_GPL,
240 I18N_NOOP(
"(c) 2004 Tobias Koenig" ) );
242 about->addAuthor(
"Tobias Koenig", 0,
"tokoe@kde.org" );
243 about->addAuthor(
"Allen Winter", 0,
"winter@kde.org" );
248 #include "kcmsdsummary.moc"