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