![]() |
KVIrc 5.2.6
Developer APIs
|
This class manages the images used by KVIrc. More...
#include <KviIconManager.h>
Public Types | |
enum | SmallIcon { None = 0 , Close = 1 , History = 2 , HistoryOff = 3 , UserMode = 4 , DefaultIcon = 5 , Dock = 6 , UnDock = 7 , QuitApp = 8 , Console = 9 , Save = 10 , ParserError = 11 , ParserWarning = 12 , Server = 13 , World = 14 , Proxy = 15 , KVIrc = 16 , Cut = 17 , Copy = 18 , Paste = 19 , Options = 20 , SocketMessage = 21 , SocketWarning = 22 , SocketError = 23 , SystemError = 24 , Raw = 25 , SystemWarning = 26 , SystemMessage = 27 , UnHandled = 28 , ServerInfo = 29 , Motd = 30 , Channel = 31 , HideDoubleView = 32 , ShowDoubleView = 33 , Op = 34 , Voice = 35 , ServerPing = 36 , ShowListView = 37 , HideListView = 38 , Join = 39 , Part = 40 , Unrecognized = 41 , Topic = 42 , Accept = 43 , Discard = 44 , OwnPrivMsg = 45 , ChanPrivMsg = 46 , Query = 47 , QueryPrivMsg = 48 , Help = 49 , QuestionMark = 50 , CtcpReply = 51 , CtcpRequestReplied = 52 , CtcpRequestIgnored = 53 , CtcpRequestFlood = 54 , CtcpRequestUnknown = 55 , Action = 56 , Avatar = 57 , Quit = 58 , Split = 59 , QuitSplit = 60 , Nick = 61 , DeOp = 62 , DeVoice = 63 , Mode = 64 , Key = 65 , Limit = 66 , Ban = 67 , UnBan = 68 , BanExcept = 69 , BanUnExcept = 70 , InviteExcept = 71 , InviteUnExcept = 72 , ChanMode = 73 , ChanModeHide = 74 , Who = 75 , Editor = 76 , DccRequest = 77 , DccMsg = 78 , DccError = 79 , IconManager = 80 , ScriptCenter = 81 , Bomb = 82 , Event = 83 , EventNoHandlers = 84 , Handler = 85 , HandlerDisabled = 86 , NickNameProblem = 87 , WhoisUser = 88 , WhoisChannels = 89 , WhoisIdle = 90 , WhoisServer = 91 , WhoisOther = 92 , Time = 93 , NotifyOnLine = 94 , NotifyOffLine = 95 , Locked = 96 , UnLocked = 97 , LockedOff = 98 , UnLockedOff = 99 , OwnPrivMsgCrypted = 100 , ChanPrivMsgCrypted = 101 , QueryPrivMsgCrypted = 102 , DccChatMsg = 103 , DccChatMsgCrypted = 104 , Irc = 105 , Folder = 106 , Home = 107 , BookMarks = 108 , Spy = 109 , Kick = 110 , Linux = 111 , Links = 112 , RegUsers = 113 , TrayIcon = 114 , UnsetMode = 115 , Favorite = 116 , Toolbar = 117 , ServerFavorite = 118 , Log = 119 , Remove = 120 , File = 121 , Icq = 122 , IcqYellow = 123 , IcqRed = 124 , IcqBlue = 125 , IcqLightGreen = 126 , IcqLightYellow = 127 , Message = 128 , MessageSent = 129 , BlueSquare = 130 , VioletSquare = 131 , YellowSquare = 132 , GreenSquare = 133 , BlackSquare = 134 , RedSquare = 135 , CyanSquare = 136 , DarkGreenSquare = 137 , Terminal = 138 , WallOps = 139 , Invisible = 140 , ServerNotice = 141 , Gnutella = 142 , Search = 143 , Files = 144 , NewNetwork = 145 , Package = 146 , NewServer = 147 , Idea = 148 , Colors = 149 , Gui = 150 , IrcView = 151 , Alias = 152 , ChannelNotice = 153 , ChannelNoticeCrypted = 154 , QueryNotice = 155 , QueryNoticeCrypted = 156 , MenuBar = 157 , Popup = 158 , Prologue = 159 , Epilogue = 160 , SharedFiles = 161 , CtcpReplyUnknown = 162 , Canvas = 163 , NickServ = 164 , ChanServ = 165 , DccVoice = 166 , Play = 167 , Record = 168 , KickOff = 169 , Away = 170 , Ident = 171 , HomePage = 172 , List = 173 , HalfOp = 174 , HalfDeOp = 175 , Invite = 176 , MultiMedia = 177 , User = 178 , Input = 179 , Messages = 180 , QueryTrace = 181 , NoChannel = 182 , BroadcastPrivMsg = 183 , BroadcastNotice = 184 , Url = 185 , RawEvent = 186 , RawEventNoHandlers = 187 , MeKick = 188 , MeOp = 189 , MeVoice = 190 , MeDeOp = 191 , MeDeVoice = 192 , MeHalfOp = 193 , MeDeHalfOp = 194 , MeBan = 195 , MeUnBan = 196 , MeBanExcept = 197 , MeBanUnExcept = 198 , MeInviteExcept = 199 , MeInviteUnExcept = 200 , ClassicWindowList = 201 , TreeWindowList = 202 , Ignore = 203 , UserList = 204 , Stats = 205 , PopupMenu = 206 , ServerConfiguration = 207 , Irc0 = 208 , Irc1 = 209 , Irc2 = 210 , Irc3 = 211 , Irc4 = 212 , Irc5 = 213 , Heart = 214 , HeartBroken = 215 , Rose = 216 , BigGrin = 217 , BigGrinGlasses = 218 , BigGrinEyes = 219 , TextExclamative = 220 , TextPoints = 221 , Kiss = 222 , Surprised1 = 223 , Ugly = 224 , Angry = 225 , Surprised2 = 226 , Smile = 227 , Tongue = 228 , Ssl = 229 , Cry = 230 , Eye = 231 , DeadChannel = 232 , DeadQuery = 233 , Sound = 234 , ToolBarEditor = 235 , TextEncoding = 236 , NewItem = 237 , NewItemByWizard = 238 , DeleteItem = 239 , EditItem = 240 , FileTransfer = 241 , ChanAdmin = 242 , ChanUnAdmin = 243 , MeChanAdmin = 244 , MeChanUnAdmin = 245 , UserOp = 246 , DeUserOp = 247 , MeUserOp = 248 , MeDeUserOp = 249 , Applet = 250 , Spam = 251 , Transparent = 252 , Notifier = 253 , UserWindow = 254 , StatusBar = 255 , NotAway = 256 , Plus = 257 , Minus = 258 , BinaryText = 259 , ChanOwner = 260 , ChanUnOwner = 261 , MeChanOwner = 262 , MeChanUnOwner = 263 , Afraid = 264 , Teeth = 265 , SysMonitor = 266 , SayColors = 267 , Finger = 268 , HighlightText = 269 , TearSmile = 270 , Shy = 271 , ServerError = 272 , Cafe = 273 , Addons = 274 , ChanOwnerAway = 275 , OpAway = 276 , VoiceAway = 277 , ChanAdminAway = 278 , UserOpAway = 279 , HalfOpAway = 280 , ClassEditor = 281 , Demoralized = 282 , Slurp = 283 , NameSpace = 284 , SaySmile = 285 , SayKvs = 286 , ThemeOptions = 287 , Bug = 288 , Refresh = 289 , Theme = 290 , ScreenShot = 291 , Update = 292 , NotUpdate = 293 , FailUpdate = 294 , UnreadText = 295 , IrcOp = 296 , IrcOpAway = 297 , DeIrcOp = 298 , MeIrcOp = 299 , MeDeIrcOp = 300 , Angel = 301 , Clown = 302 , Devil = 303 , InLove = 304 , Ninja = 305 , Pirate = 306 , Puke = 307 , Rage = 308 , Class = 309 , ClassNotBuilt = 310 , Function = 311 , SexMale = 312 , SexFemale = 313 , IrcBot = 314 , AlienIrcOp = 315 , MemoServ = 316 , Info = 317 , Warning = 318 , Shield = 319 , RawEventEditor = 320 , EventEditor = 321 , ActionEditor = 322 , AliasEditor = 323 , PopupEditor = 324 , Dcc = 325 , Socket = 326 , Cake = 327 , HandIly = 328 , ThumbDown = 329 , ThumbUp = 330 , FacePalm = 331 , Identity = 332 , NickPopup = 333 , Tools = 334 , FavoriteOff = 335 , NewProxy = 336 , ActionCrypted = 337 , TopicCrypted = 338 , CtcpCrypted = 339 , OwnAction = 340 , OwnActionCrypted = 341 , IconCount = 342 } |
Contains all KVIrc's small icons. More... | |
Public Slots | |
void | showIconWidget () |
Shows the table of icons. | |
Public Member Functions | |
void | clearCache () |
Clears the cache! | |
KviAvatar * | getAvatar (const QString &szLocalPath, const QString &szName) |
Returns the avatar If szLocalPath is empty then szName can be the identification string for the avatar If szName is empty then it is found from szLocalPath. | |
QPixmap * | getBigIcon (const QString &szName) |
Returns the big icon. | |
QPixmap * | getImage (const QString &szId, bool bCanBeNumber=true, QString *pRetPath=nullptr) |
Returns the image. | |
QPixmap * | getPixmap (const QString &szName) |
Returns the pixmap of the image. | |
KviCachedPixmap * | getPixmapWithCache (const QString &szName) |
Returns the cached pixmap of the image. | |
KviCachedPixmap * | getPixmapWithCacheScaleOnLoad (const QString &szName, int iMaxWidth, int iMaxHeight) |
Returns the cached pixmap of the image and scales it on load. | |
QPixmap * | getSmallIcon (int iIcon) |
Returns the small icon. | |
QPixmap * | getSmallIcon (SmallIcon eIcon) |
Returns the small icon. | |
int | getSmallIconIdFromName (const QString &szName) |
Returns the index of the small icon. | |
const char * | getSmallIconName (int iIcon) |
Returns the name of the small icon. | |
const char * | getSmallIconName (SmallIcon eIcon) |
Returns the name of the small icon. | |
QString | getSmallIconResourceName (SmallIcon eIcon) |
Returns the resource name of the small icon. | |
SmallIcon | iconName (int iIcon) |
Returns the name of the small icon. | |
KviIconManager () | |
Creates the icon manager object. | |
void | reloadImages () |
Reloads all images. | |
void | urlToCachedFileName (QString &szName) |
Returns the url of the image in cache. | |
~KviIconManager () | |
Destroys the icon manager object. | |
Protected Slots | |
void | iconWidgetClosed () |
Called when we close the table of icons. | |
Protected Member Functions | |
void | addToCache (const QString &szName, KviCachedPixmap *pPix) |
void | initQResourceBackend () |
Initializes the Qt resource backend. | |
QPixmap * | loadSmallIcon (int iIdx) |
Returns the icon. | |
Private Attributes | |
KviPointerHashTable< QString, KviCachedPixmap > * | m_pCachedImages = nullptr |
KviPointerHashTable< QString, int > * | m_pIconNames = nullptr |
KviIconWidget * | m_pIconWidget = nullptr |
std::array< QPixmap *, IconCount > | m_smallIcons = { { nullptr } } |
unsigned int | m_uCacheMaxSize = 1024 * 1024 |
unsigned int | m_uCacheTotalSize = 0 |
This class manages the images used by KVIrc.
We handle three types of images: builtin small icons, builtin big icons and generic images. The builtin small icons are in the pics/coresmall directory (this is to optimize the directory size since it's a linear search...), are 16x16 in size and are indexed by numbers in a way that their access is really fast. The icons used here are used mostly in KviIrcView (but not exclusively). The builtin big icons are (actually) just generic images that are eventually scaled to 32x32 if needed. One can request a builtin small icon indexed by number to be scaled to the size of 32x32 as a big icon too. The generic images are just "any" image that the underlying Qt engine is able to load. They are loaded by (relative) path and cached by name.
Contains all KVIrc's small icons.
KviIconManager::KviIconManager | ( | ) |
Creates the icon manager object.
References g_pActivityMeterPixmap, g_pApp, g_pUserChanStatePixmap, initQResourceBackend(), KVI_ACTIVITYMETER_IMAGE_NAME, KVI_USERCHANSTATE_IMAGE_NAME, m_pCachedImages, and szBuffer.
KviIconManager::~KviIconManager | ( | ) |
Destroys the icon manager object.
References g_pActivityMeterPixmap, g_pUserChanStatePixmap, i, IconCount, m_pCachedImages, m_pIconNames, m_pIconWidget, and m_smallIcons.
|
protected |
References m_pCachedImages, m_uCacheTotalSize, and KviCachedPixmap::size().
Referenced by getBigIcon(), getPixmapWithCache(), and getPixmapWithCacheScaleOnLoad().
void KviIconManager::clearCache | ( | ) |
KviAvatar * KviIconManager::getAvatar | ( | const QString & | szLocalPath, |
const QString & | szName ) |
Returns the avatar If szLocalPath is empty then szName can be the identification string for the avatar If szName is empty then it is found from szLocalPath.
szLocalPath | The local path of the avatar |
szName | The name of the avatar |
References KviApplication::Avatars, KviQString::equalCIN(), KviFileUtils::extractFileName(), KviFileUtils::fileExists(), g_pApp, KviAvatar::isValid(), KVI_OPTION_BOOL, KVI_OPTION_UINT, KviOption_boolScaleAvatarsOnLoad, KviOption_uintScaleAvatarsOnLoadHeight, KviOption_uintScaleAvatarsOnLoadWidth, and urlToCachedFileName().
QPixmap * KviIconManager::getBigIcon | ( | const QString & | szName | ) |
Returns the big icon.
szName | The icon to get |
References addToCache(), getPixmap(), getSmallIcon(), IconCount, and KviCachedPixmap::pixmap().
QPixmap * KviIconManager::getImage | ( | const QString & | szId, |
bool | bCanBeNumber = true, | ||
QString * | pRetPath = nullptr ) |
Returns the image.
szId | The ID of the image This can be a filename or a number that indicates an internal pixmap. 0 stands for "any" |
bCanBeNumber | Whether the image is specified by a number, especially for scripts or popups |
pRetPath | Holds the path of the image |
References getPixmapWithCache(), getSmallIcon(), getSmallIconIdFromName(), IconCount, KviCachedPixmap::path(), and KviCachedPixmap::pixmap().
|
inline |
Returns the pixmap of the image.
szName | The name of the image |
References getPixmapWithCache(), and KviCachedPixmap::pixmap().
Referenced by getBigIcon().
KviCachedPixmap * KviIconManager::getPixmapWithCache | ( | const QString & | szName | ) |
Returns the cached pixmap of the image.
szName | The name of the image |
References addToCache(), g_pApp, m_pCachedImages, and KviCachedPixmap::updateLastAccessTime().
Referenced by getImage(), and getPixmap().
KviCachedPixmap * KviIconManager::getPixmapWithCacheScaleOnLoad | ( | const QString & | szName, |
int | iMaxWidth, | ||
int | iMaxHeight ) |
Returns the cached pixmap of the image and scales it on load.
szName | The name of the image |
iMaxWidth | The max width to scale |
iMaxHeight | The max height to scale |
References addToCache(), g_pApp, m_pCachedImages, and KviCachedPixmap::updateLastAccessTime().
|
inline |
Returns the small icon.
iIcon | The icon to get |
References IconCount, loadSmallIcon(), and m_smallIcons.
|
inline |
Returns the small icon.
eIcon | The icon to get |
References IconCount, loadSmallIcon(), and m_smallIcons.
Referenced by getBigIcon(), and getImage().
int KviIconManager::getSmallIconIdFromName | ( | const QString & | szName | ) |
Returns the index of the small icon.
szName | The name of the icon |
References g_szIconNames, i, IconCount, and m_pIconNames.
Referenced by getImage().
const char * KviIconManager::getSmallIconName | ( | int | iIcon | ) |
Returns the name of the small icon.
iIcon | The icon to get |
References g_szIconNames.
const char * KviIconManager::getSmallIconName | ( | SmallIcon | eIcon | ) |
Returns the name of the small icon.
eIcon | The icon to get |
References g_szIconNames.
QString KviIconManager::getSmallIconResourceName | ( | SmallIcon | eIcon | ) |
Returns the resource name of the small icon.
eIcon | The icon to get |
References g_szIconNames.
KviIconManager::SmallIcon KviIconManager::iconName | ( | int | iIcon | ) |
Returns the name of the small icon.
iIcon | The icon to get |
References Accept, Action, ActionCrypted, ActionEditor, Addons, Afraid, Alias, AliasEditor, AlienIrcOp, Angel, Angry, Applet, Avatar, Away, Ban, BanExcept, BanUnExcept, BigGrin, BigGrinEyes, BigGrinGlasses, BinaryText, BlackSquare, BlueSquare, Bomb, BookMarks, BroadcastNotice, BroadcastPrivMsg, Bug, Cafe, Cake, Canvas, ChanAdmin, ChanAdminAway, ChanMode, ChanModeHide, Channel, ChannelNotice, ChannelNoticeCrypted, ChanOwner, ChanOwnerAway, ChanPrivMsg, ChanPrivMsgCrypted, ChanServ, ChanUnAdmin, ChanUnOwner, Class, ClassEditor, ClassicWindowList, ClassNotBuilt, Close, Clown, Colors, Console, Copy, Cry, CtcpCrypted, CtcpReply, CtcpReplyUnknown, CtcpRequestFlood, CtcpRequestIgnored, CtcpRequestReplied, CtcpRequestUnknown, Cut, CyanSquare, DarkGreenSquare, Dcc, DccChatMsg, DccChatMsgCrypted, DccError, DccMsg, DccRequest, DccVoice, DeadChannel, DeadQuery, DefaultIcon, DeIrcOp, DeleteItem, Demoralized, DeOp, DeUserOp, Devil, DeVoice, Discard, Dock, EditItem, Editor, Epilogue, Event, EventEditor, EventNoHandlers, Eye, FacePalm, FailUpdate, Favorite, FavoriteOff, File, Files, FileTransfer, Finger, Folder, Function, Gnutella, GreenSquare, Gui, HalfDeOp, HalfOp, HalfOpAway, HandIly, Handler, HandlerDisabled, Heart, HeartBroken, Help, HideDoubleView, HideListView, HighlightText, History, HistoryOff, Home, HomePage, IconCount, IconManager, Icq, IcqBlue, IcqLightGreen, IcqLightYellow, IcqRed, IcqYellow, Idea, Ident, Identity, Ignore, Info, InLove, Input, Invisible, Invite, InviteExcept, InviteUnExcept, Irc, Irc0, Irc1, Irc2, Irc3, Irc4, Irc5, IrcBot, IrcOp, IrcOpAway, IrcView, Join, Key, Kick, KickOff, Kiss, KVIrc, Limit, Links, Linux, List, Locked, LockedOff, Log, MeBan, MeBanExcept, MeBanUnExcept, MeChanAdmin, MeChanOwner, MeChanUnAdmin, MeChanUnOwner, MeDeHalfOp, MeDeIrcOp, MeDeOp, MeDeUserOp, MeDeVoice, MeHalfOp, MeInviteExcept, MeInviteUnExcept, MeIrcOp, MeKick, MemoServ, MenuBar, MeOp, Message, Messages, MessageSent, MeUnBan, MeUserOp, MeVoice, Minus, Mode, Motd, MultiMedia, NameSpace, NewItem, NewItemByWizard, NewNetwork, NewProxy, NewServer, Nick, NickNameProblem, NickPopup, NickServ, Ninja, NoChannel, None, NotAway, Notifier, NotifyOffLine, NotifyOnLine, NotUpdate, Op, OpAway, Options, OwnAction, OwnActionCrypted, OwnPrivMsg, OwnPrivMsgCrypted, Package, ParserError, ParserWarning, Part, Paste, Pirate, Play, Plus, Popup, PopupEditor, PopupMenu, Prologue, Proxy, Puke, Query, QueryNotice, QueryNoticeCrypted, QueryPrivMsg, QueryPrivMsgCrypted, QueryTrace, QuestionMark, Quit, QuitApp, QuitSplit, Rage, Raw, RawEvent, RawEventEditor, RawEventNoHandlers, Record, RedSquare, Refresh, RegUsers, Remove, Rose, Save, SayColors, SayKvs, SaySmile, ScreenShot, ScriptCenter, Search, Server, ServerConfiguration, ServerError, ServerFavorite, ServerInfo, ServerNotice, ServerPing, SexFemale, SexMale, SharedFiles, Shield, ShowDoubleView, ShowListView, Shy, Slurp, Smile, Socket, SocketError, SocketMessage, SocketWarning, Sound, Spam, Split, Spy, Ssl, Stats, StatusBar, Surprised1, Surprised2, SysMonitor, SystemError, SystemMessage, SystemWarning, TearSmile, Teeth, Terminal, TextEncoding, TextExclamative, TextPoints, Theme, ThemeOptions, ThumbDown, ThumbUp, Time, Tongue, Toolbar, ToolBarEditor, Tools, Topic, TopicCrypted, Transparent, TrayIcon, TreeWindowList, Ugly, UnBan, UnDock, UnHandled, UnLocked, UnLockedOff, UnreadText, Unrecognized, UnsetMode, Update, Url, User, UserList, UserMode, UserOp, UserOpAway, UserWindow, VioletSquare, Voice, VoiceAway, WallOps, Warning, Who, WhoisChannels, WhoisIdle, WhoisOther, WhoisServer, WhoisUser, World, and YellowSquare.
|
protectedslot |
Called when we close the table of icons.
References m_pIconWidget.
Referenced by showIconWidget().
|
protected |
Initializes the Qt resource backend.
References g_pApp, KviApplication::Pics, and KviApplication::SmallIcons.
Referenced by KviIconManager().
|
protected |
Returns the icon.
iIdx | The ID of the icon |
References g_pApp, g_szIconNames, IconCount, KVI_SMALLICONS_PREFIX, m_smallIcons, and szBuffer.
Referenced by getSmallIcon(), and getSmallIcon().
void KviIconManager::reloadImages | ( | ) |
|
slot |
Shows the table of icons.
References connect(), iconWidgetClosed(), KviIconWidget, and m_pIconWidget.
void KviIconManager::urlToCachedFileName | ( | QString & | szName | ) |
Returns the url of the image in cache.
szName | The path of the image |
Referenced by getAvatar().
|
private |
Referenced by addToCache(), clearCache(), getPixmapWithCache(), getPixmapWithCacheScaleOnLoad(), KviIconManager(), and ~KviIconManager().
|
private |
Referenced by getSmallIconIdFromName(), and ~KviIconManager().
|
private |
Referenced by iconWidgetClosed(), showIconWidget(), and ~KviIconManager().
Referenced by getSmallIcon(), getSmallIcon(), loadSmallIcon(), reloadImages(), and ~KviIconManager().
|
private |
|
private |
Referenced by addToCache().