korganizer Library API Documentation

koprefsdialog.cpp

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
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., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <qgroupbox.h>
00027 #include <qbuttongroup.h>
00028 #include <qlineedit.h>
00029 #include <qfont.h>
00030 #include <qslider.h>
00031 #include <qfile.h>
00032 #include <qtextstream.h>
00033 #include <qcombobox.h>
00034 #include <qvbox.h>
00035 #include <qhbox.h>
00036 #include <qspinbox.h>
00037 #include <qdatetime.h>
00038 #include <qcheckbox.h>
00039 #include <qradiobutton.h>
00040 #include <qpushbutton.h>
00041 #include <qstrlist.h>
00042 
00043 #include <kcolorbutton.h>
00044 #include <kdebug.h>
00045 #include <klocale.h>
00046 #include <kglobal.h>
00047 #include <kfontdialog.h>
00048 #include <kmessagebox.h>
00049 #include <kcolordialog.h>
00050 #include <kiconloader.h>
00051 #include <kemailsettings.h>
00052 #include <kstandarddirs.h>
00053 
00054 #include <kurlrequester.h>
00055 #include <klineedit.h>
00056 
00057 #if defined(USE_SOLARIS)
00058 #include <sys/param.h>
00059 
00060 #define ZONEINFODIR    "/usr/share/lib/zoneinfo"
00061 #define INITFILE       "/etc/default/init"
00062 #endif
00063 
00064 #include "koprefs.h"
00065 
00066 #include "koprefsdialog.h"
00067 #include "koprefsdialog.moc"
00068 
00069 
00070 KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) :
00071   KPrefsDialog(KOPrefs::instance(),parent,name,modal)
00072 {
00073   mCategoryDict.setAutoDelete(true);
00074 
00075   KGlobal::locale()->insertCatalogue("timezones");
00076 
00077   setupMainTab();
00078   setupTimeTab();
00079   setupFontsTab();
00080   setupColorsTab();
00081   setupViewsTab();
00082   //setupPrinterTab();
00083   setupGroupSchedulingTab();
00084   setupGroupAutomationTab();
00085 }
00086 
00087 
00088 KOPrefsDialog::~KOPrefsDialog()
00089 {
00090 }
00091 
00092 
00093 void KOPrefsDialog::setupMainTab()
00094 {
00095   QFrame *topFrame = addPage(i18n("Personal"),0,
00096       DesktopIcon("identity",KIcon::SizeMedium));
00097 
00098   QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
00099   topLayout->setSpacing(spacingHint());
00100   topLayout->setMargin(marginHint());
00101 
00102   KPrefsWidBool *emailControlCenter =
00103       addWidBool(i18n("&Use email settings from Control Center"),
00104                  &(KOPrefs::instance()->mEmailControlCenter),topFrame);
00105   topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1);
00106   connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
00107           SLOT(toggleEmailSettings(bool)));
00108 
00109   mNameEdit = new QLineEdit(topFrame);
00110   mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
00111   topLayout->addWidget(mNameLabel,1,0);
00112   topLayout->addWidget(mNameEdit,1,1);
00113 
00114   mEmailEdit = new QLineEdit(topFrame);
00115   mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
00116   topLayout->addWidget(mEmailLabel,2,0);
00117   topLayout->addWidget(mEmailEdit,2,1);
00118 
00119   KPrefsWidBool *bcc =
00120       addWidBool(i18n("Send copy to owner when mailing events"),
00121                  &(KOPrefs::instance()->mBcc),topFrame);
00122   topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1);
00123 
00124 
00125   QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"),
00126                                            topFrame);
00127   topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1);
00128 
00129   addWidBool(i18n("Enable automatic saving of calendar"),
00130              &(KOPrefs::instance()->mAutoSave),autoSaveGroup);
00131 
00132   QHBox *intervalBox = new QHBox(autoSaveGroup);
00133   intervalBox->setSpacing(spacingHint());
00134 
00135   QLabel *autoSaveIntervalLabel = new QLabel(i18n("Save &interval in minutes:"),intervalBox);
00136   mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox);
00137   autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin);
00138 
00139   KPrefsWidBool *confirmCheck =
00140       addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm),
00141                  topFrame);
00142   topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1);
00143 
00144 
00145   mEnableGroupScheduling =
00146       addWidBool(i18n("Enable group scheduling"),
00147                  &(KOPrefs::instance()->mEnableGroupScheduling),topFrame);
00148   topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0);
00149   connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()),
00150           SLOT(warningGroupScheduling()));
00151 
00152   mEnableProjectView =
00153       addWidBool(i18n("Enable project view"),
00154                  &(KOPrefs::instance()->mEnableProjectView),topFrame);
00155   topLayout->addWidget(mEnableProjectView->checkBox(),9,0);
00156   connect(mEnableProjectView->checkBox(),SIGNAL(clicked()),
00157           SLOT(warningProjectView()));
00158 
00159   // Can't be disabled anymore
00160   mEnableGroupScheduling->checkBox()->hide();
00161 
00162   // Disable setting, because this feature now becomes stable
00163   mEnableProjectView->checkBox()->hide();
00164 
00165   KPrefsWidRadios *defaultFormatGroup =
00166       addWidRadios(i18n("Default Calendar Format"),
00167                    &(KOPrefs::instance()->mDefaultFormat),topFrame);
00168   defaultFormatGroup->addRadio(i18n("vCalendar"));
00169   defaultFormatGroup->addRadio(i18n("iCalendar"));
00170 
00171   topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1);
00172 
00173   // Default format unconditionally is iCalendar
00174   defaultFormatGroup->groupBox()->hide();
00175 
00176   KPrefsWidRadios *mailClientGroup =
00177       addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient),
00178                    topFrame);
00179   mailClientGroup->addRadio(i18n("KMail"));
00180   mailClientGroup->addRadio(i18n("Sendmail"));
00181 
00182   topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1);
00183 
00184   KPrefsWidBool *htmlsave =
00185       addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave),
00186                  topFrame);
00187   topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1);
00188 
00189   topLayout->setRowStretch(13,1);
00190 }
00191 
00192 
00193 void KOPrefsDialog::setupTimeTab()
00194 {
00195   QFrame *topFrame = addPage(i18n("Time & Date"),0,
00196                              DesktopIcon("clock",KIcon::SizeMedium));
00197 
00198   QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
00199   topLayout->setSpacing(spacingHint());
00200   topLayout->setMargin(marginHint());
00201 
00202   QHBox *timeZoneBox = new QHBox( topFrame );
00203   topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
00204 
00205   new QLabel( i18n("Timezone:"), timeZoneBox );
00206   mTimeZoneCombo = new QComboBox( timeZoneBox );
00207 
00208   FILE *f;
00209   char tempstring[101] = "Unknown";
00210   QString sCurrentlySet(i18n("Unknown"));
00211   int nCurrentlySet = 0;
00212   QStringList list;
00213 
00214   // read the currently set time zone
00215 #if defined(USE_SOLARIS)       // MARCO
00216     char buf[MAXPATHLEN];
00217 
00218     snprintf(buf, MAXPATHLEN,
00219             "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-",
00220             INITFILE);
00221     
00222     if (f = popen(buf, "r"))
00223       {
00224        if (fgets(buf, MAXPATHLEN - 1, f) != NULL)
00225          {
00226            buf[strlen(buf) - 1] = '\0';
00227            sCurrentlySet = QString(buf);
00228          }
00229        pclose(f);
00230       }
00231 #else
00232   if((f = fopen("/etc/timezone", "r")) != NULL) {
00233     // get the currently set timezone
00234     fgets(tempstring, 100, f);
00235     tempstring[strlen(tempstring) - 1] = '\0';
00236     sCurrentlySet = QString(tempstring);
00237     fclose(f);
00238   }
00239 #endif // !USE_SOLARIS
00240 
00241   mTimeZoneCombo->insertItem(i18n("[No selection]"));
00242 
00243   // Read all system time zones
00244 #if defined(USE_SOLARIS)       // MARCO
00245     snprintf(buf, MAXPATHLEN,
00246            "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-",
00247            ZONEINFODIR, strlen(ZONEINFODIR) + 2);
00248     
00249     if (f = popen(buf, "r"))
00250       {
00251        while(fgets(buf, MAXPATHLEN - 1, f) != NULL)
00252          {
00253            buf[strlen(buf) - 1] = '\0';
00254            list.append(buf);
00255          }
00256        pclose(f);
00257       }
00258     
00259 #else
00260   f = popen("grep -e  ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r");
00261   if (!f) return;
00262   while(fgets(tempstring, 100, f) != NULL) {
00263     tempstring[strlen(tempstring)-1] = '\0';
00264     list.append(i18n(tempstring));
00265     tzonenames << tempstring;
00266   }
00267   pclose(f);
00268 #endif // !USE_SOLARIS
00269   list.sort();
00270 
00271   mTimeZoneCombo->insertStringList(list);
00272 
00273     // find the currently set time zone and select it
00274   for (int i = 0; i < mTimeZoneCombo->count(); i++)
00275     {
00276       if (mTimeZoneCombo->text(i) == sCurrentlySet)
00277         {
00278          nCurrentlySet = i;
00279          break;
00280         }
00281     }
00282 
00283   mTimeZoneCombo->setCurrentItem(nCurrentlySet);
00284   
00285   topLayout->addWidget(new QLabel(i18n("Default appointment time:"),
00286                        topFrame),1,0);
00287   mStartTimeSpin = new QSpinBox(0,23,1,topFrame);
00288   mStartTimeSpin->setSuffix(":00");
00289   topLayout->addWidget(mStartTimeSpin,1,1);
00290 
00291   topLayout->addWidget(new QLabel(i18n("Default duration of new appointment:"),
00292                        topFrame),2,0);
00293   mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame);
00294   mDefaultDurationSpin->setSuffix(":00");
00295   topLayout->addWidget(mDefaultDurationSpin,2,1);
00296 
00297   QStringList alarmList;
00298   alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes")
00299             << i18n("15 minutes") << i18n("30 minutes");
00300   topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame),
00301                        3,0);
00302   mAlarmTimeCombo = new QComboBox(topFrame);
00303   mAlarmTimeCombo->insertStringList(alarmList);
00304   topLayout->addWidget(mAlarmTimeCombo,3,1);
00305 
00306 
00307   QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
00308                                                i18n("Working Hours"),
00309                                                topFrame);
00310   topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1);
00311 
00312   QHBox *workStartBox = new QHBox(workingHoursGroup);
00313 
00314   addWidTime(i18n("Daily starting hour:"),
00315              &(KOPrefs::instance()->mWorkingHoursStart),workStartBox);
00316 
00317   QHBox *workEndBox = new QHBox(workingHoursGroup);
00318 
00319   addWidTime(i18n("Daily ending hour:"),
00320              &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox);
00321 
00322   addWidBool(i18n("Exclude holidays"),
00323              &(KOPrefs::instance()->mExcludeHolidays),workingHoursGroup);
00324 
00325   addWidBool(i18n("Exclude Saturdays"),
00326              &(KOPrefs::instance()->mExcludeSaturdays),workingHoursGroup);
00327 
00328   KPrefsWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"),
00329              &(KOPrefs::instance()->mMarcusBainsShowSeconds),
00330              topFrame);
00331   topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0);
00332 
00333   topLayout->setRowStretch(6,1);
00334 }
00335 
00336 
00337 void KOPrefsDialog::setupViewsTab()
00338 {
00339   QFrame *topFrame = addPage(i18n("Views"),0,
00340                              DesktopIcon("viewmag",KIcon::SizeMedium));
00341 
00342   QGridLayout *topLayout = new QGridLayout(topFrame,13,2);
00343   topLayout->setSpacing(spacingHint());
00344   topLayout->setMargin(marginHint());
00345 
00346   QBoxLayout *dayBeginsLayout = new QHBoxLayout;
00347   topLayout->addLayout(dayBeginsLayout,0,0);
00348 
00349   KPrefsWidTime *dayBegins =
00350     addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
00351                topFrame);
00352   dayBeginsLayout->addWidget(dayBegins->label());
00353   dayBeginsLayout->addStretch(1);
00354   dayBeginsLayout->addWidget(dayBegins->spinBox());
00355   
00356   QBoxLayout *nextDaysLayout = new QHBoxLayout;
00357   topLayout->addLayout(nextDaysLayout,1,0);
00358   nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame));  
00359   mNextXDaysSpin = new QSpinBox(2,14,1,topFrame);
00360   nextDaysLayout->addStretch(1);
00361   nextDaysLayout->addWidget(mNextXDaysSpin);
00362 
00363   QGroupBox *hourSizeGroup = new QGroupBox(1,Horizontal,
00364                                            i18n("Hour Size in Schedule View"),
00365                                            topFrame);
00366   mHourSizeSlider = new QSlider(4,30,1,10,Horizontal,hourSizeGroup);
00367   topLayout->addMultiCellWidget(hourSizeGroup,2,2,0,1);
00368 
00369   KPrefsWidBool *dailyRecur =
00370     addWidBool(i18n("Show events that recur daily in date navigator"),
00371                &(KOPrefs::instance()->mDailyRecur),topFrame);
00372   topLayout->addWidget(dailyRecur->checkBox(),3,0);
00373 
00374   KPrefsWidBool *weeklyRecur =
00375     addWidBool(i18n("Show events that recur weekly in date navigator"),
00376                &(KOPrefs::instance()->mWeeklyRecur),topFrame);
00377   topLayout->addWidget(weeklyRecur->checkBox(),4,0);
00378 
00379   KPrefsWidBool *enableToolTips =
00380       addWidBool(i18n("Enable tooltips displaying summary of events"),
00381                  &(KOPrefs::instance()->mEnableToolTips),topFrame);
00382   topLayout->addWidget(enableToolTips->checkBox(),5,0);
00383 
00384   KPrefsWidBool *enableMonthScroll =
00385       addWidBool(i18n("Enable scrollbars in month view cells"),
00386                  &(KOPrefs::instance()->mEnableMonthScroll),topFrame);
00387   topLayout->addWidget(enableMonthScroll->checkBox(),6,0);
00388 
00389   KPrefsWidBool *fullViewMonth =
00390       addWidBool(i18n("Month view uses full window"),
00391                  &(KOPrefs::instance()->mFullViewMonth),topFrame);
00392   topLayout->addWidget(fullViewMonth->checkBox(),7,0);
00393   
00394   KPrefsWidBool *coloredCategoriesInMonthView =
00395       addWidBool(i18n("Month view uses category colors"),
00396                  &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame);
00397   topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),8,0);
00398 
00399   KPrefsWidBool *fullViewTodo =
00400       addWidBool(i18n("To-do view uses full window"),
00401                  &(KOPrefs::instance()->mFullViewTodo),topFrame);
00402   topLayout->addWidget(fullViewTodo->checkBox(),9,0);
00403 
00404   KPrefsWidBool *marcusBainsEnabled =
00405       addWidBool(i18n("Show Marcus Bains line"),
00406                  &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame);
00407   topLayout->addWidget(marcusBainsEnabled->checkBox(),10,0);
00408   
00409   topLayout->setRowStretch(11,1);
00410 }
00411 
00412 
00413 void KOPrefsDialog::setupFontsTab()
00414 {
00415   QFrame *topFrame = addPage(i18n("Fonts"),0,
00416                              DesktopIcon("fonts",KIcon::SizeMedium));
00417 
00418   QGridLayout *topLayout = new QGridLayout(topFrame,5,3);
00419   topLayout->setSpacing(spacingHint());
00420   topLayout->setMargin(marginHint());
00421 
00422   KPrefsWidFont *timeBarFont =
00423       addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"),
00424                  &(KOPrefs::instance()->mTimeBarFont),topFrame);
00425   topLayout->addWidget(timeBarFont->label(),0,0);
00426   topLayout->addWidget(timeBarFont->preview(),0,1);
00427   topLayout->addWidget(timeBarFont->button(),0,2);
00428 
00429   KPrefsWidFont *monthViewFont =
00430       addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event text"),
00431                  i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame);
00432   topLayout->addWidget(monthViewFont->label(),1,0);
00433   topLayout->addWidget(monthViewFont->preview(),1,1);
00434   topLayout->addWidget(monthViewFont->button(),1,2);
00435 
00436   KPrefsWidFont *agendaViewFont =
00437       addWidFont(i18n("Event text"),i18n("Agenda view:"),
00438                  &(KOPrefs::instance()->mAgendaViewFont),topFrame);
00439   topLayout->addWidget(agendaViewFont->label(),2,0);
00440   topLayout->addWidget(agendaViewFont->preview(),2,1);
00441   topLayout->addWidget(agendaViewFont->button(),2,2);
00442 
00443   KPrefsWidFont *marcusBainsFont =
00444       addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("Marcus Bains line:"),
00445                  &(KOPrefs::instance()->mMarcusBainsFont),topFrame);
00446   topLayout->addWidget(marcusBainsFont->label(),3,0);
00447   topLayout->addWidget(marcusBainsFont->preview(),3,1);
00448   topLayout->addWidget(marcusBainsFont->button(),3,2);
00449 
00450   topLayout->setColStretch(1,1);
00451   topLayout->setRowStretch(4,1);
00452 }
00453 
00454 void KOPrefsDialog::setupColorsTab()
00455 {
00456   QFrame *topFrame = addPage(i18n("Colors"),0,
00457                              DesktopIcon("colorize",KIcon::SizeMedium));
00458 
00459   QGridLayout *topLayout = new QGridLayout(topFrame,7,2);
00460   topLayout->setSpacing(spacingHint());
00461   topLayout->setMargin(marginHint());
00462 
00463   // Holiday Color
00464   KPrefsWidColor *holidayColor =
00465       addWidColor(i18n("Holiday color:"),
00466                   &(KOPrefs::instance()->mHolidayColor),topFrame);
00467   topLayout->addWidget(holidayColor->label(),0,0);
00468   topLayout->addWidget(holidayColor->button(),0,1);
00469 
00470   // Highlight Color
00471   KPrefsWidColor *highlightColor =
00472       addWidColor(i18n("Highlight color:"),
00473                   &(KOPrefs::instance()->mHighlightColor),topFrame);
00474   topLayout->addWidget(highlightColor->label(),1,0);
00475   topLayout->addWidget(highlightColor->button(),1,1);
00476 
00477   // Event color
00478   KPrefsWidColor *eventColor =
00479       addWidColor(i18n("Default event color:"),
00480                   &(KOPrefs::instance()->mEventColor),topFrame);
00481   topLayout->addWidget(eventColor->label(),2,0);
00482   topLayout->addWidget(eventColor->button(),2,1);
00483 
00484   // agenda view background color
00485   KPrefsWidColor *agendaBgColor =
00486       addWidColor(i18n("Agenda view background color:"),
00487                   &(KOPrefs::instance()->mAgendaBgColor),topFrame);
00488   topLayout->addWidget(agendaBgColor->label(),3,0);
00489   topLayout->addWidget(agendaBgColor->button(),3,1);
00490 
00491   // working hours color
00492   KPrefsWidColor *workingHoursColor =
00493       addWidColor(i18n("Working hours color:"),
00494                   &(KOPrefs::instance()->mWorkingHoursColor),topFrame);
00495   topLayout->addWidget(workingHoursColor->label(),4,0);
00496   topLayout->addWidget(workingHoursColor->button(),4,1);
00497 
00498   // Todo due today color
00499   KPrefsWidColor *todoDueTodayColor =
00500       addWidColor(i18n("Todo due today color:"),
00501                   &(KOPrefs::instance()->mTodoDueTodayColor),topFrame);
00502   topLayout->addWidget(todoDueTodayColor->label(),5,0);
00503   topLayout->addWidget(todoDueTodayColor->button(),5,1);
00504   
00505   // Todo overdue color
00506   KPrefsWidColor *todoOverdueColor =
00507       addWidColor(i18n("Todo overdue color:"),
00508                   &(KOPrefs::instance()->mTodoOverdueColor),topFrame);
00509   topLayout->addWidget(todoOverdueColor->label(),6,0);
00510   topLayout->addWidget(todoOverdueColor->button(),6,1);
00511   
00512   // categories colors
00513   QGroupBox *categoryGroup = new QGroupBox(1,Horizontal,i18n("Categories"),
00514                                            topFrame);
00515   topLayout->addMultiCellWidget(categoryGroup,7,7,0,1);
00516 
00517   mCategoryCombo = new QComboBox(categoryGroup);
00518   mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
00519   connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
00520 
00521   mCategoryButton = new KColorButton(categoryGroup);
00522   connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
00523   updateCategoryColor();
00524 
00525   topLayout->setRowStretch(8,1);
00526 }
00527 
00528 void KOPrefsDialog::setCategoryColor()
00529 {
00530   mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
00531 }
00532 
00533 void KOPrefsDialog::updateCategoryColor()
00534 {
00535   QString cat = mCategoryCombo->currentText();
00536   QColor *color = mCategoryDict.find(cat);
00537   if (!color) {
00538     color = KOPrefs::instance()->categoryColor(cat);
00539   }
00540   if (color) {
00541     mCategoryButton->setColor(*color);
00542   }
00543 }
00544 
00545 void KOPrefsDialog::setupPrinterTab()
00546 {
00547   mPrinterTab = addPage(i18n("Printing"),0,
00548                         DesktopIcon("fileprint",KIcon::SizeMedium));
00549 
00550   QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2);
00551   topLayout->setSpacing(spacingHint());
00552   topLayout->setMargin(marginHint());
00553 
00554   topLayout->setRowStretch(4,1);
00555 }
00556 
00557 void KOPrefsDialog::setupGroupSchedulingTab()
00558 {
00559   QFrame *topFrame  = addPage(i18n("Group Scheduling"),0,
00560                               DesktopIcon("personal",KIcon::SizeMedium));
00561 
00562   QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
00563   topLayout->setSpacing(spacingHint());
00564   topLayout->setMargin(marginHint());
00565 
00566 #if 0
00567   KPrefsWidRadios *schedulerGroup =
00568       addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler),
00569                    topFrame);
00570   schedulerGroup->addRadio("Dummy"); // Only for debugging
00571   schedulerGroup->addRadio(i18n("Mail client"));
00572 
00573   topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
00574 #endif
00575 
00576   KPrefsWidRadios *sendGroup =
00577       addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend),
00578                    topFrame);
00579   sendGroup->addRadio(i18n("Send to outbox"));
00580   sendGroup->addRadio(i18n("Send directly"));
00581 
00582   topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1);
00583 
00584   topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1);
00585   mAMails = new QListView(topFrame);
00586   mAMails->addColumn(i18n("Email"),300);
00587   topLayout->addMultiCellWidget(mAMails,3,3,0,1);
00588 
00589   topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0);
00590   aEmailsEdit = new QLineEdit(topFrame);
00591   aEmailsEdit->setEnabled(false);
00592   topLayout->addWidget(aEmailsEdit,4,1);
00593 
00594   QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
00595   topLayout->addWidget(add,5,0);
00596   QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
00597   topLayout->addWidget(del,5,1);
00598 
00599   //topLayout->setRowStretch(2,1);
00600   connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
00601   connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
00602   connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
00603   connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
00604 }
00605 
00606 void KOPrefsDialog::setupGroupAutomationTab()
00607 {
00608   QFrame *topFrame  = addPage(i18n("Group Automation"),0,
00609                               DesktopIcon("personal",KIcon::SizeMedium));
00610 
00611   QGridLayout *topLayout = new QGridLayout(topFrame,5,1);
00612   topLayout->setSpacing(spacingHint());
00613   topLayout->setMargin(marginHint());
00614 
00615   KPrefsWidRadios *autoRefreshGroup =
00616       addWidRadios(i18n("Auto Send Refresh"),
00617                    &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame);
00618   autoRefreshGroup->addRadio(i18n("Never"));
00619   autoRefreshGroup->addRadio(i18n("If attendee is in addressbook"));
00620   //autoRefreshGroup->addRadio(i18n("selected emails"));
00621   topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0);
00622 
00623   KPrefsWidRadios *autoInsertGroup =
00624       addWidRadios(i18n("Auto Insert IMIP Replies"),
00625                    &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame);
00626   autoInsertGroup->addRadio(i18n("Never"));
00627   autoInsertGroup->addRadio(i18n("If attendee is in addressbook"));
00628   //autoInsertGroup->addRadio(i18n("selected emails"));
00629   topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0);
00630 
00631   KPrefsWidRadios *autoRequestGroup =
00632       addWidRadios(i18n("Auto Insert IMIP Requests"),
00633                    &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame);
00634   autoRequestGroup->addRadio(i18n("Never"));
00635   autoRequestGroup->addRadio(i18n("If organizer is in addressbook"));
00636   //autoInsertGroup->addRadio(i18n("selected emails"));
00637   topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0);
00638 
00639   KPrefsWidRadios *autoFreeBusyGroup =
00640       addWidRadios(i18n("Auto Send FreeBusy Information"),
00641                    &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame);
00642   autoFreeBusyGroup->addRadio(i18n("Never"));
00643   autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook"));
00644   //autoFreeBusyGroup->addRadio(i18n("selected emails"));
00645   topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0);
00646 
00647   KPrefsWidRadios *autoFreeBusyReplyGroup =
00648       addWidRadios(i18n("Auto Save FreeBusy Replies"),
00649                    &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame);
00650   autoFreeBusyReplyGroup->addRadio(i18n("Never"));
00651   autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook"));
00652   //autoFreeBusyGroup->addRadio(i18n("selected emails"));
00653   topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0);
00654 }
00655 
00656 void KOPrefsDialog::showPrinterTab()
00657 {
00658   showPage(pageIndex(mPrinterTab));
00659 }
00660 
00661 
00662 void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text,
00663                                const QStringList *tags)
00664 {
00665   if (tags) {
00666     int i = tags->findIndex(text);
00667     if (i > 0) combo->setCurrentItem(i);
00668   } else {
00669     for(int i=0;i<combo->count();++i) {
00670       if (combo->text(i) == text) {
00671         combo->setCurrentItem(i);
00672         break;
00673       }
00674     }
00675   }
00676 }
00677 
00678 void KOPrefsDialog::usrReadConfig()
00679 {
00680   mNameEdit->setText(KOPrefs::instance()->fullName());
00681   mEmailEdit->setText(KOPrefs::instance()->email());
00682 
00683   mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval);
00684 
00685   setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId.utf8()));
00686 
00687   mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime);
00688   mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration);
00689   mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime);
00690 
00691   mHourSizeSlider->setValue(KOPrefs::instance()->mHourSize);
00692 
00693   mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays);
00694   mAMails->clear();
00695   for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
00696             it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
00697     QListViewItem *item = new QListViewItem(mAMails);
00698     item->setText(0,*it);
00699     mAMails->insertItem(item);
00700   }
00701 }
00702 
00703 
00704 void KOPrefsDialog::usrWriteConfig()
00705 {
00706   KOPrefs::instance()->setFullName(mNameEdit->text());
00707   KOPrefs::instance()->setEmail(mEmailEdit->text());
00708 
00709   KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value();
00710 
00711   // Find untranslated selected zone
00712   QStringList::Iterator tz;
00713   for (tz = tzonenames.begin(); tz != tzonenames.end(); tz++)
00714     if (mTimeZoneCombo->currentText() == i18n((*tz).utf8()))
00715       break;
00716   if (tz != tzonenames.end())
00717     KOPrefs::instance()->mTimeZoneId = (*tz);
00718   else
00719     KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
00720 
00721   KOPrefs::instance()->mStartTime = mStartTimeSpin->value();
00722   KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value();
00723   KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem();
00724 
00725   KOPrefs::instance()->mHourSize = mHourSizeSlider->value();
00726 
00727   QDictIterator<QColor> it(mCategoryDict);
00728   while (it.current()) {
00729     KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current());
00730     ++it;
00731   }
00732 
00733   KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value();
00734   
00735   KOPrefs::instance()->mAdditionalMails.clear();
00736   QListViewItem *item;
00737   item = mAMails->firstChild();
00738   while (item)
00739   {
00740     KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
00741     item = item->nextSibling();
00742   }
00743 
00744 }
00745 
00746 void KOPrefsDialog::updateCategories()
00747 {
00748   mCategoryCombo->clear();
00749   mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
00750   updateCategoryColor();
00751 }
00752 
00753 void KOPrefsDialog::warningGroupScheduling()
00754 {
00755   warningExperimental(mEnableGroupScheduling->checkBox()->isChecked());
00756 }
00757 
00758 void KOPrefsDialog::warningProjectView()
00759 {
00760   warningExperimental(mEnableProjectView->checkBox()->isChecked());
00761 }
00762 
00763 void KOPrefsDialog::warningExperimental(bool on)
00764 {
00765   if (on) {
00766     KMessageBox::information(this,i18n("This is an experimental feature. "
00767         "It may not work, it may do nothing useful and it may cause data loss. "
00768         "Use with care.\n"
00769         "You have to restart KOrganizer for this setting to take effect."));
00770   } else {
00771     KMessageBox::information(this,
00772         i18n("You have to restart KOrganizer for this setting to take effect."));
00773   }
00774 }
00775 
00776 void KOPrefsDialog::toggleEmailSettings(bool on)
00777 {
00778   if (on) {
00779     mEmailEdit->setEnabled(false);
00780     mNameEdit->setEnabled(false);
00781     mEmailLabel->setEnabled(false);
00782     mNameLabel->setEnabled(false);
00783 
00784     KEMailSettings settings;
00785     mNameEdit->setText(settings.getSetting(KEMailSettings::RealName));
00786     mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress));
00787   } else {
00788     mEmailEdit->setEnabled(true);
00789     mNameEdit->setEnabled(true);
00790     mEmailLabel->setEnabled(true);
00791     mNameLabel->setEnabled(true);
00792   }
00793 }
00794 
00795 void KOPrefsDialog::addItem()
00796 {
00797   aEmailsEdit->setEnabled(true);
00798   QListViewItem *item = new QListViewItem(mAMails);
00799   mAMails->insertItem(item);
00800   mAMails->setSelected(item,true);
00801   aEmailsEdit->setText(i18n("(EmptyEmail)"));
00802 }
00803 
00804 void KOPrefsDialog::removeItem()
00805 {
00806   QListViewItem *item;
00807   item = mAMails->selectedItem();
00808   if (!item) return;
00809   mAMails->takeItem(item);
00810   item = mAMails->selectedItem();
00811   if (!item) {
00812     aEmailsEdit->setText("");
00813     aEmailsEdit->setEnabled(false);
00814   }
00815   if (mAMails->childCount() == 0) {
00816     aEmailsEdit->setEnabled(false);
00817   }
00818 }
00819 
00820 void KOPrefsDialog::updateItem()
00821 {
00822   QListViewItem *item;
00823   item = mAMails->selectedItem();
00824   if (!item) return;
00825   item->setText(0,aEmailsEdit->text());
00826 }
00827 
00828 void KOPrefsDialog::updateInput()
00829 {
00830   QListViewItem *item;
00831   item = mAMails->selectedItem();
00832   if (!item) return;
00833   aEmailsEdit->setEnabled(true);
00834   aEmailsEdit->setText(item->text(0));
00835 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:31 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001