• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • icons
kicontheme.cpp
Go to the documentation of this file.
1/* vi: ts=8 sts=4 sw=4
2 *
3 * kicontheme.cpp: Lowlevel icon theme handling.
4 *
5 * This file is part of the KDE project, module kdecore.
6 * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
7 * Antonio Larrosa <larrosa@kde.org>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License version 2 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include "kicontheme.h"
25#include "k3icon_p.h"
26
27#include <sys/stat.h>
28#include <unistd.h>
29#include <stdlib.h>
30
31#include <QtGui/QAction>
32#include <QtCore/QCharRef>
33#include <QtCore/QMutableStringListIterator>
34#include <QtCore/QMap>
35#include <QtCore/QSet>
36#include <QtGui/QPixmap>
37#include <QtGui/QPixmapCache>
38#include <QtGui/QImage>
39#include <QtCore/QFileInfo>
40#include <QtCore/QDir>
41
42#include <kdebug.h>
43#include <kicon.h>
44#include <kstandarddirs.h>
45#include <kglobal.h>
46#include <ksharedconfig.h>
47#include <kconfig.h>
48#include <kcomponentdata.h>
49#include <klocale.h>
50#include <kde_file.h>
51
52#include <kconfiggroup.h>
53
54// The following define exists because the Qt SVG renderer needs
55// to be improved. This will be removed soon. (ereslibre)
56#undef KDE_QT_SVG_RENDERER_FIXED
57
58class KIconTheme::KIconThemePrivate
59{
60public:
61 QString example, screenshot;
62 QString linkOverlay, lockOverlay, zipOverlay, shareOverlay;
63 bool hidden;
64 KSharedConfig::Ptr sharedConfig;
65
66 int mDefSize[6];
67 QList<int> mSizes[6];
68
69 int mDepth;
70 QString mDir, mName, mInternalName, mDesc;
71 QStringList mInherits;
72 QList<KIconThemeDir *> mDirs;
73};
74K_GLOBAL_STATIC(QString, _theme)
75K_GLOBAL_STATIC(QStringList, _theme_list)
76
77
80class KIconThemeDir
81{
82public:
83 KIconThemeDir(const QString& basedir, const QString &themedir, const KConfigGroup &config);
84
85 bool isValid() const { return mbValid; }
86 QString iconPath(const QString& name) const;
87 QStringList iconList() const;
88 QString dir() const { return mBaseDirThemeDir; }
89
90 KIconLoader::Context context() const { return mContext; }
91 KIconLoader::Type type() const { return mType; }
92 int size() const { return mSize; }
93 int minSize() const { return mMinSize; }
94 int maxSize() const { return mMaxSize; }
95 int threshold() const { return mThreshold; }
96
97private:
98 bool mbValid;
99 KIconLoader::Type mType;
100 KIconLoader::Context mContext;
101 int mSize, mMinSize, mMaxSize;
102 int mThreshold;
103
104 QString mBaseDirThemeDir;
105};
106
107
108/*** K3Icon ***/
109
110K3Icon::K3Icon()
111{
112 size = 0;
113}
114
115K3Icon::~K3Icon()
116{
117}
118
119bool K3Icon::isValid() const
120{
121 return size != 0;
122}
123
124
125/*** KIconTheme ***/
126
127KIconTheme::KIconTheme(const QString& name, const QString& appName)
128 :d(new KIconThemePrivate)
129{
130
131 d->mInternalName = name;
132
133 QStringList icnlibs;
134 QStringList::ConstIterator it, itDir;
135 QStringList themeDirs;
136 QSet<QString> addedDirs; // Used for avoiding duplicates.
137
138 // Applications can have local additions to the global "locolor" and
139 // "hicolor" icon themes. For these, the _global_ theme description
140 // files are used..
141
142 if (!appName.isEmpty() &&
143 ( name == defaultThemeName() || name== "hicolor" || name == "locolor" ) ) {
144 icnlibs = KGlobal::dirs()->resourceDirs("data");
145 for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
146 const QString cDir = *it + appName + "/icons/" + name;
147 if (QFile::exists( cDir )) {
148 themeDirs += cDir + '/';
149 }
150 }
151 }
152 // Find the theme description file. These are always global.
153
154 icnlibs = KGlobal::dirs()->resourceDirs("icon")
155 << KGlobal::dirs()->resourceDirs("xdgdata-icon")
156 << "/usr/share/pixmaps/"
157 // These are not in the icon spec, but e.g. GNOME puts some icons there anyway.
158 << KGlobal::dirs()->resourceDirs("xdgdata-pixmap");
159 icnlibs.removeDuplicates();
160
161 QString fileName, mainSection;
162 for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
163 const QString cDir = *it + name + '/';
164 if (KStandardDirs::exists(cDir)) {
165 themeDirs += cDir;
166 if (d->mDir.isEmpty()) {
167 if (KStandardDirs::exists(cDir + "index.theme")) {
168 d->mDir = cDir;
169 fileName = d->mDir + "index.theme";
170 mainSection = "Icon Theme";
171 } else if (KStandardDirs::exists(cDir + "index.desktop")) {
172 d->mDir = cDir;
173 fileName = d->mDir + "index.desktop";
174 mainSection = "KDE Icon Theme";
175 }
176 }
177 }
178 }
179
180 if (d->mDir.isEmpty()) {
181 kDebug(264) << "Icon theme" << name << "not found.";
182 return;
183 }
184
185 // Use KSharedConfig to avoid parsing the file many times, from each kinstance.
186 // Need to keep a ref to it to make this useful
187 d->sharedConfig = KSharedConfig::openConfig(fileName, KConfig::NoGlobals);
188
189 KConfigGroup cfg(d->sharedConfig, mainSection);
190 d->mName = cfg.readEntry("Name");
191 d->mDesc = cfg.readEntry("Comment");
192 d->mDepth = cfg.readEntry("DisplayDepth", 32);
193 d->mInherits = cfg.readEntry("Inherits", QStringList());
194 if (name != defaultThemeName()) {
195 for (QStringList::Iterator it = d->mInherits.begin(); it != d->mInherits.end(); ++it) {
196 if (*it == "default" || *it == "hicolor") {
197 *it = defaultThemeName();
198 }
199 }
200 }
201
202 d->hidden = cfg.readEntry("Hidden", false);
203 d->example = cfg.readPathEntry("Example", QString());
204 d->screenshot = cfg.readPathEntry("ScreenShot", QString());
205
206 const QStringList dirs = cfg.readPathEntry("Directories", QStringList());
207 for (it=dirs.begin(); it!=dirs.end(); ++it) {
208 KConfigGroup cg(d->sharedConfig, *it);
209 for (itDir=themeDirs.constBegin(); itDir!=themeDirs.constEnd(); ++itDir) {
210 const QString currentDir(*itDir + *it + '/');
211 if (!addedDirs.contains(currentDir) && KStandardDirs::exists(currentDir)) {
212 addedDirs.insert(currentDir);
213 KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg);
214 if (!dir->isValid()) {
215 delete dir;
216 }
217 else {
218 d->mDirs.append(dir);
219 }
220 }
221 }
222 }
223
224 // Expand available sizes for scalable icons to their full range
225 int i;
226 QMap<int,QList<int> > scIcons;
227 foreach(KIconThemeDir *dir, d->mDirs) {
228 if (!dir) {
229 break;
230 }
231 if ((dir->type() == KIconLoader::Scalable) && !scIcons.contains(dir->size())) {
232 QList<int> lst;
233 for (i=dir->minSize(); i<=dir->maxSize(); ++i) {
234 lst += i;
235 }
236 scIcons[dir->size()] = lst;
237 }
238 }
239
240 QStringList groups;
241 groups += "Desktop";
242 groups += "Toolbar";
243 groups += "MainToolbar";
244 groups += "Small";
245 groups += "Panel";
246 groups += "Dialog";
247 const int defDefSizes[] = { 32, 22, 22, 16, 32, 32 };
248 KConfigGroup cg(d->sharedConfig, mainSection);
249 for (it=groups.constBegin(), i=0; it!=groups.constEnd(); ++it, i++) {
250 d->mDefSize[i] = cg.readEntry(*it + "Default", defDefSizes[i]);
251 const QList<int> lst = cg.readEntry(*it + "Sizes", QList<int>());
252 QList<int> exp;
253 QList<int>::ConstIterator it2;
254 for (it2=lst.begin(); it2!=lst.end(); ++it2) {
255 if (scIcons.contains(*it2)) {
256 exp += scIcons[*it2];
257 } else {
258 exp += *it2;
259 }
260 }
261 d->mSizes[i] = exp;
262 }
263}
264
265KIconTheme::~KIconTheme()
266{
267 qDeleteAll(d->mDirs);
268 delete d;
269}
270
271QString KIconTheme::name() const
272{
273 return d->mName;
274}
275
276QString KIconTheme::internalName() const
277{
278 return d->mInternalName;
279}
280
281QString KIconTheme::description() const
282{
283 return d->mDesc;
284}
285
286QString KIconTheme::example() const
287{
288 return d->example;
289}
290
291QString KIconTheme::screenshot() const
292{
293 return d->screenshot;
294}
295
296QString KIconTheme::dir() const
297{
298 return d->mDir;
299}
300
301QStringList KIconTheme::inherits() const
302{
303 return d->mInherits;
304}
305
306bool KIconTheme::isValid() const
307{
308 return !d->mDirs.isEmpty();
309}
310
311bool KIconTheme::isHidden() const
312{
313 return d->hidden;
314}
315
316int KIconTheme::depth() const
317{
318 return d->mDepth;
319}
320
321int KIconTheme::defaultSize(KIconLoader::Group group) const
322{
323 if ((group < 0) || (group >= KIconLoader::LastGroup)) {
324 kDebug(264) << "Illegal icon group: " << group << "\n";
325 return -1;
326 }
327 return d->mDefSize[group];
328}
329
330QList<int> KIconTheme::querySizes(KIconLoader::Group group) const
331{
332 QList<int> empty;
333 if ((group < 0) || (group >= KIconLoader::LastGroup)) {
334 kDebug(264) << "Illegal icon group: " << group << "\n";
335 return empty;
336 }
337 return d->mSizes[group];
338}
339
340QStringList KIconTheme::queryIcons(int size, KIconLoader::Context context) const
341{
342 KIconThemeDir *dir;
343
344 // Try to find exact match
345 QStringList result;
346 for (int i=0; i<d->mDirs.size(); ++i) {
347 dir = d->mDirs.at(i);
348 if ((context != KIconLoader::Any) && (context != dir->context()))
349 continue;
350 if ((dir->type() == KIconLoader::Fixed) && (dir->size() == size)) {
351 result += dir->iconList();
352 continue;
353 }
354 if ((dir->type() == KIconLoader::Scalable) &&
355 (size >= dir->minSize()) && (size <= dir->maxSize())) {
356 result += dir->iconList();
357 continue;
358 }
359 if ((dir->type() == KIconLoader::Threshold) &&
360 (abs(size-dir->size())<dir->threshold())) {
361 result+=dir->iconList();
362 }
363 }
364
365 return result;
366
367/*
368 int delta = 1000, dw;
369
370 // Find close match
371 KIconThemeDir *best = 0L;
372 for(int i=0; i<d->mDirs.size(); ++i) {
373 dir = d->mDirs.at(i);
374 if ((context != KIconLoader::Any) && (context != dir->context())) {
375 continue;
376 }
377 dw = dir->size() - size;
378 if ((dw > 6) || (abs(dw) >= abs(delta)))
379 continue;
380 delta = dw;
381 best = dir;
382 }
383 if (best == 0L) {
384 return QStringList();
385 }
386
387 return best->iconList();
388 */
389}
390
391QStringList KIconTheme::queryIconsByContext(int size, KIconLoader::Context context) const
392{
393 int dw;
394 KIconThemeDir *dir;
395
396 // We want all the icons for a given context, but we prefer icons
397 // of size size . Note that this may (will) include duplicate icons
398 //QStringList iconlist[34]; // 33 == 48-16+1
399 QStringList iconlist[128]; // 33 == 48-16+1
400 // Usually, only the 0, 6 (22-16), 10 (32-22), 16 (48-32 or 32-16),
401 // 26 (48-22) and 32 (48-16) will be used, but who knows if someone
402 // will make icon themes with different icon sizes.
403
404 for (int i=0;i<d->mDirs.size();++i) {
405 dir = d->mDirs.at(i);
406 if ((context != KIconLoader::Any) && (context != dir->context()))
407 continue;
408 dw = abs(dir->size() - size);
409 iconlist[(dw<127)?dw:127]+=dir->iconList();
410 }
411
412 QStringList iconlistResult;
413 for (int i=0; i<128; i++) iconlistResult+=iconlist[i];
414
415 return iconlistResult;
416}
417
418bool KIconTheme::hasContext(KIconLoader::Context context) const
419{
420 foreach(KIconThemeDir *dir, d->mDirs) {
421 if ((context == KIconLoader::Any) || (context == dir->context())) {
422 return true;
423 }
424 }
425 return false;
426}
427
428K3Icon KIconTheme::iconPath(const QString& name, int size, KIconLoader::MatchType match) const
429{
430 K3Icon icon;
431 QString path;
432 int delta = -INT_MAX; // current icon size delta of 'icon'
433 int dw = INT_MAX; // icon size delta of current directory
434 KIconThemeDir *dir;
435
436 const int dirCount = d->mDirs.size();
437
438 // Search the directory that contains the icon which matches best to the requested
439 // size. If there is no directory which matches exactly to the requested size, the
440 // following criterias get applied:
441 // - Take a directory having icons with a minimum difference to the requested size.
442 // - Prefer directories that allow a downscaling even if the difference to
443 // the requested size is bigger than a directory where an upscaling is required.
444 for (int i = 0; i < dirCount; ++i) {
445 dir = d->mDirs.at(i);
446
447 if (match == KIconLoader::MatchExact) {
448 if ((dir->type() == KIconLoader::Fixed) && (dir->size() != size)) {
449 continue;
450 }
451 if ((dir->type() == KIconLoader::Scalable) &&
452 ((size < dir->minSize()) || (size > dir->maxSize()))) {
453 continue;
454 }
455 if ((dir->type() == KIconLoader::Threshold) &&
456 (abs(dir->size() - size) > dir->threshold())) {
457 continue;
458 }
459 } else {
460 // dw < 0 means need to scale up to get an icon of the requested size.
461 // Upscaling should only be done if no larger icon is available.
462 if (dir->type() == KIconLoader::Fixed) {
463 dw = dir->size() - size;
464 } else if (dir->type() == KIconLoader::Scalable) {
465 if (size < dir->minSize()) {
466 dw = dir->minSize() - size;
467 } else if (size > dir->maxSize()) {
468 dw = dir->maxSize() - size;
469 } else {
470 dw = 0;
471 }
472 } else if (dir->type() == KIconLoader::Threshold) {
473 if (size < dir->size() - dir->threshold()) {
474 dw = dir->size() - dir->threshold() - size;
475 } else if (size > dir->size() + dir->threshold()) {
476 dw = dir->size() + dir->threshold() - size;
477 } else {
478 dw = 0;
479 }
480 }
481 // Usually if the delta (= 'dw') of the current directory is
482 // not smaller than the delta (= 'delta') of the currently best
483 // matching icon, this candidate can be skipped. But skipping
484 // the candidate may only be done, if this does not imply
485 // in an upscaling of the icon (it is OK to use a directory with
486 // smaller icons that what we've already found, however).
487 if ((abs(dw) >= abs(delta)) && ((dw < 0) || (delta > 0))) {
488 continue;
489 }
490 }
491
492 path = dir->iconPath(name);
493 if (path.isEmpty()) {
494 continue;
495 }
496 icon.path = path;
497// The following code has been commented out because the Qt SVG renderer needs
498// to be improved. If you are going to change/remove some code from this part,
499// please contact me before (ereslibre@kde.org), or kde-core-devel@kde.org. (ereslibre)
500#ifdef KDE_QT_SVG_RENDERER_FIXED
501 icon.size = size;
502#else
503 icon.size = dir->size();
504#endif
505 icon.type = dir->type();
506 icon.threshold = dir->threshold();
507 icon.context = dir->context();
508
509 // if we got in MatchExact that far, we find no better
510 if (match == KIconLoader::MatchExact) {
511 return icon;
512 }
513 delta = dw;
514 if (delta == 0) {
515 return icon; // We won't find a better match anyway
516 }
517 }
518 return icon;
519}
520
521// static
522QString KIconTheme::current()
523{
524 // Static pointer because of unloading problems wrt DSO's.
525 if (!_theme->isEmpty()) {
526 return *_theme;
527 }
528
529 KConfigGroup cg(KGlobal::config(), "Icons");
530 *_theme = cg.readEntry("Theme4", cg.readEntry("Theme", defaultThemeName()));
531 if ( *_theme == QLatin1String("hicolor") ) {
532 *_theme = defaultThemeName();
533 }
534/* if (_theme->isEmpty())
535 {
536 if (QPixmap::defaultDepth() > 8)
537 *_theme = defaultThemeName();
538 else
539 *_theme = QLatin1String("locolor");
540 }*/
541 return *_theme;
542}
543
544// static
545QStringList KIconTheme::list()
546{
547 // Static pointer because of unloading problems wrt DSO's.
548 if (!_theme_list->isEmpty()) {
549 return *_theme_list;
550 }
551
552 const QStringList icnlibs = KGlobal::dirs()->resourceDirs("icon")
553 << KGlobal::dirs()->resourceDirs("xdgdata-icon")
554 << "/usr/share/pixmaps"
555 // These are not in the icon spec, but e.g. GNOME puts some icons there anyway.
556 << KGlobal::dirs()->resourceDirs("xdgdata-pixmap");
557
558 QStringList::ConstIterator it;
559 for (it=icnlibs.begin(); it!=icnlibs.end(); ++it) {
560 QDir dir(*it);
561 if (!dir.exists()) {
562 continue;
563 }
564 const QStringList lst = dir.entryList(QDir::Dirs);
565 QStringList::ConstIterator it2;
566 for (it2=lst.begin(); it2!=lst.end(); ++it2) {
567 if ((*it2 == ".") || (*it2 == "..") || (*it2).startsWith(QLatin1String("default.")) ) {
568 continue;
569 }
570 if (!KStandardDirs::exists(*it + *it2 + "/index.desktop") && !KStandardDirs::exists(*it + *it2 + "/index.theme")) {
571 continue;
572 }
573 KIconTheme oink(*it2);
574 if (!oink.isValid()) {
575 continue;
576 }
577
578 if (!_theme_list->contains(*it2)) {
579 _theme_list->append(*it2);
580 }
581 }
582 }
583 return *_theme_list;
584}
585
586// static
587void KIconTheme::reconfigure()
588{
589 _theme->clear();
590 _theme_list->clear();
591}
592
593// static
594QString KIconTheme::defaultThemeName()
595{
596 return QLatin1String("oxygen");
597}
598
599void KIconTheme::assignIconsToContextMenu( ContextMenus type,
600 QList<QAction*> actions )
601{
602 switch (type) {
603 // FIXME: This code depends on Qt's action ordering.
604 case TextEditor:
605 enum { UndoAct, RedoAct, Separator1, CutAct, CopyAct, PasteAct, DeleteAct, ClearAct,
606 Separator2, SelectAllAct, NCountActs };
607
608 if ( actions.count() < NCountActs ) {
609 return;
610 }
611
612 actions[UndoAct]->setIcon( KIcon("edit-undo") );
613 actions[RedoAct]->setIcon( KIcon("edit-redo") );
614 actions[CutAct]->setIcon( KIcon("edit-cut") );
615 actions[CopyAct]->setIcon( KIcon("edit-copy") );
616 actions[PasteAct]->setIcon( KIcon("edit-paste") );
617 actions[ClearAct]->setIcon( KIcon("edit-clear") );
618 actions[DeleteAct]->setIcon( KIcon("edit-delete") );
619 actions[SelectAllAct]->setIcon( KIcon("edit-select-all") );
620 break;
621
622 case ReadOnlyText:
623 if ( actions.count() < 1 ) {
624 return;
625 }
626
627 actions[0]->setIcon( KIcon("edit-copy") );
628 break;
629 }
630}
631
632/*** KIconThemeDir ***/
633
634KIconThemeDir::KIconThemeDir(const QString& basedir, const QString &themedir, const KConfigGroup &config)
635{
636 mbValid = false;
637 mBaseDirThemeDir = basedir + themedir;
638
639 mSize = config.readEntry("Size", 0);
640 mMinSize = 1; // just set the variables to something
641 mMaxSize = 50; // meaningful in case someone calls minSize or maxSize
642 mType = KIconLoader::Fixed;
643
644 if (mSize == 0) {
645 return;
646 }
647
648 QString tmp = config.readEntry("Context");
649 if (tmp == "Devices")
650 mContext = KIconLoader::Device;
651 else if (tmp == "MimeTypes")
652 mContext = KIconLoader::MimeType;
653 else if (tmp == "FileSystems")
654 mContext = KIconLoader::FileSystem;
655 else if (tmp == "Applications")
656 mContext = KIconLoader::Application;
657 else if (tmp == "Actions")
658 mContext = KIconLoader::Action;
659 else if (tmp == "Animations")
660 mContext = KIconLoader::Animation;
661 else if (tmp == "Categories")
662 mContext = KIconLoader::Category;
663 else if (tmp == "Emblems")
664 mContext = KIconLoader::Emblem;
665 else if (tmp == "Emotes")
666 mContext = KIconLoader::Emote;
667 else if (tmp == "International")
668 mContext = KIconLoader::International;
669 else if (tmp == "Places")
670 mContext = KIconLoader::Place;
671 else if (tmp == "Status")
672 mContext = KIconLoader::StatusIcon;
673 else if (tmp == "Stock") // invalid, but often present context, skip warning
674 return;
675 else {
676 kDebug(264) << "Invalid Context=" << tmp << "line for icon theme: " << dir() << "\n";
677 return;
678 }
679 tmp = config.readEntry("Type");
680 if (tmp == "Fixed")
681 mType = KIconLoader::Fixed;
682 else if (tmp == "Scalable")
683 mType = KIconLoader::Scalable;
684 else if (tmp == "Threshold")
685 mType = KIconLoader::Threshold;
686 else {
687 kDebug(264) << "Invalid Type=" << tmp << "line for icon theme: " << dir() << "\n";
688 return;
689 }
690 if (mType == KIconLoader::Scalable) {
691 mMinSize = config.readEntry("MinSize", mSize);
692 mMaxSize = config.readEntry("MaxSize", mSize);
693 } else if (mType == KIconLoader::Threshold) {
694 mThreshold = config.readEntry("Threshold", 2);
695 }
696 mbValid = true;
697}
698
699QString KIconThemeDir::iconPath(const QString& name) const
700{
701 if (!mbValid) {
702 return QString();
703 }
704
705 QString file = dir() + '/' + name;
706
707 if (KDE::access(file, R_OK) == 0) {
708 return KGlobal::hasLocale() ? KGlobal::locale()->localizedFilePath(file) : file;
709 }
710
711 return QString();
712}
713
714QStringList KIconThemeDir::iconList() const
715{
716 const QDir icondir = dir();
717
718 const QStringList formats = QStringList() << "*.png" << "*.svg" << "*.svgz" << "*.xpm";
719 const QStringList lst = icondir.entryList( formats, QDir::Files);
720
721 QStringList result;
722 QStringList::ConstIterator it;
723 for (it=lst.begin(); it!=lst.end(); ++it) {
724 result += dir() + '/' + *it;
725 }
726 return result;
727}
KConfigGroup
KConfigGroup::readPathEntry
QString readPathEntry(const char *key, const QString &aDefault) const
KConfigGroup::readEntry
QString readEntry(const char *key, const char *aDefault=0) const
KConfig::NoGlobals
NoGlobals
KIconLoader::Group
Group
The group of the icon.
Definition: kiconloader.h:127
KIconLoader::LastGroup
@ LastGroup
Last group.
Definition: kiconloader.h:145
KIconLoader::Context
Context
Defines the context of the icon.
Definition: kiconloader.h:91
KIconLoader::Category
@ Category
An icon that represents a category.
Definition: kiconloader.h:99
KIconLoader::Emblem
@ Emblem
An icon that adds information to an existing icon.
Definition: kiconloader.h:100
KIconLoader::StatusIcon
@ StatusIcon
An icon that represents an event.
Definition: kiconloader.h:104
KIconLoader::Application
@ Application
An icon that represents an application.
Definition: kiconloader.h:94
KIconLoader::FileSystem
@ FileSystem
An icon that represents a file system.
Definition: kiconloader.h:96
KIconLoader::Emote
@ Emote
An icon that expresses an emotion.
Definition: kiconloader.h:101
KIconLoader::Any
@ Any
Some icon with unknown purpose.
Definition: kiconloader.h:92
KIconLoader::Place
@ Place
An icon that represents a location (e.g. 'home', 'trash').
Definition: kiconloader.h:103
KIconLoader::MimeType
@ MimeType
An icon that represents a mime type (or file type).
Definition: kiconloader.h:97
KIconLoader::Action
@ Action
An action icon (e.g. 'save', 'print').
Definition: kiconloader.h:93
KIconLoader::International
@ International
An icon that represents a country's flag.
Definition: kiconloader.h:102
KIconLoader::Animation
@ Animation
An icon that is animated.
Definition: kiconloader.h:98
KIconLoader::Device
@ Device
An icon that represents a device.
Definition: kiconloader.h:95
KIconLoader::Type
Type
The type of the icon.
Definition: kiconloader.h:110
KIconLoader::Fixed
@ Fixed
Fixed-size icon.
Definition: kiconloader.h:111
KIconLoader::Scalable
@ Scalable
Scalable-size icon.
Definition: kiconloader.h:112
KIconLoader::Threshold
@ Threshold
A threshold icon.
Definition: kiconloader.h:113
KIconLoader::MatchType
MatchType
The type of a match.
Definition: kiconloader.h:119
KIconLoader::MatchExact
@ MatchExact
Only try to find an exact match.
Definition: kiconloader.h:120
KIconTheme
Definition: kicontheme.h:47
KIconTheme::list
static QStringList list()
List all icon themes installed on the system, global and local.
Definition: kicontheme.cpp:545
KIconTheme::isValid
bool isValid() const
The icon theme exists?
Definition: kicontheme.cpp:306
KIconTheme::querySizes
QList< int > querySizes(KIconLoader::Group group) const
Query available sizes for a group.
Definition: kicontheme.cpp:330
KIconTheme::ContextMenus
ContextMenus
Defines the context menus that assignIconsToContextMenus is aware of.
Definition: kicontheme.h:202
KIconTheme::ReadOnlyText
@ ReadOnlyText
Definition: kicontheme.h:203
KIconTheme::TextEditor
@ TextEditor
Definition: kicontheme.h:202
KIconTheme::internalName
QString internalName() const
The internal name of the icon theme (same as the name argument passed to the constructor).
Definition: kicontheme.cpp:276
KIconTheme::screenshot
QString screenshot() const
Return the name of the screenshot.
Definition: kicontheme.cpp:291
KIconTheme::reconfigure
static void reconfigure()
Reconfigure the theme.
Definition: kicontheme.cpp:587
KIconTheme::isHidden
bool isHidden() const
The icon theme should be hidden to the user?
Definition: kicontheme.cpp:311
KIconTheme::queryIconsByContext
QStringList queryIconsByContext(int size, KIconLoader::Context context=KIconLoader::Any) const
Query available icons for a context and preferred size.
Definition: kicontheme.cpp:391
KIconTheme::~KIconTheme
~KIconTheme()
Definition: kicontheme.cpp:265
KIconTheme::description
QString description() const
A description for the icon theme.
Definition: kicontheme.cpp:281
KIconTheme::current
static QString current()
Returns the current icon theme.
Definition: kicontheme.cpp:522
KIconTheme::dir
QString dir() const
Returns the toplevel theme directory.
Definition: kicontheme.cpp:296
KIconTheme::hasContext
bool hasContext(KIconLoader::Context context) const
Returns true if the theme has any icons for the given context.
Definition: kicontheme.cpp:418
KIconTheme::iconPath
K3Icon iconPath(const QString &name, int size, KIconLoader::MatchType match) const
Lookup an icon in the theme.
Definition: kicontheme.cpp:428
KIconTheme::name
QString name() const
The stylized name of the icon theme.
Definition: kicontheme.cpp:271
KIconTheme::KIconTheme
KIconTheme(const QString &name, const QString &appName=QString())
Load an icon theme by name.
Definition: kicontheme.cpp:127
KIconTheme::inherits
QStringList inherits() const
The themes this icon theme falls back on.
Definition: kicontheme.cpp:301
KIconTheme::example
QString example() const
Return the name of the "example" icon.
Definition: kicontheme.cpp:286
KIconTheme::queryIcons
QStringList queryIcons(int size, KIconLoader::Context context=KIconLoader::Any) const
Query available icons for a size and context.
Definition: kicontheme.cpp:340
KIconTheme::defaultSize
int defaultSize(KIconLoader::Group group) const
The default size of this theme for a certain icon group.
Definition: kicontheme.cpp:321
KIconTheme::assignIconsToContextMenu
static void assignIconsToContextMenu(ContextMenus type, QList< QAction * > actions)
Assigns standard icons to the various standard text edit context menus.
Definition: kicontheme.cpp:599
KIconTheme::defaultThemeName
static QString defaultThemeName()
Returns the default icon theme.
Definition: kicontheme.cpp:594
KIconTheme::depth
int depth() const
The minimum display depth required for this theme.
Definition: kicontheme.cpp:316
KIcon
A wrapper around QIcon that provides KDE icon features.
Definition: kicon.h:41
KLocale::localizedFilePath
QString localizedFilePath(const QString &filePath) const
KSharedConfig::openConfig
static KSharedConfig::Ptr openConfig(const KComponentData &componentData, const QString &fileName=QString(), OpenFlags mode=FullConfig, const char *resourceType="config")
KSharedPtr< KSharedConfig >
KStandardDirs::exists
static bool exists(const QString &fullPath)
KStandardDirs::resourceDirs
QStringList resourceDirs(const char *type) const
QList
QMap
QSet
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
kDebug
#define kDebug
kcomponentdata.h
kconfig.h
kconfiggroup.h
kdebug.h
kglobal.h
kicon.h
kicontheme.h
klocale.h
ksharedconfig.h
kstandarddirs.h
KDE::access
int access(const QString &path, int mode)
KGlobal::dirs
KStandardDirs * dirs()
KGlobal::locale
KLocale * locale()
KGlobal::hasLocale
bool hasLocale()
KGlobal::config
KSharedConfigPtr config()
group
group
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal