kalarm

preferences.h

00001 /*
00002  *  preferences.h  -  program preference settings
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2006 by David Jarvie <software@astrojar.org.uk>
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 #ifndef PREFERENCES_H
00022 #define PREFERENCES_H
00023 
00024 #include "kalarm.h"
00025 
00026 #include <qobject.h>
00027 #include <qcolor.h>
00028 #include <qfont.h>
00029 #include <qdatetime.h>
00030 #include <qvaluelist.h>
00031 class QWidget;
00032 
00033 #include "colourlist.h"
00034 #include "editdlg.h"
00035 #include "karecurrence.h"
00036 #include "recurrenceedit.h"
00037 #include "soundpicker.h"
00038 #include "timeperiod.h"
00039 
00040 
00041 // Settings configured in the Preferences dialog
00042 class Preferences : public QObject
00043 {
00044         Q_OBJECT
00045     public:
00046         enum MailClient { SENDMAIL, KMAIL };
00047         enum MailFrom   { MAIL_FROM_KMAIL, MAIL_FROM_CONTROL_CENTRE, MAIL_FROM_ADDR };
00048         enum CmdLogType { DISCARD_OUTPUT, LOG_TO_FILE, EXEC_IN_TERMINAL };
00049 
00050         static void              initialise();
00051         static void              save(bool syncToDisc = true);
00052         static void              syncToDisc();
00053         static void              updateStartOfDayCheck();
00054         static void              connect(const char* signal, const QObject* receiver, const char* member);
00055 
00056         // Access to settings
00057         static const ColourList& messageColours()                 { return mMessageColours; }
00058         static QColor            defaultBgColour()                { return mDefaultBgColour; }
00059         static QColor            defaultFgColour()                { return default_defaultFgColour; }
00060         static const QFont&      messageFont()                    { return mMessageFont; }
00061         static const QTime&      startOfDay()                     { return mStartOfDay; }
00062         static bool              hasStartOfDayChanged()           { return mStartOfDayChanged; }
00063         static bool              runInSystemTray()                { return mRunInSystemTray; }
00064         static bool              disableAlarmsIfStopped()         { return mDisableAlarmsIfStopped; }
00065         static bool              quitWarn()                       { return notifying(QUIT_WARN); }
00066         static void              setQuitWarn(bool yes)            { setNotify(QUIT_WARN, yes); }
00067         static bool              autostartTrayIcon()              { return mAutostartTrayIcon; }
00068         static bool              confirmAlarmDeletion()           { return notifying(CONFIRM_ALARM_DELETION); }
00069         static void              setConfirmAlarmDeletion(bool yes){ setNotify(CONFIRM_ALARM_DELETION, yes); }
00070         static bool              modalMessages()                  { return mModalMessages; }
00071         static int               messageButtonDelay()             { return mMessageButtonDelay; }
00072         static bool              showExpiredAlarms()              { return mShowExpiredAlarms; }
00073         static bool              showAlarmTime()                  { return mShowAlarmTime; }
00074         static bool              showTimeToAlarm()                { return mShowTimeToAlarm; }
00075         static int               tooltipAlarmCount()              { return mTooltipAlarmCount; }
00076         static bool              showTooltipAlarmTime()           { return mShowTooltipAlarmTime; }
00077         static bool              showTooltipTimeToAlarm()         { return mShowTooltipTimeToAlarm; }
00078         static const QString&    tooltipTimeToPrefix()            { return mTooltipTimeToPrefix; }
00079         static int               daemonTrayCheckInterval()        { return mDaemonTrayCheckInterval; }
00080         static MailClient        emailClient()                    { return mEmailClient; }
00081         static bool              emailCopyToKMail()               { return mEmailCopyToKMail  &&  mEmailClient == SENDMAIL; }
00082         static bool              emailQueuedNotify()              { return notifying(EMAIL_QUEUED_NOTIFY); }
00083         static void              setEmailQueuedNotify(bool yes)   { setNotify(EMAIL_QUEUED_NOTIFY, yes); }
00084         static MailFrom          emailFrom()                      { return mEmailFrom; }
00085         static bool              emailBccUseControlCentre()       { return mEmailBccFrom == MAIL_FROM_CONTROL_CENTRE; }
00086         static QString           emailAddress();
00087         static QString           emailBccAddress();
00088         static QString           cmdXTermCommand()                { return mCmdXTermCommand; }
00089         static QColor            disabledColour()                 { return mDisabledColour; }
00090         static QColor            expiredColour()                  { return mExpiredColour; }
00091         static int               expiredKeepDays()                { return mExpiredKeepDays; }
00092         static SoundPicker::Type defaultSoundType()               { return mDefaultSoundType; }
00093         static const QString&    defaultSoundFile()               { return mDefaultSoundFile; }
00094         static float             defaultSoundVolume()             { return mDefaultSoundVolume; }
00095         static bool              defaultSoundRepeat()             { return mDefaultSoundRepeat; }
00096         static int               defaultLateCancel()              { return mDefaultLateCancel; }
00097         static bool              defaultAutoClose()               { return mDefaultAutoClose; }
00098         static bool              defaultConfirmAck()              { return mDefaultConfirmAck; }
00099         static bool              defaultCopyToKOrganizer()        { return mDefaultCopyToKOrganizer; }
00100         static bool              defaultCmdScript()               { return mDefaultCmdScript; }
00101         static EditAlarmDlg::CmdLogType  
00102                                  defaultCmdLogType()              { return mDefaultCmdLogType; }
00103         static QString           defaultCmdLogFile()              { return mDefaultCmdLogFile; }
00104         static bool              defaultEmailBcc()                { return mDefaultEmailBcc; }
00105         static RecurrenceEdit::RepeatType
00106                                  defaultRecurPeriod()             { return mDefaultRecurPeriod; }
00107         static KARecurrence::Feb29Type
00108                                  defaultFeb29Type()               { return mDefaultFeb29Type; }
00109         static TimePeriod::Units defaultReminderUnits()           { return mDefaultReminderUnits; }
00110         static const QString&    defaultPreAction()               { return mDefaultPreAction; }
00111         static const QString&    defaultPostAction()              { return mDefaultPostAction; }
00112 
00113         // Config file entry names for notification messages
00114         static const QString     QUIT_WARN;
00115         static const QString     CONFIRM_ALARM_DELETION;
00116         static const QString     EMAIL_QUEUED_NOTIFY;
00117 
00118         // Default values for settings
00119         static const ColourList                 default_messageColours;
00120         static const QColor                     default_defaultBgColour;
00121         static const QColor                     default_defaultFgColour;
00122         static const QFont&                     default_messageFont()  { return mDefault_messageFont; };
00123         static const QTime                      default_startOfDay;
00124         static const bool                       default_runInSystemTray;
00125         static const bool                       default_disableAlarmsIfStopped;
00126         static const bool                       default_quitWarn;
00127         static const bool                       default_autostartTrayIcon;
00128         static const bool                       default_confirmAlarmDeletion;
00129         static const bool                       default_modalMessages;
00130         static const int                        default_messageButtonDelay;
00131         static const bool                       default_showExpiredAlarms;
00132         static const bool                       default_showAlarmTime;
00133         static const bool                       default_showTimeToAlarm;
00134         static const int                        default_tooltipAlarmCount;
00135         static const bool                       default_showTooltipAlarmTime;
00136         static const bool                       default_showTooltipTimeToAlarm;
00137         static const QString                    default_tooltipTimeToPrefix;
00138         static const int                        default_daemonTrayCheckInterval;
00139         static const MailClient                 default_emailClient;
00140         static const bool                       default_emailCopyToKMail;
00141         static MailFrom                         default_emailFrom();
00142         static const bool                       default_emailQueuedNotify;
00143         static const MailFrom                   default_emailBccFrom;
00144         static const QString                    default_emailAddress;
00145         static const QString                    default_emailBccAddress;
00146         static const QColor                     default_disabledColour;
00147         static const QColor                     default_expiredColour;
00148         static const int                        default_expiredKeepDays;
00149         static const QString                    default_defaultSoundFile;
00150         static const float                      default_defaultSoundVolume;
00151         static const int                        default_defaultLateCancel;
00152         static const bool                       default_defaultAutoClose;
00153         static const bool                       default_defaultCopyToKOrganizer;
00154         static const SoundPicker::Type          default_defaultSoundType;
00155         static const bool                       default_defaultSoundRepeat;
00156         static const bool                       default_defaultConfirmAck;
00157         static const bool                       default_defaultCmdScript;
00158         static const EditAlarmDlg::CmdLogType   default_defaultCmdLogType;
00159         static const bool                       default_defaultEmailBcc;
00160         static const RecurrenceEdit::RepeatType default_defaultRecurPeriod;
00161         static const KARecurrence::Feb29Type    default_defaultFeb29Type;
00162         static const TimePeriod::Units          default_defaultReminderUnits;
00163         static const QString                    default_defaultPreAction;
00164         static const QString                    default_defaultPostAction;
00165 
00166     signals:
00167         void  preferencesChanged();
00168         void  startOfDayChanged(const QTime& oldStartOfDay);
00169 
00170     private:
00171         Preferences()  { }     // only one instance allowed
00172         void  emitPreferencesChanged();
00173         void  emitStartOfDayChanged();
00174 
00175         static void                read();
00176         static void                convertOldPrefs();
00177         static int                 startOfDayCheck();
00178         static QString             emailFrom(MailFrom, bool useAddress, bool bcc);
00179         static MailFrom            emailFrom(const QString&);
00180         static void                setNotify(const QString& messageID, bool notify);
00181         static bool                notifying(const QString& messageID);
00182 
00183         static Preferences*        mInstance;
00184         static QFont               mDefault_messageFont;
00185         static QString             mEmailAddress;
00186         static QString             mEmailBccAddress;
00187 
00188         // All the following members are accessed by the Preferences dialog classes
00189         friend class MiscPrefTab;
00190         friend class EditPrefTab;
00191         friend class ViewPrefTab;
00192         friend class FontColourPrefTab;
00193         friend class EmailPrefTab;
00194         static void                setEmailAddress(MailFrom, const QString& address);
00195         static void                setEmailBccAddress(bool useControlCentre, const QString& address);
00196         static ColourList          mMessageColours;
00197         static QColor              mDefaultBgColour;
00198         static QFont               mMessageFont;
00199         static QTime               mStartOfDay;
00200         static bool                mRunInSystemTray;
00201         static bool                mDisableAlarmsIfStopped;
00202         static bool                mAutostartTrayIcon;
00203         static bool                mModalMessages;
00204         static int                 mMessageButtonDelay;  // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
00205         static bool                mShowExpiredAlarms;
00206         static bool                mShowAlarmTime;
00207         static bool                mShowTimeToAlarm;
00208         static int                 mTooltipAlarmCount;
00209         static bool                mShowTooltipAlarmTime;
00210         static bool                mShowTooltipTimeToAlarm;
00211         static QString             mTooltipTimeToPrefix;
00212         static int                 mDaemonTrayCheckInterval;
00213         static MailClient          mEmailClient;
00214         static MailFrom            mEmailFrom;
00215         static MailFrom            mEmailBccFrom;
00216         static bool                mEmailCopyToKMail;
00217         static QString             mCmdXTermCommand;
00218         static QColor              mDisabledColour;
00219         static QColor              mExpiredColour;
00220         static int                 mExpiredKeepDays;     // 0 = don't keep, -1 = keep indefinitely
00221         // Default settings for Edit Alarm dialog
00222         static QString             mDefaultSoundFile;
00223         static float               mDefaultSoundVolume;
00224         static int                 mDefaultLateCancel;
00225         static bool                mDefaultAutoClose;
00226         static bool                mDefaultCopyToKOrganizer;
00227         static SoundPicker::Type   mDefaultSoundType;
00228         static bool                mDefaultSoundRepeat;
00229         static bool                mDefaultConfirmAck;
00230         static bool                mDefaultEmailBcc;
00231         static bool                mDefaultCmdScript;
00232         static EditAlarmDlg::CmdLogType   mDefaultCmdLogType;
00233         static QString                    mDefaultCmdLogFile;
00234         static RecurrenceEdit::RepeatType mDefaultRecurPeriod;
00235         static KARecurrence::Feb29Type    mDefaultFeb29Type;
00236         static TimePeriod::Units   mDefaultReminderUnits;
00237         static QString             mDefaultPreAction;
00238         static QString             mDefaultPostAction;
00239         // Change tracking
00240         static QTime               mOldStartOfDay;       // previous start-of-day time
00241         static bool                mStartOfDayChanged;   // start-of-day check value doesn't tally with mStartOfDay
00242 };
00243 
00244 #endif // PREFERENCES_H
KDE Home | KDE Accessibility Home | Description of Access Keys