KIconThemes

kiconloader.h
1 /* vi: ts=8 sts=4 sw=4
2  *
3  * This file is part of the KDE project, module kdecore.
4  * Copyright (C) 2000 Geert Jansen <[email protected]>
5  * Antonio Larrosa <[email protected]>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License version 2 as published by the Free Software Foundation.
10  *
11  * This library 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 GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef KICONLOADER_H
23 #define KICONLOADER_H
24 
25 #include <QString>
26 #include <QStringList>
27 #include <QObject>
28 
29 #include <kiconthemes_export.h>
30 
31 class QIcon;
32 class QMovie;
33 class QPixmap;
34 
35 class KIconLoaderPrivate;
36 class KIconEffect;
37 class KIconTheme;
38 
39 class KPixmapSequence;
40 
78 class KICONTHEMES_EXPORT KIconLoader : public QObject
79 {
80  Q_OBJECT
81 
82 public:
86  enum Context {
87  Any,
91 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(4, 8)
93 #elif KICONTHEMES_BUILD_DEPRECATED_SINCE(4, 8)
94  FileSystem_DEPRECATED_DO_NOT_USE,
95 #endif
103  StatusIcon
104  };
105  Q_ENUM(Context)
106 
107 
110  enum Type {
113  Threshold
114  };
115  Q_ENUM(Type)
116 
117 
120  enum MatchType {
122  MatchBest
123  };
125 
126 
129  enum Group {
131  NoGroup = -1,
133  Desktop = 0,
135  FirstGroup = 0,
149  User
150  };
151  Q_ENUM(Group)
152 
153 
156  enum StdSizes {
158  SizeSmall = 16,
160  SizeSmallMedium = 22,
162  SizeMedium = 32,
164  SizeLarge = 48,
166  SizeHuge = 64,
168  SizeEnormous = 128
169  };
171 
172 
175  enum States {
180  LastState
181  };
182  Q_ENUM(States)
183 
184 
195  explicit KIconLoader(const QString &appname = QString(), const QStringList &extraSearchPaths = QStringList(), QObject *parent = nullptr);
196 
200  ~KIconLoader();
201 
206  static KIconLoader *global();
207 
216  void addAppDir(const QString &appname, const QString &themeBaseDir = QString());
217 
246  QPixmap loadIcon(const QString &name, KIconLoader::Group group, int size = 0,
247  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
248  QString *path_store = nullptr,
249  bool canReturnNull = false) const;
250 
283  // TODO KF6 merge loadIcon() and loadScaledIcon()
284  QPixmap loadScaledIcon(const QString &name, KIconLoader::Group group, qreal scale, int size = 0,
285  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
286  QString *path_store = nullptr,
287  bool canReturnNull = false) const;
288 
309  QPixmap loadMimeTypeIcon(const QString &iconName, KIconLoader::Group group, int size = 0,
310  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
311  QString *path_store = nullptr) const;
312 
320  KPixmapSequence loadPixmapSequence(const QString &iconName, int size = SizeSmall) const;
321 
322 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
323 
340  KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
341  QIcon loadIconSet(const QString &name, KIconLoader::Group group, int size = 0,
342  bool canReturnNull = false);
343 #endif
344 
359  QString iconPath(const QString &name, int group_or_size,
360  bool canReturnNull = false) const;
361 
378  // TODO KF6 merge iconPath() with and without "scale" and move that argument after "group_or_size"
379  QString iconPath(const QString &name, int group_or_size,
380  bool canReturnNull, qreal scale) const;
381 
392  QMovie *loadMovie(const QString &name, KIconLoader::Group group, int size = 0, QObject *parent = nullptr) const;
393 
403  QString moviePath(const QString &name, KIconLoader::Group group, int size = 0) const;
404 
415  QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size = 0) const;
416 
427  QStringList queryIcons(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
428 
440  QStringList queryIconsByContext(int group_or_size,
441  KIconLoader::Context context = KIconLoader::Any) const;
442 
446  bool hasContext(KIconLoader::Context context) const;
447 
454  QStringList queryIconsByDir(const QString &iconsDir) const;
455 
462  QStringList searchPaths() const;
463 
473  int currentSize(KIconLoader::Group group) const;
474 
482  KIconTheme *theme() const;
483 
488  KIconEffect *iconEffect() const;
489 
496  void reconfigure(const QString &appname, const QStringList &extraSearchPaths = QStringList());
497 
503  static QPixmap unknown();
504 
512  bool alphaBlending(KIconLoader::Group group) const;
513 
524  void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state = KIconLoader::DefaultState) const;
525 
526  bool hasIcon(const QString &iconName) const;
527 
536  void setCustomPalette(const QPalette &palette);
537 
545  QPalette customPalette() const;
546 
553  void resetPalette();
554 
555 public Q_SLOTS:
556  // TODO: while marked as deprecated, newIconLoader() is still used:
557  // internally by KIconLoadeer as well as by Plasma's Icons kcm module (state: 5.17)
558  // this needs some further cleanup work before removing it from the API with KICONTHEMES_ENABLE_DEPRECATED_SINCE
565  KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use KIconLoader::emitChange(Group)")
566  void newIconLoader();
567 
577  static void emitChange(Group group);
578 
579 Q_SIGNALS:
583  void iconLoaderSettingsChanged();
584 
590  void iconChanged(int group);
591 
592 private:
593  // @internal the data object
594  KIconLoaderPrivate *d;
595 
596  Q_PRIVATE_SLOT(d, void _k_refreshIcons(int group))
597 };
598 
599 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
600 
607 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
608 KICONTHEMES_EXPORT QPixmap DesktopIcon(const QString &name, int size = 0,
609  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
610 #endif
611 
612 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
613 
618 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
619 KICONTHEMES_EXPORT QIcon DesktopIconSet(const QString &name, int size = 0);
620 #endif
621 
622 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
623 
630 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
631 KICONTHEMES_EXPORT QPixmap BarIcon(const QString &name, int size = 0, int state = KIconLoader::DefaultState,
632  const QStringList &overlays = QStringList());
633 #endif
634 
635 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
636 
641 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
642 KICONTHEMES_EXPORT QIcon BarIconSet(const QString &name, int size = 0);
643 #endif
644 
645 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
646 
653 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
654 KICONTHEMES_EXPORT QPixmap SmallIcon(const QString &name, int size = 0,
655  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
656 #endif
657 
658 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
659 
664 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
665 KICONTHEMES_EXPORT QIcon SmallIconSet(const QString &name, int size = 0);
666 #endif
667 
668 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 63)
669 
676 KICONTHEMES_DEPRECATED_VERSION(5, 63, "See API dox for replacement")
677 KICONTHEMES_EXPORT QPixmap MainBarIcon(const QString &name, int size = 0,
678  int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
679 #endif
680 
681 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
682 
687 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
688 KICONTHEMES_EXPORT QIcon MainBarIconSet(const QString &name, int size = 0);
689 #endif
690 
691 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 65)
692 
698 KICONTHEMES_DEPRECATED_VERSION(5, 65, "See API dox for replacement")
699 KICONTHEMES_EXPORT QPixmap UserIcon(const QString &name, int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList());
700 #endif
701 
702 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 0)
703 
708 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use QIcon::fromTheme(const QString&)")
709 KICONTHEMES_EXPORT QIcon UserIconSet(const QString &name);
710 #endif
711 
712 #if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 66)
713 
719 KICONTHEMES_DEPRECATED_VERSION(5, 66, "Use QStyle::pixelMetric or KIconLoader::currentSize")
720 KICONTHEMES_EXPORT int IconSize(KIconLoader::Group group);
721 #endif
722 
723 namespace KDE
724 {
725 
733 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, KIconLoader *iconLoader = nullptr);
734 
740 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const QStringList &overlays, KIconLoader *iconLoader = nullptr);
741 
742 }
743 
744 inline KIconLoader::Group &operator++(KIconLoader::Group &group)
745 {
746  group = static_cast<KIconLoader::Group>(group + 1);
747  return group;
748 }
749 inline KIconLoader::Group operator++(KIconLoader::Group &group, int)
750 {
751  KIconLoader::Group ret = group;
752  ++group;
753  return ret;
754 }
755 
756 #endif // KICONLOADER_H
Q_ENUM(...)
The default state.
Definition: kiconloader.h:176
An icon that represents a mime type (or file type).
Definition: kiconloader.h:96
An icon that expresses an emotion.
Definition: kiconloader.h:100
Scalable-size icon.
Definition: kiconloader.h:112
An icon that represents a location (e.g. &#39;home&#39;, &#39;trash&#39;).
Definition: kiconloader.h:102
An icon that is animated.
Definition: kiconloader.h:97
An icon that represents a country&#39;s flag.
Definition: kiconloader.h:101
Some icon with unknown purpose.
Definition: kiconloader.h:87
Icon is disabled.
Definition: kiconloader.h:178
Panel (Plasma Taskbar) icons.
Definition: kiconloader.h:143
Small icons, e.g. for buttons.
Definition: kiconloader.h:141
An icon that represents a category.
Definition: kiconloader.h:98
Icon is active.
Definition: kiconloader.h:177
An icon that represents a file system.
Definition: kiconloader.h:92
Icons for use in dialog titles, page lists, etc.
Definition: kiconloader.h:145
An action icon (e.g. &#39;save&#39;, &#39;print&#39;).
Definition: kiconloader.h:88
Type
The type of the icon.
Definition: kiconloader.h:110
Main toolbar icons.
Definition: kiconloader.h:139
MatchType
The type of a match.
Definition: kiconloader.h:120
StdSizes
These are the standard sizes for icons.
Definition: kiconloader.h:156
An icon that represents an application.
Definition: kiconloader.h:89
Toolbar icons.
Definition: kiconloader.h:137
An icon that represents a device.
Definition: kiconloader.h:90
States
Defines the possible states of an icon.
Definition: kiconloader.h:175
Context
Defines the context of the icon.
Definition: kiconloader.h:86
Only try to find an exact match.
Definition: kiconloader.h:121
Group
The group of the icon.
Definition: kiconloader.h:129
Icon is selected.
Definition: kiconloader.h:179
Fixed-size icon.
Definition: kiconloader.h:111
Applies effects to icons.
Definition: kiconeffect.h:48
Iconloader for KDE.
Definition: kiconloader.h:78
An icon that adds information to an existing icon.
Definition: kiconloader.h:99
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue May 26 2020 22:51:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.