KVIrc  4.9.2
DeveloperAPIs
KviIconManager.h
Go to the documentation of this file.
1 #ifndef _KVI_ICONMANAGER_H_
2 #define _KVI_ICONMANAGER_H_
3 
4 //=============================================================================
5 //
6 // File : KviIconManager.h
7 // Creation date : Sat Jun 24 2000 14:49:24 by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
11 // Copyright (C) 2011 Elvio Basello (hellvis69 at gmail dot com)
12 //
13 // This program is FREE software. You can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the HOPE that it will be USEFUL,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 // See the GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program. If not, write to the Free Software Foundation,
25 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 //
27 //=============================================================================
28 
35 #include "kvi_settings.h"
36 #include "KviCString.h"
37 #include "KviAvatar.h"
38 #include "KviTimeUtils.h"
39 #include "KviPointerHashTable.h"
40 
41 #include <QPixmap>
42 #include <QObject>
43 #include <QWidget>
44 
45 #define KVI_BIGICON_DISCONNECTED "kvi_bigicon_disconnected.png"
46 #define KVI_BIGICON_CONNECTING "kvi_bigicon_connecting.png"
47 #define KVI_BIGICON_CONNECTED "kvi_bigicon_connected.png"
48 #define KVI_BIGICON_TOOLS "kvi_bigicon_tools.png"
49 #define KVI_BIGICON_ACTIONS "kvi_bigicon_actions.png"
50 #define KVI_BIGICON_USERACTION "kvi_bigicon_useraction.png"
51 #define KVI_BIGICON_FOLDER "kvi_bigicon_folder.png"
52 #define KVI_BIGICON_UNKNOWN "kvi_bigicon_unknown.png"
53 #define KVI_BIGICON_SEPARATOR "kvi_bigicon_separator.png"
54 #define KVI_BIGICON_KVS "kvi_bigicon_kvs.png"
55 #define KVI_BIGICON_THEME "kvi_bigicon_theme.png"
56 #define KVI_BIGICON_ADDONS "kvi_bigicon_addons.png"
57 
58 #define KVI_BIGICON_HELP "kvi_bigicon_help.png"
59 #define KVI_BIGICON_HELPINDEX "kvi_bigicon_helpindex.png"
60 #define KVI_BIGICON_HELPBACK "kvi_bigicon_helpback.png"
61 #define KVI_BIGICON_HELPFORWARD "kvi_bigicon_helpforward.png"
62 #define KVI_BIGICON_HELPCLOSE "kvi_bigicon_helpclose.png"
63 #define KVI_BIGICON_HELPSEARCH "kvi_bigicon_helpsearch.png"
64 
65 #define KVI_BIGICON_OPEN "kvi_bigicon_open.png"
66 #define KVI_BIGICON_SAVE "kvi_bigicon_save.png"
67 #define KVI_BIGICON_REMOVE "kvi_bigicon_remove.png"
68 #define KVI_BIGICON_WWW "kvi_bigicon_www.png"
69 #define KVI_BIGICON_PACK "kvi_bigicon_pack.png"
70 #define KVI_BIGICON_SCREENSHOT "kvi_bigicon_screenshot.png"
71 #define KVI_BIGICON_REGUSERS "kvi_bigicon_regusers.png"
72 
73 #define KVI_SMALLICONS_SUBDIRECTORY "coresmall"
74 #define KVI_SMALLICONS_PREFIX "kcs_"
75 
76 // FIXME: this should be removed
77 #define KVI_SMALLICONS_IMAGELIB_PREFIX "kvi_smallicon_"
78 
79 #define KVI_USERCHANSTATE_IMAGE_NAME "kvi_userchanstate.png"
80 #define KVI_ACTIVITYMETER_IMAGE_NAME "kvi_activitymeter.png"
81 
82 #define KVI_REFRESH_IMAGE_NAME "kvi_icon_refresh.png"
83 
85 
91 {
92 public:
100  KviCachedPixmap(QPixmap * pPix, const QString & szPath);
101 
105  ~KviCachedPixmap();
106 
107 private:
108  QString m_szPath;
110  QPixmap * m_pPixmap;
111  unsigned int m_uSize;
112 
113 public:
118  QPixmap * pixmap() { return m_pPixmap; };
119 
124  const QString & path() { return m_szPath; };
125 
130  unsigned int size() { return m_uSize; };
131 
136  kvi_time_t lastAccessTime() { return m_tLastAccess; };
137 
142  void updateLastAccessTime();
143 };
144 
160 class KVIRC_API KviIconManager : public QObject
161 {
162  Q_OBJECT
163 public:
169  {
170  None = 0,
171  Close = 1,
172  History = 2,
173  HistoryOff = 3,
174  UserMode = 4,
175  DefaultIcon = 5,
176  Dock = 6,
177  UnDock = 7,
178  QuitApp = 8,
179  Console = 9,
180  Save = 10,
181  ParserError = 11,
182  ParserWarning = 12,
183  Server = 13,
184  World = 14,
185  Proxy = 15,
186  KVIrc = 16,
187  Cut = 17,
188  Copy = 18,
189  Paste = 19,
190  Options = 20,
191  SocketMessage = 21,
192  SocketWarning = 22,
193  SocketError = 23,
194  SystemError = 24,
195  Raw = 25,
196  SystemWarning = 26,
197  SystemMessage = 27,
198  UnHandled = 28,
199  ServerInfo = 29,
200  Motd = 30,
201  Channel = 31,
202  HideDoubleView = 32,
203  ShowDoubleView = 33,
204  Op = 34,
205  Voice = 35,
206  ServerPing = 36,
207  ShowListView = 37,
208  HideListView = 38,
209  Join = 39,
210  Part = 40,
211  Unrecognized = 41,
212  Topic = 42,
213  Accept = 43,
214  Discard = 44,
215  OwnPrivMsg = 45,
216  ChanPrivMsg = 46,
217  Query = 47,
218  QueryPrivMsg = 48,
219  Help = 49,
220  QuestionMark = 50,
221  CtcpReply = 51,
222  CtcpRequestReplied = 52,
223  CtcpRequestIgnored = 53,
224  CtcpRequestFlood = 54,
225  CtcpRequestUnknown = 55,
226  Action = 56,
227  Avatar = 57,
228  Quit = 58,
229  Split = 59,
230  QuitSplit = 60,
231  Nick = 61,
232  DeOp = 62,
233  DeVoice = 63,
234  Mode = 64,
235  Key = 65,
236  Limit = 66,
237  Ban = 67,
238  UnBan = 68,
239  BanExcept = 69,
240  BanUnExcept = 70,
241  InviteExcept = 71,
242  InviteUnExcept = 72,
243  ChanMode = 73,
244  ChanModeHide = 74,
245  Who = 75,
246  Editor = 76,
247  DccRequest = 77,
248  DccMsg = 78,
249  DccError = 79,
250  IconManager = 80,
251  ScriptCenter = 81,
252  Bomb = 82,
253  Event = 83,
254  EventNoHandlers = 84,
255  Handler = 85,
256  HandlerDisabled = 86,
257  NickNameProblem = 87,
258  WhoisUser = 88,
259  WhoisChannels = 89,
260  WhoisIdle = 90,
261  WhoisServer = 91,
262  WhoisOther = 92,
263  Time = 93,
264  NotifyOnLine = 94,
265  NotifyOffLine = 95,
266  Locked = 96,
267  UnLocked = 97,
268  LockedOff = 98,
269  UnLockedOff = 99,
270  OwnPrivMsgCrypted = 100,
271  ChanPrivMsgCrypted = 101,
272  QueryPrivMsgCrypted = 102,
273  DccChatMsg = 103,
274  DccChatMsgCrypted = 104,
275  Irc = 105,
276  Folder = 106,
277  Home = 107,
278  BookMarks = 108,
279  Spy = 109,
280  Kick = 110,
281  Linux = 111,
282  Links = 112,
283  RegUsers = 113,
284  TrayIcon = 114,
285  UnsetMode = 115,
286  Favorite = 116,
287  Toolbar = 117,
288  ServerFavorite = 118,
289  Log = 119,
290  Remove = 120,
291  File = 121,
292  Icq = 122,
293  IcqYellow = 123,
294  IcqRed = 124,
295  IcqBlue = 125,
296  IcqLightGreen = 126,
297  IcqLightYellow = 127,
298  Message = 128,
299  MessageSent = 129,
300  BlueSquare = 130,
301  VioletSquare = 131,
302  YellowSquare = 132,
303  GreenSquare = 133,
304  BlackSquare = 134,
305  RedSquare = 135,
306  CyanSquare = 136,
307  DarkGreenSquare = 137,
308  Terminal = 138,
309  WallOps = 139,
310  Invisible = 140,
311  ServerNotice = 141,
312  Gnutella = 142,
313  Search = 143,
314  Files = 144,
315  NewNetwork = 145,
316  Package = 146,
317  NewServer = 147,
318  Idea = 148,
319  Colors = 149,
320  Gui = 150,
321  IrcView = 151,
322  Alias = 152,
323  ChannelNotice = 153,
324  ChannelNoticeCrypted = 154,
325  QueryNotice = 155,
326  QueryNoticeCrypted = 156,
327  MenuBar = 157,
328  Popup = 158,
329  Prologue = 159,
330  Epilogue = 160,
331  SharedFiles = 161,
332  CtcpReplyUnknown = 162,
333  Canvas = 163,
334  NickServ = 164,
335  ChanServ = 165,
336  DccVoice = 166,
337  Play = 167,
338  Record = 168,
339  KickOff = 169,
340  Away = 170,
341  Ident = 171,
342  HomePage = 172,
343  List = 173,
344  HalfOp = 174,
345  HalfDeOp = 175,
346  Invite = 176,
347  MultiMedia = 177,
348  User = 178,
349  Input = 179,
350  Messages = 180,
351  QueryTrace = 181,
352  NoChannel = 182,
353  BroadcastPrivMsg = 183,
354  BroadcastNotice = 184,
355  Url = 185,
356  RawEvent = 186,
357  RawEventNoHandlers = 187,
358  MeKick = 188,
359  MeOp = 189,
360  MeVoice = 190,
361  MeDeOp = 191,
362  MeDeVoice = 192,
363  MeHalfOp = 193,
364  MeDeHalfOp = 194,
365  MeBan = 195,
366  MeUnBan = 196,
367  MeBanExcept = 197,
368  MeBanUnExcept = 198,
369  MeInviteExcept = 199,
370  MeInviteUnExcept = 200,
371  ClassicWindowList = 201,
372  TreeWindowList = 202,
373  Ignore = 203,
374  UserList = 204,
375  Stats = 205,
376  PopupMenu = 206,
377  ServerConfiguration = 207,
378  Irc0 = 208,
379  Irc1 = 209,
380  Irc2 = 210,
381  Irc3 = 211,
382  Irc4 = 212,
383  Irc5 = 213,
384  Heart = 214,
385  HeartBroken = 215,
386  Rose = 216,
387  BigGrin = 217,
388  BigGrinGlasses = 218,
389  BigGrinEyes = 219,
390  TextExclamative = 220,
391  TextPoints = 221,
392  Kiss = 222,
393  Surprised1 = 223,
394  Ugly = 224,
395  Angry = 225,
396  Surprised2 = 226,
397  Smile = 227,
398  Tongue = 228,
399  Ssl = 229,
400  Cry = 230,
401  Eye = 231,
402  DeadChannel = 232,
403  DeadQuery = 233,
404  Sound = 234,
405  ToolBarEditor = 235,
406  TextEncoding = 236,
407  NewItem = 237,
408  NewItemByWizard = 238,
409  DeleteItem = 239,
410  EditItem = 240,
411  FileTransfer = 241,
412  ChanAdmin = 242,
413  ChanUnAdmin = 243,
414  MeChanAdmin = 244,
415  MeChanUnAdmin = 245,
416  UserOp = 246,
417  DeUserOp = 247,
418  MeUserOp = 248,
419  MeDeUserOp = 249,
420  Applet = 250,
421  Spam = 251,
422  Transparent = 252,
423  Notifier = 253,
424  UserWindow = 254,
425  StatusBar = 255,
426  NotAway = 256,
427  Plus = 257,
428  Minus = 258,
429  BinaryText = 259,
430  ChanOwner = 260,
431  ChanUnOwner = 261,
432  MeChanOwner = 262,
433  MeChanUnOwner = 263,
434  Afraid = 264,
435  Teeth = 265,
436  SysMonitor = 266,
437  SayColors = 267,
438  Finger = 268,
439  HighlightText = 269,
440  TearSmile = 270,
441  Shy = 271,
442  ServerError = 272,
443  Cafe = 273,
444  Addons = 274,
445  ChanOwnerAway = 275,
446  OpAway = 276,
447  VoiceAway = 277,
448  ChanAdminAway = 278,
449  UserOpAway = 279,
450  HalfOpAway = 280,
451  ClassEditor = 281,
452  Demoralized = 282,
453  Slurp = 283,
454  NameSpace = 284,
455  SaySmile = 285,
456  SayKvs = 286,
457  ThemeOptions = 287,
458  Bug = 288,
459  Refresh = 289,
460  Theme = 290,
461  ScreenShot = 291,
462  Update = 292,
463  NotUpdate = 293,
464  FailUpdate = 294,
465  UnreadText = 295,
466  IrcOp = 296,
467  IrcOpAway = 297,
468  DeIrcOp = 298,
469  MeIrcOp = 299,
470  MeDeIrcOp = 300,
471  Angel = 301,
472  Clown = 302,
473  Devil = 303,
474  InLove = 304,
475  Ninja = 305,
476  Pirate = 306,
477  Puke = 307,
478  Rage = 308,
479  Class = 309,
480  ClassNotBuilt = 310,
481  Function = 311,
482  SexMale = 312,
483  SexFemale = 313,
484  IrcBot = 314,
485  AlienIrcOp = 315,
486  MemoServ = 316,
487  Info = 317,
488  Warning = 318,
489  Shield = 319,
490  RawEventEditor = 320,
491  EventEditor = 321,
493  AliasEditor = 323,
494  PopupEditor = 324,
495  Dcc = 325,
496  Socket = 326,
497  Cake = 327,
498  HandIly = 328,
499  ThumbDown = 329,
500  ThumbUp = 330,
501  FacePalm = 331,
502  Identity = 332,
503  NickPopup = 333,
504  Tools = 334,
505  FavoriteOff = 335,
506  NewProxy = 336,
507  IconCount = 337
508  };
509 
514  KviIconManager();
515 
519  ~KviIconManager();
520 
521 private:
522  QPixmap * m_smallIcons[IconCount];
526  unsigned int m_uCacheTotalSize;
527  unsigned int m_uCacheMaxSize;
528 
529 public:
542  QPixmap * getImage(const QString & szId, bool bCanBeNumber = true, QString * pRetPath = 0);
543 
551  KviCachedPixmap * getPixmapWithCache(const QString & szName);
552 
562  KviCachedPixmap * getPixmapWithCacheScaleOnLoad(const QString & szName, int iMaxWidth, int iMaxHeight);
563 
571  QPixmap * getPixmap(const QString & szName)
572  {
573  KviCachedPixmap * pPix = getPixmapWithCache(szName);
574  return pPix ? pPix->pixmap() : 0;
575  };
576 
584  QPixmap * getBigIcon(const QString & szName);
585 
593  QPixmap * getSmallIcon(SmallIcon eIcon) { return eIcon < IconCount ? (m_smallIcons[eIcon] ? m_smallIcons[eIcon] : loadSmallIcon(eIcon)) : 0; };
594 
602  QPixmap * getSmallIcon(int iIcon) { return iIcon < IconCount ? (m_smallIcons[iIcon] ? m_smallIcons[iIcon] : loadSmallIcon(iIcon)) : 0; };
603 
609  const char * getSmallIconName(SmallIcon eIcon);
610 
617  const char * getSmallIconName(int iIcon);
618 
624  QString getSmallIconResourceName(SmallIcon eIcon);
625 
631  SmallIcon iconName(int iIcon);
632 
638  int getSmallIconIdFromName(const QString & szName);
639 
649  KviAvatar * getAvatar(const QString & szLocalPath, const QString & szName);
650 
656  void urlToCachedFileName(QString & szName);
657 
662  void clearCache();
663 
668  void reloadImages();
669 
670  //void cacheCleanup();
671 protected:
672  void addToCache(const QString & szName, KviCachedPixmap * pPix);
673 
679  QPixmap * loadSmallIcon(int iIdx);
680 
685  void initQResourceBackend();
686 public slots:
691  void showIconWidget();
692 protected slots:
697  void iconWidgetClosed();
698 };
699 
704 class KVIRC_API KviIconWidget : public QWidget
705 {
706  Q_OBJECT
707 public:
712  KviIconWidget();
713 
719  KviIconWidget(QWidget * pPar);
720 
724  ~KviIconWidget();
725 
726 protected:
731  void init();
732 
733  virtual void closeEvent(QCloseEvent * pEvent);
734  virtual bool eventFilter(QObject * pObject, QEvent * pEvent);
735 signals:
740  void closed();
741 
747  void selected(KviIconManager::SmallIcon eIcon);
748 };
749 
751 
752 #endif //_KVI_ICONMANAGER_H_
#define KVIRC_API
Definition: kvi_settings.h:128
This class manages the images used by KVIrc.
Definition: KviIconManager.h:160
QPixmap * getSmallIcon(SmallIcon eIcon)
Returns the small icon.
Definition: KviIconManager.h:593
kvi_time_t lastAccessTime()
Returns the time the image was last accessed.
Definition: KviIconManager.h:136
class KVIRC_API KviIconWidget
Definition: KviIconManager.h:84
m_pPixmap
Definition: KvsObject_pixmap.cpp:112
KviIconWidget * m_pIconWidget
Definition: KviIconManager.h:523
#define kvi_time_t
Definition: KviTimeUtils.h:43
KVIRC_API KviIconManager * g_pIconManager
Definition: KviIconManager.cpp:81
char Channel
Definition: KviIrcNumericCodes.h:391
Pointer Hash Table.
SmallIcon
Contains all KVIrc's small icons.
Definition: KviIconManager.h:168
unsigned int m_uCacheMaxSize
Definition: KviIconManager.h:527
QPixmap * m_pPixmap
Definition: KviIconManager.h:110
Avatar class.
Definition: KviAvatar.h:52
QPixmap * pixmap()
Returns the image.
Definition: KviIconManager.h:118
Avatar handling.
Time management.
Definition: ActionEditor.h:155
kvi_time_t m_tLastAccess
Definition: KviIconManager.h:109
Definition: UserWindow.h:30
KviPointerHashTable< QString, int > * m_pIconNames
Definition: KviIconManager.h:525
Mode
Definition: KviOptions.h:599
unsigned int size()
Returns the size of the image.
Definition: KviIconManager.h:130
QString m_szPath
Definition: KviIconManager.h:108
unsigned int m_uCacheTotalSize
Definition: KviIconManager.h:526
QPixmap * getPixmap(const QString &szName)
Returns the pixmap of the image.
Definition: KviIconManager.h:571
Class for holding a cached pixmap.
Definition: KviIconManager.h:90
Definition: EventEditorWindow.h:91
unsigned int m_uSize
Definition: KviIconManager.h:111
const QString & path()
Returns the path of the image.
Definition: KviIconManager.h:124
int init()
Definition: winamp.cpp:118
Definition: KviControlCodes.h:143
This file contains compile time settings.
The widget with holds the table of icons.
Definition: KviIconManager.h:704
QPixmap * getSmallIcon(int iIcon)
Returns the small icon.
Definition: KviIconManager.h:602
KviPointerHashTable< QString, KviCachedPixmap > * m_pCachedImages
Definition: KviIconManager.h:524