| 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 ICONMANAGER_H |
|---|
| 22 | #define ICONMANAGER_H |
|---|
| 23 | |
|---|
| 24 | #include "config.h" |
|---|
| 25 | |
|---|
| 26 | #include <QMap> |
|---|
| 27 | #include <QObject> |
|---|
| 28 | #include <QPair> |
|---|
| 29 | #include <QPixmap> |
|---|
| 30 | |
|---|
| 31 | #include <licq_icq.h> |
|---|
| 32 | #include <licq_user.h> |
|---|
| 33 | |
|---|
| 34 | #include "core/gui-defines.h" |
|---|
| 35 | |
|---|
| 36 | namespace LicqQtGui |
|---|
| 37 | { |
|---|
| 38 | /** |
|---|
| 39 | * Manager for icon sets used in gui |
|---|
| 40 | */ |
|---|
| 41 | class IconManager : public QObject |
|---|
| 42 | { |
|---|
| 43 | Q_OBJECT |
|---|
| 44 | |
|---|
| 45 | public: |
|---|
| 46 | enum IconType |
|---|
| 47 | { |
|---|
| 48 | // Message icons |
|---|
| 49 | StandardMessageIcon, |
|---|
| 50 | UrlMessageIcon, |
|---|
| 51 | ChatMessageIcon, |
|---|
| 52 | FileMessageIcon, |
|---|
| 53 | ContactMessageIcon, |
|---|
| 54 | SmsMessageIcon, |
|---|
| 55 | AuthorizeMessageIcon, |
|---|
| 56 | ReqAuthorizeMessageIcon, |
|---|
| 57 | |
|---|
| 58 | // Extended icons |
|---|
| 59 | BirthdayIcon, |
|---|
| 60 | CellularIcon, |
|---|
| 61 | CollapsedIcon, |
|---|
| 62 | CustomArIcon, |
|---|
| 63 | ExpandedIcon, |
|---|
| 64 | #ifdef HAVE_LIBGPGME |
|---|
| 65 | GpgKeyDisabledIcon, |
|---|
| 66 | GpgKeyEnabledIcon, |
|---|
| 67 | #endif |
|---|
| 68 | IcqPhoneActiveIcon, |
|---|
| 69 | IcqPhoneBusyIcon, |
|---|
| 70 | InvisibleIcon, |
|---|
| 71 | PfmActiveIcon, |
|---|
| 72 | PfmBusyIcon, |
|---|
| 73 | PhoneIcon, |
|---|
| 74 | SharedFilesIcon, |
|---|
| 75 | TypingIcon, |
|---|
| 76 | |
|---|
| 77 | // Menu icons |
|---|
| 78 | RemoveIcon, |
|---|
| 79 | SearchIcon, |
|---|
| 80 | #ifdef HAVE_LIBGPGME |
|---|
| 81 | GpgKeyIcon, |
|---|
| 82 | #endif |
|---|
| 83 | |
|---|
| 84 | // Toolbar icons |
|---|
| 85 | BackColorIcon, |
|---|
| 86 | BeepIcon, |
|---|
| 87 | BoldIcon, |
|---|
| 88 | EncodingIcon, |
|---|
| 89 | HistoryIcon, |
|---|
| 90 | IgnoreIcon, |
|---|
| 91 | InfoIcon, |
|---|
| 92 | ItalicIcon, |
|---|
| 93 | MenuIcon, |
|---|
| 94 | MultipleRecIcon, |
|---|
| 95 | SecureOffIcon, |
|---|
| 96 | SecureOnIcon, |
|---|
| 97 | SmileIcon, |
|---|
| 98 | StrikethroughIcon, |
|---|
| 99 | TextColorIcon, |
|---|
| 100 | ThroughServerIcon, |
|---|
| 101 | UnderlineIcon, |
|---|
| 102 | UrgentIcon, |
|---|
| 103 | |
|---|
| 104 | // Phonebook icons |
|---|
| 105 | MobileIcon, |
|---|
| 106 | SMSIcon, |
|---|
| 107 | FaxIcon, |
|---|
| 108 | PagerIcon, |
|---|
| 109 | PSTNIcon, |
|---|
| 110 | }; |
|---|
| 111 | |
|---|
| 112 | enum StatusIconType |
|---|
| 113 | { |
|---|
| 114 | OnlineStatusIcon = ICQ_STATUS_ONLINE, |
|---|
| 115 | OfflineStatusIcon = ICQ_STATUS_OFFLINE, |
|---|
| 116 | AwayStatusIcon = ICQ_STATUS_AWAY, |
|---|
| 117 | DoNotDisturbStatusIcon = ICQ_STATUS_DND, |
|---|
| 118 | OccupiedStatusIcon = ICQ_STATUS_OCCUPIED, |
|---|
| 119 | NotAvailableStatusIcon = ICQ_STATUS_NA, |
|---|
| 120 | FreeForChatStatusIcon = ICQ_STATUS_FREEFORCHAT, |
|---|
| 121 | PrivateStatusIcon = ICQ_STATUS_FxPRIVATE, |
|---|
| 122 | }; |
|---|
| 123 | |
|---|
| 124 | enum ProtocolType |
|---|
| 125 | { |
|---|
| 126 | ProtocolIcq = LICQ_PPID, |
|---|
| 127 | ProtocolMsn = MSN_PPID, |
|---|
| 128 | ProtocolAim, |
|---|
| 129 | }; |
|---|
| 130 | |
|---|
| 131 | /** |
|---|
| 132 | * Create the Icon Manager instance |
|---|
| 133 | * |
|---|
| 134 | * @param iconSet Initial icon set to load |
|---|
| 135 | * @param extendedIconSet Initial extended icon set to load |
|---|
| 136 | * @param parent Parent object |
|---|
| 137 | */ |
|---|
| 138 | static void createInstance(QString iconSet, QString extendedIconSet, QObject* parent = NULL); |
|---|
| 139 | |
|---|
| 140 | /** |
|---|
| 141 | * Get the Icon Manager |
|---|
| 142 | * |
|---|
| 143 | * @return The icon manager singleton |
|---|
| 144 | */ |
|---|
| 145 | static IconManager* instance() |
|---|
| 146 | { return myInstance; } |
|---|
| 147 | |
|---|
| 148 | /** |
|---|
| 149 | * Load a set of icons |
|---|
| 150 | * |
|---|
| 151 | * @param iconSet Name of icon set |
|---|
| 152 | * @return True if icon set was found and index files could be read |
|---|
| 153 | */ |
|---|
| 154 | bool loadIcons(QString iconSet); |
|---|
| 155 | |
|---|
| 156 | /** |
|---|
| 157 | * Load a set of extended icons |
|---|
| 158 | * |
|---|
| 159 | * @param iconSet Name of extended icon set |
|---|
| 160 | * @return True if icon set was found and index files could be read |
|---|
| 161 | */ |
|---|
| 162 | bool loadExtendedIcons(QString iconSet); |
|---|
| 163 | |
|---|
| 164 | /** |
|---|
| 165 | * Get an icon |
|---|
| 166 | * |
|---|
| 167 | * @param icon The icon type to get |
|---|
| 168 | * @return The requested icon if loaded, otherwise a null pixmap |
|---|
| 169 | */ |
|---|
| 170 | const QPixmap& getIcon(IconType icon); |
|---|
| 171 | |
|---|
| 172 | /** |
|---|
| 173 | * Get icon for a protocol status |
|---|
| 174 | * |
|---|
| 175 | * @param fullStatus Status to get icon for, should be full to include invisible flag |
|---|
| 176 | * @param id Contact id, used to differentiate between ICQ and AIM |
|---|
| 177 | * @param ppid Id of protocol to use icon set for |
|---|
| 178 | * @return The requested icon if loaded, otherwise a null pixmap |
|---|
| 179 | */ |
|---|
| 180 | const QPixmap& iconForStatus(unsigned long fullStatus, QString id = "0", unsigned long ppid = LICQ_PPID); |
|---|
| 181 | |
|---|
| 182 | /** |
|---|
| 183 | * Get icon for an event type |
|---|
| 184 | * |
|---|
| 185 | * @param subCommand Message sub command to get icon for |
|---|
| 186 | * @return The requested icon if loaded, otherwise a null pixmap |
|---|
| 187 | */ |
|---|
| 188 | const QPixmap& iconForEvent(unsigned short subCommand); |
|---|
| 189 | |
|---|
| 190 | QString iconSet() const { return myIconSet; } |
|---|
| 191 | QString extendedIconSet() const { return myExtendedIconSet; } |
|---|
| 192 | |
|---|
| 193 | signals: |
|---|
| 194 | /** |
|---|
| 195 | * The icon set has changed, emitted for all icon sets |
|---|
| 196 | */ |
|---|
| 197 | void iconsChanged(); |
|---|
| 198 | |
|---|
| 199 | /** |
|---|
| 200 | * The general icons has changed |
|---|
| 201 | */ |
|---|
| 202 | void generalIconsChanged(); |
|---|
| 203 | |
|---|
| 204 | /** |
|---|
| 205 | * The status icons has changed |
|---|
| 206 | */ |
|---|
| 207 | void statusIconsChanged(); |
|---|
| 208 | |
|---|
| 209 | /** |
|---|
| 210 | * The extended icons has changed |
|---|
| 211 | */ |
|---|
| 212 | void extendedIconsChanged(); |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | private: |
|---|
| 216 | // Singleton instance |
|---|
| 217 | static IconManager* myInstance; |
|---|
| 218 | |
|---|
| 219 | /** |
|---|
| 220 | * Constructor, private so only createInstance() can call it |
|---|
| 221 | * |
|---|
| 222 | * @param iconSet Initial icon set to load |
|---|
| 223 | * @param extendedIconSet Initial extended icon set to load |
|---|
| 224 | * @param parent Parent object |
|---|
| 225 | */ |
|---|
| 226 | IconManager(QString iconSet, QString extendedIconSet, QObject* parent = NULL); |
|---|
| 227 | |
|---|
| 228 | /** |
|---|
| 229 | * Destructor |
|---|
| 230 | */ |
|---|
| 231 | virtual ~IconManager() {} |
|---|
| 232 | |
|---|
| 233 | QString myIconSet; |
|---|
| 234 | QString myExtendedIconSet; |
|---|
| 235 | |
|---|
| 236 | // Map of current icons |
|---|
| 237 | QMap<IconType, QPixmap> myIconMap; |
|---|
| 238 | |
|---|
| 239 | // Map of status icons for different protocols |
|---|
| 240 | QMap<QPair<ProtocolType, StatusIconType>, QPixmap> myStatusIconMap; |
|---|
| 241 | |
|---|
| 242 | // Null icon that can be returned as default |
|---|
| 243 | QPixmap myEmptyIcon; |
|---|
| 244 | }; |
|---|
| 245 | |
|---|
| 246 | } // namespace LicqQtGui |
|---|
| 247 | |
|---|
| 248 | #endif |
|---|