Build with clang.
[kdepim.git] / kalarm / preferences.h
blob001a79d40dfb7e5c96161cf12deaa15a8eebecc8
1 /*
2 * preferences.h - program preference settings
3 * Program: kalarm
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.
21 #ifndef PREFERENCES_H
22 #define PREFERENCES_H
24 #include "kalarm.h"
26 #include "kalarmconfig.h"
28 #include <QObject>
29 #include <QDateTime>
31 class KTimeZone;
32 namespace KHolidays { class HolidayRegion; }
35 // Settings configured in the Preferences dialog
36 class Preferences : public PreferencesBase
38 Q_OBJECT
39 public:
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; }
47 // Access to settings
48 static void setAskAutoStart(bool yes);
49 static KTimeZone timeZone(bool reload = false);
50 static void setTimeZone(const KTimeZone&);
51 static const KHolidays::HolidayRegion& holidays();
52 static void setHolidayRegion(const QString& regionCode);
53 static QTime startOfDay() { return self()->mBase_StartOfDay.time(); }
54 static void setStartOfDay(const QTime&);
55 static QTime workDayStart() { return self()->mBase_WorkDayStart.time(); }
56 static QTime workDayEnd() { return self()->mBase_WorkDayEnd.time(); }
57 static QBitArray workDays();
58 static void setWorkDayStart(const QTime& t) { self()->setBase_WorkDayStart(QDateTime(QDate(1900,1,1), t)); }
59 static void setWorkDayEnd(const QTime& t) { self()->setBase_WorkDayEnd(QDateTime(QDate(1900,1,1), t)); }
60 static void setWorkDays(const QBitArray&);
61 static bool quitWarn() { return mUsingDefaults ? self()->base_QuitWarn() : notifying(QUIT_WARN); }
62 static void setQuitWarn(bool yes) { setNotify(QUIT_WARN, yes); }
63 static bool confirmAlarmDeletion() { return mUsingDefaults ? self()->base_ConfirmAlarmDeletion() : notifying(CONFIRM_ALARM_DELETION); }
64 static void setConfirmAlarmDeletion(bool yes){ setNotify(CONFIRM_ALARM_DELETION, yes); }
65 static bool emailCopyToKMail() { return self()->mBase_EmailCopyToKMail && self()->mEmailClient == sendmail; }
66 static void setEmailCopyToKMail(bool yes) { self()->setBase_EmailCopyToKMail(yes); }
67 static bool emailQueuedNotify() { return mUsingDefaults ? self()->base_EmailQueuedNotify() : notifying(EMAIL_QUEUED_NOTIFY); }
68 static void setEmailQueuedNotify(bool yes) { setNotify(EMAIL_QUEUED_NOTIFY, yes); }
69 static MailFrom emailFrom();
70 static QString emailAddress();
71 static void setEmailAddress(MailFrom, const QString& address);
72 static MailFrom emailBccFrom();
73 static QString emailBccAddress();
74 static void setEmailBccAddress(bool useSystemSettings, const QString& address);
75 static bool emailBccUseSystemSettings();
76 static QString cmdXTermCommand();
77 static void setCmdXTermCommand(const QString& cmd);
78 static float defaultSoundVolume() { int vol = self()->mBase_DefaultSoundVolume; return (vol < 0) ? -1 : static_cast<float>(vol) / 100; }
79 static void setDefaultSoundVolume(float v) { self()->setBase_DefaultSoundVolume(v < 0 ? -1 : static_cast<int>(v * 100)); }
81 // Config file entry names for notification messages
82 static const char* QUIT_WARN;
83 static const char* ASK_AUTO_START;
84 static const char* CONFIRM_ALARM_DELETION;
85 static const char* EMAIL_QUEUED_NOTIFY;
87 virtual bool useDefaults(bool def) { mUsingDefaults = def; return PreferencesBase::useDefaults(def); }
89 signals:
90 void timeZoneChanged(const KTimeZone& newTz);
91 void holidaysChanged(const KHolidays::HolidayRegion& newHolidays);
92 void startOfDayChanged(const QTime& newStartOfDay);
93 void workTimeChanged(const QTime& startTime, const QTime& endTime, const QBitArray& workDays);
95 private slots:
96 void timeZoneChange(const QString&);
97 void holidaysChange(const QString& regionCode);
98 void startDayChange(const QDateTime&);
99 void workTimeChange(const QDateTime&, const QDateTime&, int days);
101 private:
102 Preferences(); // only one instance allowed
103 static int startOfDayCheck(const QTime&);
104 static void setNotify(const QString& messageID, bool notify);
105 static bool notifying(const QString& messageID);
107 static Preferences* mInstance;
108 static bool mUsingDefaults;
109 static KTimeZone mSystemTimeZone;
110 static KHolidays::HolidayRegion* mHolidays;
112 // All the following members are accessed by the Preferences dialog classes
113 static int mMessageButtonDelay; // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
115 // Change tracking
116 static bool mAutoStartChangedByUser; // AutoStart has been changed by the user
119 #endif // PREFERENCES_H
121 // vim: et sw=4: