kalarm

prefdlg.cpp
00001 /*
00002  *  prefdlg.cpp  -  program preferences dialog
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2008 by David Jarvie <djarvie@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #include "kalarm.h"
00022 
00023 #include <tqobjectlist.h>
00024 #include <tqlayout.h>
00025 #include <tqbuttongroup.h>
00026 #include <tqvbox.h>
00027 #include <tqlineedit.h>
00028 #include <tqcheckbox.h>
00029 #include <tqradiobutton.h>
00030 #include <tqpushbutton.h>
00031 #include <tqcombobox.h>
00032 #include <tqwhatsthis.h>
00033 #include <tqtooltip.h>
00034 #include <tqstyle.h>
00035 
00036 #include <tdeglobal.h>
00037 #include <tdelocale.h>
00038 #include <kstandarddirs.h>
00039 #include <kshell.h>
00040 #include <tdemessagebox.h>
00041 #include <tdeaboutdata.h>
00042 #include <tdeapplication.h>
00043 #include <kiconloader.h>
00044 #include <kcolorcombo.h>
00045 #include <kstdguiitem.h>
00046 #ifdef TQ_WS_X11
00047 #include <twin.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 // Command strings for executing commands in different types of terminal windows.
00078 // %t = window title parameter
00079 // %c = command to execute in terminal
00080 // %w = command to execute in terminal, with 'sleep 86400' appended
00081 // %C = temporary command file to execute in terminal
00082 // %W = temporary command file to execute in terminal, with 'sleep 86400' appended
00083 static TQString xtermCommands[] = {
00084     TQString::fromLatin1("xterm -sb -hold -title %t -e %c"),
00085     TQString::fromLatin1("konsole --noclose -T %t -e ${SHELL:-sh} -c %c"),
00086     TQString::fromLatin1("gnome-terminal -t %t -e %W"),
00087     TQString::fromLatin1("eterm --pause -T %t -e %C"),    // some systems use eterm...
00088     TQString::fromLatin1("Eterm --pause -T %t -e %C"),    // while some use Eterm
00089     TQString::fromLatin1("rxvt -title %t -e ${SHELL:-sh} -c %w"),
00090     TQString()       // end of list indicator - don't change!
00091 };
00092 
00093 
00094 /*=============================================================================
00095 = Class KAlarmPrefDlg
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 TQ_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();   // un-minimise it if necessary
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(TQt::WDestructiveClose);
00123     setIconListAllVisible(true);
00124 
00125     TQVBox* 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 // Restore all defaults in the options...
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 // Apply the preferences that are currently selected
00166 void KAlarmPrefDlg::slotApply()
00167 {
00168     kdDebug(5950) << "KAlarmPrefDlg::slotApply()" << endl;
00169     TQString 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 // Apply the preferences that are currently selected
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 // Discard the current preferences and close the dialogue
00207 void KAlarmPrefDlg::slotCancel()
00208 {
00209     kdDebug(5950) << "KAlarmPrefDlg::slotCancel()" << endl;
00210     restore();
00211     KDialogBase::slotCancel();
00212 }
00213 
00214 // Discard the current preferences and use the present ones
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 = Class PrefsTabBase
00228 =============================================================================*/
00229 int PrefsTabBase::mIndentWidth = 0;
00230 
00231 PrefsTabBase::PrefsTabBase(TQVBox* frame)
00232     : TQWidget(frame),
00233       mPage(frame)
00234 {
00235     if (!mIndentWidth)
00236         mIndentWidth = style().subRect(TQStyle::SR_RadioButtonIndicator, this).width();
00237 }
00238 
00239 void PrefsTabBase::apply(bool syncToDisc)
00240 {
00241     Preferences::save(syncToDisc);
00242 }
00243 
00244 
00245 
00246 /*=============================================================================
00247 = Class MiscPrefTab
00248 =============================================================================*/
00249 
00250 MiscPrefTab::MiscPrefTab(TQVBox* frame)
00251     : PrefsTabBase(frame)
00252 {
00253     // Get alignment to use in TQGridLayout (AlignAuto doesn't work correctly there)
00254     int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
00255 
00256     TQGroupBox* group = new TQButtonGroup(i18n("Run Mode"), mPage, "modeGroup");
00257     TQGridLayout* grid = new TQGridLayout(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     // Run-on-demand radio button
00264     mRunOnDemand = new TQRadioButton(i18n("&Run only on demand"), group, "runDemand");
00265     mRunOnDemand->setFixedSize(mRunOnDemand->sizeHint());
00266     connect(mRunOnDemand, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotRunModeToggled(bool)));
00267     TQWhatsThis::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     // Run-in-system-tray radio button
00275     mRunInSystemTray = new TQRadioButton(i18n("Run continuously in system &tray"), group, "runTray");
00276     mRunInSystemTray->setFixedSize(mRunInSystemTray->sizeHint());
00277     connect(mRunInSystemTray, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotRunModeToggled(bool)));
00278     TQWhatsThis::add(mRunInSystemTray,
00279           i18n("Check to run KAlarm continuously in the TDE 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     // Run continuously options
00287     mDisableAlarmsIfStopped = new TQCheckBox(i18n("Disa&ble alarms while not running"), group, "disableAl");
00288     mDisableAlarmsIfStopped->setFixedSize(mDisableAlarmsIfStopped->sizeHint());
00289     connect(mDisableAlarmsIfStopped, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotDisableIfStoppedToggled(bool)));
00290     TQWhatsThis::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 TQCheckBox(i18n("Warn before &quitting"), group, "disableAl");
00295     mQuitWarn->setFixedSize(mQuitWarn->sizeHint());
00296     TQWhatsThis::add(mQuitWarn,
00297           i18n("Check to display a warning prompt before quitting KAlarm."));
00298     grid->addWidget(mQuitWarn, 4, 2, alignment);
00299 
00300     mAutostartTrayIcon = new TQCheckBox(i18n("Autostart at &login"), group, "autoTray");
00301 #ifdef AUTOSTART_BY_KALARMD
00302     connect(mAutostartTrayIcon, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotAutostartToggled(bool)));
00303 #endif
00304     grid->addMultiCellWidget(mAutostartTrayIcon, 5, 5, 0, 2, alignment);
00305 
00306     // Autostart alarm daemon
00307     mAutostartDaemon = new TQCheckBox(i18n("Start alarm monitoring at lo&gin"), group, "startDaemon");
00308     mAutostartDaemon->setFixedSize(mAutostartDaemon->sizeHint());
00309     connect(mAutostartDaemon, TQT_SIGNAL(clicked()), TQT_SLOT(slotAutostartDaemonClicked()));
00310     TQWhatsThis::add(mAutostartDaemon,
00311           i18n("Automatically start alarm monitoring whenever you start TDE, 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(TQString::fromLatin1(DAEMON_APP_NAME)));
00314     grid->addMultiCellWidget(mAutostartDaemon, 6, 6, 0, 2, alignment);
00315 
00316     group->setFixedHeight(group->sizeHint().height());
00317 
00318     // Start-of-day time
00319     TQHBox* itemBox = new TQHBox(mPage);
00320     TQHBox* box = new TQHBox(itemBox);   // this is to control the TQWhatsThis text display area
00321     box->setSpacing(KDialog::spacingHint());
00322     TQLabel* label = new TQLabel(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 TQString 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     TQWhatsThis::add(box, TQString("%1\n\n%2").arg(startOfDayText).arg(TimeSpinBox::shiftWhatsThis()));
00329     itemBox->setStretchFactor(new TQWidget(itemBox), 1);    // left adjust the controls
00330     itemBox->setFixedHeight(box->sizeHint().height());
00331 
00332     // Confirm alarm deletion?
00333     itemBox = new TQHBox(mPage);   // this is to allow left adjustment
00334     mConfirmAlarmDeletion = new TQCheckBox(i18n("Con&firm alarm deletions"), itemBox, "confirmDeletion");
00335     mConfirmAlarmDeletion->setMinimumSize(mConfirmAlarmDeletion->sizeHint());
00336     TQWhatsThis::add(mConfirmAlarmDeletion,
00337           i18n("Check to be prompted for confirmation each time you delete an alarm."));
00338     itemBox->setStretchFactor(new TQWidget(itemBox), 1);    // left adjust the controls
00339     itemBox->setFixedHeight(itemBox->sizeHint().height());
00340 
00341     // Expired alarms
00342     group = new TQGroupBox(i18n("Expired Alarms"), mPage);
00343     grid = new TQGridLayout(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 TQCheckBox(i18n("Keep alarms after e&xpiry"), group, "keepExpired");
00348     mKeepExpired->setFixedSize(mKeepExpired->sizeHint());
00349     connect(mKeepExpired, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotExpiredToggled(bool)));
00350     TQWhatsThis::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 TQHBox(group);
00355     box->setSpacing(KDialog::spacingHint());
00356     mPurgeExpired = new TQCheckBox(i18n("Discard ex&pired alarms after:"), box, "purgeExpired");
00357     mPurgeExpired->setMinimumSize(mPurgeExpired->sizeHint());
00358     connect(mPurgeExpired, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotExpiredToggled(bool)));
00359     mPurgeAfter = new SpinBox(box);
00360     mPurgeAfter->setMinValue(1);
00361     mPurgeAfter->setLineShiftStep(10);
00362     mPurgeAfter->setMinimumSize(mPurgeAfter->sizeHint());
00363     mPurgeAfterLabel = new TQLabel(i18n("da&ys"), box);
00364     mPurgeAfterLabel->setMinimumSize(mPurgeAfterLabel->sizeHint());
00365     mPurgeAfterLabel->setBuddy(mPurgeAfter);
00366     TQWhatsThis::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 TQPushButton(i18n("Clear Expired Alar&ms"), group);
00371     mClearExpired->setFixedSize(mClearExpired->sizeHint());
00372     connect(mClearExpired, TQT_SIGNAL(clicked()), TQT_SLOT(slotClearExpired()));
00373     TQWhatsThis::add(mClearExpired,
00374           i18n("Delete all existing expired alarms."));
00375     grid->addWidget(mClearExpired, 3, 1, alignment);
00376     group->setFixedHeight(group->sizeHint().height());
00377 
00378     // Terminal window to use for command alarms
00379     group = new TQGroupBox(i18n("Terminal for Command Alarms"), mPage);
00380     TQWhatsThis::add(group,
00381           i18n("Choose which application to use when a command alarm is executed in a terminal window"));
00382     grid = new TQGridLayout(group, 1, 3, KDialog::marginHint(), KDialog::spacingHint());
00383     grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
00384     int row = 0;
00385 
00386     mXtermType = new TQButtonGroup(group);
00387     mXtermType->hide();
00388     TQString 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         TQString cmd = xtermCommands[mXtermCount];
00394         TQStringList args = KShell::splitArgs(cmd);
00395         if (args.isEmpty()  ||  TDEStandardDirs::findExe(args[0]).isEmpty())
00396             continue;
00397         TQRadioButton* radio = new TQRadioButton(args[0], group);
00398         radio->setMinimumSize(radio->sizeHint());
00399         mXtermType->insert(radio, mXtermCount);
00400         if (mXtermFirst < 0)
00401             mXtermFirst = mXtermCount;   // note the id of the first button
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         TQWhatsThis::add(radio, whatsThis.arg(cmd));
00408         grid->addWidget(radio, (row = index/3 + 1), index % 3, TQt::AlignAuto);
00409         ++index;
00410     }
00411 
00412     box = new TQHBox(group);
00413     grid->addMultiCellWidget(box, row + 1, row + 1, 0, 2, TQt::AlignAuto);
00414     TQRadioButton* radio = new TQRadioButton(i18n("Other:"), box);
00415     radio->setFixedSize(radio->sizeHint());
00416     connect(radio, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotOtherTerminalToggled(bool)));
00417     mXtermType->insert(radio, mXtermCount);
00418     if (mXtermFirst < 0)
00419         mXtermFirst = mXtermCount;   // note the id of the first button
00420     mXtermCommand = new TQLineEdit(box);
00421     TQWhatsThis::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 TQWidget(mPage), 1);    // top adjust the widgets
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     TQString 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     // First validate anything entered in Other X-terminal command
00460     int xtermID = mXtermType->selectedId();
00461     if (xtermID >= mXtermCount)
00462     {
00463         TQString cmd = mXtermCommand->text();
00464         if (cmd.isEmpty())
00465             xtermID = -1;       // 'Other' is only acceptable if it's non-blank
00466         else
00467         {
00468             TQStringList args = KShell::splitArgs(cmd);
00469             cmd = args.isEmpty() ? TQString() : args[0];
00470             if (TDEStandardDirs::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                               TQString(), 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     TQWhatsThis::add(mAutostartTrayIcon, (systray ? i18n("Check to run KAlarm whenever you start TDE.")
00539                                                  : i18n("Check to display the system tray icon whenever you start TDE.")));
00540     mDisableAlarmsIfStopped->setEnabled(systray);
00541     slotDisableIfStoppedToggled(true);
00542 }
00543 
00544 /******************************************************************************
00545 * If autostart at login is selected, the daemon must be autostarted so that it
00546 * can autostart KAlarm, in which case disable the daemon autostart option.
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 = Class EmailPrefTab
00594 =============================================================================*/
00595 
00596 EmailPrefTab::EmailPrefTab(TQVBox* frame)
00597     : PrefsTabBase(frame),
00598       mAddressChanged(false),
00599       mBccAddressChanged(false)
00600 {
00601     TQHBox* box = new TQHBox(mPage);
00602     box->setSpacing(2*KDialog::spacingHint());
00603     TQLabel* label = new TQLabel(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, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotEmailClientChanged(int)));
00613     box->setFixedHeight(box->sizeHint().height());
00614     TQWhatsThis::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 TQHBox(mPage);   // this is to allow left adjustment
00621     mEmailCopyToKMail = new TQCheckBox(i18n("Co&py sent emails into KMail's %1 folder").arg(KAMail::i18n_sent_mail()), box);
00622     mEmailCopyToKMail->setFixedSize(mEmailCopyToKMail->sizeHint());
00623     TQWhatsThis::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 TQWidget(box), 1);    // left adjust the controls
00626     box->setFixedHeight(box->sizeHint().height());
00627 
00628     // Your Email Address group box
00629     TQGroupBox* group = new TQGroupBox(i18n("Your Email Address"), mPage);
00630     TQGridLayout* grid = new TQGridLayout(group, 6, 3, KDialog::marginHint(), KDialog::spacingHint());
00631     grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
00632     grid->setColStretch(1, 1);
00633 
00634     // 'From' email address controls ...
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, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotFromAddrChanged(int)));
00641 
00642     // Line edit to enter a 'From' email address
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 TQLineEdit(group);
00649     connect(mEmailAddress, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotAddressChanged()));
00650     TQString whatsThis = i18n("Your email address, used to identify you as the sender when sending email alarms.");
00651     TQWhatsThis::add(radio, whatsThis);
00652     TQWhatsThis::add(mEmailAddress, whatsThis);
00653     radio->setFocusWidget(mEmailAddress);
00654     grid->addWidget(mEmailAddress, 1, 2);
00655 
00656     // 'From' email address to be taken from Control Centre
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     TQWhatsThis::add(radio,
00661           i18n("Check to use the email address set in the Trinity Control Center, to identify you as the sender when sending email alarms."));
00662     grid->addMultiCellWidget(radio, 2, 2, 1, 2, TQt::AlignAuto);
00663 
00664     // 'From' email address to be picked from KMail's identities when the email alarm is configured
00665     radio = new RadioButton(i18n("Use KMail &identities"), group);
00666     radio->setFixedSize(radio->sizeHint());
00667     mFromAddressGroup->insert(radio, Preferences::MAIL_FROM_KMAIL);
00668     TQWhatsThis::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, TQt::AlignAuto);
00673 
00674     // 'Bcc' email address controls ...
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, TQT_SIGNAL(buttonSet(int)), TQT_SLOT(slotBccAddrChanged(int)));
00682 
00683     // Line edit to enter a 'Bcc' email address
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 TQLineEdit(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     TQWhatsThis::add(radio, whatsThis);
00693     TQWhatsThis::add(mEmailBccAddress, whatsThis);
00694     radio->setFocusWidget(mEmailBccAddress);
00695     grid->addWidget(mEmailBccAddress, 5, 2);
00696 
00697     // 'Bcc' email address to be taken from Control Centre
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     TQWhatsThis::add(radio,
00702           i18n("Check to use the email address set in the Trinity Control Center, for blind copying email alarms to yourself."));
00703     grid->addMultiCellWidget(radio, 6, 6, 1, 2, TQt::AlignAuto);
00704 
00705     group->setFixedHeight(group->sizeHint().height());
00706 
00707     box = new TQHBox(mPage);   // this is to allow left adjustment
00708     mEmailQueuedNotify = new TQCheckBox(i18n("&Notify when remote emails are queued"), box);
00709     mEmailQueuedNotify->setFixedSize(mEmailQueuedNotify->sizeHint());
00710     TQWhatsThis::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 TQWidget(box), 1);    // left adjust the controls
00714     box->setFixedHeight(box->sizeHint().height());
00715 
00716     mPage->setStretchFactor(new TQWidget(mPage), 1);    // top adjust the widgets
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 TQString& address)
00749 {
00750     mFromAddressGroup->setButton(from);
00751     mEmailAddress->setText(from == Preferences::MAIL_FROM_ADDR ? address.stripWhiteSpace() : TQString());
00752 }
00753 
00754 void EmailPrefTab::setEmailBccAddress(bool useControlCentre, const TQString& address)
00755 {
00756     mBccAddressGroup->setButton(useControlCentre ? Preferences::MAIL_FROM_CONTROL_CENTRE : Preferences::MAIL_FROM_ADDR);
00757     mEmailBccAddress->setText(useControlCentre ? TQString() : 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 TQString EmailPrefTab::validate()
00778 {
00779     if (mAddressChanged)
00780     {
00781         mAddressChanged = false;
00782         TQString 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 TQString();
00792 }
00793 
00794 TQString EmailPrefTab::validateAddr(ButtonGroup* group, TQLineEdit* addr, const TQString& msg)
00795 {
00796     TQString 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 TQString();
00802             errmsg = i18n("No email address is currently set in the Trinity Control Center. %1").arg(errmsg);
00803             break;
00804         case Preferences::MAIL_FROM_KMAIL:
00805             if (KAMail::identitiesExist())
00806                 return TQString();
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 TQString();
00812             break;
00813     }
00814     return errmsg;
00815 }
00816 
00817 
00818 /*=============================================================================
00819 = Class FontColourPrefTab
00820 =============================================================================*/
00821 
00822 FontColourPrefTab::FontColourPrefTab(TQVBox* frame)
00823     : PrefsTabBase(frame)
00824 {
00825     mFontChooser = new FontColourChooser(mPage, 0, false, TQStringList(), i18n("Message Font && Color"), true, false);
00826     mPage->setStretchFactor(mFontChooser, 1);
00827 
00828     TQFrame* layoutBox = new TQFrame(mPage);
00829     TQHBoxLayout* hlayout = new TQHBoxLayout(layoutBox);
00830     TQVBoxLayout* colourLayout = new TQVBoxLayout(hlayout, KDialog::spacingHint());
00831     hlayout->addStretch();
00832 
00833     TQHBox* box = new TQHBox(layoutBox);    // to group widgets for TQWhatsThis text
00834     box->setSpacing(KDialog::spacingHint()/2);
00835     colourLayout->addWidget(box);
00836     TQLabel* label1 = new TQLabel(i18n("Di&sabled alarm color:"), box);
00837     box->setStretchFactor(new TQWidget(box), 1);
00838     mDisabledColour = new KColorCombo(box);
00839     label1->setBuddy(mDisabledColour);
00840     TQWhatsThis::add(box,
00841           i18n("Choose the text color in the alarm list for disabled alarms."));
00842 
00843     box = new TQHBox(layoutBox);    // to group widgets for TQWhatsThis text
00844     box->setSpacing(KDialog::spacingHint()/2);
00845     colourLayout->addWidget(box);
00846     TQLabel* label2 = new TQLabel(i18n("E&xpired alarm color:"), box);
00847     box->setStretchFactor(new TQWidget(box), 1);
00848     mExpiredColour = new KColorCombo(box);
00849     label2->setBuddy(mExpiredColour);
00850     TQWhatsThis::add(box,
00851           i18n("Choose the text color in the alarm list for expired alarms."));
00852 }
00853 
00854 void FontColourPrefTab::restore()
00855 {
00856     mFontChooser->setBgColour(Preferences::mDefaultBgColour);
00857     mFontChooser->setColours(Preferences::mMessageColours);
00858     mFontChooser->setFont(Preferences::mMessageFont);
00859     mDisabledColour->setColor(Preferences::mDisabledColour);
00860     mExpiredColour->setColor(Preferences::mExpiredColour);
00861 }
00862 
00863 void FontColourPrefTab::apply(bool syncToDisc)
00864 {
00865     Preferences::mDefaultBgColour = mFontChooser->bgColour();
00866     Preferences::mMessageColours  = mFontChooser->colours();
00867     Preferences::mMessageFont     = mFontChooser->font();
00868     Preferences::mDisabledColour  = mDisabledColour->color();
00869     Preferences::mExpiredColour   = mExpiredColour->color();
00870     PrefsTabBase::apply(syncToDisc);
00871 }
00872 
00873 void FontColourPrefTab::setDefaults()
00874 {
00875     mFontChooser->setBgColour(Preferences::default_defaultBgColour);
00876     mFontChooser->setColours(Preferences::default_messageColours);
00877     mFontChooser->setFont(Preferences::default_messageFont());
00878     mDisabledColour->setColor(Preferences::default_disabledColour);
00879     mExpiredColour->setColor(Preferences::default_expiredColour);
00880 }
00881 
00882 
00883 /*=============================================================================
00884 = Class EditPrefTab
00885 =============================================================================*/
00886 
00887 EditPrefTab::EditPrefTab(TQVBox* frame)
00888     : PrefsTabBase(frame)
00889 {
00890     // Get alignment to use in TQLabel::setAlignment(alignment | TQt::WordBreak)
00891     // (AlignAuto doesn't work correctly there)
00892     int alignment = TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft;
00893 
00894     int groupTopMargin = fontMetrics().lineSpacing()/2;
00895     TQString defsetting   = i18n("The default setting for \"%1\" in the alarm edit dialog.");
00896     TQString soundSetting = i18n("Check to select %1 as the default setting for \"%2\" in the alarm edit dialog.");
00897 
00898     // DISPLAY ALARMS
00899     TQGroupBox* group = new TQGroupBox(i18n("Display Alarms"), mPage);
00900     TQBoxLayout* layout = new TQVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
00901     layout->addSpacing(groupTopMargin);
00902 
00903     mConfirmAck = new TQCheckBox(EditAlarmDlg::i18n_k_ConfirmAck(), group, "defConfAck");
00904     mConfirmAck->setMinimumSize(mConfirmAck->sizeHint());
00905     TQWhatsThis::add(mConfirmAck, defsetting.arg(EditAlarmDlg::i18n_ConfirmAck()));
00906     layout->addWidget(mConfirmAck, 0, TQt::AlignAuto);
00907 
00908     mAutoClose = new TQCheckBox(LateCancelSelector::i18n_i_AutoCloseWinLC(), group, "defAutoClose");
00909     mAutoClose->setMinimumSize(mAutoClose->sizeHint());
00910     TQWhatsThis::add(mAutoClose, defsetting.arg(LateCancelSelector::i18n_AutoCloseWin()));
00911     layout->addWidget(mAutoClose, 0, TQt::AlignAuto);
00912 
00913     TQHBox* box = new TQHBox(group);
00914     box->setSpacing(KDialog::spacingHint());
00915     layout->addWidget(box);
00916     TQLabel* label = new TQLabel(i18n("Reminder &units:"), box);
00917     label->setFixedSize(label->sizeHint());
00918     mReminderUnits = new TQComboBox(box, "defWarnUnits");
00919     mReminderUnits->insertItem(TimePeriod::i18n_Minutes(), TimePeriod::MINUTES);
00920     mReminderUnits->insertItem(TimePeriod::i18n_Hours_Mins(), TimePeriod::HOURS_MINUTES);
00921     mReminderUnits->insertItem(TimePeriod::i18n_Days(), TimePeriod::DAYS);
00922     mReminderUnits->insertItem(TimePeriod::i18n_Weeks(), TimePeriod::WEEKS);
00923     mReminderUnits->setFixedSize(mReminderUnits->sizeHint());
00924     label->setBuddy(mReminderUnits);
00925     TQWhatsThis::add(box,
00926           i18n("The default units for the reminder in the alarm edit dialog."));
00927     box->setStretchFactor(new TQWidget(box), 1);    // left adjust the control
00928 
00929     mSpecialActionsButton = new SpecialActionsButton(EditAlarmDlg::i18n_SpecialActions(), box);
00930     mSpecialActionsButton->setFixedSize(mSpecialActionsButton->sizeHint());
00931 
00932     // SOUND
00933     TQButtonGroup* bgroup = new TQButtonGroup(SoundPicker::i18n_Sound(), mPage, "soundGroup");
00934     layout = new TQVBoxLayout(bgroup, KDialog::marginHint(), KDialog::spacingHint());
00935     layout->addSpacing(groupTopMargin);
00936 
00937     TQBoxLayout* hlayout = new TQHBoxLayout(layout, KDialog::spacingHint());
00938     mSound = new TQComboBox(false, bgroup, "defSound");
00939     mSound->insertItem(SoundPicker::i18n_None());         // index 0
00940     mSound->insertItem(SoundPicker::i18n_Beep());         // index 1
00941     mSound->insertItem(SoundPicker::i18n_File());         // index 2
00942     if (theApp()->speechEnabled())
00943         mSound->insertItem(SoundPicker::i18n_Speak());  // index 3
00944     mSound->setMinimumSize(mSound->sizeHint());
00945     TQWhatsThis::add(mSound, defsetting.arg(SoundPicker::i18n_Sound()));
00946     hlayout->addWidget(mSound);
00947     hlayout->addStretch(1);
00948 
00949 #ifndef WITHOUT_ARTS
00950     mSoundRepeat = new TQCheckBox(i18n("Repea&t sound file"), bgroup, "defRepeatSound");
00951     mSoundRepeat->setMinimumSize(mSoundRepeat->sizeHint());
00952     TQWhatsThis::add(mSoundRepeat, i18n("sound file \"Repeat\" checkbox", "The default setting for sound file \"%1\" in the alarm edit dialog.").arg(SoundDlg::i18n_Repeat()));
00953     hlayout->addWidget(mSoundRepeat);
00954 #endif
00955 
00956     box = new TQHBox(bgroup);   // this is to control the TQWhatsThis text display area
00957     box->setSpacing(KDialog::spacingHint());
00958     mSoundFileLabel = new TQLabel(i18n("Sound &file:"), box);
00959     mSoundFileLabel->setFixedSize(mSoundFileLabel->sizeHint());
00960     mSoundFile = new TQLineEdit(box);
00961     mSoundFileLabel->setBuddy(mSoundFile);
00962     mSoundFileBrowse = new TQPushButton(box);
00963     mSoundFileBrowse->setPixmap(SmallIcon("document-open"));
00964     mSoundFileBrowse->setFixedSize(mSoundFileBrowse->sizeHint());
00965     connect(mSoundFileBrowse, TQT_SIGNAL(clicked()), TQT_SLOT(slotBrowseSoundFile()));
00966     TQToolTip::add(mSoundFileBrowse, i18n("Choose a sound file"));
00967     TQWhatsThis::add(box,
00968           i18n("Enter the default sound file to use in the alarm edit dialog."));
00969     box->setFixedHeight(box->sizeHint().height());
00970     layout->addWidget(box);
00971     bgroup->setFixedHeight(bgroup->sizeHint().height());
00972 
00973     // COMMAND ALARMS
00974     group = new TQGroupBox(i18n("Command Alarms"), mPage);
00975     layout = new TQVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
00976     layout->addSpacing(groupTopMargin);
00977     layout = new TQHBoxLayout(layout, KDialog::spacingHint());
00978 
00979     mCmdScript = new TQCheckBox(EditAlarmDlg::i18n_p_EnterScript(), group, "defCmdScript");
00980     mCmdScript->setMinimumSize(mCmdScript->sizeHint());
00981     TQWhatsThis::add(mCmdScript, defsetting.arg(EditAlarmDlg::i18n_EnterScript()));
00982     layout->addWidget(mCmdScript);
00983     layout->addStretch();
00984 
00985     mCmdXterm = new TQCheckBox(EditAlarmDlg::i18n_w_ExecInTermWindow(), group, "defCmdXterm");
00986     mCmdXterm->setMinimumSize(mCmdXterm->sizeHint());
00987     TQWhatsThis::add(mCmdXterm, defsetting.arg(EditAlarmDlg::i18n_ExecInTermWindow()));
00988     layout->addWidget(mCmdXterm);
00989 
00990     // EMAIL ALARMS
00991     group = new TQGroupBox(i18n("Email Alarms"), mPage);
00992     layout = new TQVBoxLayout(group, KDialog::marginHint(), KDialog::spacingHint());
00993     layout->addSpacing(groupTopMargin);
00994 
00995     // BCC email to sender
00996     mEmailBcc = new TQCheckBox(EditAlarmDlg::i18n_e_CopyEmailToSelf(), group, "defEmailBcc");
00997     mEmailBcc->setMinimumSize(mEmailBcc->sizeHint());
00998     TQWhatsThis::add(mEmailBcc, defsetting.arg(EditAlarmDlg::i18n_CopyEmailToSelf()));
00999     layout->addWidget(mEmailBcc, 0, TQt::AlignAuto);
01000 
01001     // MISCELLANEOUS
01002     // Show in KOrganizer
01003     mCopyToKOrganizer = new TQCheckBox(EditAlarmDlg::i18n_g_ShowInKOrganizer(), mPage, "defShowKorg");
01004     mCopyToKOrganizer->setMinimumSize(mCopyToKOrganizer->sizeHint());
01005     TQWhatsThis::add(mCopyToKOrganizer, defsetting.arg(EditAlarmDlg::i18n_ShowInKOrganizer()));
01006 
01007     // Late cancellation
01008     box = new TQHBox(mPage);
01009     box->setSpacing(KDialog::spacingHint());
01010     mLateCancel = new TQCheckBox(LateCancelSelector::i18n_n_CancelIfLate(), box, "defCancelLate");
01011     mLateCancel->setMinimumSize(mLateCancel->sizeHint());
01012     TQWhatsThis::add(mLateCancel, defsetting.arg(LateCancelSelector::i18n_CancelIfLate()));
01013     box->setStretchFactor(new TQWidget(box), 1);    // left adjust the control
01014 
01015     // Recurrence
01016     TQHBox* itemBox = new TQHBox(box);   // this is to control the TQWhatsThis text display area
01017     itemBox->setSpacing(KDialog::spacingHint());
01018     label = new TQLabel(i18n("&Recurrence:"), itemBox);
01019     label->setFixedSize(label->sizeHint());
01020     mRecurPeriod = new TQComboBox(itemBox, "defRecur");
01021     mRecurPeriod->insertItem(RecurrenceEdit::i18n_NoRecur());
01022     mRecurPeriod->insertItem(RecurrenceEdit::i18n_AtLogin());
01023     mRecurPeriod->insertItem(RecurrenceEdit::i18n_HourlyMinutely());
01024     mRecurPeriod->insertItem(RecurrenceEdit::i18n_Daily());
01025     mRecurPeriod->insertItem(RecurrenceEdit::i18n_Weekly());
01026     mRecurPeriod->insertItem(RecurrenceEdit::i18n_Monthly());
01027     mRecurPeriod->insertItem(RecurrenceEdit::i18n_Yearly());
01028     mRecurPeriod->setFixedSize(mRecurPeriod->sizeHint());
01029     label->setBuddy(mRecurPeriod);
01030     TQWhatsThis::add(itemBox,
01031           i18n("The default setting for the recurrence rule in the alarm edit dialog."));
01032     box->setFixedHeight(itemBox->sizeHint().height());
01033 
01034     // How to handle February 29th in yearly recurrences
01035     TQVBox* vbox = new TQVBox(mPage);   // this is to control the TQWhatsThis text display area
01036     vbox->setSpacing(KDialog::spacingHint());
01037     label = new TQLabel(i18n("In non-leap years, repeat yearly February 29th alarms on:"), vbox);
01038     label->setAlignment(alignment | TQt::WordBreak);
01039     itemBox = new TQHBox(vbox);
01040     itemBox->setSpacing(2*KDialog::spacingHint());
01041     mFeb29 = new TQButtonGroup(itemBox);
01042     mFeb29->hide();
01043     TQWidget* widget = new TQWidget(itemBox);
01044     widget->setFixedWidth(3*KDialog::spacingHint());
01045     TQRadioButton* radio = new TQRadioButton(i18n("February 2&8th"), itemBox);
01046     radio->setMinimumSize(radio->sizeHint());
01047     mFeb29->insert(radio, KARecurrence::FEB29_FEB28);
01048     radio = new TQRadioButton(i18n("March &1st"), itemBox);
01049     radio->setMinimumSize(radio->sizeHint());
01050     mFeb29->insert(radio, KARecurrence::FEB29_MAR1);
01051     radio = new TQRadioButton(i18n("Do &not repeat"), itemBox);
01052     radio->setMinimumSize(radio->sizeHint());
01053     mFeb29->insert(radio, KARecurrence::FEB29_FEB29);
01054     itemBox->setFixedHeight(itemBox->sizeHint().height());
01055     TQWhatsThis::add(vbox,
01056           i18n("For yearly recurrences, choose what date, if any, alarms due on February 29th should occur in non-leap years.\n"
01057                "Note that the next scheduled occurrence of existing alarms is not re-evaluated when you change this setting."));
01058 
01059     mPage->setStretchFactor(new TQWidget(mPage), 1);    // top adjust the widgets
01060 }
01061 
01062 void EditPrefTab::restore()
01063 {
01064     mAutoClose->setChecked(Preferences::mDefaultAutoClose);
01065     mConfirmAck->setChecked(Preferences::mDefaultConfirmAck);
01066     mReminderUnits->setCurrentItem(Preferences::mDefaultReminderUnits);
01067     mSpecialActionsButton->setActions(Preferences::mDefaultPreAction, Preferences::mDefaultPostAction);
01068     mSound->setCurrentItem(soundIndex(Preferences::mDefaultSoundType));
01069     mSoundFile->setText(Preferences::mDefaultSoundFile);
01070 #ifndef WITHOUT_ARTS
01071     mSoundRepeat->setChecked(Preferences::mDefaultSoundRepeat);
01072 #endif
01073     mCmdScript->setChecked(Preferences::mDefaultCmdScript);
01074     mCmdXterm->setChecked(Preferences::mDefaultCmdLogType == EditAlarmDlg::EXEC_IN_TERMINAL);
01075     mEmailBcc->setChecked(Preferences::mDefaultEmailBcc);
01076     mCopyToKOrganizer->setChecked(Preferences::mDefaultCopyToKOrganizer);
01077     mLateCancel->setChecked(Preferences::mDefaultLateCancel);
01078     mRecurPeriod->setCurrentItem(recurIndex(Preferences::mDefaultRecurPeriod));
01079     mFeb29->setButton(Preferences::mDefaultFeb29Type);
01080 }
01081 
01082 void EditPrefTab::apply(bool syncToDisc)
01083 {
01084     Preferences::mDefaultAutoClose        = mAutoClose->isChecked();
01085     Preferences::mDefaultConfirmAck       = mConfirmAck->isChecked();
01086     Preferences::mDefaultReminderUnits    = static_cast<TimePeriod::Units>(mReminderUnits->currentItem());
01087     Preferences::mDefaultPreAction        = mSpecialActionsButton->preAction();
01088     Preferences::mDefaultPostAction       = mSpecialActionsButton->postAction();
01089     switch (mSound->currentItem())
01090     {
01091         case 3:  Preferences::mDefaultSoundType = SoundPicker::SPEAK;      break;
01092         case 2:  Preferences::mDefaultSoundType = SoundPicker::PLAY_FILE;  break;
01093         case 1:  Preferences::mDefaultSoundType = SoundPicker::BEEP;       break;
01094         case 0:
01095         default: Preferences::mDefaultSoundType = SoundPicker::NONE;       break;
01096     }
01097     Preferences::mDefaultSoundFile        = mSoundFile->text();
01098 #ifndef WITHOUT_ARTS
01099     Preferences::mDefaultSoundRepeat      = mSoundRepeat->isChecked();
01100 #endif
01101     Preferences::mDefaultCmdScript        = mCmdScript->isChecked();
01102     Preferences::mDefaultCmdLogType       = (mCmdXterm->isChecked() ? EditAlarmDlg::EXEC_IN_TERMINAL : EditAlarmDlg::DISCARD_OUTPUT);
01103     Preferences::mDefaultEmailBcc         = mEmailBcc->isChecked();
01104     Preferences::mDefaultCopyToKOrganizer = mCopyToKOrganizer->isChecked();
01105     Preferences::mDefaultLateCancel       = mLateCancel->isChecked() ? 1 : 0;
01106     switch (mRecurPeriod->currentItem())
01107     {
01108         case 6:  Preferences::mDefaultRecurPeriod = RecurrenceEdit::ANNUAL;    break;
01109         case 5:  Preferences::mDefaultRecurPeriod = RecurrenceEdit::MONTHLY;   break;
01110         case 4:  Preferences::mDefaultRecurPeriod = RecurrenceEdit::WEEKLY;    break;
01111         case 3:  Preferences::mDefaultRecurPeriod = RecurrenceEdit::DAILY;     break;
01112         case 2:  Preferences::mDefaultRecurPeriod = RecurrenceEdit::SUBDAILY;  break;
01113         case 1:  Preferences::mDefaultRecurPeriod = RecurrenceEdit::AT_LOGIN;  break;
01114         case 0:
01115         default: Preferences::mDefaultRecurPeriod = RecurrenceEdit::NO_RECUR;  break;
01116     }
01117     int feb29 = mFeb29->selectedId();
01118     Preferences::mDefaultFeb29Type  = (feb29 >= 0) ? static_cast<KARecurrence::Feb29Type>(feb29) : Preferences::default_defaultFeb29Type;
01119     PrefsTabBase::apply(syncToDisc);
01120 }
01121 
01122 void EditPrefTab::setDefaults()
01123 {
01124     mAutoClose->setChecked(Preferences::default_defaultAutoClose);
01125     mConfirmAck->setChecked(Preferences::default_defaultConfirmAck);
01126     mReminderUnits->setCurrentItem(Preferences::default_defaultReminderUnits);
01127     mSpecialActionsButton->setActions(Preferences::default_defaultPreAction, Preferences::default_defaultPostAction);
01128     mSound->setCurrentItem(soundIndex(Preferences::default_defaultSoundType));
01129     mSoundFile->setText(Preferences::default_defaultSoundFile);
01130 #ifndef WITHOUT_ARTS
01131     mSoundRepeat->setChecked(Preferences::default_defaultSoundRepeat);
01132 #endif
01133     mCmdScript->setChecked(Preferences::default_defaultCmdScript);
01134     mCmdXterm->setChecked(Preferences::default_defaultCmdLogType == EditAlarmDlg::EXEC_IN_TERMINAL);
01135     mEmailBcc->setChecked(Preferences::default_defaultEmailBcc);
01136     mCopyToKOrganizer->setChecked(Preferences::default_defaultCopyToKOrganizer);
01137     mLateCancel->setChecked(Preferences::default_defaultLateCancel);
01138     mRecurPeriod->setCurrentItem(recurIndex(Preferences::default_defaultRecurPeriod));
01139     mFeb29->setButton(Preferences::default_defaultFeb29Type);
01140 }
01141 
01142 void EditPrefTab::slotBrowseSoundFile()
01143 {
01144     TQString defaultDir;
01145     TQString url = SoundPicker::browseFile(defaultDir, mSoundFile->text());
01146     if (!url.isEmpty())
01147         mSoundFile->setText(url);
01148 }
01149 
01150 int EditPrefTab::soundIndex(SoundPicker::Type type)
01151 {
01152     switch (type)
01153     {
01154         case SoundPicker::SPEAK:      return 3;
01155         case SoundPicker::PLAY_FILE:  return 2;
01156         case SoundPicker::BEEP:       return 1;
01157         case SoundPicker::NONE:
01158         default:                      return 0;
01159     }
01160 }
01161 
01162 int EditPrefTab::recurIndex(RecurrenceEdit::RepeatType type)
01163 {
01164     switch (type)
01165     {
01166         case RecurrenceEdit::ANNUAL:   return 6;
01167         case RecurrenceEdit::MONTHLY:  return 5;
01168         case RecurrenceEdit::WEEKLY:   return 4;
01169         case RecurrenceEdit::DAILY:    return 3;
01170         case RecurrenceEdit::SUBDAILY: return 2;
01171         case RecurrenceEdit::AT_LOGIN: return 1;
01172         case RecurrenceEdit::NO_RECUR:
01173         default:                       return 0;
01174     }
01175 }
01176 
01177 TQString EditPrefTab::validate()
01178 {
01179     if (mSound->currentItem() == SoundPicker::PLAY_FILE  &&  mSoundFile->text().isEmpty())
01180     {
01181         mSoundFile->setFocus();
01182         return i18n("You must enter a sound file when %1 is selected as the default sound type").arg(SoundPicker::i18n_File());;
01183     }
01184     return TQString();
01185 }
01186 
01187 
01188 /*=============================================================================
01189 = Class ViewPrefTab
01190 =============================================================================*/
01191 
01192 ViewPrefTab::ViewPrefTab(TQVBox* frame)
01193     : PrefsTabBase(frame)
01194 {
01195     TQGroupBox* group = new TQGroupBox(i18n("System Tray Tooltip"), mPage);
01196     TQGridLayout* grid = new TQGridLayout(group, 5, 3, KDialog::marginHint(), KDialog::spacingHint());
01197     grid->setColStretch(2, 1);
01198     grid->addColSpacing(0, indentWidth());
01199     grid->addColSpacing(1, indentWidth());
01200     grid->addRowSpacing(0, fontMetrics().lineSpacing()/2);
01201 
01202     mTooltipShowAlarms = new TQCheckBox(i18n("Show next &24 hours' alarms"), group, "tooltipShow");
01203     mTooltipShowAlarms->setMinimumSize(mTooltipShowAlarms->sizeHint());
01204     connect(mTooltipShowAlarms, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotTooltipAlarmsToggled(bool)));
01205     TQWhatsThis::add(mTooltipShowAlarms,
01206           i18n("Specify whether to include in the system tray tooltip, a summary of alarms due in the next 24 hours"));
01207     grid->addMultiCellWidget(mTooltipShowAlarms, 1, 1, 0, 2, TQt::AlignAuto);
01208 
01209     TQHBox* box = new TQHBox(group);
01210     box->setSpacing(KDialog::spacingHint());
01211     mTooltipMaxAlarms = new TQCheckBox(i18n("Ma&ximum number of alarms to show:"), box, "tooltipMax");
01212     mTooltipMaxAlarms->setMinimumSize(mTooltipMaxAlarms->sizeHint());
01213     connect(mTooltipMaxAlarms, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotTooltipMaxToggled(bool)));
01214     mTooltipMaxAlarmCount = new SpinBox(1, 99, 1, box);
01215     mTooltipMaxAlarmCount->setLineShiftStep(5);
01216     mTooltipMaxAlarmCount->setMinimumSize(mTooltipMaxAlarmCount->sizeHint());
01217     TQWhatsThis::add(box,
01218           i18n("Uncheck to display all of the next 24 hours' alarms in the system tray tooltip. "
01219                "Check to enter an upper limit on the number to be displayed."));
01220     grid->addMultiCellWidget(box, 2, 2, 1, 2, TQt::AlignAuto);
01221 
01222     mTooltipShowTime = new TQCheckBox(MainWindow::i18n_m_ShowAlarmTime(), group, "tooltipTime");
01223     mTooltipShowTime->setMinimumSize(mTooltipShowTime->sizeHint());
01224     connect(mTooltipShowTime, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotTooltipTimeToggled(bool)));
01225     TQWhatsThis::add(mTooltipShowTime,
01226           i18n("Specify whether to show in the system tray tooltip, the time at which each alarm is due"));
01227     grid->addMultiCellWidget(mTooltipShowTime, 3, 3, 1, 2, TQt::AlignAuto);
01228 
01229     mTooltipShowTimeTo = new TQCheckBox(MainWindow::i18n_l_ShowTimeToAlarm(), group, "tooltipTimeTo");
01230     mTooltipShowTimeTo->setMinimumSize(mTooltipShowTimeTo->sizeHint());
01231     connect(mTooltipShowTimeTo, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotTooltipTimeToToggled(bool)));
01232     TQWhatsThis::add(mTooltipShowTimeTo,
01233           i18n("Specify whether to show in the system tray tooltip, how long until each alarm is due"));
01234     grid->addMultiCellWidget(mTooltipShowTimeTo, 4, 4, 1, 2, TQt::AlignAuto);
01235 
01236     box = new TQHBox(group);   // this is to control the TQWhatsThis text display area
01237     box->setSpacing(KDialog::spacingHint());
01238     mTooltipTimeToPrefixLabel = new TQLabel(i18n("&Prefix:"), box);
01239     mTooltipTimeToPrefixLabel->setFixedSize(mTooltipTimeToPrefixLabel->sizeHint());
01240     mTooltipTimeToPrefix = new TQLineEdit(box);
01241     mTooltipTimeToPrefixLabel->setBuddy(mTooltipTimeToPrefix);
01242     TQWhatsThis::add(box,
01243           i18n("Enter the text to be displayed in front of the time until the alarm, in the system tray tooltip"));
01244     box->setFixedHeight(box->sizeHint().height());
01245     grid->addWidget(box, 5, 2, TQt::AlignAuto);
01246     group->setMaximumHeight(group->sizeHint().height());
01247 
01248     mModalMessages = new TQCheckBox(i18n("Message &windows have a title bar and take keyboard focus"), mPage, "modalMsg");
01249     mModalMessages->setMinimumSize(mModalMessages->sizeHint());
01250     TQWhatsThis::add(mModalMessages,
01251           i18n("Specify the characteristics of alarm message windows:\n"
01252                "- If checked, the window is a normal window with a title bar, which grabs keyboard input when it is displayed.\n"
01253                "- If unchecked, the window does not interfere with your typing when "
01254                "it is displayed, but it has no title bar and cannot be moved or resized."));
01255 
01256     TQHBox* itemBox = new TQHBox(mPage);   // this is to control the TQWhatsThis text display area
01257     box = new TQHBox(itemBox);
01258     box->setSpacing(KDialog::spacingHint());
01259     TQLabel* label = new TQLabel(i18n("System tray icon &update interval:"), box);
01260     mDaemonTrayCheckInterval = new SpinBox(1, 9999, 1, box, "daemonCheck");
01261     mDaemonTrayCheckInterval->setLineShiftStep(10);
01262     mDaemonTrayCheckInterval->setMinimumSize(mDaemonTrayCheckInterval->sizeHint());
01263     label->setBuddy(mDaemonTrayCheckInterval);
01264     label = new TQLabel(i18n("seconds"), box);
01265     TQWhatsThis::add(box,
01266           i18n("How often to update the system tray icon to indicate whether or not the Alarm Daemon is monitoring alarms."));
01267     itemBox->setStretchFactor(new TQWidget(itemBox), 1);    // left adjust the controls
01268     itemBox->setFixedHeight(box->sizeHint().height());
01269 
01270     mPage->setStretchFactor(new TQWidget(mPage), 1);    // top adjust the widgets
01271 }
01272 
01273 void ViewPrefTab::restore()
01274 {
01275     setTooltip(Preferences::mTooltipAlarmCount,
01276                Preferences::mShowTooltipAlarmTime,
01277                Preferences::mShowTooltipTimeToAlarm,
01278                Preferences::mTooltipTimeToPrefix);
01279     mModalMessages->setChecked(Preferences::mModalMessages);
01280     mDaemonTrayCheckInterval->setValue(Preferences::mDaemonTrayCheckInterval);
01281 }
01282 
01283 void ViewPrefTab::apply(bool syncToDisc)
01284 {
01285     int n = mTooltipShowAlarms->isChecked() ? -1 : 0;
01286     if (n  &&  mTooltipMaxAlarms->isChecked())
01287         n = mTooltipMaxAlarmCount->value();
01288     Preferences::mTooltipAlarmCount       = n;
01289     Preferences::mShowTooltipAlarmTime    = mTooltipShowTime->isChecked();
01290     Preferences::mShowTooltipTimeToAlarm  = mTooltipShowTimeTo->isChecked();
01291     Preferences::mTooltipTimeToPrefix     = mTooltipTimeToPrefix->text();
01292     Preferences::mModalMessages           = mModalMessages->isChecked();
01293     Preferences::mDaemonTrayCheckInterval = mDaemonTrayCheckInterval->value();
01294     PrefsTabBase::apply(syncToDisc);
01295 }
01296 
01297 void ViewPrefTab::setDefaults()
01298 {
01299     setTooltip(Preferences::default_tooltipAlarmCount,
01300                Preferences::default_showTooltipAlarmTime,
01301                Preferences::default_showTooltipTimeToAlarm,
01302                Preferences::default_tooltipTimeToPrefix);
01303     mModalMessages->setChecked(Preferences::default_modalMessages);
01304     mDaemonTrayCheckInterval->setValue(Preferences::default_daemonTrayCheckInterval);
01305 }
01306 
01307 void ViewPrefTab::setTooltip(int maxAlarms, bool time, bool timeTo, const TQString& prefix)
01308 {
01309     if (!timeTo)
01310         time = true;    // ensure that at least one time option is ticked
01311 
01312     // Set the states of the controls without calling signal
01313     // handlers, since these could change the checkboxes' states.
01314     mTooltipShowAlarms->blockSignals(true);
01315     mTooltipShowTime->blockSignals(true);
01316     mTooltipShowTimeTo->blockSignals(true);
01317 
01318     mTooltipShowAlarms->setChecked(maxAlarms);
01319     mTooltipMaxAlarms->setChecked(maxAlarms > 0);
01320     mTooltipMaxAlarmCount->setValue(maxAlarms > 0 ? maxAlarms : 1);
01321     mTooltipShowTime->setChecked(time);
01322     mTooltipShowTimeTo->setChecked(timeTo);
01323     mTooltipTimeToPrefix->setText(prefix);
01324 
01325     mTooltipShowAlarms->blockSignals(false);
01326     mTooltipShowTime->blockSignals(false);
01327     mTooltipShowTimeTo->blockSignals(false);
01328 
01329     // Enable/disable controls according to their states
01330     slotTooltipTimeToToggled(timeTo);
01331     slotTooltipAlarmsToggled(maxAlarms);
01332 }
01333 
01334 void ViewPrefTab::slotTooltipAlarmsToggled(bool on)
01335 {
01336     mTooltipMaxAlarms->setEnabled(on);
01337     mTooltipMaxAlarmCount->setEnabled(on && mTooltipMaxAlarms->isChecked());
01338     mTooltipShowTime->setEnabled(on);
01339     mTooltipShowTimeTo->setEnabled(on);
01340     on = on && mTooltipShowTimeTo->isChecked();
01341     mTooltipTimeToPrefix->setEnabled(on);
01342     mTooltipTimeToPrefixLabel->setEnabled(on);
01343 }
01344 
01345 void ViewPrefTab::slotTooltipMaxToggled(bool on)
01346 {
01347     mTooltipMaxAlarmCount->setEnabled(on && mTooltipMaxAlarms->isEnabled());
01348 }
01349 
01350 void ViewPrefTab::slotTooltipTimeToggled(bool on)
01351 {
01352     if (!on  &&  !mTooltipShowTimeTo->isChecked())
01353         mTooltipShowTimeTo->setChecked(true);
01354 }
01355 
01356 void ViewPrefTab::slotTooltipTimeToToggled(bool on)
01357 {
01358     if (!on  &&  !mTooltipShowTime->isChecked())
01359         mTooltipShowTime->setChecked(true);
01360     on = on && mTooltipShowTimeTo->isEnabled();
01361     mTooltipTimeToPrefix->setEnabled(on);
01362     mTooltipTimeToPrefixLabel->setEnabled(on);
01363 }