QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSkinHintTable.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_SKIN_HINT_TABLE_H
7#define QSK_SKIN_HINT_TABLE_H
8
9#include "QskAspect.h"
10
11#include <qvariant.h>
12#include <qhash.h>
13
15
16class QSK_EXPORT QskSkinHintTable
17{
18 public:
22
23 QskSkinHintTable& operator=( const QskSkinHintTable& );
24
25 bool setAnimation( QskAspect, QskAnimationHint );
26 QskAnimationHint animation( QskAspect ) const;
27
28 bool setHint( QskAspect, const QVariant& );
29 const QVariant& hint( QskAspect ) const;
30
31 template< typename T > bool setHint( QskAspect, const T& );
32 template< typename T > T hint( QskAspect ) const;
33
34 bool removeHint( QskAspect );
35 QVariant takeHint( QskAspect );
36
37 bool hasHint( QskAspect ) const;
38
39 const QHash< QskAspect, QVariant >& hints() const;
40
41 bool hasAnimators() const;
42 bool hasHints() const;
43
44 QskAspect::States states() const;
45
46 void clear();
47
48 const QVariant* resolvedHint( QskAspect,
49 QskAspect* resolvedAspect = nullptr ) const;
50
51 QskAspect resolvedAspect( QskAspect ) const;
52
53 QskAspect resolvedAnimator(
55
56 bool isResolutionMatching( QskAspect, QskAspect ) const;
57
58 private:
59
60 static const QVariant invalidHint;
61
62 QHash< QskAspect, QVariant >* m_hints = nullptr;
63
64 unsigned short m_animatorCount = 0;
65 QskAspect::States m_states;
66};
67
68inline bool QskSkinHintTable::hasHints() const
69{
70 return m_hints != nullptr;
71}
72
73inline QskAspect::States QskSkinHintTable::states() const
74{
75 return m_states;
76}
77
78inline bool QskSkinHintTable::hasAnimators() const
79{
80 return m_animatorCount > 0;
81}
82
83inline bool QskSkinHintTable::hasHint( QskAspect aspect ) const
84{
85 return m_hints && m_hints->contains( aspect );
86}
87
88inline const QVariant& QskSkinHintTable::hint( QskAspect aspect ) const
89{
90 if ( m_hints != nullptr )
91 {
92 auto it = m_hints->constFind( aspect );
93 if ( it != m_hints->constEnd() )
94 return it.value();
95 }
96
97 return invalidHint;
98}
99
100template< typename T >
101inline bool QskSkinHintTable::setHint( QskAspect aspect, const T& hint )
102{
103 return setHint( aspect, QVariant::fromValue( hint ) );
104}
105
106template< typename T >
107inline T QskSkinHintTable::hint( QskAspect aspect ) const
108{
109 return hint( aspect ).value< T >();
110}
111
112#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15