kalarm

preferences.h
1/*
2 * preferences.h - program preference settings
3 * Program: kalarm
4 * Copyright © 2001-2007 by David Jarvie <djarvie@kde.org>
5 *
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.
10 *
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.
15 *
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.
19 */
20
21#ifndef PREFERENCES_H
22#define PREFERENCES_H
23
24#include "kalarm.h"
25
26#include <tqobject.h>
27#include <tqcolor.h>
28#include <tqfont.h>
29#include <tqdatetime.h>
30#include <tqvaluelist.h>
31class TQWidget;
32
33#include "colourlist.h"
34#include "editdlg.h"
35#include "karecurrence.h"
36#include "recurrenceedit.h"
37#include "soundpicker.h"
38#include "timeperiod.h"
39
40
41// Settings configured in the Preferences dialog
42class Preferences : public TQObject
43{
44 TQ_OBJECT
45
46 public:
47 enum MailClient { SENDMAIL, KMAIL };
48 enum MailFrom { MAIL_FROM_KMAIL, MAIL_FROM_CONTROL_CENTRE, MAIL_FROM_ADDR };
49 enum CmdLogType { DISCARD_OUTPUT, LOG_TO_FILE, EXEC_IN_TERMINAL };
50
51 static void initialise();
52 static void save(bool syncToDisc = true);
53 static void syncToDisc();
54 static void updateStartOfDayCheck();
55 static void connect(const char* signal, const TQObject* receiver, const char* member);
56
57 // Access to settings
58 static const ColourList& messageColours() { return mMessageColours; }
59 static TQColor defaultBgColour() { return mDefaultBgColour; }
60 static TQColor defaultFgColour() { return default_defaultFgColour; }
61 static const TQFont& messageFont() { return mMessageFont; }
62 static const TQTime& startOfDay() { return mStartOfDay; }
63 static bool hasStartOfDayChanged() { return mStartOfDayChanged; }
64 static bool runInSystemTray() { return mRunInSystemTray; }
65 static bool disableAlarmsIfStopped() { return mDisableAlarmsIfStopped; }
66 static bool quitWarn() { return notifying(QUIT_WARN); }
67 static void setQuitWarn(bool yes) { setNotify(QUIT_WARN, yes); }
68 static bool autostartTrayIcon() { return mAutostartTrayIcon; }
69 static bool confirmAlarmDeletion() { return notifying(CONFIRM_ALARM_DELETION); }
70 static void setConfirmAlarmDeletion(bool yes){ setNotify(CONFIRM_ALARM_DELETION, yes); }
71 static bool modalMessages() { return mModalMessages; }
72 static int messageButtonDelay() { return mMessageButtonDelay; }
73 static int tooltipAlarmCount() { return mTooltipAlarmCount; }
74 static bool showTooltipAlarmTime() { return mShowTooltipAlarmTime; }
75 static bool showTooltipTimeToAlarm() { return mShowTooltipTimeToAlarm; }
76 static const TQString& tooltipTimeToPrefix() { return mTooltipTimeToPrefix; }
77 static int daemonTrayCheckInterval() { return mDaemonTrayCheckInterval; }
78 static MailClient emailClient() { return mEmailClient; }
79 static bool emailCopyToKMail() { return mEmailCopyToKMail && mEmailClient == SENDMAIL; }
80 static bool emailQueuedNotify() { return notifying(EMAIL_QUEUED_NOTIFY); }
81 static void setEmailQueuedNotify(bool yes) { setNotify(EMAIL_QUEUED_NOTIFY, yes); }
82 static MailFrom emailFrom() { return mEmailFrom; }
83 static bool emailBccUseControlCentre() { return mEmailBccFrom == MAIL_FROM_CONTROL_CENTRE; }
84 static TQString emailAddress();
85 static TQString emailBccAddress();
86 static TQString cmdXTermCommand() { return mCmdXTermCommand; }
87 static TQColor disabledColour() { return mDisabledColour; }
88 static TQColor expiredColour() { return mExpiredColour; }
89 static int expiredKeepDays() { return mExpiredKeepDays; }
90 static SoundPicker::Type defaultSoundType() { return mDefaultSoundType; }
91 static const TQString& defaultSoundFile() { return mDefaultSoundFile; }
92 static float defaultSoundVolume() { return mDefaultSoundVolume; }
93 static bool defaultSoundRepeat() { return mDefaultSoundRepeat; }
94 static int defaultLateCancel() { return mDefaultLateCancel; }
95 static bool defaultAutoClose() { return mDefaultAutoClose; }
96 static bool defaultConfirmAck() { return mDefaultConfirmAck; }
97 static bool defaultCopyToKOrganizer() { return mDefaultCopyToKOrganizer; }
98 static bool defaultCmdScript() { return mDefaultCmdScript; }
99 static EditAlarmDlg::CmdLogType
100 defaultCmdLogType() { return mDefaultCmdLogType; }
101 static TQString defaultCmdLogFile() { return mDefaultCmdLogFile; }
102 static bool defaultEmailBcc() { return mDefaultEmailBcc; }
103 static RecurrenceEdit::RepeatType
104 defaultRecurPeriod() { return mDefaultRecurPeriod; }
105 static KARecurrence::Feb29Type
106 defaultFeb29Type() { return mDefaultFeb29Type; }
107 static TimePeriod::Units defaultReminderUnits() { return mDefaultReminderUnits; }
108 static const TQString& defaultPreAction() { return mDefaultPreAction; }
109 static const TQString& defaultPostAction() { return mDefaultPostAction; }
110
111 // Config file entry names for notification messages
112 static const TQString QUIT_WARN;
113 static const TQString CONFIRM_ALARM_DELETION;
114 static const TQString EMAIL_QUEUED_NOTIFY;
115
116 // Default values for settings
117 static const ColourList default_messageColours;
118 static const TQColor default_defaultBgColour;
119 static const TQColor default_defaultFgColour;
120 static const TQFont& default_messageFont() { return mDefault_messageFont; };
121 static const TQTime default_startOfDay;
122 static const bool default_runInSystemTray;
123 static const bool default_disableAlarmsIfStopped;
124 static const bool default_quitWarn;
125 static const bool default_autostartTrayIcon;
126 static const bool default_confirmAlarmDeletion;
127 static const bool default_modalMessages;
128 static const int default_messageButtonDelay;
129 static const int default_tooltipAlarmCount;
130 static const bool default_showTooltipAlarmTime;
131 static const bool default_showTooltipTimeToAlarm;
132 static const TQString default_tooltipTimeToPrefix;
133 static const int default_daemonTrayCheckInterval;
134 static const MailClient default_emailClient;
135 static const bool default_emailCopyToKMail;
136 static MailFrom default_emailFrom();
137 static const bool default_emailQueuedNotify;
138 static const MailFrom default_emailBccFrom;
139 static const TQString default_emailAddress;
140 static const TQString default_emailBccAddress;
141 static const TQColor default_disabledColour;
142 static const TQColor default_expiredColour;
143 static const int default_expiredKeepDays;
144 static const TQString default_defaultSoundFile;
145 static const float default_defaultSoundVolume;
146 static const int default_defaultLateCancel;
147 static const bool default_defaultAutoClose;
148 static const bool default_defaultCopyToKOrganizer;
149 static const SoundPicker::Type default_defaultSoundType;
150 static const bool default_defaultSoundRepeat;
151 static const bool default_defaultConfirmAck;
152 static const bool default_defaultCmdScript;
153 static const EditAlarmDlg::CmdLogType default_defaultCmdLogType;
154 static const bool default_defaultEmailBcc;
155 static const RecurrenceEdit::RepeatType default_defaultRecurPeriod;
156 static const KARecurrence::Feb29Type default_defaultFeb29Type;
157 static const TimePeriod::Units default_defaultReminderUnits;
158 static const TQString default_defaultPreAction;
159 static const TQString default_defaultPostAction;
160
161 signals:
162 void preferencesChanged();
163 void startOfDayChanged(const TQTime& oldStartOfDay);
164
165 private:
166 Preferences() { } // only one instance allowed
167 void emitPreferencesChanged();
168 void emitStartOfDayChanged();
169
170 static void read();
171 static void convertOldPrefs();
172 static int startOfDayCheck();
173 static TQString emailFrom(MailFrom, bool useAddress, bool bcc);
174 static MailFrom emailFrom(const TQString&);
175 static void setNotify(const TQString& messageID, bool notify);
176 static bool notifying(const TQString& messageID);
177
178 static Preferences* mInstance;
179 static TQFont mDefault_messageFont;
180 static TQString mEmailAddress;
181 static TQString mEmailBccAddress;
182
183 // All the following members are accessed by the Preferences dialog classes
184 friend class MiscPrefTab;
185 friend class EditPrefTab;
186 friend class ViewPrefTab;
187 friend class FontColourPrefTab;
188 friend class EmailPrefTab;
189 static void setEmailAddress(MailFrom, const TQString& address);
190 static void setEmailBccAddress(bool useControlCentre, const TQString& address);
191 static ColourList mMessageColours;
192 static TQColor mDefaultBgColour;
193 static TQFont mMessageFont;
194 static TQTime mStartOfDay;
195 static bool mRunInSystemTray;
196 static bool mDisableAlarmsIfStopped;
197 static bool mAutostartTrayIcon;
198 static bool mModalMessages;
199 static int mMessageButtonDelay; // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
200 static int mTooltipAlarmCount;
201 static bool mShowTooltipAlarmTime;
202 static bool mShowTooltipTimeToAlarm;
203 static TQString mTooltipTimeToPrefix;
204 static int mDaemonTrayCheckInterval;
205 static MailClient mEmailClient;
206 static MailFrom mEmailFrom;
207 static MailFrom mEmailBccFrom;
208 static bool mEmailCopyToKMail;
209 static TQString mCmdXTermCommand;
210 static TQColor mDisabledColour;
211 static TQColor mExpiredColour;
212 static int mExpiredKeepDays; // 0 = don't keep, -1 = keep indefinitely
213 // Default settings for Edit Alarm dialog
214 static TQString mDefaultSoundFile;
215 static float mDefaultSoundVolume;
216 static int mDefaultLateCancel;
217 static bool mDefaultAutoClose;
218 static bool mDefaultCopyToKOrganizer;
219 static SoundPicker::Type mDefaultSoundType;
220 static bool mDefaultSoundRepeat;
221 static bool mDefaultConfirmAck;
222 static bool mDefaultEmailBcc;
223 static bool mDefaultCmdScript;
224 static EditAlarmDlg::CmdLogType mDefaultCmdLogType;
225 static TQString mDefaultCmdLogFile;
226 static RecurrenceEdit::RepeatType mDefaultRecurPeriod;
227 static KARecurrence::Feb29Type mDefaultFeb29Type;
228 static TimePeriod::Units mDefaultReminderUnits;
229 static TQString mDefaultPreAction;
230 static TQString mDefaultPostAction;
231 // Change tracking
232 static TQTime mOldStartOfDay; // previous start-of-day time
233 static bool mStartOfDayChanged; // start-of-day check value doesn't tally with mStartOfDay
234};
235
236#endif // PREFERENCES_H