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