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
23 #include <kconfigskeleton.h>
28 template< class T
, class S
> class QMap
;
30 class AccountSettings
: public KConfigSkeleton
33 AccountSettings( KSharedConfig::Ptr
*config
, BoxSettings
*parent
, int boxnr
, int accountnr
);
34 AccountSettings( const AccountSettings
& other
);
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
);
73 virtual void usrReadConfig();
74 virtual void usrWriteConfig();
77 void copy( const AccountSettings
& );
84 KSharedConfig::Ptr
*m_config
;
90 bool m_useBoxSettings
;
100 QMap
< QString
, QString
> *m_settings
;
103 class BoxSettings
: public KConfigSkeleton
106 BoxSettings( KSharedConfig::Ptr
*config
, int boxnr
);
107 BoxSettings( const BoxSettings
& other
);
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
);
168 void deleteAccount( int accountnr
);
169 void swapAccounts( int account1
, int account2
);
171 virtual void usrReadConfig();
172 virtual void usrWriteConfig();
175 void copy( const BoxSettings
& other
);
177 enum MouseButton
{ Left
= 0, Middle
= 1, Right
= 2 };
187 bool m_hasBgColor
[2];
188 bool m_hasFgColor
[2];
192 QColor
*m_bgColor
[2];
193 QColor
*m_fgColor
[2];
198 bool m_clickCommand
[3][5];
203 QString
*m_newcommand
;
207 QList
< AccountSettings
* > *m_accounts
;
209 KSharedConfig::Ptr
*m_config
;
212 class Settings
: public KConfigSkeleton
216 Settings( const 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;
232 void deleteBox( int nr
);
233 void swapBox( int elem1
, int elem2
);
235 static Settings
* self();
237 virtual void usrReadConfig();
238 virtual void usrWriteConfig();
241 void copy( const Settings
& other
);
245 QList
< BoxSettings
* > *m_box
;
247 static KSharedConfig::Ptr
*m_config
;
248 static Settings
* m_self
;
251 #endif //MK_SETTINGS_H