-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgraphicseffectsstorage.h
More file actions
58 lines (53 loc) · 2.41 KB
/
graphicseffectsstorage.h
File metadata and controls
58 lines (53 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef GRAPHICSEFFECTSSTORAGE_H
#define GRAPHICSEFFECTSSTORAGE_H
#include "filestorage.h"
#include <QGraphicsEffect>
class QDomElement;
class UTILS_EXPORT GraphicsEffectsStorage : public FileStorage
{
Q_OBJECT
public:
GraphicsEffectsStorage(const QString &AStorage, const QString &ASubStorage = QString::null, QObject *AParent = NULL);
~GraphicsEffectsStorage();
// this will install effect for all child widgets that matches the mask (class and/or object name)
bool installGraphicsEffect(QWidget * widget, const QString & key);
// this will install effect for all application's widgets that matches the mask (class and/or object name)
bool installGraphicsEffect(const QString & key);
// this will uninstall effect for all child widgets that matches the mask (class and/or object name)
bool uninstallGraphicsEffect(QWidget * widget, const QString & key);
// this will uninstall effect for all application's widgets that matches the mask (class and/or object name)
bool uninstallGraphicsEffect(const QString & key);
// returns all effects for the specifyed key
QList<QGraphicsEffect*> getEffects(const QString & key);
// returns first effect for the specifyed key
QGraphicsEffect * getFirstEffect(const QString & key);
public:
static GraphicsEffectsStorage * staticStorage(const QString & storage);
protected:
struct EffectMask
{
QString key;
QStringList classNames;
QStringList objectNames;
bool operator ==(const EffectMask & other) const
{
return key == other.key && classNames == other.classNames && objectNames == other.objectNames;
}
};
friend uint qHash(const GraphicsEffectsStorage::EffectMask &mask);
void parseFile(const QString & key);
QGraphicsEffect * parseGraphicEffect(const QDomElement & element);
QGraphicsEffect * copyEffect(const QGraphicsEffect * effect) const;
QGraphicsEffect * effectForMask(const EffectMask & mask, QObject * parent) const;
bool widetMatchesTheMask(QWidget* widget, const EffectMask & mask) const;
private:
static QMultiHash<QString, EffectMask> keyMaskCache;
static QHash<EffectMask, QGraphicsEffect *> effectCache;
static QHash<QString, GraphicsEffectsStorage *> staticStorages;
static QSet<QString> loadedKeysCache;
};
inline uint qHash(const GraphicsEffectsStorage::EffectMask &mask)
{
return qHash(mask.key + " | "+ mask.classNames.join(";") + " | " + mask.objectNames.join(";"));
}
#endif // GRAPHICSEFFECTSSTORAGE_H