From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- SQLiteStudio3/guiSQLiteStudio/icon.h | 104 +++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 SQLiteStudio3/guiSQLiteStudio/icon.h (limited to 'SQLiteStudio3/guiSQLiteStudio/icon.h') diff --git a/SQLiteStudio3/guiSQLiteStudio/icon.h b/SQLiteStudio3/guiSQLiteStudio/icon.h new file mode 100644 index 0000000..d6512c9 --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/icon.h @@ -0,0 +1,104 @@ +#ifndef ICONS_H +#define ICONS_H + +#include "guiSQLiteStudio_global.h" +#include +#include +#include + +class QMovie; + +#define DEF_ICONS(TypeName, ObjName, Defs) \ + struct GUI_API_EXPORT TypeName \ + { \ + Defs \ + }; \ + TypeName ObjName; + +#define DEF_ICON(E,N) Icon E = Icon(#E, N); +#define DEF_ICO2(E,Src,Attr) Icon E = Icon::createFrom(#E, Src, Icon::Attr); +#define DEF_ICO3(E,Src) Icon E = Icon::aliasOf(#E, &Src); + +class GUI_API_EXPORT Icon +{ + public: + enum Attributes + { + NONE, + PLUS, + MINUS, + EDIT, + DELETE, + DENIED, + INFO, + WARNING, + QUESTION, + ERROR, + SORT_ASC, + SORT_DESC + }; + + Icon(const QString& name, const QString& fileName); + Icon(const Icon& other); + ~Icon(); + + QString getFileName() const; + QString getName() const; + QString getPath() const; + bool isNull() const; + bool isMovie() const; + void load(); + QString toImgSrc() const; + QString toBase64Url() const; + QByteArray toBase64() const; + QByteArray toPixmapBytes() const; + QString toUrl() const; + QIcon* toQIconPtr() const; + QIcon toQIcon() const; + Icon* toIconPtr(); + QPixmap toQPixmap() const; + QMovie* toQMoviePtr() const; + QVariant toQVariant() const; + QIcon* with(Attributes attr); + + operator Icon*(); + operator QIcon() const; + operator QIcon*() const; + operator QPixmap() const; + operator QMovie*() const; + operator QVariant() const; + + static void init(); + static void loadAll(); + static void reloadAll(); + static Icon& createFrom(const QString& name, Icon* copy, Attributes attr); + static Icon& aliasOf(const QString& name, Icon* other); + static QIcon merge(const QIcon& icon, Attributes attr); + + private: + explicit Icon(const QString& name); + + static QString getIconNameForAttribute(Attributes attr); + static QIcon mergeAttribute(const QIcon* icon, Attributes attr); + + bool loaded = false; + bool movie = false; + QString name; + Attributes attr = NONE; + QString fileName; + QString filePath; + Icon* copyFrom = nullptr; + Icon* aliased = nullptr; + QMovie* movieHandle = nullptr; + QIcon* iconHandle = nullptr; + QHash dynamicallyAttributed; + + static QHash instances; +}; + +GUI_API_EXPORT QDataStream &operator<<(QDataStream &out, const Icon* icon); +GUI_API_EXPORT QDataStream &operator>>(QDataStream &in, const Icon*& icon); + +Q_DECLARE_METATYPE(const Icon*) + +#endif // ICONS_H -- cgit v1.2.3