removed the content from template.docbook, which is completly unrelated to kmobiletools
[kdepim.git] / korn / settings.h
blob28c8a9c26de3b16753929aab106134c2b62e2902
1 /*
2 * Copyright (C) 2006, Mart Kelder (mart@kelder31.nl)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef MK_SETTINGS_H
21 #define MK_SETTINGS_H
23 #include <kconfigskeleton.h>
25 class BoxSettings;
26 class QString;
28 template< class T, class S > class QMap;
30 class AccountSettings : public KConfigSkeleton
31 { Q_OBJECT
32 public:
33 AccountSettings( KSharedConfig::Ptr *config, BoxSettings *parent, int boxnr, int accountnr );
34 AccountSettings( const AccountSettings& other );
35 ~AccountSettings();
37 AccountSettings& operator=( const AccountSettings &other );
39 void newGroup( int boxnr, int accountnr );
41 QString protocol() const;
42 void setProtocol( const QString& val );
44 QString accountName() const;
45 void setAccountName( const QString& val );
47 int accountNumber() const { return m_accountnr; }
49 bool useBoxSettings() const { return m_useBoxSettings; }
50 void setUseBoxSettings( bool val ) { m_useBoxSettings = val; }
52 int reset() const { return m_reset; }
53 void setReset( int val ) { m_reset = val; }
55 int interval() const { return m_interval; }
56 void setInterval( int val ) { m_interval = val; }
58 bool passivePopup() const;
59 void setPassivePopup( bool val ) { m_passivePopup = val; }
61 bool passiveDate() const;
62 void setPassiveDate( bool val ) { m_passiveDate = val; }
64 QString command() const;
65 void setCommand( const QString& val );
67 QString sound() const;
68 void setSound( const QString& val );
70 QMap< QString, QString > readEntries() const;
71 void writeEntries( const QMap< QString, QString > &settings );
72 protected:
73 virtual void usrReadConfig();
74 virtual void usrWriteConfig();
75 private:
76 void init();
77 void copy( const AccountSettings& );
79 signals:
80 void resetChanged();
81 private:
82 //Parent
83 BoxSettings *m_box;
84 KSharedConfig::Ptr *m_config;
85 int m_boxnr;
86 int m_accountnr;
87 //General entries
88 QString *m_protocol;
89 QString *m_name;
90 bool m_useBoxSettings;
91 int m_reset;
92 int m_interval;
94 //New mail settings
95 bool m_passivePopup;
96 bool m_passiveDate;
97 QString *m_command;
98 QString *m_sound;
100 QMap< QString, QString > *m_settings;
103 class BoxSettings : public KConfigSkeleton
104 { Q_OBJECT
105 public:
106 BoxSettings( KSharedConfig::Ptr *config, int boxnr );
107 BoxSettings( const BoxSettings& other );
108 ~BoxSettings();
110 enum State { Normal = 0, New = 1 };
111 enum Action { Recheck = 0, Reset = 1, View = 2, Run = 3, Popup = 4 };
113 void newGroup( int boxnr );
115 QString boxName() const;
116 void setBoxName( const QString& val );
118 QString command() const;
119 void setCommand( const QString& val );
121 bool hasAnimation( State state ) const { return m_hasAnim[ state ]; }
122 void setHasAnimation( State state, bool val ) { m_hasAnim[ state ] = val; }
124 bool hasBackgroundColor( State state ) const { return m_hasBgColor[ state ]; }
125 void setHasBackgroundColor( State state, bool val ) { m_hasBgColor[ state ] = val; }
127 bool hasForegroundColor( State state ) const { return m_hasFgColor[ state ]; }
128 void setHasForegroundColor( State state, bool val ) { m_hasFgColor[ state ] = val; }
130 bool hasFont( State state ) const { return m_hasFont[ state ]; }
131 void setHasFont( State state, bool val ) { m_hasFont[ state ] = val; }
133 bool hasIcon( State state ) const { return m_hasIcon[ state ]; }
134 void setHasIcon( State state, bool val ) { m_hasIcon[ state ] = val; }
136 QString animation( State state ) const;
137 void setAnimation( State state, const QString& val );
139 QColor backgroundColor( State state ) const;
140 void setBackgroundColor( State state, const QColor& val );
142 QColor foregroundColor( State state ) const;
143 void setForegroundColor( State state, const QColor& val );
145 QFont font( State state ) const;
146 void setFont( State state, const QFont& val );
148 QString icon( State state ) const;
149 void setIcon( State state, const QString& val );
151 bool clickCommand( Qt::MouseButton button, Action action );
152 void setClickCommand( Qt::MouseButton, Action action, bool val );
154 bool passivePopup() const { return m_passivePopup; }
155 void setPassivePopup( bool val ) { m_passivePopup = val; }
157 bool passiveDate() const { return m_passiveDate; }
158 void setPassiveDate( bool val ) { m_passiveDate = val; }
160 QString newCommand() const;
161 void setNewCommand( const QString& val );
163 QString sound() const;
164 void setSound( const QString& val );
166 AccountSettings* account( int accountnr );
167 void addAccount();
168 void deleteAccount( int accountnr );
169 void swapAccounts( int account1, int account2 );
170 protected:
171 virtual void usrReadConfig();
172 virtual void usrWriteConfig();
173 private:
174 void init();
175 void copy( const BoxSettings& other );
176 private:
177 enum MouseButton { Left = 0, Middle = 1, Right = 2 };
179 int m_boxnr;
181 //General settings
182 QString *m_boxname;
183 QString *m_command;
185 //Visual settings
186 bool m_hasAnim[2];
187 bool m_hasBgColor[2];
188 bool m_hasFgColor[2];
189 bool m_hasFont[2];
190 bool m_hasIcon[2];
191 QString *m_anim[2];
192 QColor *m_bgColor[2];
193 QColor *m_fgColor[2];
194 QFont *m_font[2];
195 QString *m_icon[2];
197 //Click commands
198 bool m_clickCommand[3][5];
200 //New mail settings
201 bool m_passivePopup;
202 bool m_passiveDate;
203 QString *m_newcommand;
204 QString *m_sound;
206 //Accounts
207 QList< AccountSettings* > *m_accounts;
209 KSharedConfig::Ptr *m_config;
212 class Settings : public KConfigSkeleton
213 { Q_OBJECT
214 public:
215 Settings();
216 Settings( const Settings& );
217 ~Settings();
219 Settings& operator=( const Settings& other );
221 enum Layout { Horizontal, Vertical, Docked };
223 void setLayout( Layout val ) { m_layout = (int)val; }
224 Layout layout() const { return (Settings::Layout)m_layout; }
226 void setUseWallet( bool val ) { m_useWallet = val; }
227 bool useWallet() const { return m_useWallet; }
229 BoxSettings* getBox( int nr );
230 const BoxSettings* getBox( int nr ) const;
231 void addBox();
232 void deleteBox( int nr );
233 void swapBox( int elem1, int elem2 );
235 static Settings* self();
236 protected:
237 virtual void usrReadConfig();
238 virtual void usrWriteConfig();
239 private:
240 void init();
241 void copy( const Settings& other );
242 private:
243 int m_layout;
244 bool m_useWallet;
245 QList< BoxSettings* > *m_box;
247 static KSharedConfig::Ptr *m_config;
248 static Settings* m_self;
251 #endif //MK_SETTINGS_H