2 * preferences.h - program preference settings
4 * Copyright © 2001-2010 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "kalarmconfig.h"
32 namespace KHolidays
{ class HolidayRegion
; }
35 // Settings configured in the Preferences dialog
36 class Preferences
: public PreferencesBase
40 enum MailFrom
{ MAIL_FROM_KMAIL
, MAIL_FROM_SYS_SETTINGS
, MAIL_FROM_ADDR
};
42 static Preferences
* self();
43 static void connect(const char* signal
, const QObject
* receiver
, const char* member
);
44 static bool autoStartChangedByUser() { return mAutoStartChangedByUser
; }
45 static void setAutoStartChangedByUser(bool c
){ mAutoStartChangedByUser
= c
; }
48 static QString
previousVersion() { return mPreviousVersion
; }
49 static Backend
previousBackend() { return mPreviousBackend
; }
50 static void setAskAutoStart(bool yes
);
51 static KTimeZone
timeZone(bool reload
= false);
52 static void setTimeZone(const KTimeZone
&);
53 static const KHolidays::HolidayRegion
& holidays();
54 static void setHolidayRegion(const QString
& regionCode
);
55 static QTime
startOfDay() { return self()->mBase_StartOfDay
.time(); }
56 static void setStartOfDay(const QTime
&);
57 static QTime
workDayStart() { return self()->mBase_WorkDayStart
.time(); }
58 static QTime
workDayEnd() { return self()->mBase_WorkDayEnd
.time(); }
59 static QBitArray
workDays();
60 static void setWorkDayStart(const QTime
& t
) { self()->setBase_WorkDayStart(QDateTime(QDate(1900,1,1), t
)); }
61 static void setWorkDayEnd(const QTime
& t
) { self()->setBase_WorkDayEnd(QDateTime(QDate(1900,1,1), t
)); }
62 static void setWorkDays(const QBitArray
&);
63 static bool quitWarn() { return mUsingDefaults
? self()->base_QuitWarn() : notifying(QUIT_WARN
); }
64 static void setQuitWarn(bool yes
) { setNotify(QUIT_WARN
, yes
); }
65 static bool confirmAlarmDeletion() { return mUsingDefaults
? self()->base_ConfirmAlarmDeletion() : notifying(CONFIRM_ALARM_DELETION
); }
66 static void setConfirmAlarmDeletion(bool yes
){ setNotify(CONFIRM_ALARM_DELETION
, yes
); }
67 static bool emailCopyToKMail() { return self()->mBase_EmailCopyToKMail
&& self()->mEmailClient
== sendmail
; }
68 static void setEmailCopyToKMail(bool yes
) { self()->setBase_EmailCopyToKMail(yes
); }
69 static bool emailQueuedNotify() { return mUsingDefaults
? self()->base_EmailQueuedNotify() : notifying(EMAIL_QUEUED_NOTIFY
); }
70 static void setEmailQueuedNotify(bool yes
) { setNotify(EMAIL_QUEUED_NOTIFY
, yes
); }
71 static MailFrom
emailFrom();
72 static QString
emailAddress();
73 static void setEmailAddress(MailFrom
, const QString
& address
);
74 static MailFrom
emailBccFrom();
75 static QString
emailBccAddress();
76 static void setEmailBccAddress(bool useSystemSettings
, const QString
& address
);
77 static bool emailBccUseSystemSettings();
78 static QString
cmdXTermCommand();
79 static void setCmdXTermCommand(const QString
& cmd
);
80 static float defaultSoundVolume() { int vol
= self()->mBase_DefaultSoundVolume
; return (vol
< 0) ? -1 : static_cast<float>(vol
) / 100; }
81 static void setDefaultSoundVolume(float v
) { self()->setBase_DefaultSoundVolume(v
< 0 ? -1 : static_cast<int>(v
* 100)); }
83 // Config file entry names for notification messages
84 static const QLatin1String QUIT_WARN
;
85 static const QLatin1String ASK_AUTO_START
;
86 static const QLatin1String CONFIRM_ALARM_DELETION
;
87 static const QLatin1String EMAIL_QUEUED_NOTIFY
;
89 virtual bool useDefaults(bool def
) { mUsingDefaults
= def
; return PreferencesBase::useDefaults(def
); }
92 void timeZoneChanged(const KTimeZone
& newTz
);
93 void holidaysChanged(const KHolidays::HolidayRegion
& newHolidays
);
94 void startOfDayChanged(const QTime
& newStartOfDay
);
95 void workTimeChanged(const QTime
& startTime
, const QTime
& endTime
, const QBitArray
& workDays
);
98 void timeZoneChange(const QString
&);
99 void holidaysChange(const QString
& regionCode
);
100 void startDayChange(const QDateTime
&);
101 void workTimeChange(const QDateTime
&, const QDateTime
&, int days
);
104 Preferences(); // only one instance allowed
105 static int startOfDayCheck(const QTime
&);
106 static void setNotify(const QString
& messageID
, bool notify
);
107 static bool notifying(const QString
& messageID
);
109 static Preferences
* mInstance
;
110 static bool mUsingDefaults
;
111 static KTimeZone mSystemTimeZone
;
112 static KHolidays::HolidayRegion
* mHolidays
;
113 static QString mPreviousVersion
; // last KAlarm version which wrote the config file
114 static Backend mPreviousBackend
; // backend used by last used version of KAlarm
116 // All the following members are accessed by the Preferences dialog classes
117 static int mMessageButtonDelay
; // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
120 static bool mAutoStartChangedByUser
; // AutoStart has been changed by the user
123 #endif // PREFERENCES_H