28 #include <tqgroupbox.h>
29 #include <tqbuttongroup.h>
30 #include <tqlineedit.h>
33 #include <tqcombobox.h>
37 #include <tqspinbox.h>
38 #include <tqcheckbox.h>
39 #include <tqradiobutton.h>
40 #include <tqpushbutton.h>
41 #include <tqstrlist.h>
42 #include <tqlistview.h>
43 #include <tqtabwidget.h>
44 #include <tqwhatsthis.h>
46 #include <kcolorbutton.h>
47 #include <kcombobox.h>
49 #include <tdelocale.h>
50 #include <tdeglobal.h>
51 #include <tdemessagebox.h>
52 #include <kiconloader.h>
53 #include <knuminput.h>
54 #include <tdeemailsettings.h>
55 #include <kcalendarsystem.h>
57 #include <kpushbutton.h>
59 #include <kstandarddirs.h>
60 #include <ksimpleconfig.h>
61 #include <kholidays.h>
62 #include <kurlrequester.h>
66 #if defined(USE_SOLARIS)
67 #include <sys/param.h>
69 #define ZONEINFODIR "/usr/share/lib/zoneinfo"
70 #define INITFILE "/etc/default/init"
75 #include "koprefsdialog.h"
76 #include "kogroupwareprefspage.h"
77 #include "ktimeedit.h"
78 #include "koglobals.h"
79 #include "stdcalendar.h"
80 #include <tdemacros.h>
83 KOPrefsDialogMain::KOPrefsDialogMain( TQWidget *parent,
const char *name )
84 : KPrefsModule( KOPrefs::instance(), parent, name )
86 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
88 TQVBox *topFrame =
new TQVBox(
this );
89 topTopLayout->addWidget( topFrame );
91 topFrame->setSpacing( KDialog::spacingHint() );
93 KPrefsWidBool *emailControlCenter =
94 addWidBool( KOPrefs::instance()->emailControlCenterItem(), topFrame );
95 connect(emailControlCenter->checkBox(),TQ_SIGNAL(toggled(
bool)),
96 TQ_SLOT(toggleEmailSettings(
bool)));
98 mUserEmailSettings =
new TQGrid( 2, topFrame );
100 addWidString( KOPrefs::instance()->userNameItem(), mUserEmailSettings );
101 addWidString( KOPrefs::instance()->userEmailItem(), mUserEmailSettings );
103 TQGroupBox *saveGroup =
new TQGroupBox(1,TQt::Horizontal,i18n(
"Saving Calendar"),
106 addWidBool( KOPrefs::instance()->htmlWithSaveItem(), saveGroup );
108 KPrefsWidBool *autoSave = addWidBool( KOPrefs::instance()->autoSaveItem(), saveGroup );
110 TQHBox *intervalBox =
new TQHBox( saveGroup );
111 addWidInt( KOPrefs::instance()->autoSaveIntervalItem(), intervalBox );
112 connect( autoSave->checkBox(), TQ_SIGNAL( toggled(
bool ) ),
113 intervalBox, TQ_SLOT( setEnabled(
bool ) ) );
114 intervalBox->setSpacing( KDialog::spacingHint() );
115 new TQWidget( intervalBox );
117 addWidBool( KOPrefs::instance()->confirmItem(), topFrame );
118 addWidRadios( KOPrefs::instance()->destinationItem(), topFrame);
119 addWidRadios( KOPrefs::instance()->defaultEmailAttachMethodItem(), topFrame );
121 topTopLayout->addStretch( 1 );
126 void KOPrefsDialogMain::toggleEmailSettings(
bool on )
128 mUserEmailSettings->setEnabled( !on );
141 TDE_EXPORT TDECModule *create_korganizerconfigmain( TQWidget *parent,
const char * )
143 return new KOPrefsDialogMain( parent,
"kcmkorganizermain" );
148 class KOPrefsDialogTime :
public KPrefsModule
151 KOPrefsDialogTime( TQWidget *parent,
const char *name )
152 : KPrefsModule( KOPrefs::instance(), parent, name )
154 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
156 TQWidget *topFrame =
new TQWidget(
this );
157 topTopLayout->addWidget( topFrame );
159 TQGridLayout *topLayout =
new TQGridLayout(topFrame,6,2);
160 topLayout->setSpacing( KDialog::spacingHint() );
162 TQHBox *timeZoneBox =
new TQHBox( topFrame );
163 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
165 TQLabel *timeZoneLabel =
new TQLabel( i18n(
"Timezone:"), timeZoneBox );
166 TQString whatsThis = i18n(
"Select your timezone from the list of "
167 "locations on this drop down box. If your city "
168 "is not listed, select one which shares the "
169 "same timezone. KOrganizer will automatically "
170 "adjust for daylight savings." );
171 TQWhatsThis::add( timeZoneLabel, whatsThis );
172 mTimeZoneCombo =
new TQComboBox( timeZoneBox );
174 connect( mTimeZoneCombo, TQ_SIGNAL( activated(
int ) ),
175 TQ_SLOT( slotWidChanged() ) );
178 char tempstring[101] =
"Unknown";
179 TQString sCurrentlySet(i18n(
"Unknown"));
180 int nCurrentlySet = 0;
184 #if defined(USE_SOLARIS)
185 char buf[MAXPATHLEN];
187 snprintf(buf, MAXPATHLEN,
188 "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-",
191 if (f = popen(buf,
"r"))
193 if (fgets(buf, MAXPATHLEN - 1, f) != NULL)
195 buf[strlen(buf) - 1] =
'\0';
196 sCurrentlySet = TQString(buf);
201 if((f = fopen(
"/etc/timezone",
"r")) != NULL) {
203 fgets(tempstring, 100, f);
204 tempstring[strlen(tempstring) - 1] =
'\0';
205 sCurrentlySet = TQString(tempstring);
210 mTimeZoneCombo->insertItem(i18n(
"[No selection]"));
213 #if defined(USE_SOLARIS)
214 snprintf(buf, MAXPATHLEN,
215 "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-",
216 ZONEINFODIR, strlen(ZONEINFODIR) + 2);
218 if (f = popen(buf,
"r"))
220 while(fgets(buf, MAXPATHLEN - 1, f) != NULL)
222 buf[strlen(buf) - 1] =
'\0';
229 f = popen(
"grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3",
"r");
231 while(fgets(tempstring, 100, f) != NULL) {
232 tempstring[strlen(tempstring)-1] =
'\0';
233 list.append(i18n(tempstring));
234 tzonenames << tempstring;
240 mTimeZoneCombo->insertStringList(list);
243 for (
int i = 0; i < mTimeZoneCombo->count(); ++i )
245 if (mTimeZoneCombo->text(i) == sCurrentlySet)
252 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
253 TQWhatsThis::add( mTimeZoneCombo, whatsThis );
256 TQHBox *holidayRegBox =
new TQHBox( topFrame );
257 topLayout->addMultiCellWidget( holidayRegBox, 1, 1, 0, 1 );
259 TQLabel *holidayLabel =
new TQLabel( i18n(
"Use holiday region:" ), holidayRegBox );
260 whatsThis = i18n(
"Select from which region you want to use the "
261 "holidays here. Defined holidays are shown as "
262 "non-working days in the date navigator, the "
263 "agenda view, etc." );
264 TQWhatsThis::add( holidayLabel, whatsThis );
266 mHolidayCombo =
new TQComboBox( holidayRegBox );
267 connect( mHolidayCombo, TQ_SIGNAL( activated(
int ) ),
268 TQ_SLOT( slotWidChanged() ) );
270 TQWhatsThis::add( mHolidayCombo, whatsThis );
272 TQString currentHolidayName;
273 TQStringList holidayList;
274 TQStringList countryList = KHolidays::locations();
275 TQStringList::ConstIterator it;
277 for ( it = countryList.begin(); it != countryList.end(); ++it ) {
278 TQString countryFile = locate(
"locale",
279 "l10n/" + (*it) +
"/entry.desktop" );
281 if ( !countryFile.isEmpty() ) {
282 KSimpleConfig cfg( countryFile );
283 cfg.setGroup(
"KCM Locale" );
284 regionName = cfg.readEntry(
"Name" );
286 if (regionName.isEmpty()) regionName = (*it);
288 holidayList << regionName;
289 mRegionMap[regionName] = (*it);
291 if ( KOGlobals::self()->holidays()
292 && ((*it) == KOGlobals::self()->holidays()->location()) )
293 currentHolidayName = regionName;
296 holidayList.push_front( i18n(
"(None)") );
298 mHolidayCombo->insertStringList(holidayList);
300 for (
int i=0; i < mHolidayCombo->count(); ++i) {
301 if ( mHolidayCombo->text(i) == currentHolidayName ) {
302 mHolidayCombo->setCurrentItem(i);
307 KPrefsWidTime *dayBegins =
308 addWidTime( KOPrefs::instance()->dayBeginsItem(), topFrame );
309 topLayout->addWidget( dayBegins->label(), 2, 0 );
310 topLayout->addWidget( dayBegins->timeEdit(), 2, 1 );
312 KPrefsWidTime *defaultTime =
313 addWidTime( KOPrefs::instance()->startTimeItem(), topFrame );
314 topLayout->addWidget( defaultTime->label(), 3, 0);
315 topLayout->addWidget( defaultTime->timeEdit(), 3, 1);
317 KPrefsWidDuration *defaultDuration =
318 addWidDuration( KOPrefs::instance()->defaultDurationItem(), topFrame );
319 topLayout->addWidget( defaultDuration->label(), 4, 0 );
320 topLayout->addWidget( defaultDuration->timeEdit(), 4, 1 );
322 TQGroupBox *remindersGroupBox =
new TQGroupBox( 1, TQt::Horizontal,
325 topLayout->addMultiCellWidget( remindersGroupBox, 5, 5, 0, 1 );
327 TQHBox *remindersBox =
new TQHBox( remindersGroupBox );
328 new TQLabel( i18n(
"Default reminder time:" ), remindersBox );
330 mReminderTimeSpin =
new KIntSpinBox( remindersBox );
331 connect( mReminderTimeSpin, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(slotWidChanged()) );
333 mReminderUnitsCombo =
new KComboBox( remindersBox );
334 connect( mReminderUnitsCombo, TQ_SIGNAL(activated(
int)), TQ_SLOT(slotWidChanged()) );
335 mReminderUnitsCombo->insertItem( i18n(
"minute(s)" ) );
336 mReminderUnitsCombo->insertItem( i18n(
"hour(s)" ) );
337 mReminderUnitsCombo->insertItem( i18n(
"day(s)" ) );
339 TQHBox *audioFileRemindersBox =
new TQHBox( remindersGroupBox );
341 TQCheckBox *cb = addWidBool( KOPrefs::instance()->defaultAudioFileRemindersItem(),
342 audioFileRemindersBox )->checkBox();
343 cb->setText( TQString() );
345 if ( KOPrefs::instance()->audioFilePathItem()->value().isEmpty() ) {
346 TQString defAudioFile = TDEGlobal::dirs()->findResourceDir(
"sound",
"KDE-Sys-Warning.ogg");
347 KOPrefs::instance()->audioFilePathItem()->setValue( defAudioFile +
"KDE-Sys-Warning.ogg" );
349 TQString filter = i18n(
"*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra|"
350 "Audio Files (*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra)" );
351 KURLRequester *rq = addWidPath( KOPrefs::instance()->audioFilePathItem(),
352 audioFileRemindersBox, filter )->urlRequester();
353 rq->setEnabled( cb->isChecked() );
354 connect( cb, TQ_SIGNAL(toggled(
bool)),
355 rq, TQ_SLOT(setEnabled(
bool)) );
357 TQHBox *eventRemindersBox =
new TQHBox( remindersGroupBox );
358 addWidBool( KOPrefs::instance()->defaultEventRemindersItem(), eventRemindersBox )->checkBox();
360 TQHBox *todoRemindersBox =
new TQHBox( remindersGroupBox );
361 addWidBool( KOPrefs::instance()->defaultTodoRemindersItem(), todoRemindersBox )->checkBox();
363 TQLabel *alarmDefaultLabel =
new TQLabel( i18n(
"Enable reminders by default:" ), topFrame);
364 topLayout->addWidget( alarmDefaultLabel, 6, 0 );
365 mAlarmTimeDefaultCheckBox =
new TQCheckBox( topFrame );
366 topLayout->addWidget( mAlarmTimeDefaultCheckBox, 6, 1 );
367 connect( mAlarmTimeDefaultCheckBox, TQ_SIGNAL( toggled(
bool ) ),
368 TQ_SLOT( slotWidChanged() ) );
370 TQGroupBox *workingHoursGroup =
new TQGroupBox(1,TQt::Horizontal,
371 i18n(
"Working Hours"),
373 topLayout->addMultiCellWidget( workingHoursGroup, 7, 7, 0, 1 );
375 TQHBox *workDaysBox =
new TQHBox( workingHoursGroup );
377 int weekStart=TDEGlobal::locale()->weekStartDay();
378 for (
int i = 0; i < 7; ++i ) {
379 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
380 TQString weekDayName = calSys->weekDayName( (i + weekStart + 6)%7 + 1,
true );
381 if ( KOPrefs::instance()->mCompactDialogs ) {
382 weekDayName = weekDayName.left( 1 );
384 int index = ( i + weekStart + 6 ) % 7;
385 mWorkDays[ index ] =
new TQCheckBox( weekDayName, workDaysBox );
386 TQWhatsThis::add( mWorkDays[ index ],
387 i18n(
"Check this box to make KOrganizer mark the "
388 "working hours for this day of the week. "
389 "If this is a work day for you, check "
390 "this box, or the working hours will not be "
391 "marked with color." ) );
393 connect( mWorkDays[ index ], TQ_SIGNAL( stateChanged(
int ) ),
394 TQ_SLOT( slotWidChanged() ) );
397 TQHBox *workStartBox =
new TQHBox(workingHoursGroup);
398 addWidTime( KOPrefs::instance()->workingHoursStartItem(), workStartBox );
400 TQHBox *workEndBox =
new TQHBox(workingHoursGroup);
401 addWidTime( KOPrefs::instance()->workingHoursEndItem(), workEndBox );
404 addWidBool( KOPrefs::instance()->excludeHolidaysItem(),
407 topLayout->setRowStretch(8,1);
415 setCombo( mTimeZoneCombo,
416 i18n( KOPrefs::instance()->mTimeZoneId.utf8() ) );
418 mReminderTimeSpin->setValue( KOPrefs::instance()->mReminderTime );
419 mReminderUnitsCombo->setCurrentItem( KOPrefs::instance()->mReminderTimeUnits );
421 for (
int i = 0; i < 7; ++i ) {
422 mWorkDays[i]->setChecked( (1<<i) & (KOPrefs::instance()->mWorkWeekMask) );
426 void usrWriteConfig()
429 TQStringList::Iterator tz;
430 for ( tz = tzonenames.begin(); tz != tzonenames.end(); ++tz )
431 if (mTimeZoneCombo->currentText() == i18n((*tz).utf8()))
433 if (tz != tzonenames.end())
434 KOPrefs::instance()->mTimeZoneId = (*tz);
436 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
438 KOPrefs::instance()->mHolidays = ( mHolidayCombo->currentItem() == 0 ) ?
440 mRegionMap[mHolidayCombo->currentText()];
442 KOPrefs::instance()->mReminderTime = mReminderTimeSpin->value();
443 KOPrefs::instance()->mReminderTimeUnits = mReminderUnitsCombo->currentItem();
446 for (
int i = 0; i < 7; ++i ) {
447 if (mWorkDays[i]->isChecked()) mask = mask | (1<<i);
449 KOPrefs::instance()->mWorkWeekMask = mask;
450 KOPrefs::instance()->writeConfig();
453 void setCombo( TQComboBox *combo,
const TQString &text,
454 const TQStringList *tags = 0 )
457 int i = tags->findIndex(text);
458 if (i > 0) combo->setCurrentItem(i);
460 for(
int i=0;i<combo->count();++i) {
461 if (combo->text(i) == text) {
462 combo->setCurrentItem(i);
470 TQComboBox *mTimeZoneCombo;
471 TQStringList tzonenames;
472 TQComboBox *mHolidayCombo;
473 TQMap<TQString,TQString> mRegionMap;
474 KIntSpinBox *mReminderTimeSpin;
475 KComboBox *mReminderUnitsCombo;
476 TQCheckBox *mAlarmTimeDefaultCheckBox;
477 TQCheckBox *mWorkDays[7];
482 TDECModule *create_korganizerconfigtime( TQWidget *parent,
const char * )
484 TDEGlobal::locale()->insertCatalogue(
"timezones" );
485 return new KOPrefsDialogTime( parent,
"kcmkorganizertime" );
490 class KOPrefsDialogViews :
public KPrefsModule
493 KOPrefsDialogViews( TQWidget *parent,
const char *name )
494 : KPrefsModule( KOPrefs::instance(), parent, name )
496 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
498 TQWidget *topFrame =
new TQWidget(
this );
499 topTopLayout->addWidget( topFrame );
501 TQBoxLayout *topLayout =
new TQVBoxLayout( topFrame );
502 topLayout->setSpacing( KDialog::spacingHint() );
504 KPrefsWidBool *enableToolTips =
505 addWidBool( KOPrefs::instance()->enableToolTipsItem(), topFrame );
506 topLayout->addWidget( enableToolTips->checkBox() );
508 KPrefsWidBool *showTodosAgenda =
509 addWidBool( KOPrefs::instance()->showAllDayTodoItem(), topFrame );
510 topLayout->addWidget( showTodosAgenda->checkBox() );
513 TQGroupBox *dateNavGroup =
new TQGroupBox( 1, TQt::Horizontal,
514 i18n(
"Date Navigator"),
516 addWidBool( KOPrefs::instance()->dailyRecurItem(), dateNavGroup );
517 addWidBool( KOPrefs::instance()->weeklyRecurItem(), dateNavGroup );
518 addWidBool( KOPrefs::instance()->weekNumbersShowWorkItem(), dateNavGroup );
519 topLayout->addWidget( dateNavGroup );
523 TQGroupBox *agendaGroup =
new TQGroupBox( 1, TQt::Horizontal,
527 TQHBox *hourSizeBox =
new TQHBox( agendaGroup );
528 KPrefsWidInt *hourSize =
529 addWidInt( KOPrefs::instance()->hourSizeItem(), hourSizeBox );
530 hourSize->spinBox()->setSuffix(i18n(
"suffix in the hour size spin box",
" pixel"));
532 new TQWidget( hourSizeBox );
534 TQHBox *nextDaysBox =
new TQHBox( agendaGroup );
535 KPrefsWidInt *nextDays =
536 addWidInt( KOPrefs::instance()->nextXDaysItem(), nextDaysBox );
537 nextDays->spinBox()->setSuffix(i18n(
"suffix in the N days spin box",
" days"));
538 new TQWidget( nextDaysBox );
540 KPrefsWidBool *marcusBainsEnabled =
541 addWidBool( KOPrefs::instance()->marcusBainsEnabledItem(), agendaGroup );
543 KPrefsWidBool *marcusBainsShowSeconds =
544 addWidBool( KOPrefs::instance()->marcusBainsShowSecondsItem(), agendaGroup );
545 connect( marcusBainsEnabled->checkBox(), TQ_SIGNAL( toggled(
bool ) ),
546 marcusBainsShowSeconds->checkBox(), TQ_SLOT( setEnabled(
bool ) ) );
548 addWidBool( KOPrefs::instance()->selectionStartsEditorItem(), agendaGroup );
550 addWidCombo( KOPrefs::instance()->agendaViewColorsItem(), agendaGroup );
552 addWidCombo( KOPrefs::instance()->agendaViewCalendarDisplayItem(), agendaGroup );
554 topLayout->addWidget( agendaGroup );
557 TQGroupBox *monthGroup =
new TQGroupBox( 1, TQt::Horizontal,
560 addWidBool( KOPrefs::instance()->enableMonthScrollItem(), monthGroup );
561 addWidBool( KOPrefs::instance()->fullViewMonthItem(), monthGroup );
562 addWidCombo( KOPrefs::instance()->monthItemColorsItem(), monthGroup );
563 topLayout->addWidget( monthGroup );
567 TQGroupBox *todoGroup =
new TQGroupBox( 1, TQt::Horizontal,
570 addWidBool( KOPrefs::instance()->fullViewTodoItem(), todoGroup );
571 addWidBool( KOPrefs::instance()->recordTodosInJournalsItem(), todoGroup );
572 topLayout->addWidget( todoGroup );
574 topLayout->addStretch( 1 );
582 TDECModule *create_korganizerconfigviews( TQWidget *parent,
const char * )
584 return new KOPrefsDialogViews( parent,
"kcmkorganizerviews" );
589 class KOPrefsDialogFonts :
public KPrefsModule
592 KOPrefsDialogFonts( TQWidget *parent,
const char *name )
593 : KPrefsModule( KOPrefs::instance(), parent, name )
595 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
597 TQWidget *topFrame =
new TQWidget(
this );
598 topTopLayout->addWidget( topFrame );
600 TQGridLayout *topLayout =
new TQGridLayout(topFrame,5,3);
601 topLayout->setSpacing( KDialog::spacingHint() );
603 KPrefsWidFont *timeBarFont =
604 addWidFont( KOPrefs::instance()->timeBarFontItem(), topFrame,
605 TDEGlobal::locale()->formatTime( TQTime( 12, 34 ) ) );
606 topLayout->addWidget(timeBarFont->label(),0,0);
607 topLayout->addWidget(timeBarFont->preview(),0,1);
608 topLayout->addWidget(timeBarFont->button(),0,2);
610 KPrefsWidFont *monthViewFont =
611 addWidFont( KOPrefs::instance()->monthViewFontItem(), topFrame,
612 TDEGlobal::locale()->formatTime(TQTime(12,34)) +
" " +
613 i18n(
"Event text") );
615 topLayout->addWidget(monthViewFont->label(),1,0);
616 topLayout->addWidget(monthViewFont->preview(),1,1);
617 topLayout->addWidget(monthViewFont->button(),1,2);
619 KPrefsWidFont *agendaViewFont =
620 addWidFont( KOPrefs::instance()->agendaViewFontItem(),
621 topFrame, i18n(
"Event text") );
622 topLayout->addWidget(agendaViewFont->label(),2,0);
623 topLayout->addWidget(agendaViewFont->preview(),2,1);
624 topLayout->addWidget(agendaViewFont->button(),2,2);
626 KPrefsWidFont *marcusBainsFont =
627 addWidFont( KOPrefs::instance()->marcusBainsFontItem(), topFrame,
628 TDEGlobal::locale()->formatTime( TQTime( 12, 34, 23 ) ) );
629 topLayout->addWidget(marcusBainsFont->label(),3,0);
630 topLayout->addWidget(marcusBainsFont->preview(),3,1);
631 topLayout->addWidget(marcusBainsFont->button(),3,2);
633 topLayout->setColStretch(1,1);
634 topLayout->setRowStretch(4,1);
642 TDECModule *create_korganizerconfigfonts( TQWidget *parent,
const char * )
644 return new KOPrefsDialogFonts( parent,
"kcmkorganizerfonts" );
649 KOPrefsDialogColors::KOPrefsDialogColors( TQWidget *parent,
const char *name )
650 : KPrefsModule( KOPrefs::instance(), parent, name )
652 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
654 TQWidget *topFrame =
new TQWidget(
this );
655 topTopLayout->addWidget( topFrame );
657 TQGridLayout *topLayout =
new TQGridLayout(topFrame,7,2);
658 topLayout->setSpacing( KDialog::spacingHint() );
661 KPrefsWidColor *holidayColor =
662 addWidColor( KOPrefs::instance()->holidayColorItem(), topFrame );
663 topLayout->addWidget(holidayColor->label(),0,0);
664 topLayout->addWidget(holidayColor->button(),0,1);
667 KPrefsWidColor *highlightColor =
668 addWidColor( KOPrefs::instance()->highlightColorItem(), topFrame );
669 topLayout->addWidget(highlightColor->label(),1,0);
670 topLayout->addWidget(highlightColor->button(),1,1);
673 KPrefsWidColor *agendaBgColor =
674 addWidColor( KOPrefs::instance()->agendaBgColorItem(), topFrame );
675 topLayout->addWidget(agendaBgColor->label(),2,0);
676 topLayout->addWidget(agendaBgColor->button(),2,1);
679 KPrefsWidColor *workingHoursColor =
680 addWidColor( KOPrefs::instance()->workingHoursColorItem(), topFrame );
681 topLayout->addWidget(workingHoursColor->label(),3,0);
682 topLayout->addWidget(workingHoursColor->button(),3,1);
685 KPrefsWidColor *todoDueTodayColor =
686 addWidColor( KOPrefs::instance()->todoDueTodayColorItem(), topFrame );
687 topLayout->addWidget(todoDueTodayColor->label(),4,0);
688 topLayout->addWidget(todoDueTodayColor->button(),4,1);
691 KPrefsWidColor *todoOverdueColor =
692 addWidColor( KOPrefs::instance()->todoOverdueColorItem(), topFrame );
693 topLayout->addWidget(todoOverdueColor->label(),5,0);
694 topLayout->addWidget(todoOverdueColor->button(),5,1);
697 KPrefsWidColor *unsetCategoryColor =
698 addWidColor( KOPrefs::instance()->unsetCategoryColorItem(), topFrame );
699 topLayout->addWidget( unsetCategoryColor->label(), 6, 0 );
700 topLayout->addWidget( unsetCategoryColor->button(), 6, 1 );
703 TQGroupBox *categoryGroup =
new TQGroupBox(1,TQt::Horizontal,i18n(
"Categories"),
705 topLayout->addMultiCellWidget(categoryGroup,7,7,0,1);
708 mCategoryCombo =
new TQComboBox(categoryGroup);
709 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
710 TQWhatsThis::add( mCategoryCombo,
711 i18n(
"Select here the event category you want to modify. "
712 "You can change the selected category color using "
713 "the button below." ) );
714 connect(mCategoryCombo,TQ_SIGNAL(activated(
int)),TQ_SLOT(updateCategoryColor()));
716 mCategoryButton =
new KColorButton(categoryGroup);
717 TQWhatsThis::add( mCategoryButton,
718 i18n(
"Choose here the color of the event category selected "
719 "using the combo box above." ) );
720 connect(mCategoryButton,TQ_SIGNAL(changed(
const TQColor &)),TQ_SLOT(setCategoryColor()));
721 updateCategoryColor();
724 TQGroupBox *resourceGroup =
new TQGroupBox(1,TQt::Horizontal,i18n(
"Resources"),
726 topLayout->addMultiCellWidget(resourceGroup,8,8,0,1);
728 mResourceCombo =
new TQComboBox(resourceGroup);
729 TQWhatsThis::add( mResourceCombo,
730 i18n(
"Select here resource you want to modify. "
731 "You can change the selected resource color using "
732 "the button below." ) );
733 connect(mResourceCombo,TQ_SIGNAL(activated(
int)),TQ_SLOT(updateResourceColor()));
735 mResourceButton =
new KColorButton(resourceGroup);
736 TQWhatsThis::add( mResourceButton,
737 i18n(
"Choose here the color of the resource selected "
738 "using the combo box above." ) );
739 connect(mResourceButton,TQ_SIGNAL(changed(
const TQColor &)),TQ_SLOT(setResourceColor()));
742 topLayout->setRowStretch(9,1);
747 void KOPrefsDialogColors::usrWriteConfig()
749 TQDictIterator<TQColor> itCat(mCategoryDict);
750 while (itCat.current()) {
751 KOPrefs::instance()->setCategoryColor(itCat.currentKey(),*itCat.current());
755 TQDictIterator<TQColor> itRes(mResourceDict);
756 while (itRes.current()) {
757 KOPrefs::instance()->setResourceColor(itRes.currentKey(),*itRes.current());
762 void KOPrefsDialogColors::usrReadConfig()
768 void KOPrefsDialogColors::updateCategories()
770 mCategoryCombo->clear();
771 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
772 updateCategoryColor();
775 void KOPrefsDialogColors::setCategoryColor()
777 mCategoryDict.replace(mCategoryCombo->currentText(),
new TQColor(mCategoryButton->color()));
781 void KOPrefsDialogColors::updateCategoryColor()
783 TQString cat = mCategoryCombo->currentText();
784 TQColor *color = mCategoryDict.find(cat);
786 color = KOPrefs::instance()->categoryColor(cat);
789 mCategoryButton->setColor(*color);
793 void KOPrefsDialogColors::updateResources()
795 mResourceCombo->clear();
796 mResourceIdentifier.clear();
797 kdDebug( 5850) <<
"KOPrefsDialogColors::updateResources()" << endl;
799 KCal::CalendarResourceManager *manager = KOrg::StdCalendar::self()->resourceManager();
801 kdDebug(5850) <<
"Loading Calendar resources...:" << endl;
802 KCal::CalendarResourceManager::Iterator it;
803 for( it = manager->begin(); it != manager->end(); ++it ) {
804 if ( !(*it)->subresources().isEmpty() ) {
805 TQStringList subresources = (*it)->subresources();
806 for ( uint i = 0; i < subresources.count(); ++i ) {
807 TQString resource = subresources[ i ];
808 if ( (*it)->subresourceActive( resource ) ) {
809 mResourceCombo->insertItem( (*it)->labelForSubresource( resource ) );
810 mResourceIdentifier.append( resource );
815 mResourceCombo->insertItem( (*it)->resourceName() );
816 mResourceIdentifier.append( (*it)->identifier() );
819 updateResourceColor();
822 void KOPrefsDialogColors::setResourceColor()
824 kdDebug( 5850) <<
"KOPrefsDialogColors::setResorceColor()" << endl;
826 mResourceDict.replace( mResourceIdentifier[mResourceCombo->currentItem()],
827 new TQColor( mResourceButton->color() ) );
831 void KOPrefsDialogColors::updateResourceColor()
833 kdDebug( 5850 ) <<
"KOPrefsDialogColors::updateResourceColor()" << endl;
834 TQString res= mResourceIdentifier[mResourceCombo->currentItem()];
835 TQColor *color = mCategoryDict.find(res);
837 color = KOPrefs::instance()->resourceColor( res );
840 mResourceButton->setColor(*color);
845 TDECModule *create_korganizerconfigcolors( TQWidget *parent,
const char * )
847 return new KOPrefsDialogColors( parent,
"kcmkorganizercolors" );
852 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling( TQWidget *parent,
const char *name )
853 : KPrefsModule( KOPrefs::instance(), parent, name )
855 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
857 TQWidget *topFrame =
new TQWidget(
this );
858 topTopLayout->addWidget( topFrame );
860 TQGridLayout *topLayout =
new TQGridLayout(topFrame,6,2);
861 topLayout->setSpacing( KDialog::spacingHint() );
863 KPrefsWidBool *useGroupwareBool =
864 addWidBool( KOPrefs::instance()->useGroupwareCommunicationItem(),
866 topLayout->addMultiCellWidget(useGroupwareBool->checkBox(),0,0,0,1);
872 addWidBool( KOPrefs::instance()->bccItem(), topFrame );
873 topLayout->addMultiCellWidget(bcc->checkBox(),1,1,0,1);
875 KPrefsWidRadios *mailClientGroup =
876 addWidRadios( KOPrefs::instance()->mailClientItem(), topFrame );
877 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),2,2,0,1);
881 KPrefsWidRadios *schedulerGroup =
882 addWidRadios(i18n(
"Scheduler Mail Client"),KOPrefs::instance()->mIMIPScheduler,
884 schedulerGroup->addRadio(
"Dummy");
885 schedulerGroup->addRadio(i18n(
"Mail client"));
887 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
890 TQLabel *aMailsLabel =
new TQLabel(i18n(
"Additional email addresses:"),topFrame);
891 TQString whatsThis = i18n(
"Add, edit or remove additional e-mails addresses "
892 "here. These email addresses are the ones you "
893 "have in addition to the one set in personal "
894 "preferences. If you are an attendee of one event, "
895 "but use another email address there, you need to "
896 "list this address here so KOrganizer can "
897 "recognize it as yours." );
898 TQWhatsThis::add( aMailsLabel, whatsThis );
899 topLayout->addMultiCellWidget(aMailsLabel,3,3,0,1);
900 mAMails =
new TQListView(topFrame);
901 TQWhatsThis::add( mAMails, whatsThis );
903 mAMails->addColumn(i18n(
"Email"),300);
904 topLayout->addMultiCellWidget(mAMails,4,4,0,1);
906 TQLabel *aEmailsEditLabel =
new TQLabel(i18n(
"Additional email address:"),topFrame);
907 whatsThis = i18n(
"Edit additional e-mails addresses here. To edit an "
908 "address select it from the list above "
909 "or press the \"New\" button below. These email "
910 "addresses are the ones you have in addition to the "
911 "one set in personal preferences." );
912 TQWhatsThis::add( aEmailsEditLabel, whatsThis );
913 topLayout->addWidget(aEmailsEditLabel,5,0);
914 aEmailsEdit =
new TQLineEdit(topFrame);
915 TQWhatsThis::add( aEmailsEdit, whatsThis );
916 aEmailsEdit->setEnabled(
false);
917 topLayout->addWidget(aEmailsEdit,5,1);
919 TQPushButton *add =
new TQPushButton(i18n(
"New"),topFrame,
"new");
920 whatsThis = i18n(
"Press this button to add a new entry to the "
921 "additional e-mail addresses list. Use the edit "
922 "box above to edit the new entry." );
923 TQWhatsThis::add( add, whatsThis );
924 topLayout->addWidget(add,6,0);
925 TQPushButton *del =
new TQPushButton(i18n(
"Remove"),topFrame,
"remove");
926 TQWhatsThis::add( del, whatsThis );
927 topLayout->addWidget(del,6,1);
930 connect(add, TQ_SIGNAL( clicked() ),
this, TQ_SLOT(addItem()) );
931 connect(del, TQ_SIGNAL( clicked() ),
this, TQ_SLOT(removeItem()) );
932 connect(aEmailsEdit,TQ_SIGNAL( textChanged(
const TQString&) ),
this,TQ_SLOT(updateItem()));
933 connect(mAMails,TQ_SIGNAL(selectionChanged(TQListViewItem *)),TQ_SLOT(updateInput()));
938 void KOPrefsDialogGroupScheduling::usrReadConfig()
941 for ( TQStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
942 it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
943 TQListViewItem *item =
new TQListViewItem(mAMails);
944 item->setText(0,*it);
945 mAMails->insertItem(item);
949 void KOPrefsDialogGroupScheduling::usrWriteConfig()
951 KOPrefs::instance()->mAdditionalMails.clear();
952 TQListViewItem *item;
953 item = mAMails->firstChild();
956 KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
957 item = item->nextSibling();
961 void KOPrefsDialogGroupScheduling::addItem()
963 aEmailsEdit->setEnabled(
true);
964 TQListViewItem *item =
new TQListViewItem(mAMails);
965 mAMails->insertItem(item);
966 mAMails->setSelected(item,
true);
967 aEmailsEdit->setText(i18n(
"(EmptyEmail)"));
971 void KOPrefsDialogGroupScheduling::removeItem()
973 TQListViewItem *item;
974 item = mAMails->selectedItem();
976 mAMails->takeItem(item);
977 item = mAMails->selectedItem();
979 aEmailsEdit->setText(
"");
980 aEmailsEdit->setEnabled(
false);
982 if (mAMails->childCount() == 0) {
983 aEmailsEdit->setEnabled(
false);
988 void KOPrefsDialogGroupScheduling::updateItem()
990 TQListViewItem *item;
991 item = mAMails->selectedItem();
993 item->setText(0,aEmailsEdit->text());
997 void KOPrefsDialogGroupScheduling::updateInput()
999 TQListViewItem *item;
1000 item = mAMails->selectedItem();
1002 aEmailsEdit->setEnabled(
true);
1003 aEmailsEdit->setText(item->text(0));
1008 TDECModule *create_korganizerconfiggroupscheduling( TQWidget *parent,
1011 return new KOPrefsDialogGroupScheduling( parent,
1012 "kcmkorganizergroupscheduling" );
1017 KOPrefsDialogGroupwareScheduling::KOPrefsDialogGroupwareScheduling( TQWidget *parent,
const char *name )
1018 : KPrefsModule( KOPrefs::instance(), parent, name )
1020 mGroupwarePage =
new KOGroupwarePrefsPage(
this );
1021 connect( mGroupwarePage, TQ_SIGNAL( changed() ), TQ_SLOT( slotWidChanged() ) );
1022 (
new TQVBoxLayout(
this ) )->addWidget( mGroupwarePage );
1027 void KOPrefsDialogGroupwareScheduling::usrReadConfig()
1029 mGroupwarePage->publishEnable->setChecked( KOPrefs::instance()->mFreeBusyPublishAuto );
1030 mGroupwarePage->publishDelay->setValue( KOPrefs::instance()->mFreeBusyPublishDelay );
1031 mGroupwarePage->publishDays->setValue( KOPrefs::instance()->mFreeBusyPublishDays );
1033 mGroupwarePage->publishUrl->setText( KOPrefs::instance()->mFreeBusyPublishUrl );
1034 mGroupwarePage->publishUser->setText( KOPrefs::instance()->mFreeBusyPublishUser );
1035 mGroupwarePage->publishPassword->setText( KOPrefs::instance()->mFreeBusyPublishPassword );
1036 mGroupwarePage->publishSavePassword->setChecked( KOPrefs::instance()->mFreeBusyPublishSavePassword );
1038 mGroupwarePage->retrieveEnable->setChecked( KOPrefs::instance()->mFreeBusyRetrieveAuto );
1039 mGroupwarePage->fullDomainRetrieval->setChecked( KOPrefs::instance()->mFreeBusyFullDomainRetrieval );
1040 mGroupwarePage->retrieveUrl->setText( KOPrefs::instance()->mFreeBusyRetrieveUrl );
1041 mGroupwarePage->retrieveUser->setText( KOPrefs::instance()->mFreeBusyRetrieveUser );
1042 mGroupwarePage->retrievePassword->setText( KOPrefs::instance()->mFreeBusyRetrievePassword );
1043 mGroupwarePage->retrieveSavePassword->setChecked( KOPrefs::instance()->mFreeBusyRetrieveSavePassword );
1046 void KOPrefsDialogGroupwareScheduling::usrWriteConfig()
1048 KOPrefs::instance()->mFreeBusyPublishAuto = mGroupwarePage->publishEnable->isChecked();
1049 KOPrefs::instance()->mFreeBusyPublishDelay = mGroupwarePage->publishDelay->value();
1050 KOPrefs::instance()->mFreeBusyPublishDays = mGroupwarePage->publishDays->value();
1052 KOPrefs::instance()->mFreeBusyPublishUrl = mGroupwarePage->publishUrl->text();
1053 KOPrefs::instance()->mFreeBusyPublishUser = mGroupwarePage->publishUser->text();
1054 KOPrefs::instance()->mFreeBusyPublishPassword = mGroupwarePage->publishPassword->text();
1055 KOPrefs::instance()->mFreeBusyPublishSavePassword = mGroupwarePage->publishSavePassword->isChecked();
1057 KOPrefs::instance()->mFreeBusyRetrieveAuto = mGroupwarePage->retrieveEnable->isChecked();
1058 KOPrefs::instance()->mFreeBusyFullDomainRetrieval = mGroupwarePage->fullDomainRetrieval->isChecked();
1059 KOPrefs::instance()->mFreeBusyRetrieveUrl = mGroupwarePage->retrieveUrl->text();
1060 KOPrefs::instance()->mFreeBusyRetrieveUser = mGroupwarePage->retrieveUser->text();
1061 KOPrefs::instance()->mFreeBusyRetrievePassword = mGroupwarePage->retrievePassword->text();
1062 KOPrefs::instance()->mFreeBusyRetrieveSavePassword = mGroupwarePage->retrieveSavePassword->isChecked();
1065 TQString configFile = locateLocal(
"data",
"korganizer/freebusyurls" );
1066 TDEConfig cfg( configFile );
1067 cfg.deleteGroup( KOPrefs::instance()->email() );
1072 TDECModule *create_korganizerconfigfreebusy( TQWidget *parent,
const char * )
1074 return new KOPrefsDialogGroupwareScheduling( parent,
1075 "kcmkorganizerfreebusy" );
1081 class PluginItem :
public TQCheckListItem {
1083 PluginItem( TQListView *parent, KService::Ptr service ) :
1084 TQCheckListItem( parent, service->name(), TQCheckListItem::CheckBox ), mService( service )
1086 KService::Ptr service() {
return mService; }
1088 KService::Ptr mService;
1095 KOPrefsDialogPlugins::KOPrefsDialogPlugins( TQWidget *parent,
const char* name )
1096 : KPrefsModule( KOPrefs::instance(), parent, name )
1098 TQBoxLayout *topTopLayout =
new TQVBoxLayout(
this );
1100 TQWidget *topFrame =
new TQWidget(
this );
1101 topTopLayout->addWidget( topFrame );
1102 TQBoxLayout *topLayout =
new TQVBoxLayout( topFrame );
1103 topLayout->setSpacing( KDialog::spacingHint() );
1105 mListView =
new TQListView( topFrame );
1106 mListView->addColumn( i18n(
"Name") );
1107 mListView->setResizeMode( TQListView::LastColumn );
1108 topLayout->addWidget( mListView );
1110 mDescription =
new TQLabel( topFrame );
1111 mDescription->setAlignment( TQLabel::NoAccel | TQLabel::WordBreak | TQLabel::AlignVCenter );
1112 mDescription->setFrameShape( TQLabel::Panel );
1113 mDescription->setFrameShadow( TQLabel::Sunken );
1114 mDescription->setMinimumSize( TQSize( 0, 55 ) );
1115 mDescription->setSizePolicy(
1116 TQSizePolicy( (TQSizePolicy::SizeType)5, (TQSizePolicy::SizeType)0,
1117 0, 0, mDescription->sizePolicy().hasHeightForWidth() ) );
1118 topLayout->addWidget( mDescription );
1121 TQWidget *buttonRow =
new TQWidget( topFrame );
1122 TQBoxLayout *buttonRowLayout =
new TQHBoxLayout( buttonRow );
1123 mConfigureButton =
new KPushButton( KGuiItem( i18n(
"Configure &Plugin..."),
1124 "configure", TQString(), i18n(
"This button allows you to configure"
1125 " the plugin that you have selected in the list above") ), buttonRow );
1127 buttonRowLayout->addWidget( mConfigureButton );
1128 buttonRowLayout->addItem(
new TQSpacerItem(1, 1, TQSizePolicy::Expanding) );
1129 topLayout->addWidget( buttonRow );
1130 connect( mConfigureButton, TQ_SIGNAL( clicked() ), TQ_SLOT( configure() ) );
1132 connect( mListView, TQ_SIGNAL( selectionChanged( TQListViewItem* ) ),
1133 TQ_SLOT( selectionChanged( TQListViewItem* ) ) );
1134 connect( mListView, TQ_SIGNAL( clicked( TQListViewItem* ) ),
1135 TQ_SLOT( slotWidChanged() ) );
1139 selectionChanged( 0 );
1142 void KOPrefsDialogPlugins::usrReadConfig()
1145 TDETrader::OfferList plugins = KOCore::self()->availablePlugins();
1146 plugins += KOCore::self()->availableParts();
1148 TQStringList selectedPlugins = KOPrefs::instance()->mSelectedPlugins;
1150 TDETrader::OfferList::ConstIterator it;
1151 for( it = plugins.begin(); it != plugins.end(); ++it ) {
1152 TQCheckListItem *item =
new PluginItem( mListView, *it );
1153 if ( selectedPlugins.find( (*it)->desktopEntryName() ) !=
1154 selectedPlugins.end() ) {
1155 item->setOn(
true );
1160 void KOPrefsDialogPlugins::usrWriteConfig()
1162 TQStringList selectedPlugins;
1164 PluginItem *item =
static_cast<PluginItem *
>( mListView->firstChild() );
1166 if( item->isOn() ) {
1167 selectedPlugins.append( item->service()->desktopEntryName() );
1169 item =
static_cast<PluginItem *
>( item->nextSibling() );
1171 KOPrefs::instance()->mSelectedPlugins = selectedPlugins;
1174 void KOPrefsDialogPlugins::configure()
1176 PluginItem *item =
static_cast<PluginItem *
>( mListView->selectedItem() );
1177 if ( !item )
return;
1179 KOrg::Plugin *plugin = KOCore::self()->loadPlugin( item->service() );
1182 plugin->configure(
this );
1185 KMessageBox::sorry(
this, i18n(
"Unable to configure this plugin" ),
1186 "PluginConfigUnable" );
1190 void KOPrefsDialogPlugins::selectionChanged( TQListViewItem *i )
1192 PluginItem *item =
dynamic_cast<PluginItem*
>( i );
1194 mConfigureButton->setEnabled(
false );
1195 mDescription->setText( TQString() );
1199 TQVariant variant = item->service()->property(
"X-TDE-KOrganizer-HasSettings" );
1201 bool hasSettings =
true;
1202 if ( variant.isValid() )
1203 hasSettings = variant.toBool();
1205 mDescription->setText( item->service()->comment() );
1206 mConfigureButton->setEnabled( hasSettings );
1213 TDECModule *create_korganizerconfigplugins( TQWidget *parent,
const char * )
1215 return new KOPrefsDialogPlugins( parent,
1216 "kcmkorganizerplugins" );
1223 TDECModule *create_korgdesignerfields( TQWidget *parent,
const char * ) {
1224 return new KOPrefsDesignerFields( parent,
"kcmkorgdesignerfields" );
1228 KOPrefsDesignerFields::KOPrefsDesignerFields( TQWidget *parent,
const char *name )
1229 : KCMDesignerFields( parent, name )
1233 TQString KOPrefsDesignerFields::localUiDir()
1235 TQString dir = locateLocal(
"data",
"korganizer/designer/event/");
1236 kdDebug() <<
"KOPrefsDesignerFields::localUiDir(): " << dir << endl;
1240 TQString KOPrefsDesignerFields::uiPath()
1242 return "korganizer/designer/event/";
1245 void KOPrefsDesignerFields::writeActivePages(
const TQStringList &activePages )
1247 KOPrefs::instance()->setActiveDesignerFields( activePages );
1248 KOPrefs::instance()->writeConfig();
1251 TQStringList KOPrefsDesignerFields::readActivePages()
1253 return KOPrefs::instance()->activeDesignerFields();
1256 TQString KOPrefsDesignerFields::applicationName()
1258 return "KORGANIZER";
1261 #include "koprefsdialog.moc"