00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kalarm.h"
00022
00023 #include <qobjectlist.h>
00024 #include <qlayout.h>
00025 #include <qbuttongroup.h>
00026 #include <qvbox.h>
00027 #include <qlineedit.h>
00028 #include <qcheckbox.h>
00029 #include <qradiobutton.h>
00030 #include <qpushbutton.h>
00031 #include <qcombobox.h>
00032 #include <qwhatsthis.h>
00033 #include <qtooltip.h>
00034 #include <qstyle.h>
00035
00036 #include <kglobal.h>
00037 #include <klocale.h>
00038 #include <kstandarddirs.h>
00039 #include <kshell.h>
00040 #include <kmessagebox.h>
00041 #include <kaboutdata.h>
00042 #include <kapplication.h>
00043 #include <kiconloader.h>
00044 #include <kcolorcombo.h>
00045 #include <kstdguiitem.h>
00046 #include <kdebug.h>
00047
00048 #include <kalarmd/kalarmd.h>
00049
00050 #include "alarmcalendar.h"
00051 #include "alarmtimewidget.h"
00052 #include "daemon.h"
00053 #include "editdlg.h"
00054 #include "fontcolour.h"
00055 #include "functions.h"
00056 #include "kalarmapp.h"
00057 #include "kamail.h"
00058 #include "label.h"
00059 #include "latecancel.h"
00060 #include "mainwindow.h"
00061 #include "preferences.h"
00062 #include "radiobutton.h"
00063 #include "recurrenceedit.h"
00064 #ifndef WITHOUT_ARTS
00065 #include "sounddlg.h"
00066 #endif
00067 #include "soundpicker.h"
00068 #include "specialactions.h"
00069 #include "timeedit.h"
00070 #include "timespinbox.h"
00071 #include "traywindow.h"
00072 #include "prefdlg.moc"
00073
00074
00075
00076
00077
00078
00079
00080 static QString xtermCommands[] = {
00081 QString::fromLatin1("xterm -sb -hold -title %t -e %c"),
00082 QString::fromLatin1("konsole --noclose -T %t -e ${SHELL:-sh} -c %c"),
00083 QString::fromLatin1("gnome-terminal -t %t -e %W"),
00084 QString::fromLatin1("eterm --pause -T %t -e %C"),
00085 QString::fromLatin1("Eterm --pause -T %t -e %C"),
00086 QString::fromLatin1("rxvt -title %t -e ${SHELL:-sh} -c %w"),
00087 QString::null
00088 };
00089
00090
00091
00092
00093
00094
00095 KAlarmPrefDlg::KAlarmPrefDlg()
00096 : KDialogBase(IconList, i18n("Preferences"), Help | Default | Ok | Apply | Cancel, Ok, 0, "PrefDlg", true, true)
00097 {
00098 setIconListAllVisible(true);
00099
00100 QVBox* frame = addVBoxPage(i18n("General"), i18n("General"), DesktopIcon("misc"));
00101 mMiscPage = new MiscPrefTab(frame);
00102
00103 frame = addVBoxPage(i18n("Email"), i18n("Email Alarm Settings"), DesktopIcon("mail_generic"));
00104 mEmailPage = new EmailPrefTab(frame);
00105
00106 frame = addVBoxPage(i18n("View"), i18n("View Settings"), DesktopIcon("view_choose"));
00107 mViewPage = new ViewPrefTab(frame);
00108
00109 frame = addVBoxPage(i18n("Font & Color"), i18n("Default Font and Color"), DesktopIcon("colorize"));
00110 mFontColourPage = new FontColourPrefTab(frame);
00111
00112 frame = addVBoxPage(i18n("Edit"), i18n("Default Alarm Edit Settings"), DesktopIcon("edit"));
00113 mEditPage = new EditPrefTab(frame);
00114
00115 restore();
00116 adjustSize();
00117 }
00118
00119 KAlarmPrefDlg::~KAlarmPrefDlg()
00120 {
00121 }
00122
00123
00124 void KAlarmPrefDlg::slotDefault()
00125 {
00126 kdDebug(5950) << "KAlarmPrefDlg::slotDefault()" << endl;
00127 mFontColourPage->setDefaults();
00128 mEmailPage->setDefaults();
00129 mViewPage->setDefaults();
00130 mEditPage->setDefaults();
00131 mMiscPage->setDefaults();
00132 }
00133
00134 void KAlarmPrefDlg::slotHelp()
00135 {
00136 kapp->invokeHelp("preferences");
00137 }
00138
00139
00140 void KAlarmPrefDlg::slotApply()
00141 {
00142 kdDebug(5950) << "KAlarmPrefDlg::slotApply()" << endl;
00143 QString errmsg = mEmailPage->validate();
00144 if (!errmsg.isEmpty())
00145 {
00146 showPage(pageIndex(mEmailPage->parentWidget()));
00147 if (KMessageBox::warningYesNo(this, errmsg) != KMessageBox::Yes)
00148 {
00149 mValid = false;
00150 return;
00151 }
00152 }
00153 errmsg = mEditPage->validate();
00154 if (!errmsg.isEmpty())
00155 {
00156 showPage(pageIndex(mEditPage->parentWidget()));
00157 KMessageBox::sorry(this, errmsg);
00158 mValid = false;
00159 return;
00160 }
00161 mValid = true;
00162 mFontColourPage->apply(false);
00163 mEmailPage->apply(false);
00164 mViewPage->apply(false);
00165 mEditPage->apply(false);
00166 mMiscPage->apply(false);
00167 Preferences::syncToDisc();
00168 }
00169
00170
00171 void KAlarmPrefDlg::slotOk()
00172 {
00173 kdDebug(5950) << "KAlarmPrefDlg::slotOk()" << endl;
00174 mValid = true;
00175 slotApply();
00176 if (mValid)
00177 KDialogBase::slotOk();
00178 }
00179
00180
00181 void KAlarmPrefDlg::slotCancel()
00182 {
00183 kdDebug(5950) << "KAlarmPrefDlg::slotCancel()" << endl;
00184 restore();
00185 KDialogBase::slotCancel();
00186 }
00187
00188
00189 void KAlarmPrefDlg::restore()
00190 {
00191 kdDebug(5950) << "KAlarmPrefDlg::restore()" << endl;
00192 mFontColourPage->restore();
00193 mEmailPage->restore();
00194 mViewPage->restore();
00195 mEditPage->restore();
00196 mMiscPage->restore();
00197 }
00198
00199
00200
00201
00202
00203 int PrefsTabBase::mIndentWidth = 0;
00204
00205 PrefsTabBase::PrefsTabBase(QVBox* frame)
00206 : QWidget(frame),
00207 mPage(frame)
00208 {
00209 if (!mIndentWidth)
00210 mIndentWidth = 3 * KDialog::spacingHint();
00211 }
00212
00213 void PrefsTabBase::apply(bool syncToDisc)
00214 {
00215 Preferences::save(syncToDisc);
00216 }
00217
00218
00219
00220
00221
00222
00223
00224 MiscPrefTab::MiscPrefTab(QVBox* frame)
00225 : PrefsTabBase(frame)
00226 {
00227
00228 int alignment = QApplication::reverseLayout() ? Qt::AlignRight : Qt::AlignLeft;
00229
00230 QGroupBox* group = new QButtonGroup(i18n("Run Mode"), mPage, "modeGroup");
00231 QGridLayout* grid = new QGridLayout(group, 6, 2, KDialog::marginHint(), KDialog::spacingHint());
00232 grid->setColStretch(2, 1);
00233 grid->addColSpacing(0, indentWidth());
00234 grid->addColSpacing(1, indentWidth());
00235 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
00236
00237
00238 mRunOnDemand = new QRadioButton(i18n("&Run only on demand"), group, "runDemand");
00239 mRunOnDemand->setFixedSize(mRunOnDemand->sizeHint());
00240 connect(mRunOnDemand, SIGNAL(toggled(bool)), SLOT(slotRunModeToggled(bool)));
00241 QWhatsThis::add(mRunOnDemand,
00242 i18n("Check to run KAlarm only when required.\n\n"
00243 "Notes:\n"
00244 "1. Alarms are displayed even when KAlarm is not running, since alarm monitoring is done by the alarm daemon.\n"
00245 "2. With this option selected, the system tray icon can be displayed or hidden independently of KAlarm."));
00246 grid->addMultiCellWidget(mRunOnDemand, 1, 1, 0, 2, alignment);
00247
00248
00249 mRunInSystemTray = new QRadioButton(i18n("Run continuously in system &tray"), group, "runTray");
00250 mRunInSystemTray->setFixedSize(mRunInSystemTray->sizeHint());
00251 connect(mRunInSystemTray, SIGNAL(toggled(bool)), SLOT(slotRunModeToggled(bool)));
00252 QWhatsThis::add(mRunInSystemTray,
00253 i18n("Check to run KAlarm continuously in the KDE system tray.\n\n"
00254 "Notes:\n"
00255 "1. With this option selected, closing the system tray icon will quit KAlarm.\n"
00256 "2. You do not need to select this option in order for alarms to be displayed, since alarm monitoring is done by the alarm daemon."
00257 " Running in the system tray simply provides easy access and a status indication."));
00258 grid->addMultiCellWidget(mRunInSystemTray, 2, 2, 0, 2, alignment);
00259
00260
00261 mDisableAlarmsIfStopped = new QCheckBox(i18n("Disa&ble alarms while not running"), group, "disableAl");
00262 mDisableAlarmsIfStopped->setFixedSize(mDisableAlarmsIfStopped->sizeHint());
00263 connect(mDisableAlarmsIfStopped, SIGNAL(toggled(bool)), SLOT(slotDisableIfStoppedToggled(bool)));
00264 QWhatsThis::add(mDisableAlarmsIfStopped,
00265 i18n("Check to disable alarms whenever KAlarm is not running. Alarms will only appear while the system tray icon is visible."));
00266 grid->addMultiCellWidget(mDisableAlarmsIfStopped, 3, 3, 1, 2, alignment);
00267
00268 mQuitWarn = new QCheckBox(i18n("Warn before &quitting"), group, "disableAl");
00269 mQuitWarn->setFixedSize(mQuitWarn->sizeHint());
00270 QWhatsThis::add(mQuitWarn,
00271 i18n("Check to display a warning prompt before quitting KAlarm."));
00272 grid->addWidget(mQuitWarn, 4, 2, alignment);
00273
00274 mAutostartTrayIcon = new QCheckBox(i18n("Autostart at &login"), group, "autoTray");
00275 #ifdef AUTOSTART_BY_KALARMD
00276 connect(mAutostartTrayIcon, SIGNAL(toggled(bool)), SLOT(slotAutostartToggled(bool)));
00277 #endif
00278 grid->addMultiCellWidget(mAutostartTrayIcon, 5, 5, 0, 2, alignment);
00279
00280
00281 mAutostartDaemon = new QCheckBox(i18n("Start alarm monitoring at lo&gin"), group, "startDaemon");
00282 mAutostartDaemon->setFixedSize(mAutostartDaemon->sizeHint());
00283 connect(mAutostartDaemon, SIGNAL(clicked()), SLOT(slotAutostartDaemonClicked()));
00284 QWhatsThis::add(mAutostartDaemon,
00285 i18n("Automatically start alarm monitoring whenever you start KDE, by running the alarm daemon (%1).\n\n"
00286 "This option should always be checked unless you intend to discontinue use of KAlarm.")
00287 .arg(QString::fromLatin1(DAEMON_APP_NAME)));
00288 grid->addMultiCellWidget(mAutostartDaemon, 6, 6, 0, 2, alignment);
00289
00290 group->setFixedHeight(group->sizeHint().height());
00291
00292
00293 QHBox* itemBox = new QHBox(mPage);
00294 QHBox* box = new QHBox(itemBox);
00295 box->setSpacing(KDialog::spacingHint());
00296 QLabel* label = new QLabel(i18n("&Start of day for date-only alarms:"), box);
00297 mStartOfDay = new TimeEdit(box);
00298 mStartOfDay->setFixedSize(mStartOfDay->sizeHint());
00299 label->setBuddy(mStartOfDay);
00300 static const QString startOfDayText = i18n("The earliest time of day at which a date-only alarm (i.e. "
00301 "an alarm with \"any time\" specified) will be triggered.");
00302 QWhatsThis::add(box, QString("%1\n\n%2").arg(startOfDayText).arg(TimeSpinBox::shiftWhatsThis()));
00303 itemBox->setStretchFactor(new QWidget(itemBox), 1);
00304 itemBox->setFixedHeight(box->sizeHint().height());
00305
00306
00307 itemBox = new QHBox(mPage);
00308 mConfirmAlarmDeletion = new QCheckBox(i18n("Con&firm alarm deletions"), itemBox, "confirmDeletion");
00309 mConfirmAlarmDeletion->setMinimumSize(mConfirmAlarmDeletion->sizeHint());
00310 QWhatsThis::add(mConfirmAlarmDeletion,
00311 i18n("Check to be prompted for confirmation each time you delete an alarm."));
00312 itemBox->setStretchFactor(new QWidget(itemBox), 1);
00313 itemBox->setFixedHeight(box->sizeHint().height());
00314
00315
00316 group = new QGroupBox(i18n("Expired Alarms"), mPage);
00317 grid = new QGridLayout(group, 2, 2, KDialog::marginHint(), KDialog::spacingHint());
00318 grid->setColStretch(1, 1);
00319 grid->addColSpacing(0, indentWidth());
00320 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
00321 mKeepExpired = new QCheckBox(i18n("Keep alarms after e&xpiry"), group, "keepExpired");
00322 mKeepExpired->setFixedSize(mKeepExpired->sizeHint());
00323 connect(mKeepExpired, SIGNAL(toggled(bool)), SLOT(slotExpiredToggled(bool)));
00324 QWhatsThis::add(mKeepExpired,
00325 i18n("Check to store alarms after expiry or deletion (except deleted alarms which were never triggered)."));
00326 grid->addMultiCellWidget(mKeepExpired, 1, 1, 0, 1, alignment);
00327
00328 box = new QHBox(group);
00329 box->setSpacing(KDialog::spacingHint());
00330 mPurgeExpired = new QCheckBox(i18n("Discard ex&pired alarms after:"), box, "purgeExpired");
00331 mPurgeExpired->setMinimumSize(mPurgeExpired->sizeHint());
00332 connect(mPurgeExpired, SIGNAL(toggled(bool)), SLOT(slotExpiredToggled(bool)));
00333 mPurgeAfter = new SpinBox(box);
00334 mPurgeAfter->setMinValue(1);
00335 mPurgeAfter->setLineShiftStep(10);
00336 mPurgeAfter->setMinimumSize(mPurgeAfter->sizeHint());
00337 mPurgeAfterLabel = new QLabel(i18n("da&ys"), box);
00338 mPurgeAfterLabel->setMinimumSize(mPurgeAfterLabel->sizeHint());
00339 mPurgeAfterLabel->setBuddy(mPurgeAfter);
00340 QWhatsThis::add(box,
00341 i18n("Uncheck to store expired alarms indefinitely. Check to enter how long expired alarms should be stored."));
00342 grid->addWidget(box, 2, 1, alignment);
00343
00344 mClearExpired = new QPushButton(i18n("Clear Expired Alar&ms"), group);
00345 mClearExpired->setFixedSize(mClearExpired->sizeHint());
00346 connect(mClearExpired, SIGNAL(clicked()), SLOT(slotClearExpired()));
00347 QWhatsThis::add(mClearExpired,
00348 i18n("Delete all existing expired alarms."));
00349 grid->addWidget(mClearExpired, 3, 1, alignment);
00350 group->setFixedHeight(group->sizeHint().height());
00351
00352
00353 group = new QGroupBox(i18n("Terminal for Command Alarms"), mPage);
00354 QWhatsThis::add(group,
00355 i18n("Choose which application to use when a command alarm is executed in a terminal window"));
00356 grid = new QGridLayout(group, 1, 3, KDialog::marginHint(), KDialog::spacingHint());
00357 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
00358 int row = 0;
00359
00360 mXtermType = new QButtonGroup(group);
00361 mXtermType->hide();
00362 QString whatsThis = i18n("The parameter is a command line, e.g. 'xterm -e'", "Check to execute command alarms in a terminal window by '%1'");
00363 int index = 0;
00364 for (mXtermCount = 0; !xtermCommands[mXtermCount].isNull(); ++mXtermCount)
00365 {
00366 QString cmd = xtermCommands[mXtermCount];
00367 QStringList args = KShell::splitArgs(cmd);
00368 if (args.isEmpty() || KStandardDirs::findExe(args[0]).isEmpty())
00369 continue;
00370 QRadioButton* radio = new QRadioButton(args[0], group);
00371 radio->setMinimumSize(radio->sizeHint());
00372 mXtermType->insert(radio, mXtermCount);
00373 cmd.replace("%t", kapp->aboutData()->programName());
00374 cmd.replace("%c", "<command>");
00375 cmd.replace("%w", "<command; sleep>");
00376 cmd.replace("%C", "[command]");
00377 cmd.replace("%W", "[command; sleep]");
00378 QWhatsThis::add(radio, whatsThis.arg(cmd));
00379 grid->addWidget(radio, (row = index/3 + 1), index % 3, Qt::AlignAuto);
00380 ++index;
00381 }
00382
00383 box = new QHBox(group);
00384 grid->addMultiCellWidget(box, row + 1, row + 1, 0, 2, Qt::AlignAuto);
00385 QRadioButton* radio = new QRadioButton(i18n("Other:"), box);
00386 radio->setFixedSize(radio->sizeHint());
00387 connect(radio, SIGNAL(toggled(bool)), SLOT(slotOtherTerminalToggled(bool)));
00388 mXtermType->insert(radio, mXtermCount);
00389 mXtermCommand = new QLineEdit(box);
00390 QWhatsThis::add(box,
00391 i18n("Enter the full command line needed to execute a command in your chosen terminal window. "
00392 "By default the alarm's command string will be appended to what you enter here. "
00393 "See the KAlarm Handbook for details of special codes to tailor the command line."));
00394
00395 mPage->setStretchFactor(new QWidget(mPage), 1);
00396 }
00397
00398 void MiscPrefTab::restore()
00399 {
00400 mAutostartDaemon->setChecked(Daemon::autoStart());
00401 bool systray = Preferences::mRunInSystemTray;
00402 mRunInSystemTray->setChecked(systray);
00403 mRunOnDemand->setChecked(!systray);
00404 mDisableAlarmsIfStopped->setChecked(Preferences::mDisableAlarmsIfStopped);
00405 mQuitWarn->setChecked(Preferences::quitWarn());
00406 mAutostartTrayIcon->setChecked(Preferences::mAutostartTrayIcon);
00407 mConfirmAlarmDeletion->setChecked(Preferences::confirmAlarmDeletion());
00408 mStartOfDay->setValue(Preferences::mStartOfDay);
00409 setExpiredControls(Preferences::mExpiredKeepDays);
00410 QString xtermCmd = Preferences::cmdXTermCommand();
00411 int id = 0;
00412 if (!xtermCmd.isEmpty())
00413 {
00414 for ( ; id < mXtermCount; ++id)
00415 {
00416 if (mXtermType->find(id) && xtermCmd == xtermCommands[id])
00417 break;
00418 }
00419 }
00420 mXtermType->setButton(id);
00421 mXtermCommand->setEnabled(id == mXtermCount);
00422 mXtermCommand->setText(id == mXtermCount ? xtermCmd : "");
00423 slotDisableIfStoppedToggled(true);
00424 }
00425
00426 void MiscPrefTab::apply(bool syncToDisc)
00427 {
00428
00429 int xtermID = mXtermType->selectedId();
00430 if (xtermID >= mXtermCount)
00431 {
00432 QString cmd = mXtermCommand->text();
00433 if (cmd.isEmpty())
00434 xtermID = 0;
00435 else
00436 {
00437 QStringList args = KShell::splitArgs(cmd);
00438 cmd = args.isEmpty() ? QString::null : args[0];
00439 if (KStandardDirs::findExe(cmd).isEmpty())
00440 {
00441 mXtermCommand->setFocus();
00442 if (KMessageBox::warningContinueCancel(this, i18n("Command to invoke terminal window not found:\n%1").arg(cmd))
00443 != KMessageBox::Continue)
00444 return;
00445 }
00446 }
00447 }
00448 bool systray = mRunInSystemTray->isChecked();
00449 Preferences::mRunInSystemTray = systray;
00450 Preferences::mDisableAlarmsIfStopped = mDisableAlarmsIfStopped->isChecked();
00451 if (mQuitWarn->isEnabled())
00452 Preferences::setQuitWarn(mQuitWarn->isChecked());
00453 Preferences::mAutostartTrayIcon = mAutostartTrayIcon->isChecked();
00454 #ifdef AUTOSTART_BY_KALARMD
00455 bool newAutostartDaemon = mAutostartDaemon->isChecked() || Preferences::mAutostartTrayIcon;
00456 #else
00457 bool newAutostartDaemon = mAutostartDaemon->isChecked();
00458 #endif
00459 if (newAutostartDaemon != Daemon::autoStart())
00460 Daemon::enableAutoStart(newAutostartDaemon);
00461 Preferences::setConfirmAlarmDeletion(mConfirmAlarmDeletion->isChecked());
00462 int sod = mStartOfDay->value();
00463 Preferences::mStartOfDay.setHMS(sod/60, sod%60, 0);
00464 Preferences::mExpiredKeepDays = !mKeepExpired->isChecked() ? 0
00465 : mPurgeExpired->isChecked() ? mPurgeAfter->value() : -1;
00466 Preferences::mCmdXTermCommand = (xtermID < mXtermCount) ? xtermCommands[xtermID] : mXtermCommand->text();
00467 PrefsTabBase::apply(syncToDisc);
00468 }
00469
00470 void MiscPrefTab::setDefaults()
00471 {
00472 mAutostartDaemon->setChecked(true);
00473 bool systray = Preferences::default_runInSystemTray;
00474 mRunInSystemTray->setChecked(systray);
00475 mRunOnDemand->setChecked(!systray);
00476 mDisableAlarmsIfStopped->setChecked(Preferences::default_disableAlarmsIfStopped);
00477 mQuitWarn->setChecked(Preferences::default_quitWarn);
00478 mAutostartTrayIcon->setChecked(Preferences::default_autostartTrayIcon);
00479 mConfirmAlarmDeletion->setChecked(Preferences::default_confirmAlarmDeletion);
00480 mStartOfDay->setValue(Preferences::default_startOfDay);
00481 setExpiredControls(Preferences::default_expiredKeepDays);
00482 mXtermType->setButton(0);
00483 mXtermCommand->setEnabled(false);
00484 slotDisableIfStoppedToggled(true);
00485 }
00486
00487 void MiscPrefTab::slotAutostartDaemonClicked()
00488 {
00489 if (!mAutostartDaemon->isChecked()
00490 && KMessageBox::warningYesNo(this,
00491 i18n("You should not uncheck this option unless you intend to discontinue use of KAlarm"),
00492 QString::null, KStdGuiItem::cont(), KStdGuiItem::cancel()
00493 ) != KMessageBox::Yes)
00494 mAutostartDaemon->setChecked(true);
00495 }
00496
00497 void MiscPrefTab::slotRunModeToggled(bool)
00498 {
00499 bool systray = mRunInSystemTray->isOn();
00500 mAutostartTrayIcon->setText(systray ? i18n("Autostart at &login") : i18n("Autostart system tray &icon at login"));
00501 QWhatsThis::add(mAutostartTrayIcon, (systray ? i18n("Check to run KAlarm whenever you start KDE.")
00502 : i18n("Check to display the system tray icon whenever you start KDE.")));
00503 mDisableAlarmsIfStopped->setEnabled(systray);
00504 slotDisableIfStoppedToggled(true);
00505 }
00506
00507
00508
00509
00510
00511 void MiscPrefTab::slotAutostartToggled(bool)
00512 {
00513 #ifdef AUTOSTART_BY_KALARMD
00514 mAutostartDaemon->setEnabled(!mAutostartTrayIcon->isChecked());
00515 #endif
00516 }
00517
00518 void MiscPrefTab::slotDisableIfStoppedToggled(bool)
00519 {
00520 bool enable = mDisableAlarmsIfStopped->isEnabled() && mDisableAlarmsIfStopped->isChecked();
00521 mQuitWarn->setEnabled(enable);
00522 }
00523
00524 void MiscPrefTab::setExpiredControls(int purgeDays)
00525 {
00526 mKeepExpired->setChecked(purgeDays);
00527 mPurgeExpired->setChecked(purgeDays > 0);
00528 mPurgeAfter->setValue(purgeDays > 0 ? purgeDays : 0);
00529 slotExpiredToggled(true);
00530 }
00531
00532 void MiscPrefTab::slotExpiredToggled(bool)
00533 {
00534 bool keep = mKeepExpired->isChecked();
00535 bool after = keep && mPurgeExpired->isChecked();
00536 mPurgeExpired->setEnabled(keep);
00537 mPurgeAfter->setEnabled(after);
00538 mPurgeAfterLabel->setEnabled(keep);
00539 mClearExpired->setEnabled(keep);
00540 }
00541
00542 void MiscPrefTab::slotClearExpired()
00543 {
00544 AlarmCalendar* cal = AlarmCalendar::expiredCalendarOpen();
00545 if (cal)
00546 cal->purgeAll();
00547 }
00548
00549 void MiscPrefTab::slotOtherTerminalToggled(bool on)
00550 {
00551 mXtermCommand->setEnabled(on);
00552 }
00553
00554
00555
00556
00557
00558
00559 EmailPrefTab::EmailPrefTab(QVBox* frame)
00560 : PrefsTabBase(frame),
00561 mAddressChanged(false),
00562 mBccAddressChanged(false)
00563 {
00564 QHBox* box = new QHBox(mPage);
00565 box->setSpacing(2*KDialog::spacingHint());
00566 QLabel* label = new QLabel(i18n("Email client:"), box);
00567 mEmailClient = new ButtonGroup(box);
00568 mEmailClient->hide();
00569 RadioButton* radio = new RadioButton(i18n("&KMail"), box, "kmail");
00570 radio->setMinimumSize(radio->sizeHint());
00571 mEmailClient->insert(radio, Preferences::KMAIL);
00572 radio = new RadioButton(i18n("&Sendmail"), box, "sendmail");
00573 radio->setMinimumSize(radio->sizeHint());
00574 mEmailClient->insert(radio, Preferences::SENDMAIL);
00575 connect(mEmailClient, SIGNAL(buttonSet(int)), SLOT(slotEmailClientChanged(int)));
00576 box->setFixedHeight(box->sizeHint().height());
00577 QWhatsThis::add(box,
00578 i18n("Choose how to send email when an email alarm is triggered.\n"
00579 "KMail: The email is added to KMail's outbox if KMail is running. If not, "
00580 "a KMail composer window is displayed to enable you to send the email.\n"
00581 "Sendmail: The email is sent automatically. This option will only work if "
00582 "your system is configured to use 'sendmail' or a sendmail compatible mail transport agent."));
00583
00584 box = new QHBox(mPage);
00585 mEmailCopyToKMail = new QCheckBox(i18n("Co&py sent emails into KMail's %1 folder").arg(KAMail::i18n_sent_mail()), box);
00586 mEmailCopyToKMail->setFixedSize(mEmailCopyToKMail->sizeHint());
00587 QWhatsThis::add(mEmailCopyToKMail,
00588 i18n("After sending an email, store a copy in KMail's %1 folder").arg(KAMail::i18n_sent_mail()));
00589 box->setStretchFactor(new QWidget(box), 1);
00590 box->setFixedHeight(box->sizeHint().height());
00591
00592
00593 QGroupBox* group = new QGroupBox(i18n("Your Email Address"), mPage);
00594 QGridLayout* grid = new QGridLayout(group, 6, 3, KDialog::marginHint(), KDialog::spacingHint());
00595 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
00596 grid->setColStretch(1, 1);
00597
00598
00599 label = new Label(EditAlarmDlg::i18n_f_EmailFrom(), group);
00600 label->setFixedSize(label->sizeHint());
00601 grid->addWidget(label, 1, 0);
00602 mFromAddressGroup = new ButtonGroup(group);
00603 mFromAddressGroup->hide();
00604 connect(mFromAddressGroup, SIGNAL(buttonSet(int)), SLOT(slotFromAddrChanged(int)));
00605
00606
00607 radio = new RadioButton(group);
00608 mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_ADDR);
00609 radio->setFixedSize(radio->sizeHint());
00610 label->setBuddy(radio);
00611 grid->addWidget(radio, 1, 1);
00612 mEmailAddress = new QLineEdit(group);
00613 connect(mEmailAddress, SIGNAL(textChanged(const QString&)), SLOT(slotAddressChanged()));
00614 QString whatsThis = i18n("Your email address, used to identify you as the sender when sending email alarms.");
00615 QWhatsThis::add(radio, whatsThis);
00616 QWhatsThis::add(mEmailAddress, whatsThis);
00617 radio->setFocusWidget(mEmailAddress);
00618 grid->addWidget(mEmailAddress, 1, 2);
00619
00620
00621 radio = new RadioButton(i18n("&Use address from Control Center"), group);
00622 radio->setFixedSize(radio->sizeHint());
00623 mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_CONTROL_CENTRE);
00624 QWhatsThis::add(radio,
00625 i18n("Check to use the email address set in the KDE Control Center, to identify you as the sender when sending email alarms."));
00626 grid->addMultiCellWidget(radio, 2, 2, 1, 2, Qt::AlignAuto);
00627
00628
00629 radio = new RadioButton(i18n("Use KMail &identities"), group);
00630 radio->setFixedSize(radio->sizeHint());
00631 mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_KMAIL);
00632 QWhatsThis::add(radio,
00633 i18n("Check to use KMail's email identities to identify you as the sender when sending email alarms. "
00634 "For existing email alarms, KMail's default identity will be used. "
00635 "For new email alarms, you will be able to pick which of KMail's identities to use."));
00636 grid->addMultiCellWidget(radio, 3, 3, 1, 2, Qt::AlignAuto);
00637
00638
00639 grid->addRowSpacing(4, KDialog::spacingHint());
00640 label = new Label(i18n("'Bcc' email address", "&Bcc:"), group);
00641 label->setFixedSize(label->sizeHint());
00642 grid->addWidget(label, 5, 0);
00643 mBccAddressGroup = new ButtonGroup(group);
00644 mBccAddressGroup->hide();
00645 connect(mBccAddressGroup, SIGNAL(buttonSet(int)), SLOT(slotBccAddrChanged(int)));
00646
00647
00648 radio = new RadioButton(group);
00649 radio->setFixedSize(radio->sizeHint());
00650 mBccAddressGroup->insert(radio, Preferences::MAIL_FROM_ADDR);
00651 label->setBuddy(radio);
00652 grid->addWidget(radio, 5, 1);
00653 mEmailBccAddress = new QLineEdit(group);
00654 whatsThis = i18n("Your email address, used for blind copying email alarms to yourself. "
00655 "If you want blind copies to be sent to your account on the computer which KAlarm runs on, you can simply enter your user login name.");
00656 QWhatsThis::add(radio, whatsThis);
00657 QWhatsThis::add(mEmailBccAddress, whatsThis);
00658 radio->setFocusWidget(mEmailBccAddress);
00659 grid->addWidget(mEmailBccAddress, 5, 2);
00660
00661
00662 radio = new RadioButton(i18n("Us&e address from Control Center"), group);
00663 radio->setFixedSize(radio->sizeHint());
00664 mBccAddressGroup->insert(radio, Preferences::MAIL_FROM_CONTROL_CENTRE);
00665 QWhatsThis::add(radio,
00666 i18n("Check to use the email address set in the KDE Control Center, for blind copying email alarms to yourself."));
00667 grid->addMultiCellWidget(radio, 6, 6, 1, 2, Qt::AlignAuto);
00668
00669 group->setFixedHeight(group->sizeHint().height());
00670
00671 box = new QHBox(mPage);
00672 mEmailQueuedNotify = new QCheckBox(i18n("&Notify when remote emails are queued"), box);
00673 mEmailQueuedNotify->setFixedSize(mEmailQueuedNotify->sizeHint());
00674 QWhatsThis::add(mEmailQueuedNotify,
00675 i18n("Display a notification message whenever an email alarm has queued an email for sending to a remote system. "
00676 "This could be useful if, for example, you have a dial-up connection, so that you can then ensure that the email is actually transmitted."));
00677 box->setStretchFactor(new QWidget(box), 1);
00678 box->setFixedHeight(box->sizeHint().height());
00679
00680 mPage->setStretchFactor(new QWidget(mPage), 1);
00681 }
00682
00683 void EmailPrefTab::restore()
00684 {
00685 mEmailClient->setButton(Preferences::mEmailClient);
00686 mEmailCopyToKMail->setChecked(Preferences::emailCopyToKMail());
00687 setEmailAddress(Preferences::mEmailFrom, Preferences::mEmailAddress);
00688 setEmailBccAddress((Preferences::mEmailBccFrom == Preferences::MAIL_FROM_CONTROL_CENTRE), Preferences::mEmailBccAddress);
00689 mEmailQueuedNotify->setChecked(Preferences::emailQueuedNotify());
00690 mAddressChanged = mBccAddressChanged = false;
00691 }
00692
00693 void EmailPrefTab::apply(bool syncToDisc)
00694 {
00695 int client = mEmailClient->id(mEmailClient->selected());
00696 Preferences::mEmailClient = (client >= 0) ? Preferences::MailClient(client) : Preferences::default_emailClient;
00697 Preferences::mEmailCopyToKMail = mEmailCopyToKMail->isChecked();
00698 Preferences::setEmailAddress(static_cast<Preferences::MailFrom>(mFromAddressGroup->selectedId()), mEmailAddress->text().stripWhiteSpace());
00699 Preferences::setEmailBccAddress((mBccAddressGroup->selectedId() == Preferences::MAIL_FROM_CONTROL_CENTRE), mEmailBccAddress->text().stripWhiteSpace());
00700 Preferences::setEmailQueuedNotify(mEmailQueuedNotify->isChecked());
00701 PrefsTabBase::apply(syncToDisc);
00702 }
00703
00704 void EmailPrefTab::setDefaults()
00705 {
00706 mEmailClient->setButton(Preferences::default_emailClient);
00707 setEmailAddress(Preferences::default_emailFrom(), Preferences::default_emailAddress);
00708 setEmailBccAddress((Preferences::default_emailBccFrom == Preferences::MAIL_FROM_CONTROL_CENTRE), Preferences::default_emailBccAddress);
00709 mEmailQueuedNotify->setChecked(Preferences::default_emailQueuedNotify);
00710 }
00711
00712 void EmailPrefTab::setEmailAddress(Preferences::MailFrom from, const QString& address)
00713 {
00714 mFromAddressGroup->setButton(from);
00715 mEmailAddress->setText(from == Preferences::MAIL_FROM_ADDR ? address.stripWhiteSpace() : QString());
00716 }
00717
00718 void EmailPrefTab::setEmailBccAddress(bool useControlCentre, const QString& address)
00719 {
00720 mBccAddressGroup->setButton(useControlCentre ? Preferences::MAIL_FROM_CONTROL_CENTRE : Preferences::MAIL_FROM_ADDR);
00721 mEmailBccAddress->setText(useControlCentre ? QString() : address.stripWhiteSpace());
00722 }
00723
00724 void EmailPrefTab::slotEmailClientChanged(int id)
00725 {
00726 mEmailCopyToKMail->setEnabled(id == Preferences::SENDMAIL);
00727 }
00728
00729 void EmailPrefTab::slotFromAddrChanged(int id)
00730 {
00731 mEmailAddress->setEnabled(id == Preferences::MAIL_FROM_ADDR);
00732 mAddressChanged = true;
00733 }
00734
00735 void EmailPrefTab::slotBccAddrChanged(int id)
00736 {
00737 mEmailBccAddress->setEnabled(id == Preferences::MAIL_FROM_ADDR);
00738 mBccAddressChanged = true;
00739 }
00740
00741 QString EmailPrefTab::validate()
00742 {
00743 if (mAddressChanged)
00744 {
00745 mAddressChanged = false;
00746 QString errmsg = validateAddr(mFromAddressGroup, mEmailAddress, KAMail::i18n_NeedFromEmailAddress());
00747 if (!errmsg.isEmpty())
00748 return errmsg;
00749 }
00750 if (mBccAddressChanged)
00751 {
00752 mBccAddressChanged = false;
00753 return validateAddr(mBccAddressGroup, mEmailBccAddress, i18n("No valid 'Bcc' email address is specified."));
00754 }
00755 return QString::null;
00756 }
00757
00758 QString EmailPrefTab::validateAddr(ButtonGroup* group, QLineEdit* addr, const QString& msg)
00759 {
00760 QString errmsg = i18n("%1\nAre you sure you want to save your changes?").arg(msg);
00761 switch (group->selectedId())
00762 {
00763 case Preferences::MAIL_FROM_CONTROL_CENTRE:
00764 if (!KAMail::controlCentreAddress().isEmpty())
00765 return QString::null;
00766 errmsg = i18n("No email address is currently set in the KDE Control Center. %1").arg(errmsg);
00767 break;
00768 case Preferences::MAIL_FROM_KMAIL:
00769 if (KAMail::identitiesExist())
00770 return QString::null;
00771 errmsg = i18n("No KMail identities currently exist. %1").arg(errmsg);
00772 break;
00773 case Preferences::MAIL_FROM_ADDR:
00774 if (!addr->text().stripWhiteSpace().isEmpty())
00775 return QString::null;
00776 break;
00777 }
00778 return errmsg;
00779 }
00780
00781
00782
00783
00784
00785
00786 FontColourPrefTab::FontColourPrefTab(QVBox* frame)
00787 : PrefsTabBase(frame)
00788 {
00789 mFontChooser = new FontColourChooser(mPage, 0, false, QStringList(), i18n("Message Font && Color"), true, false);
00790
00791 QHBox* layoutBox = new QHBox(mPage);
00792 QHBox* box = new QHBox(layoutBox);
00793 box->setSpacing(KDialog::spacingHint());
00794 QLabel* label1 = new QLabel(i18n("Di&sabled alarm color:"), box);
00795
00796 box->setStretchFactor(new QWidget(box), 1);
00797 mDisabledColour = new KColorCombo(box);
00798 mDisabledColour->setMinimumSize(mDisabledColour->sizeHint());
00799 label1->setBuddy(mDisabledColour);
00800 QWhatsThis::add(box,
00801 i18n("Choose the text color in the alarm list for disabled alarms."));
00802 layoutBox->setStretchFactor(new QWidget(layoutBox), 1);
00803 layoutBox->setFixedHeight(layoutBox->sizeHint().height());
00804
00805 layoutBox = new QHBox(mPage);
00806 box = new QHBox(layoutBox);
00807 box->setSpacing(KDialog::spacingHint());
00808 QLabel* label2 = new QLabel(i18n("E&xpired alarm color:"), box);
00809
00810 box->setStretchFactor(new QWidget(box), 1);
00811 mExpiredColour = new KColorCombo(box);
00812 mExpiredColour->setMinimumSize(mExpiredColour->sizeHint());
00813 label2->setBuddy(mExpiredColour);
00814 QWhatsThis::add(box,
00815 i18n("Choose the text color in the alarm list for expired alarms."));
00816 layoutBox->setStretchFactor(new QWidget(layoutBox), 1);
00817 layoutBox->setFixedHeight(layoutBox->sizeHint().height());
00818
00819
00820 QSize size = label1->sizeHint();
00821 QSize size2 = label2->sizeHint();
00822 if (size2.width() > size.width())
00823 size.setWidth(size2.width());
00824 label1->setFixedSize(size);
00825 label2->setFixedSize(size);
00826
00827 mPage->setStretchFactor(new QWidget(mPage), 1);
00828 }
00829
00830 void FontColourPrefTab::restore()
00831 {
00832 mFontChooser->setBgColour(Preferences::mDefaultBgColour);
00833 mFontChooser->setColours(Preferences::mMessageColours);
00834 mFontChooser->setFont(Preferences::mMessageFont);
00835 mDisabledColour->setColor(Preferences::mDisabledColour);
00836 mExpiredColour->setColor(Preferences::mExpiredColour);
00837 }
00838
00839 void FontColourPrefTab::apply(bool syncToDisc)
00840 {
00841 Preferences::mDefaultBgColour = mFontChooser->bgColour();
00842 Preferences::mMessageColours = mFontChooser->colours();
00843 Preferences::mMessageFont = mFontChooser->font();
00844 Preferences::mDisabledColour = mDisabledColour->color();
00845 Preferences::mExpiredColour = mExpiredColour->color();
00846 PrefsTabBase::apply(syncToDisc);
00847 }
00848
00849 void FontColourPrefTab::setDefaults()
00850 {
00851 mFontChooser->setBgColour(Preferences::default_defaultBgColour);
00852 mFontChooser->setColours(Preferences::default_messageColours);
00853 mFontChooser->setFont(Preferences::default_messageFont());
00854 mDisabledColour->setColor(Preferences::default_disabledColour);
00855 mExpiredColour->setColor(Preferences::default_expiredColour);
00856 }
00857
00858
00859
00860
00861
00862
00863 EditPrefTab::EditPrefTab(QVBox* frame)
00864 : PrefsTabBase(frame)
00865 {
00866
00867
00868 int alignment = QApplication::reverseLayout() ? Qt::AlignRight : Qt::AlignLeft;
00869
00870 int groupTopMargin = fontMetrics().lineSpacing()/2;
00871 QString defsetting = i18n("The default setting for \"%1\" in the alarm edit dialog.");
00872 QString soundSetting = i18n("Check to select %1 as the default setting for \"%2\" in the alarm edit dialog.");
00873
00874
00875 QGroupBox* group = new QGroupBox(i18n("Display Alarms"), mPage);
00876 QBoxLayout* layout = new QVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
00877 layout->addSpacing(groupTopMargin);
00878
00879 mConfirmAck = new QCheckBox(EditAlarmDlg::i18n_k_ConfirmAck(), group, "defConfAck");
00880 mConfirmAck->setMinimumSize(mConfirmAck->sizeHint());
00881 QWhatsThis::add(mConfirmAck, defsetting.arg(EditAlarmDlg::i18n_ConfirmAck()));
00882 layout->addWidget(mConfirmAck, 0, Qt::AlignAuto);
00883
00884 mAutoClose = new QCheckBox(LateCancelSelector::i18n_i_AutoCloseWinLC(), group, "defAutoClose");
00885 mAutoClose->setMinimumSize(mAutoClose->sizeHint());
00886 QWhatsThis::add(mAutoClose, defsetting.arg(LateCancelSelector::i18n_AutoCloseWin()));
00887 layout->addWidget(mAutoClose, 0, Qt::AlignAuto);
00888
00889 QHBox* box = new QHBox(group);
00890 box->setSpacing(KDialog::spacingHint());
00891 layout->addWidget(box);
00892 QLabel* label = new QLabel(i18n("Reminder &units:"), box);
00893 label->setFixedSize(label->sizeHint());
00894 mReminderUnits = new QComboBox(box, "defWarnUnits");
00895 mReminderUnits->insertItem(TimePeriod::i18n_Hours_Mins(), TimePeriod::HOURS_MINUTES);
00896 mReminderUnits->insertItem(TimePeriod::i18n_Days(), TimePeriod::DAYS);
00897 mReminderUnits->insertItem(TimePeriod::i18n_Weeks(), TimePeriod::WEEKS);
00898 mReminderUnits->setFixedSize(mReminderUnits->sizeHint());
00899 label->setBuddy(mReminderUnits);
00900 QWhatsThis::add(box,
00901 i18n("The default units for the reminder in the alarm edit dialog."));
00902 box->setStretchFactor(new QWidget(box), 1);
00903
00904 mSpecialActionsButton = new SpecialActionsButton(EditAlarmDlg::i18n_SpecialActions(), box);
00905 mSpecialActionsButton->setFixedSize(mSpecialActionsButton->sizeHint());
00906
00907
00908 QButtonGroup* bgroup = new QButtonGroup(SoundPicker::i18n_Sound(), mPage, "soundGroup");
00909 layout = new QVBoxLayout(bgroup, KDialog::marginHint(), KDialog::spacingHint());
00910 layout->addSpacing(groupTopMargin);
00911
00912 QBoxLayout* hlayout = new QHBoxLayout(layout, KDialog::spacingHint());
00913 mSound = new QComboBox(false, bgroup, "defSound");
00914 mSound->insertItem(SoundPicker::i18n_None());
00915 mSound->insertItem(SoundPicker::i18n_Beep());
00916 mSound->insertItem(SoundPicker::i18n_File());
00917 if (theApp()->speechEnabled())
00918 mSound->insertItem(SoundPicker::i18n_Speak());
00919 mSound->setMinimumSize(mSound->sizeHint());
00920 QWhatsThis::add(mSound, defsetting.arg(SoundPicker::i18n_Sound()));
00921 hlayout->addWidget(mSound);
00922 hlayout->addStretch(1);
00923
00924 #ifndef WITHOUT_ARTS
00925 mSoundRepeat = new QCheckBox(i18n("Repea&t sound file"), bgroup, "defRepeatSound");
00926 mSoundRepeat->setMinimumSize(mSoundRepeat->sizeHint());
00927 QWhatsThis::add(mSoundRepeat, i18n("sound file \"Repeat\" checkbox", "The default setting for sound file \"%1\" in the alarm edit dialog.").arg(SoundDlg::i18n_Repeat()));
00928 hlayout->addWidget(mSoundRepeat);
00929 #endif
00930
00931 box = new QHBox(bgroup);
00932 box->setSpacing(KDialog::spacingHint());
00933 mSoundFileLabel = new QLabel(i18n("Sound &file:"), box);
00934 mSoundFileLabel->setFixedSize(mSoundFileLabel->sizeHint());
00935 mSoundFile = new QLineEdit(box);
00936 mSoundFileLabel->setBuddy(mSoundFile);
00937 mSoundFileBrowse = new QPushButton(box);
00938 mSoundFileBrowse->setPixmap(SmallIcon("fileopen"));
00939 mSoundFileBrowse->setFixedSize(mSoundFileBrowse->sizeHint());
00940 connect(mSoundFileBrowse, SIGNAL(clicked()), SLOT(slotBrowseSoundFile()));
00941 QToolTip::add(mSoundFileBrowse, i18n("Choose a sound file"));
00942 QWhatsThis::add(box,
00943 i18n("Enter the default sound file to use in the alarm edit dialog."));
00944 box->setFixedHeight(box->sizeHint().height());
00945 layout->addWidget(box);
00946 bgroup->setFixedHeight(bgroup->sizeHint().height());
00947
00948
00949 group = new QGroupBox(i18n("Command Alarms"), mPage);
00950 layout = new QVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
00951 layout->addSpacing(groupTopMargin);
00952 layout = new QHBoxLayout(layout, KDialog::spacingHint());
00953
00954 mCmdScript = new QCheckBox(EditAlarmDlg::i18n_p_EnterScript(), group, "defCmdScript");
00955 mCmdScript->setMinimumSize(mCmdScript->sizeHint());
00956 QWhatsThis::add(mCmdScript, defsetting.arg(EditAlarmDlg::i18n_EnterScript()));
00957 layout->addWidget(mCmdScript);
00958 layout->addStretch();
00959
00960 mCmdXterm = new QCheckBox(EditAlarmDlg::i18n_w_ExecInTermWindow(), group, "defCmdXterm");
00961 mCmdXterm->setMinimumSize(mCmdXterm->sizeHint());
00962 QWhatsThis::add(mCmdXterm, defsetting.arg(EditAlarmDlg::i18n_ExecInTermWindow()));
00963 layout->addWidget(mCmdXterm);
00964
00965
00966 group = new QGroupBox(i18n("Email Alarms"), mPage);
00967 layout = new QVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
00968 layout->addSpacing(groupTopMargin);
00969
00970
00971 mEmailBcc = new QCheckBox(EditAlarmDlg::i18n_e_CopyEmailToSelf(), group, "defEmailBcc");
00972 mEmailBcc->setMinimumSize(mEmailBcc->sizeHint());
00973 QWhatsThis::add(mEmailBcc, defsetting.arg(EditAlarmDlg::i18n_CopyEmailToSelf()));
00974 layout->addWidget(mEmailBcc, 0, Qt::AlignAuto);
00975
00976
00977
00978 mCopyToKOrganizer = new QCheckBox(EditAlarmDlg::i18n_g_ShowInKOrganizer(), mPage, "defShowKorg");
00979 mCopyToKOrganizer->setMinimumSize(mCopyToKOrganizer->sizeHint());
00980 QWhatsThis::add(mCopyToKOrganizer, defsetting.arg(EditAlarmDlg::i18n_ShowInKOrganizer()));
00981
00982
00983 box = new QHBox(mPage);
00984 box->setSpacing(KDialog::spacingHint());
00985 mLateCancel = new QCheckBox(LateCancelSelector::i18n_n_CancelIfLate(), box, "defCancelLate");
00986 mLateCancel->setMinimumSize(mLateCancel->sizeHint());
00987 QWhatsThis::add(mLateCancel, defsetting.arg(LateCancelSelector::i18n_CancelIfLate()));
00988 box->setStretchFactor(new QWidget(box), 1);
00989
00990
00991 QHBox* itemBox = new QHBox(box);
00992 itemBox->setSpacing(KDialog::spacingHint());
00993 label = new QLabel(i18n("&Recurrence:"), itemBox);
00994 label->setFixedSize(label->sizeHint());
00995 mRecurPeriod = new QComboBox(itemBox, "defRecur");
00996 mRecurPeriod->insertItem(RecurrenceEdit::i18n_NoRecur());
00997 mRecurPeriod->insertItem(RecurrenceEdit::i18n_AtLogin());
00998 mRecurPeriod->insertItem(RecurrenceEdit::i18n_HourlyMinutely());
00999 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Daily());
01000 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Weekly());
01001 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Monthly());
01002 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Yearly());
01003 mRecurPeriod->setFixedSize(mRecurPeriod->sizeHint());
01004 label->setBuddy(mRecurPeriod);
01005 QWhatsThis::add(itemBox,
01006 i18n("The default setting for the recurrence rule in the alarm edit dialog."));
01007 box->setFixedHeight(itemBox->sizeHint().height());
01008
01009
01010 QVBox* vbox = new QVBox(mPage);
01011 vbox->setSpacing(KDialog::spacingHint());
01012 label = new QLabel(i18n("In non-leap years, repeat yearly February 29th alarms on:"), vbox);
01013 label->setAlignment(alignment | Qt::WordBreak);
01014 itemBox = new QHBox(vbox);
01015 itemBox->setSpacing(2*KDialog::spacingHint());
01016 mFeb29 = new QButtonGroup(itemBox);
01017 mFeb29->hide();
01018 QWidget* widget = new QWidget(itemBox);
01019 widget->setFixedWidth(3*KDialog::spacingHint());
01020 QRadioButton* radio = new QRadioButton(i18n("February 2&8th"), itemBox);
01021 radio->setMinimumSize(radio->sizeHint());
01022 mFeb29->insert(radio, KARecurrence::FEB29_FEB28);
01023 radio = new QRadioButton(i18n("March &1st"), itemBox);
01024 radio->setMinimumSize(radio->sizeHint());
01025 mFeb29->insert(radio, KARecurrence::FEB29_MAR1);
01026 radio = new QRadioButton(i18n("Do ¬ repeat"), itemBox);
01027 radio->setMinimumSize(radio->sizeHint());
01028 mFeb29->insert(radio, KARecurrence::FEB29_FEB29);
01029 itemBox->setFixedHeight(itemBox->sizeHint().height());
01030 QWhatsThis::add(vbox,
01031 i18n("For yearly recurrences, choose what date, if any, alarms due on February 29th should occur in non-leap years.\n"
01032 "Note that the next scheduled occurrence of existing alarms is not re-evaluated when you change this setting."));
01033
01034 mPage->setStretchFactor(new QWidget(mPage), 1);
01035 }
01036
01037 void EditPrefTab::restore()
01038 {
01039 mAutoClose->setChecked(Preferences::mDefaultAutoClose);
01040 mConfirmAck->setChecked(Preferences::mDefaultConfirmAck);
01041 mReminderUnits->setCurrentItem(Preferences::mDefaultReminderUnits);
01042 mSpecialActionsButton->setActions(Preferences::mDefaultPreAction, Preferences::mDefaultPostAction);
01043 mSound->setCurrentItem(soundIndex(Preferences::mDefaultSoundType));
01044 mSoundFile->setText(Preferences::mDefaultSoundFile);
01045 #ifndef WITHOUT_ARTS
01046 mSoundRepeat->setChecked(Preferences::mDefaultSoundRepeat);
01047 #endif
01048 mCmdScript->setChecked(Preferences::mDefaultCmdScript);
01049 mCmdXterm->setChecked(Preferences::mDefaultCmdLogType == EditAlarmDlg::EXEC_IN_TERMINAL);
01050 mEmailBcc->setChecked(Preferences::mDefaultEmailBcc);
01051 mCopyToKOrganizer->setChecked(Preferences::mDefaultCopyToKOrganizer);
01052 mLateCancel->setChecked(Preferences::mDefaultLateCancel);
01053 mRecurPeriod->setCurrentItem(recurIndex(Preferences::mDefaultRecurPeriod));
01054 mFeb29->setButton(Preferences::mDefaultFeb29Type);
01055 }
01056
01057 void EditPrefTab::apply(bool syncToDisc)
01058 {
01059 Preferences::mDefaultAutoClose = mAutoClose->isChecked();
01060 Preferences::mDefaultConfirmAck = mConfirmAck->isChecked();
01061 Preferences::mDefaultReminderUnits = static_cast<TimePeriod::Units>(mReminderUnits->currentItem());
01062 Preferences::mDefaultPreAction = mSpecialActionsButton->preAction();
01063 Preferences::mDefaultPostAction = mSpecialActionsButton->postAction();
01064 switch (mSound->currentItem())
01065 {
01066 case 3: Preferences::mDefaultSoundType = SoundPicker::SPEAK; break;
01067 case 2: Preferences::mDefaultSoundType = SoundPicker::PLAY_FILE; break;
01068 case 1: Preferences::mDefaultSoundType = SoundPicker::BEEP; break;
01069 case 0:
01070 default: Preferences::mDefaultSoundType = SoundPicker::NONE; break;
01071 }
01072 Preferences::mDefaultSoundFile = mSoundFile->text();
01073 #ifndef WITHOUT_ARTS
01074 Preferences::mDefaultSoundRepeat = mSoundRepeat->isChecked();
01075 #endif
01076 Preferences::mDefaultCmdScript = mCmdScript->isChecked();
01077 Preferences::mDefaultCmdLogFile = (mCmdXterm->isChecked() ? EditAlarmDlg::EXEC_IN_TERMINAL : EditAlarmDlg::DISCARD_OUTPUT);
01078 Preferences::mDefaultEmailBcc = mEmailBcc->isChecked();
01079 Preferences::mDefaultCopyToKOrganizer = mCopyToKOrganizer->isChecked();
01080 Preferences::mDefaultLateCancel = mLateCancel->isChecked() ? 1 : 0;
01081 switch (mRecurPeriod->currentItem())
01082 {
01083 case 6: Preferences::mDefaultRecurPeriod = RecurrenceEdit::ANNUAL; break;
01084 case 5: Preferences::mDefaultRecurPeriod = RecurrenceEdit::MONTHLY; break;
01085 case 4: Preferences::mDefaultRecurPeriod = RecurrenceEdit::WEEKLY; break;
01086 case 3: Preferences::mDefaultRecurPeriod = RecurrenceEdit::DAILY; break;
01087 case 2: Preferences::mDefaultRecurPeriod = RecurrenceEdit::SUBDAILY; break;
01088 case 1: Preferences::mDefaultRecurPeriod = RecurrenceEdit::AT_LOGIN; break;
01089 case 0:
01090 default: Preferences::mDefaultRecurPeriod = RecurrenceEdit::NO_RECUR; break;
01091 }
01092 int feb29 = mFeb29->selectedId();
01093 Preferences::mDefaultFeb29Type = (feb29 >= 0) ? static_cast<KARecurrence::Feb29Type>(feb29) : Preferences::default_defaultFeb29Type;
01094 PrefsTabBase::apply(syncToDisc);
01095 }
01096
01097 void EditPrefTab::setDefaults()
01098 {
01099 mAutoClose->setChecked(Preferences::default_defaultAutoClose);
01100 mConfirmAck->setChecked(Preferences::default_defaultConfirmAck);
01101 mReminderUnits->setCurrentItem(Preferences::default_defaultReminderUnits);
01102 mSpecialActionsButton->setActions(Preferences::default_defaultPreAction, Preferences::default_defaultPostAction);
01103 mSound->setCurrentItem(soundIndex(Preferences::default_defaultSoundType));
01104 mSoundFile->setText(Preferences::default_defaultSoundFile);
01105 #ifndef WITHOUT_ARTS
01106 mSoundRepeat->setChecked(Preferences::default_defaultSoundRepeat);
01107 #endif
01108 mCmdScript->setChecked(Preferences::default_defaultCmdScript);
01109 mCmdXterm->setChecked(Preferences::default_defaultCmdLogType == EditAlarmDlg::EXEC_IN_TERMINAL);
01110 mEmailBcc->setChecked(Preferences::default_defaultEmailBcc);
01111 mCopyToKOrganizer->setChecked(Preferences::default_defaultCopyToKOrganizer);
01112 mLateCancel->setChecked(Preferences::default_defaultLateCancel);
01113 mRecurPeriod->setCurrentItem(recurIndex(Preferences::default_defaultRecurPeriod));
01114 mFeb29->setButton(Preferences::default_defaultFeb29Type);
01115 }
01116
01117 void EditPrefTab::slotBrowseSoundFile()
01118 {
01119 QString defaultDir;
01120 QString url = SoundPicker::browseFile(defaultDir, mSoundFile->text());
01121 if (!url.isEmpty())
01122 mSoundFile->setText(url);
01123 }
01124
01125 int EditPrefTab::soundIndex(SoundPicker::Type type)
01126 {
01127 switch (type)
01128 {
01129 case SoundPicker::SPEAK: return 3;
01130 case SoundPicker::PLAY_FILE: return 2;
01131 case SoundPicker::BEEP: return 1;
01132 case SoundPicker::NONE:
01133 default: return 0;
01134 }
01135 }
01136
01137 int EditPrefTab::recurIndex(RecurrenceEdit::RepeatType type)
01138 {
01139 switch (type)
01140 {
01141 case RecurrenceEdit::ANNUAL: return 6;
01142 case RecurrenceEdit::MONTHLY: return 5;
01143 case RecurrenceEdit::WEEKLY: return 4;
01144 case RecurrenceEdit::DAILY: return 3;
01145 case RecurrenceEdit::SUBDAILY: return 2;
01146 case RecurrenceEdit::AT_LOGIN: return 1;
01147 case RecurrenceEdit::NO_RECUR:
01148 default: return 0;
01149 }
01150 }
01151
01152 QString EditPrefTab::validate()
01153 {
01154 if (mSound->currentItem() == SoundPicker::PLAY_FILE && mSoundFile->text().isEmpty())
01155 {
01156 mSoundFile->setFocus();
01157 return i18n("You must enter a sound file when %1 is selected as the default sound type").arg(SoundPicker::i18n_File());;
01158 }
01159 return QString::null;
01160 }
01161
01162
01163
01164
01165
01166
01167 ViewPrefTab::ViewPrefTab(QVBox* frame)
01168 : PrefsTabBase(frame)
01169 {
01170 QGroupBox* group = new QGroupBox(i18n("Alarm List"), mPage);
01171 QBoxLayout* layout = new QVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
01172 layout->addSpacing(fontMetrics().lineSpacing()/2);
01173
01174 mListShowTime = new QCheckBox(MainWindow::i18n_t_ShowAlarmTime(), group, "listTime");
01175 mListShowTime->setMinimumSize(mListShowTime->sizeHint());
01176 connect(mListShowTime, SIGNAL(toggled(bool)), SLOT(slotListTimeToggled(bool)));
01177 QWhatsThis::add(mListShowTime,
01178 i18n("Specify whether to show in the alarm list, the time at which each alarm is due"));
01179 layout->addWidget(mListShowTime, 0, Qt::AlignAuto);
01180
01181 mListShowTimeTo = new QCheckBox(MainWindow::i18n_n_ShowTimeToAlarm(), group, "listTimeTo");
01182 mListShowTimeTo->setMinimumSize(mListShowTimeTo->sizeHint());
01183 connect(mListShowTimeTo, SIGNAL(toggled(bool)), SLOT(slotListTimeToToggled(bool)));
01184 QWhatsThis::add(mListShowTimeTo,
01185 i18n("Specify whether to show in the alarm list, how long until each alarm is due"));
01186 layout->addWidget(mListShowTimeTo, 0, Qt::AlignAuto);
01187 group->setMaximumHeight(group->sizeHint().height());
01188
01189 group = new QGroupBox(i18n("System Tray Tooltip"), mPage);
01190 QGridLayout* grid = new QGridLayout(group, 5, 3, KDialog::marginHint(), KDialog::spacingHint());
01191 grid->setColStretch(2, 1);
01192 grid->addColSpacing(0, indentWidth());
01193 grid->addColSpacing(1, indentWidth());
01194 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
01195
01196 mTooltipShowAlarms = new QCheckBox(i18n("Show next &24 hours' alarms"), group, "tooltipShow");
01197 mTooltipShowAlarms->setMinimumSize(mTooltipShowAlarms->sizeHint());
01198 connect(mTooltipShowAlarms, SIGNAL(toggled(bool)), SLOT(slotTooltipAlarmsToggled(bool)));
01199 QWhatsThis::add(mTooltipShowAlarms,
01200 i18n("Specify whether to include in the system tray tooltip, a summary of alarms due in the next 24 hours"));
01201 grid->addMultiCellWidget(mTooltipShowAlarms, 1, 1, 0, 2, Qt::AlignAuto);
01202
01203 QHBox* box = new QHBox(group);
01204 box->setSpacing(KDialog::spacingHint());
01205 mTooltipMaxAlarms = new QCheckBox(i18n("Ma&ximum number of alarms to show:"), box, "tooltipMax");
01206 mTooltipMaxAlarms->setMinimumSize(mTooltipMaxAlarms->sizeHint());
01207 connect(mTooltipMaxAlarms, SIGNAL(toggled(bool)), SLOT(slotTooltipMaxToggled(bool)));
01208 mTooltipMaxAlarmCount = new SpinBox(1, 99, 1, box);
01209 mTooltipMaxAlarmCount->setLineShiftStep(5);
01210 mTooltipMaxAlarmCount->setMinimumSize(mTooltipMaxAlarmCount->sizeHint());
01211 QWhatsThis::add(box,
01212 i18n("Uncheck to display all of the next 24 hours' alarms in the system tray tooltip. "
01213 "Check to enter an upper limit on the number to be displayed."));
01214 grid->addMultiCellWidget(box, 2, 2, 1, 2, Qt::AlignAuto);
01215
01216 mTooltipShowTime = new QCheckBox(MainWindow::i18n_m_ShowAlarmTime(), group, "tooltipTime");
01217 mTooltipShowTime->setMinimumSize(mTooltipShowTime->sizeHint());
01218 connect(mTooltipShowTime, SIGNAL(toggled(bool)), SLOT(slotTooltipTimeToggled(bool)));
01219 QWhatsThis::add(mTooltipShowTime,
01220 i18n("Specify whether to show in the system tray tooltip, the time at which each alarm is due"));
01221 grid->addMultiCellWidget(mTooltipShowTime, 3, 3, 1, 2, Qt::AlignAuto);
01222
01223 mTooltipShowTimeTo = new QCheckBox(MainWindow::i18n_l_ShowTimeToAlarm(), group, "tooltipTimeTo");
01224 mTooltipShowTimeTo->setMinimumSize(mTooltipShowTimeTo->sizeHint());
01225 connect(mTooltipShowTimeTo, SIGNAL(toggled(bool)), SLOT(slotTooltipTimeToToggled(bool)));
01226 QWhatsThis::add(mTooltipShowTimeTo,
01227 i18n("Specify whether to show in the system tray tooltip, how long until each alarm is due"));
01228 grid->addMultiCellWidget(mTooltipShowTimeTo, 4, 4, 1, 2, Qt::AlignAuto);
01229
01230 box = new QHBox(group);
01231 box->setSpacing(KDialog::spacingHint());
01232 mTooltipTimeToPrefixLabel = new QLabel(i18n("&Prefix:"), box);
01233 mTooltipTimeToPrefixLabel->setFixedSize(mTooltipTimeToPrefixLabel->sizeHint());
01234 mTooltipTimeToPrefix = new QLineEdit(box);
01235 mTooltipTimeToPrefixLabel->setBuddy(mTooltipTimeToPrefix);
01236 QWhatsThis::add(box,
01237 i18n("Enter the text to be displayed in front of the time until the alarm, in the system tray tooltip"));
01238 box->setFixedHeight(box->sizeHint().height());
01239 grid->addWidget(box, 5, 2, Qt::AlignAuto);
01240 group->setMaximumHeight(group->sizeHint().height());
01241
01242 mModalMessages = new QCheckBox(i18n("Message &windows have a title bar and take keyboard focus"), mPage, "modalMsg");
01243 mModalMessages->setMinimumSize(mModalMessages->sizeHint());
01244 QWhatsThis::add(mModalMessages,
01245 i18n("Specify the characteristics of alarm message windows:\n"
01246 "- If checked, the window is a normal window with a title bar, which grabs keyboard input when it is displayed.\n"
01247 "- If unchecked, the window does not interfere with your typing when "
01248 "it is displayed, but it has no title bar and cannot be moved or resized."));
01249
01250 mShowExpiredAlarms = new QCheckBox(MainWindow::i18n_e_ShowExpiredAlarms(), mPage, "showExpired");
01251 mShowExpiredAlarms->setMinimumSize(mShowExpiredAlarms->sizeHint());
01252 QWhatsThis::add(mShowExpiredAlarms,
01253 i18n("Specify whether to show expired alarms in the alarm list"));
01254
01255 QHBox* itemBox = new QHBox(mPage);
01256 box = new QHBox(itemBox);
01257 box->setSpacing(KDialog::spacingHint());
01258 QLabel* label = new QLabel(i18n("System tray icon &update interval:"), box);
01259 mDaemonTrayCheckInterval = new SpinBox(1, 9999, 1, box, "daemonCheck");
01260 mDaemonTrayCheckInterval->setLineShiftStep(10);
01261 mDaemonTrayCheckInterval->setMinimumSize(mDaemonTrayCheckInterval->sizeHint());
01262 label->setBuddy(mDaemonTrayCheckInterval);
01263 label = new QLabel(i18n("seconds"), box);
01264 QWhatsThis::add(box,
01265 i18n("How often to update the system tray icon to indicate whether or not the Alarm Daemon is monitoring alarms."));
01266 itemBox->setStretchFactor(new QWidget(itemBox), 1);
01267 itemBox->setFixedHeight(box->sizeHint().height());
01268
01269 mPage->setStretchFactor(new QWidget(mPage), 1);
01270 }
01271
01272 void ViewPrefTab::restore()
01273 {
01274 setList(Preferences::mShowAlarmTime,
01275 Preferences::mShowTimeToAlarm);
01276 setTooltip(Preferences::mTooltipAlarmCount,
01277 Preferences::mShowTooltipAlarmTime,
01278 Preferences::mShowTooltipTimeToAlarm,
01279 Preferences::mTooltipTimeToPrefix);
01280 mModalMessages->setChecked(Preferences::mModalMessages);
01281 mShowExpiredAlarms->setChecked(Preferences::mShowExpiredAlarms);
01282 mDaemonTrayCheckInterval->setValue(Preferences::mDaemonTrayCheckInterval);
01283 }
01284
01285 void ViewPrefTab::apply(bool syncToDisc)
01286 {
01287 Preferences::mShowAlarmTime = mListShowTime->isChecked();
01288 Preferences::mShowTimeToAlarm = mListShowTimeTo->isChecked();
01289 int n = mTooltipShowAlarms->isChecked() ? -1 : 0;
01290 if (n && mTooltipMaxAlarms->isChecked())
01291 n = mTooltipMaxAlarmCount->value();
01292 Preferences::mTooltipAlarmCount = n;
01293 Preferences::mShowTooltipAlarmTime = mTooltipShowTime->isChecked();
01294 Preferences::mShowTooltipTimeToAlarm = mTooltipShowTimeTo->isChecked();
01295 Preferences::mTooltipTimeToPrefix = mTooltipTimeToPrefix->text();
01296 Preferences::mModalMessages = mModalMessages->isChecked();
01297 Preferences::mShowExpiredAlarms = mShowExpiredAlarms->isChecked();
01298 Preferences::mDaemonTrayCheckInterval = mDaemonTrayCheckInterval->value();
01299 PrefsTabBase::apply(syncToDisc);
01300 }
01301
01302 void ViewPrefTab::setDefaults()
01303 {
01304 setList(Preferences::default_showAlarmTime,
01305 Preferences::default_showTimeToAlarm);
01306 setTooltip(Preferences::default_tooltipAlarmCount,
01307 Preferences::default_showTooltipAlarmTime,
01308 Preferences::default_showTooltipTimeToAlarm,
01309 Preferences::default_tooltipTimeToPrefix);
01310 mModalMessages->setChecked(Preferences::default_modalMessages);
01311 mShowExpiredAlarms->setChecked(Preferences::default_showExpiredAlarms);
01312 mDaemonTrayCheckInterval->setValue(Preferences::default_daemonTrayCheckInterval);
01313 }
01314
01315 void ViewPrefTab::setList(bool time, bool timeTo)
01316 {
01317 if (!timeTo)
01318 time = true;
01319
01320
01321
01322 mListShowTime->blockSignals(true);
01323 mListShowTimeTo->blockSignals(true);
01324
01325 mListShowTime->setChecked(time);
01326 mListShowTimeTo->setChecked(timeTo);
01327
01328 mListShowTime->blockSignals(false);
01329 mListShowTimeTo->blockSignals(false);
01330 }
01331
01332 void ViewPrefTab::setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix)
01333 {
01334 if (!timeTo)
01335 time = true;
01336
01337
01338
01339 mTooltipShowAlarms->blockSignals(true);
01340 mTooltipShowTime->blockSignals(true);
01341 mTooltipShowTimeTo->blockSignals(true);
01342
01343 mTooltipShowAlarms->setChecked(maxAlarms);
01344 mTooltipMaxAlarms->setChecked(maxAlarms > 0);
01345 mTooltipMaxAlarmCount->setValue(maxAlarms > 0 ? maxAlarms : 1);
01346 mTooltipShowTime->setChecked(time);
01347 mTooltipShowTimeTo->setChecked(timeTo);
01348 mTooltipTimeToPrefix->setText(prefix);
01349
01350 mTooltipShowAlarms->blockSignals(false);
01351 mTooltipShowTime->blockSignals(false);
01352 mTooltipShowTimeTo->blockSignals(false);
01353
01354
01355 slotTooltipTimeToToggled(timeTo);
01356 slotTooltipAlarmsToggled(maxAlarms);
01357 }
01358
01359 void ViewPrefTab::slotListTimeToggled(bool on)
01360 {
01361 if (!on && !mListShowTimeTo->isChecked())
01362 mListShowTimeTo->setChecked(true);
01363 }
01364
01365 void ViewPrefTab::slotListTimeToToggled(bool on)
01366 {
01367 if (!on && !mListShowTime->isChecked())
01368 mListShowTime->setChecked(true);
01369 }
01370
01371 void ViewPrefTab::slotTooltipAlarmsToggled(bool on)
01372 {
01373 mTooltipMaxAlarms->setEnabled(on);
01374 mTooltipMaxAlarmCount->setEnabled(on && mTooltipMaxAlarms->isChecked());
01375 mTooltipShowTime->setEnabled(on);
01376 mTooltipShowTimeTo->setEnabled(on);
01377 on = on && mTooltipShowTimeTo->isChecked();
01378 mTooltipTimeToPrefix->setEnabled(on);
01379 mTooltipTimeToPrefixLabel->setEnabled(on);
01380 }
01381
01382 void ViewPrefTab::slotTooltipMaxToggled(bool on)
01383 {
01384 mTooltipMaxAlarmCount->setEnabled(on && mTooltipMaxAlarms->isEnabled());
01385 }
01386
01387 void ViewPrefTab::slotTooltipTimeToggled(bool on)
01388 {
01389 if (!on && !mTooltipShowTimeTo->isChecked())
01390 mTooltipShowTimeTo->setChecked(true);
01391 }
01392
01393 void ViewPrefTab::slotTooltipTimeToToggled(bool on)
01394 {
01395 if (!on && !mTooltipShowTime->isChecked())
01396 mTooltipShowTime->setChecked(true);
01397 on = on && mTooltipShowTimeTo->isEnabled();
01398 mTooltipTimeToPrefix->setEnabled(on);
01399 mTooltipTimeToPrefixLabel->setEnabled(on);
01400 }