23 #include <tqobjectlist.h>
25 #include <tqbuttongroup.h>
27 #include <tqlineedit.h>
28 #include <tqcheckbox.h>
29 #include <tqradiobutton.h>
30 #include <tqpushbutton.h>
31 #include <tqcombobox.h>
32 #include <tqwhatsthis.h>
33 #include <tqtooltip.h>
36 #include <tdeglobal.h>
37 #include <tdelocale.h>
38 #include <kstandarddirs.h>
40 #include <tdemessagebox.h>
41 #include <tdeaboutdata.h>
42 #include <tdeapplication.h>
43 #include <kiconloader.h>
44 #include <kcolorcombo.h>
45 #include <kstdguiitem.h>
51 #include <kalarmd/kalarmd.h>
53 #include "alarmcalendar.h"
54 #include "alarmtimewidget.h"
57 #include "fontcolour.h"
62 #include "latecancel.h"
64 #include "preferences.h"
65 #include "radiobutton.h"
66 #include "recurrenceedit.h"
70 #include "soundpicker.h"
71 #include "specialactions.h"
73 #include "timespinbox.h"
74 #include "traywindow.h"
75 #include "prefdlg.moc"
83 static TQString xtermCommands[] = {
84 TQString::fromLatin1(
"xterm -sb -hold -title %t -e %c"),
85 TQString::fromLatin1(
"konsole --noclose -T %t -e ${SHELL:-sh} -c %c"),
86 TQString::fromLatin1(
"gnome-terminal -t %t -e %W"),
87 TQString::fromLatin1(
"eterm --pause -T %t -e %C"),
88 TQString::fromLatin1(
"Eterm --pause -T %t -e %C"),
89 TQString::fromLatin1(
"rxvt -title %t -e ${SHELL:-sh} -c %w"),
98 KAlarmPrefDlg* KAlarmPrefDlg::mInstance = 0;
100 void KAlarmPrefDlg::display()
104 mInstance =
new KAlarmPrefDlg;
110 KWin::WindowInfo info = KWin::windowInfo(mInstance->winId(),
static_cast<unsigned long>(NET::WMGeometry | NET::WMDesktop));
111 KWin::setCurrentDesktop(info.desktop());
113 mInstance->showNormal();
115 mInstance->setActiveWindow();
119 KAlarmPrefDlg::KAlarmPrefDlg()
120 : KDialogBase(IconList, i18n(
"Preferences"), Help | Default | Ok | Apply | Cancel, Ok, 0,
"PrefDlg", false, true)
122 setWFlags(TQt::WDestructiveClose);
123 setIconListAllVisible(
true);
125 TQVBox* frame = addVBoxPage(i18n(
"General"), i18n(
"General"), DesktopIcon(
"misc"));
126 mMiscPage =
new MiscPrefTab(frame);
128 frame = addVBoxPage(i18n(
"Email"), i18n(
"Email Alarm Settings"), DesktopIcon(
"mail_generic"));
129 mEmailPage =
new EmailPrefTab(frame);
131 frame = addVBoxPage(i18n(
"View"), i18n(
"View Settings"), DesktopIcon(
"view_choose"));
132 mViewPage =
new ViewPrefTab(frame);
134 frame = addVBoxPage(i18n(
"Font & Color"), i18n(
"Default Font and Color"), DesktopIcon(
"colorize"));
135 mFontColourPage =
new FontColourPrefTab(frame);
137 frame = addVBoxPage(i18n(
"Edit"), i18n(
"Default Alarm Edit Settings"), DesktopIcon(
"edit"));
138 mEditPage =
new EditPrefTab(frame);
144 KAlarmPrefDlg::~KAlarmPrefDlg()
150 void KAlarmPrefDlg::slotDefault()
152 kdDebug(5950) <<
"KAlarmPrefDlg::slotDefault()" << endl;
153 mFontColourPage->setDefaults();
154 mEmailPage->setDefaults();
155 mViewPage->setDefaults();
156 mEditPage->setDefaults();
157 mMiscPage->setDefaults();
160 void KAlarmPrefDlg::slotHelp()
162 kapp->invokeHelp(
"preferences");
166 void KAlarmPrefDlg::slotApply()
168 kdDebug(5950) <<
"KAlarmPrefDlg::slotApply()" << endl;
169 TQString errmsg = mEmailPage->validate();
170 if (!errmsg.isEmpty())
172 showPage(pageIndex(mEmailPage->parentWidget()));
173 if (KMessageBox::warningYesNo(
this, errmsg) != KMessageBox::Yes)
179 errmsg = mEditPage->validate();
180 if (!errmsg.isEmpty())
182 showPage(pageIndex(mEditPage->parentWidget()));
183 KMessageBox::sorry(
this, errmsg);
188 mFontColourPage->apply(
false);
189 mEmailPage->apply(
false);
190 mViewPage->apply(
false);
191 mEditPage->apply(
false);
192 mMiscPage->apply(
false);
193 Preferences::syncToDisc();
197 void KAlarmPrefDlg::slotOk()
199 kdDebug(5950) <<
"KAlarmPrefDlg::slotOk()" << endl;
203 KDialogBase::slotOk();
207 void KAlarmPrefDlg::slotCancel()
209 kdDebug(5950) <<
"KAlarmPrefDlg::slotCancel()" << endl;
211 KDialogBase::slotCancel();
215 void KAlarmPrefDlg::restore()
217 kdDebug(5950) <<
"KAlarmPrefDlg::restore()" << endl;
218 mFontColourPage->restore();
219 mEmailPage->restore();
220 mViewPage->restore();
221 mEditPage->restore();
222 mMiscPage->restore();
229 int PrefsTabBase::mIndentWidth = 0;
231 PrefsTabBase::PrefsTabBase(TQVBox* frame)
236 mIndentWidth = style().subRect(TQStyle::SR_RadioButtonIndicator,
this).width();
239 void PrefsTabBase::apply(
bool syncToDisc)
241 Preferences::save(syncToDisc);
250 MiscPrefTab::MiscPrefTab(TQVBox* frame)
251 : PrefsTabBase(frame)
254 int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
256 TQGroupBox* group =
new TQButtonGroup(i18n(
"Run Mode"), mPage,
"modeGroup");
257 TQGridLayout* grid =
new TQGridLayout(group, 6, 2, KDialog::marginHint(), KDialog::spacingHint());
258 grid->setColStretch(2, 1);
259 grid->addColSpacing(0, indentWidth());
260 grid->addColSpacing(1, indentWidth());
261 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
264 mRunOnDemand =
new TQRadioButton(i18n(
"&Run only on demand"), group,
"runDemand");
265 mRunOnDemand->setFixedSize(mRunOnDemand->sizeHint());
266 connect(mRunOnDemand, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotRunModeToggled(
bool)));
267 TQWhatsThis::add(mRunOnDemand,
268 i18n(
"Check to run KAlarm only when required.\n\n"
270 "1. Alarms are displayed even when KAlarm is not running, since alarm monitoring is done by the alarm daemon.\n"
271 "2. With this option selected, the system tray icon can be displayed or hidden independently of KAlarm."));
272 grid->addMultiCellWidget(mRunOnDemand, 1, 1, 0, 2, alignment);
275 mRunInSystemTray =
new TQRadioButton(i18n(
"Run continuously in system &tray"), group,
"runTray");
276 mRunInSystemTray->setFixedSize(mRunInSystemTray->sizeHint());
277 connect(mRunInSystemTray, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotRunModeToggled(
bool)));
278 TQWhatsThis::add(mRunInSystemTray,
279 i18n(
"Check to run KAlarm continuously in the TDE system tray.\n\n"
281 "1. With this option selected, closing the system tray icon will quit KAlarm.\n"
282 "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."
283 " Running in the system tray simply provides easy access and a status indication."));
284 grid->addMultiCellWidget(mRunInSystemTray, 2, 2, 0, 2, alignment);
287 mDisableAlarmsIfStopped =
new TQCheckBox(i18n(
"Disa&ble alarms while not running"), group,
"disableAl");
288 mDisableAlarmsIfStopped->setFixedSize(mDisableAlarmsIfStopped->sizeHint());
289 connect(mDisableAlarmsIfStopped, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotDisableIfStoppedToggled(
bool)));
290 TQWhatsThis::add(mDisableAlarmsIfStopped,
291 i18n(
"Check to disable alarms whenever KAlarm is not running. Alarms will only appear while the system tray icon is visible."));
292 grid->addMultiCellWidget(mDisableAlarmsIfStopped, 3, 3, 1, 2, alignment);
294 mQuitWarn =
new TQCheckBox(i18n(
"Warn before &quitting"), group,
"disableAl");
295 mQuitWarn->setFixedSize(mQuitWarn->sizeHint());
296 TQWhatsThis::add(mQuitWarn,
297 i18n(
"Check to display a warning prompt before quitting KAlarm."));
298 grid->addWidget(mQuitWarn, 4, 2, alignment);
300 mAutostartTrayIcon =
new TQCheckBox(i18n(
"Autostart at &login"), group,
"autoTray");
301 #ifdef AUTOSTART_BY_KALARMD
302 connect(mAutostartTrayIcon, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotAutostartToggled(
bool)));
304 grid->addMultiCellWidget(mAutostartTrayIcon, 5, 5, 0, 2, alignment);
307 mAutostartDaemon =
new TQCheckBox(i18n(
"Start alarm monitoring at lo&gin"), group,
"startDaemon");
308 mAutostartDaemon->setFixedSize(mAutostartDaemon->sizeHint());
309 connect(mAutostartDaemon, TQ_SIGNAL(clicked()), TQ_SLOT(slotAutostartDaemonClicked()));
310 TQWhatsThis::add(mAutostartDaemon,
311 i18n(
"Automatically start alarm monitoring whenever you start TDE, by running the alarm daemon (%1).\n\n"
312 "This option should always be checked unless you intend to discontinue use of KAlarm.")
313 .arg(TQString::fromLatin1(DAEMON_APP_NAME)));
314 grid->addMultiCellWidget(mAutostartDaemon, 6, 6, 0, 2, alignment);
316 group->setFixedHeight(group->sizeHint().height());
319 TQHBox* itemBox =
new TQHBox(mPage);
320 TQHBox* box =
new TQHBox(itemBox);
321 box->setSpacing(KDialog::spacingHint());
322 TQLabel* label =
new TQLabel(i18n(
"&Start of day for date-only alarms:"), box);
323 mStartOfDay =
new TimeEdit(box);
324 mStartOfDay->setFixedSize(mStartOfDay->sizeHint());
325 label->setBuddy(mStartOfDay);
326 static const TQString startOfDayText = i18n(
"The earliest time of day at which a date-only alarm (i.e. "
327 "an alarm with \"any time\" specified) will be triggered.");
328 TQWhatsThis::add(box, TQString(
"%1\n\n%2").arg(startOfDayText).arg(TimeSpinBox::shiftWhatsThis()));
329 itemBox->setStretchFactor(
new TQWidget(itemBox), 1);
330 itemBox->setFixedHeight(box->sizeHint().height());
333 itemBox =
new TQHBox(mPage);
334 mConfirmAlarmDeletion =
new TQCheckBox(i18n(
"Con&firm alarm deletions"), itemBox,
"confirmDeletion");
335 mConfirmAlarmDeletion->setMinimumSize(mConfirmAlarmDeletion->sizeHint());
336 TQWhatsThis::add(mConfirmAlarmDeletion,
337 i18n(
"Check to be prompted for confirmation each time you delete an alarm."));
338 itemBox->setStretchFactor(
new TQWidget(itemBox), 1);
339 itemBox->setFixedHeight(itemBox->sizeHint().height());
342 group =
new TQGroupBox(i18n(
"Expired Alarms"), mPage);
343 grid =
new TQGridLayout(group, 2, 2, KDialog::marginHint(), KDialog::spacingHint());
344 grid->setColStretch(1, 1);
345 grid->addColSpacing(0, indentWidth());
346 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
347 mKeepExpired =
new TQCheckBox(i18n(
"Keep alarms after e&xpiry"), group,
"keepExpired");
348 mKeepExpired->setFixedSize(mKeepExpired->sizeHint());
349 connect(mKeepExpired, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotExpiredToggled(
bool)));
350 TQWhatsThis::add(mKeepExpired,
351 i18n(
"Check to store alarms after expiry or deletion (except deleted alarms which were never triggered)."));
352 grid->addMultiCellWidget(mKeepExpired, 1, 1, 0, 1, alignment);
354 box =
new TQHBox(group);
355 box->setSpacing(KDialog::spacingHint());
356 mPurgeExpired =
new TQCheckBox(i18n(
"Discard ex&pired alarms after:"), box,
"purgeExpired");
357 mPurgeExpired->setMinimumSize(mPurgeExpired->sizeHint());
358 connect(mPurgeExpired, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotExpiredToggled(
bool)));
359 mPurgeAfter =
new SpinBox(box);
360 mPurgeAfter->setMinValue(1);
361 mPurgeAfter->setLineShiftStep(10);
362 mPurgeAfter->setMinimumSize(mPurgeAfter->sizeHint());
363 mPurgeAfterLabel =
new TQLabel(i18n(
"da&ys"), box);
364 mPurgeAfterLabel->setMinimumSize(mPurgeAfterLabel->sizeHint());
365 mPurgeAfterLabel->setBuddy(mPurgeAfter);
366 TQWhatsThis::add(box,
367 i18n(
"Uncheck to store expired alarms indefinitely. Check to enter how long expired alarms should be stored."));
368 grid->addWidget(box, 2, 1, alignment);
370 mClearExpired =
new TQPushButton(i18n(
"Clear Expired Alar&ms"), group);
371 mClearExpired->setFixedSize(mClearExpired->sizeHint());
372 connect(mClearExpired, TQ_SIGNAL(clicked()), TQ_SLOT(slotClearExpired()));
373 TQWhatsThis::add(mClearExpired,
374 i18n(
"Delete all existing expired alarms."));
375 grid->addWidget(mClearExpired, 3, 1, alignment);
376 group->setFixedHeight(group->sizeHint().height());
379 group =
new TQGroupBox(i18n(
"Terminal for Command Alarms"), mPage);
380 TQWhatsThis::add(group,
381 i18n(
"Choose which application to use when a command alarm is executed in a terminal window"));
382 grid =
new TQGridLayout(group, 1, 3, KDialog::marginHint(), KDialog::spacingHint());
383 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
386 mXtermType =
new TQButtonGroup(group);
388 TQString whatsThis = i18n(
"The parameter is a command line, e.g. 'xterm -e'",
"Check to execute command alarms in a terminal window by '%1'");
391 for (mXtermCount = 0; !xtermCommands[mXtermCount].isNull(); ++mXtermCount)
393 TQString cmd = xtermCommands[mXtermCount];
394 TQStringList args = KShell::splitArgs(cmd);
395 if (args.isEmpty() || TDEStandardDirs::findExe(args[0]).isEmpty())
397 TQRadioButton* radio =
new TQRadioButton(args[0], group);
398 radio->setMinimumSize(radio->sizeHint());
399 mXtermType->insert(radio, mXtermCount);
401 mXtermFirst = mXtermCount;
402 cmd.replace(
"%t", kapp->aboutData()->programName());
403 cmd.replace(
"%c",
"<command>");
404 cmd.replace(
"%w",
"<command; sleep>");
405 cmd.replace(
"%C",
"[command]");
406 cmd.replace(
"%W",
"[command; sleep]");
407 TQWhatsThis::add(radio, whatsThis.arg(cmd));
408 grid->addWidget(radio, (row = index/3 + 1), index % 3, TQt::AlignAuto);
412 box =
new TQHBox(group);
413 grid->addMultiCellWidget(box, row + 1, row + 1, 0, 2, TQt::AlignAuto);
414 TQRadioButton* radio =
new TQRadioButton(i18n(
"Other:"), box);
415 radio->setFixedSize(radio->sizeHint());
416 connect(radio, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotOtherTerminalToggled(
bool)));
417 mXtermType->insert(radio, mXtermCount);
419 mXtermFirst = mXtermCount;
420 mXtermCommand =
new TQLineEdit(box);
421 TQWhatsThis::add(box,
422 i18n(
"Enter the full command line needed to execute a command in your chosen terminal window. "
423 "By default the alarm's command string will be appended to what you enter here. "
424 "See the KAlarm Handbook for details of special codes to tailor the command line."));
426 mPage->setStretchFactor(
new TQWidget(mPage), 1);
429 void MiscPrefTab::restore()
431 mAutostartDaemon->setChecked(Daemon::autoStart());
432 bool systray = Preferences::mRunInSystemTray;
433 mRunInSystemTray->setChecked(systray);
434 mRunOnDemand->setChecked(!systray);
435 mDisableAlarmsIfStopped->setChecked(Preferences::mDisableAlarmsIfStopped);
436 mQuitWarn->setChecked(Preferences::quitWarn());
437 mAutostartTrayIcon->setChecked(Preferences::mAutostartTrayIcon);
438 mConfirmAlarmDeletion->setChecked(Preferences::confirmAlarmDeletion());
439 mStartOfDay->setValue(Preferences::mStartOfDay);
440 setExpiredControls(Preferences::mExpiredKeepDays);
441 TQString xtermCmd = Preferences::cmdXTermCommand();
442 int id = mXtermFirst;
443 if (!xtermCmd.isEmpty())
445 for ( ;
id < mXtermCount; ++id)
447 if (mXtermType->find(
id) && xtermCmd == xtermCommands[
id])
451 mXtermType->setButton(
id);
452 mXtermCommand->setEnabled(
id == mXtermCount);
453 mXtermCommand->setText(
id == mXtermCount ? xtermCmd :
"");
454 slotDisableIfStoppedToggled(
true);
457 void MiscPrefTab::apply(
bool syncToDisc)
460 int xtermID = mXtermType->selectedId();
461 if (xtermID >= mXtermCount)
463 TQString cmd = mXtermCommand->text();
468 TQStringList args = KShell::splitArgs(cmd);
469 cmd = args.isEmpty() ? TQString() : args[0];
470 if (TDEStandardDirs::findExe(cmd).isEmpty())
472 mXtermCommand->setFocus();
473 if (KMessageBox::warningContinueCancel(
this, i18n(
"Command to invoke terminal window not found:\n%1").arg(cmd))
474 != KMessageBox::Continue)
481 xtermID = mXtermFirst;
482 mXtermType->setButton(mXtermFirst);
485 bool systray = mRunInSystemTray->isChecked();
486 Preferences::mRunInSystemTray = systray;
487 Preferences::mDisableAlarmsIfStopped = mDisableAlarmsIfStopped->isChecked();
488 if (mQuitWarn->isEnabled())
489 Preferences::setQuitWarn(mQuitWarn->isChecked());
490 Preferences::mAutostartTrayIcon = mAutostartTrayIcon->isChecked();
491 #ifdef AUTOSTART_BY_KALARMD
492 bool newAutostartDaemon = mAutostartDaemon->isChecked() || Preferences::mAutostartTrayIcon;
494 bool newAutostartDaemon = mAutostartDaemon->isChecked();
496 if (newAutostartDaemon != Daemon::autoStart())
497 Daemon::enableAutoStart(newAutostartDaemon);
498 Preferences::setConfirmAlarmDeletion(mConfirmAlarmDeletion->isChecked());
499 int sod = mStartOfDay->value();
500 Preferences::mStartOfDay.setHMS(sod/60, sod%60, 0);
501 Preferences::mExpiredKeepDays = !mKeepExpired->isChecked() ? 0
502 : mPurgeExpired->isChecked() ? mPurgeAfter->value() : -1;
503 Preferences::mCmdXTermCommand = (xtermID < mXtermCount) ? xtermCommands[xtermID] : mXtermCommand->text();
504 PrefsTabBase::apply(syncToDisc);
507 void MiscPrefTab::setDefaults()
509 mAutostartDaemon->setChecked(
true);
510 bool systray = Preferences::default_runInSystemTray;
511 mRunInSystemTray->setChecked(systray);
512 mRunOnDemand->setChecked(!systray);
513 mDisableAlarmsIfStopped->setChecked(Preferences::default_disableAlarmsIfStopped);
514 mQuitWarn->setChecked(Preferences::default_quitWarn);
515 mAutostartTrayIcon->setChecked(Preferences::default_autostartTrayIcon);
516 mConfirmAlarmDeletion->setChecked(Preferences::default_confirmAlarmDeletion);
517 mStartOfDay->setValue(Preferences::default_startOfDay);
518 setExpiredControls(Preferences::default_expiredKeepDays);
519 mXtermType->setButton(mXtermFirst);
520 mXtermCommand->setEnabled(
false);
521 slotDisableIfStoppedToggled(
true);
524 void MiscPrefTab::slotAutostartDaemonClicked()
526 if (!mAutostartDaemon->isChecked()
527 && KMessageBox::warningYesNo(
this,
528 i18n(
"You should not uncheck this option unless you intend to discontinue use of KAlarm"),
529 TQString(), KStdGuiItem::cont(), KStdGuiItem::cancel()
530 ) != KMessageBox::Yes)
531 mAutostartDaemon->setChecked(
true);
534 void MiscPrefTab::slotRunModeToggled(
bool)
536 bool systray = mRunInSystemTray->isOn();
537 mAutostartTrayIcon->setText(systray ? i18n(
"Autostart at &login") : i18n(
"Autostart system tray &icon at login"));
538 TQWhatsThis::add(mAutostartTrayIcon, (systray ? i18n(
"Check to run KAlarm whenever you start TDE.")
539 : i18n(
"Check to display the system tray icon whenever you start TDE.")));
540 mDisableAlarmsIfStopped->setEnabled(systray);
541 slotDisableIfStoppedToggled(
true);
548 void MiscPrefTab::slotAutostartToggled(
bool)
550 #ifdef AUTOSTART_BY_KALARMD
551 mAutostartDaemon->setEnabled(!mAutostartTrayIcon->isChecked());
555 void MiscPrefTab::slotDisableIfStoppedToggled(
bool)
557 bool enable = mDisableAlarmsIfStopped->isEnabled() && mDisableAlarmsIfStopped->isChecked();
558 mQuitWarn->setEnabled(enable);
561 void MiscPrefTab::setExpiredControls(
int purgeDays)
563 mKeepExpired->setChecked(purgeDays);
564 mPurgeExpired->setChecked(purgeDays > 0);
565 mPurgeAfter->setValue(purgeDays > 0 ? purgeDays : 0);
566 slotExpiredToggled(
true);
569 void MiscPrefTab::slotExpiredToggled(
bool)
571 bool keep = mKeepExpired->isChecked();
572 bool after = keep && mPurgeExpired->isChecked();
573 mPurgeExpired->setEnabled(keep);
574 mPurgeAfter->setEnabled(after);
575 mPurgeAfterLabel->setEnabled(keep);
576 mClearExpired->setEnabled(keep);
579 void MiscPrefTab::slotClearExpired()
586 void MiscPrefTab::slotOtherTerminalToggled(
bool on)
588 mXtermCommand->setEnabled(on);
596 EmailPrefTab::EmailPrefTab(TQVBox* frame)
597 : PrefsTabBase(frame),
598 mAddressChanged(false),
599 mBccAddressChanged(false)
601 TQHBox* box =
new TQHBox(mPage);
602 box->setSpacing(2*KDialog::spacingHint());
603 TQLabel* label =
new TQLabel(i18n(
"Email client:"), box);
604 mEmailClient =
new ButtonGroup(box);
605 mEmailClient->hide();
606 RadioButton* radio =
new RadioButton(i18n(
"&KMail"), box,
"kmail");
607 radio->setMinimumSize(radio->sizeHint());
608 mEmailClient->insert(radio, Preferences::KMAIL);
609 radio =
new RadioButton(i18n(
"&Sendmail"), box,
"sendmail");
610 radio->setMinimumSize(radio->sizeHint());
611 mEmailClient->insert(radio, Preferences::SENDMAIL);
612 connect(mEmailClient, TQ_SIGNAL(buttonSet(
int)), TQ_SLOT(slotEmailClientChanged(
int)));
613 box->setFixedHeight(box->sizeHint().height());
614 TQWhatsThis::add(box,
615 i18n(
"Choose how to send email when an email alarm is triggered.\n"
616 "KMail: The email is sent automatically via KMail. KMail is started first if necessary.\n"
617 "Sendmail: The email is sent automatically. This option will only work if "
618 "your system is configured to use sendmail or a sendmail compatible mail transport agent."));
620 box =
new TQHBox(mPage);
621 mEmailCopyToKMail =
new TQCheckBox(i18n(
"Co&py sent emails into KMail's %1 folder").arg(KAMail::i18n_sent_mail()), box);
622 mEmailCopyToKMail->setFixedSize(mEmailCopyToKMail->sizeHint());
623 TQWhatsThis::add(mEmailCopyToKMail,
624 i18n(
"After sending an email, store a copy in KMail's %1 folder").arg(KAMail::i18n_sent_mail()));
625 box->setStretchFactor(
new TQWidget(box), 1);
626 box->setFixedHeight(box->sizeHint().height());
629 TQGroupBox* group =
new TQGroupBox(i18n(
"Your Email Address"), mPage);
630 TQGridLayout* grid =
new TQGridLayout(group, 6, 3, KDialog::marginHint(), KDialog::spacingHint());
631 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
632 grid->setColStretch(1, 1);
635 label =
new Label(EditAlarmDlg::i18n_f_EmailFrom(), group);
636 label->setFixedSize(label->sizeHint());
637 grid->addWidget(label, 1, 0);
638 mFromAddressGroup =
new ButtonGroup(group);
639 mFromAddressGroup->hide();
640 connect(mFromAddressGroup, TQ_SIGNAL(buttonSet(
int)), TQ_SLOT(slotFromAddrChanged(
int)));
643 radio =
new RadioButton(group);
644 mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_ADDR);
645 radio->setFixedSize(radio->sizeHint());
646 label->setBuddy(radio);
647 grid->addWidget(radio, 1, 1);
648 mEmailAddress =
new TQLineEdit(group);
649 connect(mEmailAddress, TQ_SIGNAL(textChanged(
const TQString&)), TQ_SLOT(slotAddressChanged()));
650 TQString whatsThis = i18n(
"Your email address, used to identify you as the sender when sending email alarms.");
651 TQWhatsThis::add(radio, whatsThis);
652 TQWhatsThis::add(mEmailAddress, whatsThis);
653 radio->setFocusWidget(mEmailAddress);
654 grid->addWidget(mEmailAddress, 1, 2);
657 radio =
new RadioButton(i18n(
"&Use address from Control Center"), group);
658 radio->setFixedSize(radio->sizeHint());
659 mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_CONTROL_CENTRE);
660 TQWhatsThis::add(radio,
661 i18n(
"Check to use the email address set in the Trinity Control Center, to identify you as the sender when sending email alarms."));
662 grid->addMultiCellWidget(radio, 2, 2, 1, 2, TQt::AlignAuto);
665 radio =
new RadioButton(i18n(
"Use KMail &identities"), group);
666 radio->setFixedSize(radio->sizeHint());
667 mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_KMAIL);
668 TQWhatsThis::add(radio,
669 i18n(
"Check to use KMail's email identities to identify you as the sender when sending email alarms. "
670 "For existing email alarms, KMail's default identity will be used. "
671 "For new email alarms, you will be able to pick which of KMail's identities to use."));
672 grid->addMultiCellWidget(radio, 3, 3, 1, 2, TQt::AlignAuto);
675 grid->addRowSpacing(4, KDialog::spacingHint());
676 label =
new Label(i18n(
"'Bcc' email address",
"&Bcc:"), group);
677 label->setFixedSize(label->sizeHint());
678 grid->addWidget(label, 5, 0);
679 mBccAddressGroup =
new ButtonGroup(group);
680 mBccAddressGroup->hide();
681 connect(mBccAddressGroup, TQ_SIGNAL(buttonSet(
int)), TQ_SLOT(slotBccAddrChanged(
int)));
684 radio =
new RadioButton(group);
685 radio->setFixedSize(radio->sizeHint());
686 mBccAddressGroup->insert(radio, Preferences::MAIL_FROM_ADDR);
687 label->setBuddy(radio);
688 grid->addWidget(radio, 5, 1);
689 mEmailBccAddress =
new TQLineEdit(group);
690 whatsThis = i18n(
"Your email address, used for blind copying email alarms to yourself. "
691 "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.");
692 TQWhatsThis::add(radio, whatsThis);
693 TQWhatsThis::add(mEmailBccAddress, whatsThis);
694 radio->setFocusWidget(mEmailBccAddress);
695 grid->addWidget(mEmailBccAddress, 5, 2);
698 radio =
new RadioButton(i18n(
"Us&e address from Control Center"), group);
699 radio->setFixedSize(radio->sizeHint());
700 mBccAddressGroup->insert(radio, Preferences::MAIL_FROM_CONTROL_CENTRE);
701 TQWhatsThis::add(radio,
702 i18n(
"Check to use the email address set in the Trinity Control Center, for blind copying email alarms to yourself."));
703 grid->addMultiCellWidget(radio, 6, 6, 1, 2, TQt::AlignAuto);
705 group->setFixedHeight(group->sizeHint().height());
707 box =
new TQHBox(mPage);
708 mEmailQueuedNotify =
new TQCheckBox(i18n(
"&Notify when remote emails are queued"), box);
709 mEmailQueuedNotify->setFixedSize(mEmailQueuedNotify->sizeHint());
710 TQWhatsThis::add(mEmailQueuedNotify,
711 i18n(
"Display a notification message whenever an email alarm has queued an email for sending to a remote system. "
712 "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."));
713 box->setStretchFactor(
new TQWidget(box), 1);
714 box->setFixedHeight(box->sizeHint().height());
716 mPage->setStretchFactor(
new TQWidget(mPage), 1);
719 void EmailPrefTab::restore()
721 mEmailClient->setButton(Preferences::mEmailClient);
722 mEmailCopyToKMail->setChecked(Preferences::emailCopyToKMail());
723 setEmailAddress(Preferences::mEmailFrom, Preferences::mEmailAddress);
724 setEmailBccAddress((Preferences::mEmailBccFrom == Preferences::MAIL_FROM_CONTROL_CENTRE), Preferences::mEmailBccAddress);
725 mEmailQueuedNotify->setChecked(Preferences::emailQueuedNotify());
726 mAddressChanged = mBccAddressChanged =
false;
729 void EmailPrefTab::apply(
bool syncToDisc)
731 int client = mEmailClient->id(mEmailClient->selected());
732 Preferences::mEmailClient = (client >= 0) ? Preferences::MailClient(client) : Preferences::default_emailClient;
733 Preferences::mEmailCopyToKMail = mEmailCopyToKMail->isChecked();
734 Preferences::setEmailAddress(
static_cast<Preferences::MailFrom
>(mFromAddressGroup->selectedId()), mEmailAddress->text().stripWhiteSpace());
735 Preferences::setEmailBccAddress((mBccAddressGroup->selectedId() == Preferences::MAIL_FROM_CONTROL_CENTRE), mEmailBccAddress->text().stripWhiteSpace());
736 Preferences::setEmailQueuedNotify(mEmailQueuedNotify->isChecked());
737 PrefsTabBase::apply(syncToDisc);
740 void EmailPrefTab::setDefaults()
742 mEmailClient->setButton(Preferences::default_emailClient);
743 setEmailAddress(Preferences::default_emailFrom(), Preferences::default_emailAddress);
744 setEmailBccAddress((Preferences::default_emailBccFrom == Preferences::MAIL_FROM_CONTROL_CENTRE), Preferences::default_emailBccAddress);
745 mEmailQueuedNotify->setChecked(Preferences::default_emailQueuedNotify);
748 void EmailPrefTab::setEmailAddress(Preferences::MailFrom from,
const TQString& address)
750 mFromAddressGroup->setButton(from);
751 mEmailAddress->setText(from == Preferences::MAIL_FROM_ADDR ? address.stripWhiteSpace() : TQString());
754 void EmailPrefTab::setEmailBccAddress(
bool useControlCentre,
const TQString& address)
756 mBccAddressGroup->setButton(useControlCentre ? Preferences::MAIL_FROM_CONTROL_CENTRE : Preferences::MAIL_FROM_ADDR);
757 mEmailBccAddress->setText(useControlCentre ? TQString() : address.stripWhiteSpace());
760 void EmailPrefTab::slotEmailClientChanged(
int id)
762 mEmailCopyToKMail->setEnabled(
id == Preferences::SENDMAIL);
765 void EmailPrefTab::slotFromAddrChanged(
int id)
767 mEmailAddress->setEnabled(
id == Preferences::MAIL_FROM_ADDR);
768 mAddressChanged =
true;
771 void EmailPrefTab::slotBccAddrChanged(
int id)
773 mEmailBccAddress->setEnabled(
id == Preferences::MAIL_FROM_ADDR);
774 mBccAddressChanged =
true;
777 TQString EmailPrefTab::validate()
781 mAddressChanged =
false;
782 TQString errmsg = validateAddr(mFromAddressGroup, mEmailAddress, KAMail::i18n_NeedFromEmailAddress());
783 if (!errmsg.isEmpty())
786 if (mBccAddressChanged)
788 mBccAddressChanged =
false;
789 return validateAddr(mBccAddressGroup, mEmailBccAddress, i18n(
"No valid 'Bcc' email address is specified."));
794 TQString EmailPrefTab::validateAddr(ButtonGroup* group, TQLineEdit* addr,
const TQString& msg)
796 TQString errmsg = i18n(
"%1\nAre you sure you want to save your changes?").arg(msg);
797 switch (group->selectedId())
799 case Preferences::MAIL_FROM_CONTROL_CENTRE:
800 if (!KAMail::controlCentreAddress().isEmpty())
802 errmsg = i18n(
"No email address is currently set in the Trinity Control Center. %1").arg(errmsg);
804 case Preferences::MAIL_FROM_KMAIL:
805 if (KAMail::identitiesExist())
807 errmsg = i18n(
"No KMail identities currently exist. %1").arg(errmsg);
809 case Preferences::MAIL_FROM_ADDR:
810 if (!addr->text().stripWhiteSpace().isEmpty())
822 FontColourPrefTab::FontColourPrefTab(TQVBox* frame)
823 : PrefsTabBase(frame)
825 mFontChooser =
new FontColourChooser(mPage, 0,
false, TQStringList(), i18n(
"Message Font && Color"),
true,
false);
826 mPage->setStretchFactor(mFontChooser, 1);
828 TQFrame* layoutBox =
new TQFrame(mPage);
829 TQHBoxLayout* hlayout =
new TQHBoxLayout(layoutBox);
830 TQVBoxLayout* colourLayout =
new TQVBoxLayout(hlayout, KDialog::spacingHint());
831 hlayout->addStretch();
833 TQHBox* box =
new TQHBox(layoutBox);
834 box->setSpacing(KDialog::spacingHint()/2);
835 colourLayout->addWidget(box);
836 TQLabel* label1 =
new TQLabel(i18n(
"Di&sabled alarm color:"), box);
837 box->setStretchFactor(
new TQWidget(box), 1);
838 mDisabledColour =
new KColorCombo(box);
839 label1->setBuddy(mDisabledColour);
840 TQWhatsThis::add(box,
841 i18n(
"Choose the text color in the alarm list for disabled alarms."));
843 box =
new TQHBox(layoutBox);
844 box->setSpacing(KDialog::spacingHint()/2);
845 colourLayout->addWidget(box);
846 TQLabel* label2 =
new TQLabel(i18n(
"E&xpired alarm color:"), box);
847 box->setStretchFactor(
new TQWidget(box), 1);
848 mExpiredColour =
new KColorCombo(box);
849 label2->setBuddy(mExpiredColour);
850 TQWhatsThis::add(box,
851 i18n(
"Choose the text color in the alarm list for expired alarms."));
854 void FontColourPrefTab::restore()
856 mFontChooser->setBgColour(Preferences::mDefaultBgColour);
857 mFontChooser->setColours(Preferences::mMessageColours);
858 mFontChooser->setFont(Preferences::mMessageFont);
859 mDisabledColour->setColor(Preferences::mDisabledColour);
860 mExpiredColour->setColor(Preferences::mExpiredColour);
863 void FontColourPrefTab::apply(
bool syncToDisc)
865 Preferences::mDefaultBgColour = mFontChooser->bgColour();
866 Preferences::mMessageColours = mFontChooser->colours();
867 Preferences::mMessageFont = mFontChooser->font();
868 Preferences::mDisabledColour = mDisabledColour->color();
869 Preferences::mExpiredColour = mExpiredColour->color();
870 PrefsTabBase::apply(syncToDisc);
873 void FontColourPrefTab::setDefaults()
875 mFontChooser->setBgColour(Preferences::default_defaultBgColour);
876 mFontChooser->setColours(Preferences::default_messageColours);
877 mFontChooser->setFont(Preferences::default_messageFont());
878 mDisabledColour->setColor(Preferences::default_disabledColour);
879 mExpiredColour->setColor(Preferences::default_expiredColour);
887 EditPrefTab::EditPrefTab(TQVBox* frame)
888 : PrefsTabBase(frame)
892 int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
894 int groupTopMargin = fontMetrics().lineSpacing()/2;
895 TQString defsetting = i18n(
"The default setting for \"%1\" in the alarm edit dialog.");
896 TQString soundSetting = i18n(
"Check to select %1 as the default setting for \"%2\" in the alarm edit dialog.");
899 TQGroupBox* group =
new TQGroupBox(i18n(
"Display Alarms"), mPage);
900 TQBoxLayout* layout =
new TQVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
901 layout->addSpacing(groupTopMargin);
903 mConfirmAck =
new TQCheckBox(EditAlarmDlg::i18n_k_ConfirmAck(), group,
"defConfAck");
904 mConfirmAck->setMinimumSize(mConfirmAck->sizeHint());
905 TQWhatsThis::add(mConfirmAck, defsetting.arg(EditAlarmDlg::i18n_ConfirmAck()));
906 layout->addWidget(mConfirmAck, 0, TQt::AlignAuto);
908 mAutoClose =
new TQCheckBox(LateCancelSelector::i18n_i_AutoCloseWinLC(), group,
"defAutoClose");
909 mAutoClose->setMinimumSize(mAutoClose->sizeHint());
910 TQWhatsThis::add(mAutoClose, defsetting.arg(LateCancelSelector::i18n_AutoCloseWin()));
911 layout->addWidget(mAutoClose, 0, TQt::AlignAuto);
913 TQHBox* box =
new TQHBox(group);
914 box->setSpacing(KDialog::spacingHint());
915 layout->addWidget(box);
916 TQLabel* label =
new TQLabel(i18n(
"Reminder &units:"), box);
917 label->setFixedSize(label->sizeHint());
918 mReminderUnits =
new TQComboBox(box,
"defWarnUnits");
919 mReminderUnits->insertItem(TimePeriod::i18n_Minutes(), TimePeriod::MINUTES);
920 mReminderUnits->insertItem(TimePeriod::i18n_Hours_Mins(), TimePeriod::HOURS_MINUTES);
921 mReminderUnits->insertItem(TimePeriod::i18n_Days(), TimePeriod::DAYS);
922 mReminderUnits->insertItem(TimePeriod::i18n_Weeks(), TimePeriod::WEEKS);
923 mReminderUnits->setFixedSize(mReminderUnits->sizeHint());
924 label->setBuddy(mReminderUnits);
925 TQWhatsThis::add(box,
926 i18n(
"The default units for the reminder in the alarm edit dialog."));
927 box->setStretchFactor(
new TQWidget(box), 1);
929 mSpecialActionsButton =
new SpecialActionsButton(EditAlarmDlg::i18n_SpecialActions(), box);
930 mSpecialActionsButton->setFixedSize(mSpecialActionsButton->sizeHint());
933 TQButtonGroup* bgroup =
new TQButtonGroup(SoundPicker::i18n_Sound(), mPage,
"soundGroup");
934 layout =
new TQVBoxLayout(bgroup, KDialog::marginHint(), KDialog::spacingHint());
935 layout->addSpacing(groupTopMargin);
937 TQBoxLayout* hlayout =
new TQHBoxLayout(layout, KDialog::spacingHint());
938 mSound =
new TQComboBox(
false, bgroup,
"defSound");
939 mSound->insertItem(SoundPicker::i18n_None());
940 mSound->insertItem(SoundPicker::i18n_Beep());
941 mSound->insertItem(SoundPicker::i18n_File());
942 if (theApp()->speechEnabled())
943 mSound->insertItem(SoundPicker::i18n_Speak());
944 mSound->setMinimumSize(mSound->sizeHint());
945 TQWhatsThis::add(mSound, defsetting.arg(SoundPicker::i18n_Sound()));
946 hlayout->addWidget(mSound);
947 hlayout->addStretch(1);
950 mSoundRepeat =
new TQCheckBox(i18n(
"Repea&t sound file"), bgroup,
"defRepeatSound");
951 mSoundRepeat->setMinimumSize(mSoundRepeat->sizeHint());
952 TQWhatsThis::add(mSoundRepeat, i18n(
"sound file \"Repeat\" checkbox",
"The default setting for sound file \"%1\" in the alarm edit dialog.").arg(SoundDlg::i18n_Repeat()));
953 hlayout->addWidget(mSoundRepeat);
956 box =
new TQHBox(bgroup);
957 box->setSpacing(KDialog::spacingHint());
958 mSoundFileLabel =
new TQLabel(i18n(
"Sound &file:"), box);
959 mSoundFileLabel->setFixedSize(mSoundFileLabel->sizeHint());
960 mSoundFile =
new TQLineEdit(box);
961 mSoundFileLabel->setBuddy(mSoundFile);
962 mSoundFileBrowse =
new TQPushButton(box);
963 mSoundFileBrowse->setPixmap(SmallIcon(
"document-open"));
964 mSoundFileBrowse->setFixedSize(mSoundFileBrowse->sizeHint());
965 connect(mSoundFileBrowse, TQ_SIGNAL(clicked()), TQ_SLOT(slotBrowseSoundFile()));
966 TQToolTip::add(mSoundFileBrowse, i18n(
"Choose a sound file"));
967 TQWhatsThis::add(box,
968 i18n(
"Enter the default sound file to use in the alarm edit dialog."));
969 box->setFixedHeight(box->sizeHint().height());
970 layout->addWidget(box);
971 bgroup->setFixedHeight(bgroup->sizeHint().height());
974 group =
new TQGroupBox(i18n(
"Command Alarms"), mPage);
975 layout =
new TQVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
976 layout->addSpacing(groupTopMargin);
977 layout =
new TQHBoxLayout(layout, KDialog::spacingHint());
979 mCmdScript =
new TQCheckBox(EditAlarmDlg::i18n_p_EnterScript(), group,
"defCmdScript");
980 mCmdScript->setMinimumSize(mCmdScript->sizeHint());
981 TQWhatsThis::add(mCmdScript, defsetting.arg(EditAlarmDlg::i18n_EnterScript()));
982 layout->addWidget(mCmdScript);
983 layout->addStretch();
985 mCmdXterm =
new TQCheckBox(EditAlarmDlg::i18n_w_ExecInTermWindow(), group,
"defCmdXterm");
986 mCmdXterm->setMinimumSize(mCmdXterm->sizeHint());
987 TQWhatsThis::add(mCmdXterm, defsetting.arg(EditAlarmDlg::i18n_ExecInTermWindow()));
988 layout->addWidget(mCmdXterm);
991 group =
new TQGroupBox(i18n(
"Email Alarms"), mPage);
992 layout =
new TQVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
993 layout->addSpacing(groupTopMargin);
996 mEmailBcc =
new TQCheckBox(EditAlarmDlg::i18n_e_CopyEmailToSelf(), group,
"defEmailBcc");
997 mEmailBcc->setMinimumSize(mEmailBcc->sizeHint());
998 TQWhatsThis::add(mEmailBcc, defsetting.arg(EditAlarmDlg::i18n_CopyEmailToSelf()));
999 layout->addWidget(mEmailBcc, 0, TQt::AlignAuto);
1003 mCopyToKOrganizer =
new TQCheckBox(EditAlarmDlg::i18n_g_ShowInKOrganizer(), mPage,
"defShowKorg");
1004 mCopyToKOrganizer->setMinimumSize(mCopyToKOrganizer->sizeHint());
1005 TQWhatsThis::add(mCopyToKOrganizer, defsetting.arg(EditAlarmDlg::i18n_ShowInKOrganizer()));
1008 box =
new TQHBox(mPage);
1009 box->setSpacing(KDialog::spacingHint());
1010 mLateCancel =
new TQCheckBox(LateCancelSelector::i18n_n_CancelIfLate(), box,
"defCancelLate");
1011 mLateCancel->setMinimumSize(mLateCancel->sizeHint());
1012 TQWhatsThis::add(mLateCancel, defsetting.arg(LateCancelSelector::i18n_CancelIfLate()));
1013 box->setStretchFactor(
new TQWidget(box), 1);
1016 TQHBox* itemBox =
new TQHBox(box);
1017 itemBox->setSpacing(KDialog::spacingHint());
1018 label =
new TQLabel(i18n(
"&Recurrence:"), itemBox);
1019 label->setFixedSize(label->sizeHint());
1020 mRecurPeriod =
new TQComboBox(itemBox,
"defRecur");
1021 mRecurPeriod->insertItem(RecurrenceEdit::i18n_NoRecur());
1022 mRecurPeriod->insertItem(RecurrenceEdit::i18n_AtLogin());
1023 mRecurPeriod->insertItem(RecurrenceEdit::i18n_HourlyMinutely());
1024 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Daily());
1025 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Weekly());
1026 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Monthly());
1027 mRecurPeriod->insertItem(RecurrenceEdit::i18n_Yearly());
1028 mRecurPeriod->setFixedSize(mRecurPeriod->sizeHint());
1029 label->setBuddy(mRecurPeriod);
1030 TQWhatsThis::add(itemBox,
1031 i18n(
"The default setting for the recurrence rule in the alarm edit dialog."));
1032 box->setFixedHeight(itemBox->sizeHint().height());
1035 TQVBox* vbox =
new TQVBox(mPage);
1036 vbox->setSpacing(KDialog::spacingHint());
1037 label =
new TQLabel(i18n(
"In non-leap years, repeat yearly February 29th alarms on:"), vbox);
1038 label->setAlignment(alignment | TQt::WordBreak);
1039 itemBox =
new TQHBox(vbox);
1040 itemBox->setSpacing(2*KDialog::spacingHint());
1041 mFeb29 =
new TQButtonGroup(itemBox);
1043 TQWidget* widget =
new TQWidget(itemBox);
1044 widget->setFixedWidth(3*KDialog::spacingHint());
1045 TQRadioButton* radio =
new TQRadioButton(i18n(
"February 2&8th"), itemBox);
1046 radio->setMinimumSize(radio->sizeHint());
1047 mFeb29->insert(radio, KARecurrence::FEB29_FEB28);
1048 radio =
new TQRadioButton(i18n(
"March &1st"), itemBox);
1049 radio->setMinimumSize(radio->sizeHint());
1050 mFeb29->insert(radio, KARecurrence::FEB29_MAR1);
1051 radio =
new TQRadioButton(i18n(
"Do ¬ repeat"), itemBox);
1052 radio->setMinimumSize(radio->sizeHint());
1053 mFeb29->insert(radio, KARecurrence::FEB29_FEB29);
1054 itemBox->setFixedHeight(itemBox->sizeHint().height());
1055 TQWhatsThis::add(vbox,
1056 i18n(
"For yearly recurrences, choose what date, if any, alarms due on February 29th should occur in non-leap years.\n"
1057 "Note that the next scheduled occurrence of existing alarms is not re-evaluated when you change this setting."));
1059 mPage->setStretchFactor(
new TQWidget(mPage), 1);
1062 void EditPrefTab::restore()
1064 mAutoClose->setChecked(Preferences::mDefaultAutoClose);
1065 mConfirmAck->setChecked(Preferences::mDefaultConfirmAck);
1066 mReminderUnits->setCurrentItem(Preferences::mDefaultReminderUnits);
1067 mSpecialActionsButton->setActions(Preferences::mDefaultPreAction, Preferences::mDefaultPostAction);
1068 mSound->setCurrentItem(soundIndex(Preferences::mDefaultSoundType));
1069 mSoundFile->setText(Preferences::mDefaultSoundFile);
1070 #ifndef WITHOUT_ARTS
1071 mSoundRepeat->setChecked(Preferences::mDefaultSoundRepeat);
1073 mCmdScript->setChecked(Preferences::mDefaultCmdScript);
1074 mCmdXterm->setChecked(Preferences::mDefaultCmdLogType == EditAlarmDlg::EXEC_IN_TERMINAL);
1075 mEmailBcc->setChecked(Preferences::mDefaultEmailBcc);
1076 mCopyToKOrganizer->setChecked(Preferences::mDefaultCopyToKOrganizer);
1077 mLateCancel->setChecked(Preferences::mDefaultLateCancel);
1078 mRecurPeriod->setCurrentItem(recurIndex(Preferences::mDefaultRecurPeriod));
1079 mFeb29->setButton(Preferences::mDefaultFeb29Type);
1082 void EditPrefTab::apply(
bool syncToDisc)
1084 Preferences::mDefaultAutoClose = mAutoClose->isChecked();
1085 Preferences::mDefaultConfirmAck = mConfirmAck->isChecked();
1086 Preferences::mDefaultReminderUnits =
static_cast<TimePeriod::Units
>(mReminderUnits->currentItem());
1087 Preferences::mDefaultPreAction = mSpecialActionsButton->preAction();
1088 Preferences::mDefaultPostAction = mSpecialActionsButton->postAction();
1089 switch (mSound->currentItem())
1091 case 3: Preferences::mDefaultSoundType = SoundPicker::SPEAK;
break;
1092 case 2: Preferences::mDefaultSoundType = SoundPicker::PLAY_FILE;
break;
1093 case 1: Preferences::mDefaultSoundType = SoundPicker::BEEP;
break;
1095 default: Preferences::mDefaultSoundType = SoundPicker::NONE;
break;
1097 Preferences::mDefaultSoundFile = mSoundFile->text();
1098 #ifndef WITHOUT_ARTS
1099 Preferences::mDefaultSoundRepeat = mSoundRepeat->isChecked();
1101 Preferences::mDefaultCmdScript = mCmdScript->isChecked();
1102 Preferences::mDefaultCmdLogType = (mCmdXterm->isChecked() ? EditAlarmDlg::EXEC_IN_TERMINAL : EditAlarmDlg::DISCARD_OUTPUT);
1103 Preferences::mDefaultEmailBcc = mEmailBcc->isChecked();
1104 Preferences::mDefaultCopyToKOrganizer = mCopyToKOrganizer->isChecked();
1105 Preferences::mDefaultLateCancel = mLateCancel->isChecked() ? 1 : 0;
1106 switch (mRecurPeriod->currentItem())
1108 case 6: Preferences::mDefaultRecurPeriod = RecurrenceEdit::ANNUAL;
break;
1109 case 5: Preferences::mDefaultRecurPeriod = RecurrenceEdit::MONTHLY;
break;
1110 case 4: Preferences::mDefaultRecurPeriod = RecurrenceEdit::WEEKLY;
break;
1111 case 3: Preferences::mDefaultRecurPeriod = RecurrenceEdit::DAILY;
break;
1112 case 2: Preferences::mDefaultRecurPeriod = RecurrenceEdit::SUBDAILY;
break;
1113 case 1: Preferences::mDefaultRecurPeriod = RecurrenceEdit::AT_LOGIN;
break;
1115 default: Preferences::mDefaultRecurPeriod = RecurrenceEdit::NO_RECUR;
break;
1117 int feb29 = mFeb29->selectedId();
1118 Preferences::mDefaultFeb29Type = (feb29 >= 0) ?
static_cast<KARecurrence::Feb29Type
>(feb29) : Preferences::default_defaultFeb29Type;
1119 PrefsTabBase::apply(syncToDisc);
1122 void EditPrefTab::setDefaults()
1124 mAutoClose->setChecked(Preferences::default_defaultAutoClose);
1125 mConfirmAck->setChecked(Preferences::default_defaultConfirmAck);
1126 mReminderUnits->setCurrentItem(Preferences::default_defaultReminderUnits);
1127 mSpecialActionsButton->setActions(Preferences::default_defaultPreAction, Preferences::default_defaultPostAction);
1128 mSound->setCurrentItem(soundIndex(Preferences::default_defaultSoundType));
1129 mSoundFile->setText(Preferences::default_defaultSoundFile);
1130 #ifndef WITHOUT_ARTS
1131 mSoundRepeat->setChecked(Preferences::default_defaultSoundRepeat);
1133 mCmdScript->setChecked(Preferences::default_defaultCmdScript);
1134 mCmdXterm->setChecked(Preferences::default_defaultCmdLogType == EditAlarmDlg::EXEC_IN_TERMINAL);
1135 mEmailBcc->setChecked(Preferences::default_defaultEmailBcc);
1136 mCopyToKOrganizer->setChecked(Preferences::default_defaultCopyToKOrganizer);
1137 mLateCancel->setChecked(Preferences::default_defaultLateCancel);
1138 mRecurPeriod->setCurrentItem(recurIndex(Preferences::default_defaultRecurPeriod));
1139 mFeb29->setButton(Preferences::default_defaultFeb29Type);
1142 void EditPrefTab::slotBrowseSoundFile()
1144 TQString defaultDir;
1145 TQString url = SoundPicker::browseFile(defaultDir, mSoundFile->text());
1147 mSoundFile->setText(url);
1150 int EditPrefTab::soundIndex(SoundPicker::Type type)
1154 case SoundPicker::SPEAK:
return 3;
1155 case SoundPicker::PLAY_FILE:
return 2;
1156 case SoundPicker::BEEP:
return 1;
1157 case SoundPicker::NONE:
1162 int EditPrefTab::recurIndex(RecurrenceEdit::RepeatType type)
1166 case RecurrenceEdit::ANNUAL:
return 6;
1167 case RecurrenceEdit::MONTHLY:
return 5;
1168 case RecurrenceEdit::WEEKLY:
return 4;
1169 case RecurrenceEdit::DAILY:
return 3;
1170 case RecurrenceEdit::SUBDAILY:
return 2;
1171 case RecurrenceEdit::AT_LOGIN:
return 1;
1172 case RecurrenceEdit::NO_RECUR:
1177 TQString EditPrefTab::validate()
1179 if (mSound->currentItem() == SoundPicker::PLAY_FILE && mSoundFile->text().isEmpty())
1181 mSoundFile->setFocus();
1182 return i18n(
"You must enter a sound file when %1 is selected as the default sound type").arg(SoundPicker::i18n_File());;
1192 ViewPrefTab::ViewPrefTab(TQVBox* frame)
1193 : PrefsTabBase(frame)
1195 TQGroupBox* group =
new TQGroupBox(i18n(
"System Tray Tooltip"), mPage);
1196 TQGridLayout* grid =
new TQGridLayout(group, 5, 3, KDialog::marginHint(), KDialog::spacingHint());
1197 grid->setColStretch(2, 1);
1198 grid->addColSpacing(0, indentWidth());
1199 grid->addColSpacing(1, indentWidth());
1200 grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
1202 mTooltipShowAlarms =
new TQCheckBox(i18n(
"Show next &24 hours' alarms"), group,
"tooltipShow");
1203 mTooltipShowAlarms->setMinimumSize(mTooltipShowAlarms->sizeHint());
1204 connect(mTooltipShowAlarms, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotTooltipAlarmsToggled(
bool)));
1205 TQWhatsThis::add(mTooltipShowAlarms,
1206 i18n(
"Specify whether to include in the system tray tooltip, a summary of alarms due in the next 24 hours"));
1207 grid->addMultiCellWidget(mTooltipShowAlarms, 1, 1, 0, 2, TQt::AlignAuto);
1209 TQHBox* box =
new TQHBox(group);
1210 box->setSpacing(KDialog::spacingHint());
1211 mTooltipMaxAlarms =
new TQCheckBox(i18n(
"Ma&ximum number of alarms to show:"), box,
"tooltipMax");
1212 mTooltipMaxAlarms->setMinimumSize(mTooltipMaxAlarms->sizeHint());
1213 connect(mTooltipMaxAlarms, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotTooltipMaxToggled(
bool)));
1214 mTooltipMaxAlarmCount =
new SpinBox(1, 99, 1, box);
1215 mTooltipMaxAlarmCount->setLineShiftStep(5);
1216 mTooltipMaxAlarmCount->setMinimumSize(mTooltipMaxAlarmCount->sizeHint());
1217 TQWhatsThis::add(box,
1218 i18n(
"Uncheck to display all of the next 24 hours' alarms in the system tray tooltip. "
1219 "Check to enter an upper limit on the number to be displayed."));
1220 grid->addMultiCellWidget(box, 2, 2, 1, 2, TQt::AlignAuto);
1222 mTooltipShowTime =
new TQCheckBox(MainWindow::i18n_m_ShowAlarmTime(), group,
"tooltipTime");
1223 mTooltipShowTime->setMinimumSize(mTooltipShowTime->sizeHint());
1224 connect(mTooltipShowTime, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotTooltipTimeToggled(
bool)));
1225 TQWhatsThis::add(mTooltipShowTime,
1226 i18n(
"Specify whether to show in the system tray tooltip, the time at which each alarm is due"));
1227 grid->addMultiCellWidget(mTooltipShowTime, 3, 3, 1, 2, TQt::AlignAuto);
1229 mTooltipShowTimeTo =
new TQCheckBox(MainWindow::i18n_l_ShowTimeToAlarm(), group,
"tooltipTimeTo");
1230 mTooltipShowTimeTo->setMinimumSize(mTooltipShowTimeTo->sizeHint());
1231 connect(mTooltipShowTimeTo, TQ_SIGNAL(toggled(
bool)), TQ_SLOT(slotTooltipTimeToToggled(
bool)));
1232 TQWhatsThis::add(mTooltipShowTimeTo,
1233 i18n(
"Specify whether to show in the system tray tooltip, how long until each alarm is due"));
1234 grid->addMultiCellWidget(mTooltipShowTimeTo, 4, 4, 1, 2, TQt::AlignAuto);
1236 box =
new TQHBox(group);
1237 box->setSpacing(KDialog::spacingHint());
1238 mTooltipTimeToPrefixLabel =
new TQLabel(i18n(
"&Prefix:"), box);
1239 mTooltipTimeToPrefixLabel->setFixedSize(mTooltipTimeToPrefixLabel->sizeHint());
1240 mTooltipTimeToPrefix =
new TQLineEdit(box);
1241 mTooltipTimeToPrefixLabel->setBuddy(mTooltipTimeToPrefix);
1242 TQWhatsThis::add(box,
1243 i18n(
"Enter the text to be displayed in front of the time until the alarm, in the system tray tooltip"));
1244 box->setFixedHeight(box->sizeHint().height());
1245 grid->addWidget(box, 5, 2, TQt::AlignAuto);
1246 group->setMaximumHeight(group->sizeHint().height());
1248 mModalMessages =
new TQCheckBox(i18n(
"Message &windows have a title bar and take keyboard focus"), mPage,
"modalMsg");
1249 mModalMessages->setMinimumSize(mModalMessages->sizeHint());
1250 TQWhatsThis::add(mModalMessages,
1251 i18n(
"Specify the characteristics of alarm message windows:\n"
1252 "- If checked, the window is a normal window with a title bar, which grabs keyboard input when it is displayed.\n"
1253 "- If unchecked, the window does not interfere with your typing when "
1254 "it is displayed, but it has no title bar and cannot be moved or resized."));
1256 TQHBox* itemBox =
new TQHBox(mPage);
1257 box =
new TQHBox(itemBox);
1258 box->setSpacing(KDialog::spacingHint());
1259 TQLabel* label =
new TQLabel(i18n(
"System tray icon &update interval:"), box);
1260 mDaemonTrayCheckInterval =
new SpinBox(1, 9999, 1, box,
"daemonCheck");
1261 mDaemonTrayCheckInterval->setLineShiftStep(10);
1262 mDaemonTrayCheckInterval->setMinimumSize(mDaemonTrayCheckInterval->sizeHint());
1263 label->setBuddy(mDaemonTrayCheckInterval);
1264 label =
new TQLabel(i18n(
"seconds"), box);
1265 TQWhatsThis::add(box,
1266 i18n(
"How often to update the system tray icon to indicate whether or not the Alarm Daemon is monitoring alarms."));
1267 itemBox->setStretchFactor(
new TQWidget(itemBox), 1);
1268 itemBox->setFixedHeight(box->sizeHint().height());
1270 mPage->setStretchFactor(
new TQWidget(mPage), 1);
1273 void ViewPrefTab::restore()
1275 setTooltip(Preferences::mTooltipAlarmCount,
1276 Preferences::mShowTooltipAlarmTime,
1277 Preferences::mShowTooltipTimeToAlarm,
1278 Preferences::mTooltipTimeToPrefix);
1279 mModalMessages->setChecked(Preferences::mModalMessages);
1280 mDaemonTrayCheckInterval->setValue(Preferences::mDaemonTrayCheckInterval);
1283 void ViewPrefTab::apply(
bool syncToDisc)
1285 int n = mTooltipShowAlarms->isChecked() ? -1 : 0;
1286 if (n && mTooltipMaxAlarms->isChecked())
1287 n = mTooltipMaxAlarmCount->value();
1288 Preferences::mTooltipAlarmCount = n;
1289 Preferences::mShowTooltipAlarmTime = mTooltipShowTime->isChecked();
1290 Preferences::mShowTooltipTimeToAlarm = mTooltipShowTimeTo->isChecked();
1291 Preferences::mTooltipTimeToPrefix = mTooltipTimeToPrefix->text();
1292 Preferences::mModalMessages = mModalMessages->isChecked();
1293 Preferences::mDaemonTrayCheckInterval = mDaemonTrayCheckInterval->value();
1294 PrefsTabBase::apply(syncToDisc);
1297 void ViewPrefTab::setDefaults()
1299 setTooltip(Preferences::default_tooltipAlarmCount,
1300 Preferences::default_showTooltipAlarmTime,
1301 Preferences::default_showTooltipTimeToAlarm,
1302 Preferences::default_tooltipTimeToPrefix);
1303 mModalMessages->setChecked(Preferences::default_modalMessages);
1304 mDaemonTrayCheckInterval->setValue(Preferences::default_daemonTrayCheckInterval);
1307 void ViewPrefTab::setTooltip(
int maxAlarms,
bool time,
bool timeTo,
const TQString& prefix)
1314 mTooltipShowAlarms->blockSignals(
true);
1315 mTooltipShowTime->blockSignals(
true);
1316 mTooltipShowTimeTo->blockSignals(
true);
1318 mTooltipShowAlarms->setChecked(maxAlarms);
1319 mTooltipMaxAlarms->setChecked(maxAlarms > 0);
1320 mTooltipMaxAlarmCount->setValue(maxAlarms > 0 ? maxAlarms : 1);
1321 mTooltipShowTime->setChecked(time);
1322 mTooltipShowTimeTo->setChecked(timeTo);
1323 mTooltipTimeToPrefix->setText(prefix);
1325 mTooltipShowAlarms->blockSignals(
false);
1326 mTooltipShowTime->blockSignals(
false);
1327 mTooltipShowTimeTo->blockSignals(
false);
1330 slotTooltipTimeToToggled(timeTo);
1331 slotTooltipAlarmsToggled(maxAlarms);
1334 void ViewPrefTab::slotTooltipAlarmsToggled(
bool on)
1336 mTooltipMaxAlarms->setEnabled(on);
1337 mTooltipMaxAlarmCount->setEnabled(on && mTooltipMaxAlarms->isChecked());
1338 mTooltipShowTime->setEnabled(on);
1339 mTooltipShowTimeTo->setEnabled(on);
1340 on = on && mTooltipShowTimeTo->isChecked();
1341 mTooltipTimeToPrefix->setEnabled(on);
1342 mTooltipTimeToPrefixLabel->setEnabled(on);
1345 void ViewPrefTab::slotTooltipMaxToggled(
bool on)
1347 mTooltipMaxAlarmCount->setEnabled(on && mTooltipMaxAlarms->isEnabled());
1350 void ViewPrefTab::slotTooltipTimeToggled(
bool on)
1352 if (!on && !mTooltipShowTimeTo->isChecked())
1353 mTooltipShowTimeTo->setChecked(
true);
1356 void ViewPrefTab::slotTooltipTimeToToggled(
bool on)
1358 if (!on && !mTooltipShowTime->isChecked())
1359 mTooltipShowTime->setChecked(
true);
1360 on = on && mTooltipShowTimeTo->isEnabled();
1361 mTooltipTimeToPrefix->setEnabled(on);
1362 mTooltipTimeToPrefixLabel->setEnabled(on);
Provides read and write access to calendar files.
the KAlarm application object