KIconThemes

kiconloader.h
1 /* vi: ts=8 sts=4 sw=4
2 
3  This file is part of the KDE project, module kdecore.
4  SPDX-FileCopyrightText: 2000 Geert Jansen <[email protected]>
5  SPDX-FileCopyrightText: 2000 Antonio Larrosa <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-only
8 */
9 
10 #ifndef KICONLOADER_H
11 #define KICONLOADER_H
12 
13 #include <QString>
14 #include <QStringList>
15 #include <QObject>
16 
17 #include <kiconthemes_export.h>
18 
19 class QIcon;
20 class QMovie;
21 class QPixmap;
22 
23 class KIconLoaderPrivate;
24 class KIconEffect;
25 class KIconTheme;
26 
27 class KPixmapSequence;
28 
66 class KICONTHEMES_EXPORT KIconLoader : public QObject
67 {
68  Q_OBJECT
69 
70 public:
74  enum Context {
75  Any,
79 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(4, 8)
81 #elif KICONTHEMES_BUILD_DEPRECATED_SINCE(4, 8)
82  FileSystem_DEPRECATED_DO_NOT_USE,
83 #endif
91  StatusIcon
92  };
94 
95 
98  enum Type {
101  Threshold
102  };
103  Q_ENUM(Type)
104 
105 
108  enum MatchType {
110  MatchBest
111  };
113 
114 
117  enum Group {
119  NoGroup = -1,
121  Desktop = 0,
123  FirstGroup = 0,
137  User
138  };
139  Q_ENUM(Group)
140 
141 
144  enum StdSizes {
146  SizeSmall = 16,
148  SizeSmallMedium = 22,
150  SizeMedium = 32,
152  SizeLarge = 48,
154  SizeHuge = 64,
156  SizeEnormous = 128
157  };
159 
160 
163  enum States {
168  LastState
169  };
170  Q_ENUM(States)
171 
172 
183  explicit KIconLoader(const QString &appname = QString(), const QStringList &extraSearchPaths = QStringList(), QObject *parent = nullptr);
184 
188  ~KIconLoader();
189 
194  static KIconLoader *global();
195 
204  void addAppDir(const QString &appname, const QString &themeBaseDir = QString());
205 
234  QPixmap loadIcon(const QString &name, KIconLoader::Group group, int size = 0,
235  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
236  QString *path_store = nullptr,
237  bool canReturnNull = false) const;
238 
271  // TODO KF6 merge loadIcon() and loadScaledIcon()
272  QPixmap loadScaledIcon(const QString &name, KIconLoader::Group group, qreal scale, int size = 0,
273  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
274  QString *path_store = nullptr,
275  bool canReturnNull = false) const;
276 
297  QPixmap loadMimeTypeIcon(const QString &iconName, KIconLoader::Group group, int size = 0,
298  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
299  QString *path_store = nullptr) const;
300 
308  KPixmapSequence loadPixmapSequence(const QString &iconName, int size = SizeSmall) const;
309 
310 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
311 
328  KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
329  QIcon loadIconSet(const QString &name, KIconLoader::Group group, int size = 0,
330  bool canReturnNull = false);
331 #endif
332 
347  QString iconPath(const QString &name, int group_or_size,
348  bool canReturnNull = false) const;
349 
366  // TODO KF6 merge iconPath() with and without "scale" and move that argument after "group_or_size"
367  QString iconPath(const QString &name, int group_or_size,
368  bool canReturnNull, qreal scale) const;
369 
380  QMovie *loadMovie(const QString &name, KIconLoader::Group group, int size = 0, QObject *parent = nullptr) const;
381 
391  QString moviePath(const QString &name, KIconLoader::Group group, int size = 0) const;
392 
403  QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size = 0) const;
404 
415  QStringList queryIcons(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
416 
428  QStringList queryIconsByContext(int group_or_size,
429  KIconLoader::Context context = KIconLoader::Any) const;
430 
434  bool hasContext(KIconLoader::Context context) const;
435 
442  QStringList queryIconsByDir(const QString &iconsDir) const;
443 
450  QStringList searchPaths() const;
451 
461  int currentSize(KIconLoader::Group group) const;
462 
470  KIconTheme *theme() const;
471 
476  KIconEffect *iconEffect() const;
477 
484  void reconfigure(const QString &appname, const QStringList &extraSearchPaths = QStringList());
485 
491  static QPixmap unknown();
492 
500  bool alphaBlending(KIconLoader::Group group) const;
501 
512  void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state = KIconLoader::DefaultState) const;
513 
514  bool hasIcon(const QString &iconName) const;
515 
524  void setCustomPalette(const QPalette &palette);
525 
533  QPalette customPalette() const;
534 
541  void resetPalette();
542 
543 public Q_SLOTS:
544  // TODO: while marked as deprecated, newIconLoader() is still used:
545  // internally by KIconLoadeer as well as by Plasma's Icons kcm module (state: 5.17)
546  // this needs some further cleanup work before removing it from the API with KICONTHEMES_ENABLE_DEPRECATED_SINCE
553  KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use KIconLoader::emitChange(Group)")
554  void newIconLoader();
555 
565  static void emitChange(Group group);
566 
567 Q_SIGNALS:
571  void iconLoaderSettingsChanged();
572 
578  void iconChanged(int group);
579 
580 private:
581  // @internal the data object
582  KIconLoaderPrivate *d;
583 
584  Q_PRIVATE_SLOT(d, void _k_refreshIcons(int group))
585 };
586 
587 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
588 
595 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
596 KICONTHEMES_EXPORT QPixmap DesktopIcon(const QString &name, int size = 0,
597  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
598 #endif
599 
600 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
601 
606 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
607 KICONTHEMES_EXPORT QIcon DesktopIconSet(const QString &name, int size = 0);
608 #endif
609 
610 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
611 
618 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
619 KICONTHEMES_EXPORT QPixmap BarIcon(const QString &name, int size = 0, int state = KIconLoader::DefaultState,
620  const QStringList &overlays = QStringList());
621 #endif
622 
623 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
624 
629 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
630 KICONTHEMES_EXPORT QIcon BarIconSet(const QString &name, int size = 0);
631 #endif
632 
633 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
634 
641 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
642 KICONTHEMES_EXPORT QPixmap SmallIcon(const QString &name, int size = 0,
643  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
644 #endif
645 
646 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
647 
652 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
653 KICONTHEMES_EXPORT QIcon SmallIconSet(const QString &name, int size = 0);
654 #endif
655 
656 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
657 
664 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
665 KICONTHEMES_EXPORT QPixmap MainBarIcon(const QString &name, int size = 0,
666  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
667 #endif
668 
669 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
670 
675 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
676 KICONTHEMES_EXPORT QIcon MainBarIconSet(const QString &name, int size = 0);
677 #endif
678 
679 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 65)
680 
686 KICONTHEMES_DEPRECATED_VERSION(5, 65, "See API dox for replacement")
687 KICONTHEMES_EXPORT QPixmap UserIcon(const QString &name, int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
688 #endif
689 
690 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
691 
696 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
697 KICONTHEMES_EXPORT QIcon UserIconSet(const QString &name);
698 #endif
699 
700 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 66)
701 
707 KICONTHEMES_DEPRECATED_VERSION(5, 66, "Use QStyle::pixelMetric or KIconLoader::currentSize")
708 KICONTHEMES_EXPORT int IconSize(KIconLoader::Group group);
709 #endif
710 
711 namespace KDE
712 {
713 
721 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, KIconLoader *iconLoader = nullptr);
722 
728 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const QStringList &overlays, KIconLoader *iconLoader = nullptr);
729 
730 }
731 
732 inline KIconLoader::Group &operator++(KIconLoader::Group &group)
733 {
734  group = static_cast<KIconLoader::Group>(group + 1);
735  return group;
736 }
737 inline KIconLoader::Group operator++(KIconLoader::Group &group, int)
738 {
739  KIconLoader::Group ret = group;
740  ++group;
741  return ret;
742 }
743 
744 #endif // KICONLOADER_H
Q_ENUM(...)
The default state.
Definition: kiconloader.h:164
An icon that represents a mime type (or file type).
Definition: kiconloader.h:84
An icon that expresses an emotion.
Definition: kiconloader.h:88
Scalable-size icon.
Definition: kiconloader.h:100
An icon that represents a location (e.g. &#39;home&#39;, &#39;trash&#39;).
Definition: kiconloader.h:90
An icon that is animated.
Definition: kiconloader.h:85
An icon that represents a country&#39;s flag.
Definition: kiconloader.h:89
Some icon with unknown purpose.
Definition: kiconloader.h:75
Icon is disabled.
Definition: kiconloader.h:166
Panel (Plasma Taskbar) icons.
Definition: kiconloader.h:131
Small icons, e.g. for buttons.
Definition: kiconloader.h:129
An icon that represents a category.
Definition: kiconloader.h:86
Icon is active.
Definition: kiconloader.h:165
An icon that represents a file system.
Definition: kiconloader.h:80
Icons for use in dialog titles, page lists, etc.
Definition: kiconloader.h:133
An action icon (e.g. &#39;save&#39;, &#39;print&#39;).
Definition: kiconloader.h:76
Type
The type of the icon.
Definition: kiconloader.h:98
Main toolbar icons.
Definition: kiconloader.h:127
MatchType
The type of a match.
Definition: kiconloader.h:108
StdSizes
These are the standard sizes for icons.
Definition: kiconloader.h:144
An icon that represents an application.
Definition: kiconloader.h:77
Toolbar icons.
Definition: kiconloader.h:125
An icon that represents a device.
Definition: kiconloader.h:78
States
Defines the possible states of an icon.
Definition: kiconloader.h:163
Context
Defines the context of the icon.
Definition: kiconloader.h:74
Only try to find an exact match.
Definition: kiconloader.h:109
Group
The group of the icon.
Definition: kiconloader.h:117
Icon is selected.
Definition: kiconloader.h:167
Fixed-size icon.
Definition: kiconloader.h:99
Applies effects to icons.
Definition: kiconeffect.h:37
Iconloader for KDE.
Definition: kiconloader.h:66
An icon that adds information to an existing icon.
Definition: kiconloader.h:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Sep 18 2020 22:41:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.