1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2007-2011 Licq developers
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef CONFIG_GENERAL_H
21 #define CONFIG_GENERAL_H
22 
23 #include "config.h"
24 
25 #include <QFont>
26 #include <QObject>
27 #include <QRect>
28 
29 namespace Licq
30 {
31 class IniFile;
32 }
33 
34 namespace LicqQtGui
35 {
36 namespace Config
37 {
38 /**
39  * General configuration, including main window and dock icon
40  */
41 class General : public QObject
42 {
43   Q_OBJECT
44 
45 public:
46   enum DockMode
47   {
48     DockNone = 0,
49     DockDefault = 1,
50     DockThemed = 2,
51     DockTray = 3
52   };
53 
54   /**
55    * Create the singleton instance
56    *
57    * @param parent Parent object
58    */
59   static void createInstance(QObject* parent = NULL);
60 
61   /**
62    * Get the singleton instance
63    *
64    * @return The instance
65    */
instance()66   static General* instance()
67   { return myInstance; }
68 
69 
70   /**
71    * Constuctor
72    */
73   General(QObject* parent = 0);
74 
~General()75   ~General() {}
76 
77   void blockUpdates(bool block);
78 
79   // Get functions
useDoubleReturn()80   bool useDoubleReturn() const { return myUseDoubleReturn; }
defaultFont()81   const QFont& defaultFont() const { return myDefaultFont; }
defaultFixedFont()82   const QFont& defaultFixedFont() const { return myDefaultFixedFont; }
83   QFont normalFont() const;
editFont()84   const QFont& editFont() const { return myEditFont; }
historyFont()85   const QFont& historyFont() const { return myHistoryFont; }
fixedFont()86   const QFont& fixedFont() const { return myFixedFont; }
87 
88 #ifndef USE_KDE
89   QString guiStyle() const;
90 #endif
91 
miniMode()92   bool miniMode() const { return myMiniMode; }
showGroupIfNoMsg()93   bool showGroupIfNoMsg() const { return myShowGroupIfNoMsg; }
boldOnMsg()94   bool boldOnMsg() const { return myBoldOnMsg; }
mainwinDraggable()95   bool mainwinDraggable() const { return myMainwinDraggable; }
mainwinSticky()96   bool mainwinSticky() const { return myMainwinSticky; }
autoRaiseMainwin()97   bool autoRaiseMainwin() const { return myAutoRaiseMainwin; }
mainwinStartHidden()98   bool mainwinStartHidden() const { return myMainwinStartHidden; }
mainwinRect()99   const QRect& mainwinRect() const { return myMainwinRect; }
100 
dockMode()101   DockMode dockMode() const { return myDockMode; }
102 #ifndef USE_KDE
defaultIconFortyEight()103   bool defaultIconFortyEight() const { return myDefaultIconFortyEight; }
themedIconTheme()104   const QString& themedIconTheme() const { return myThemedIconTheme; }
105 #endif
trayBlink()106   bool trayBlink() const { return myTrayBlink; }
trayMsgOnlineNotify()107   bool trayMsgOnlineNotify() const { return myTrayMsgOnlineNotify; }
108 
autoAwayTime()109   int autoAwayTime() const { return myAutoAwayTime; }
autoNaTime()110   int autoNaTime() const { return myAutoNaTime; }
autoOfflineTime()111   int autoOfflineTime() const { return myAutoOfflineTime; }
autoAwayMess()112   int autoAwayMess() const { return myAutoAwayMess; }
autoNaMess()113   int autoNaMess() const { return myAutoNaMess; }
114 
115 public slots:
116   /**
117    * Load configuration from file
118    */
119   void loadConfiguration(Licq::IniFile& iniFile);
120 
121   /**
122    * Save configuration to file
123    */
124   void saveConfiguration(Licq::IniFile& iniFile) const;
125 
126   // Set functions
127   void setUseDoubleReturn(bool useDoubleReturn);
128   void setNormalFont(const QString& normalFont);
129   void setEditFont(const QString& editFont);
130   void setHistoryFont(const QString& historyFont);
131   void setFixedFont(const QString& fixedFont);
132 
133   void setMiniMode(bool miniMode);
134   void setShowGroupIfNoMsg(bool showGroupIfNoMsg);
135   void setBoldOnMsg(bool boldOnMsg);
136   void setMainwinDraggable(bool mainwinDraggable);
137   void setMainwinSticky(bool mainwinSticky);
138   void setAutoRaiseMainwin(bool autoRaiseMainwin);
139   void setMainwinStartHidden(bool mainwinStartHidden);
140   void setMainwinRect(const QRect& geometry);
141 
142 #ifndef USE_KDE
143   void setGuiStyle(const QString& guiStyle);
144 #endif
145 
146   void setDockMode(DockMode dockMode);
147 #ifndef USE_KDE
148   void setDefaultIconFortyEight(bool defaultIconFortyEight);
149   void setThemedIconTheme(const QString& themedIconTheme);
150 #endif
151   void setTrayBlink(bool trayBlink);
152   void setTrayMsgOnlineNotify(bool trayMsgOnlineNotify);
153 
154   void setAutoAwayTime(int autoAwayTime);
155   void setAutoNaTime(int autoNaTime);
156   void setAutoOfflineTime(int autoOfflineTime);
157   void setAutoAwayMess(int autoAwayMess);
158   void setAutoNaMess(int autoNaMess);
159 
160   // Toggle functions for convenience
161   void toggleMiniMode();
162 
163 signals:
164   /**
165    * Configuration affecting main window has changed
166    */
167   void mainwinChanged();
168 
169   /**
170    * Dock icon type has changed
171    */
172   void dockModeChanged();
173 
174   /**
175    * Configuration affecting dock icon has changed
176    */
177   void dockChanged();
178 
179   /**
180    * Font configuration has changed (not emitted for normal font)
181    */
182   void fontChanged();
183 
184   /**
185    * GUI Style has changed
186    */
187   void styleChanged();
188 
189   /**
190    * Popup key has changed
191    */
192   void msgPopupKeyChanged(const QString& newKey);
193 
194 private:
195   static General* myInstance;
196 
197   // Changes have been made that should trigger changed() signal
198   bool myMainwinHasChanged;
199   bool myDockHasChanged;
200   bool myDockModeHasChanged;
201   bool myFontHasChanged;
202   bool myStyleHasChanged;
203   bool myBlockUpdates;
204 
205   // General configuration
206   bool myUseDoubleReturn;
207   QFont myDefaultFont;
208   QFont myDefaultFixedFont;
209   QFont myEditFont;
210   QFont myHistoryFont;
211   QFont myFixedFont;
212 #ifndef USE_KDE
213   QString myDefaultStyle;
214 #endif
215 
216   // Mainwin configuration
217   bool myMiniMode;
218   bool myShowGroupIfNoMsg;
219   bool myBoldOnMsg;
220   bool myMainwinDraggable;
221   bool myMainwinSticky;
222   bool myAutoRaiseMainwin;
223   bool myMainwinStartHidden;
224   bool myFrameTransparent;
225   QRect myMainwinRect;
226 
227   // Dock configuration
228   DockMode myDockMode;
229 #ifndef USE_KDE
230   bool myDefaultIconFortyEight;
231   QString myThemedIconTheme;
232 #endif
233   bool myTrayBlink;
234   bool myTrayMsgOnlineNotify;
235 
236   // Auto status configuration
237   int myAutoAwayTime;
238   int myAutoNaTime;
239   int myAutoOfflineTime;
240   int myAutoAwayMess;
241   int myAutoNaMess;
242 };
243 
244 } // namespace Config
245 } // namespace LicqQtGui
246 
247 #endif
248