QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSkin.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_SKIN_H
7#define QSK_SKIN_H
8
9#include "QskAspect.h"
10
11#include <qcolor.h>
12#include <qobject.h>
13
14#include <memory>
15#include <type_traits>
16
17class QskSkinnable;
18class QskSkinlet;
19
20class QskColorFilter;
21class QskGraphic;
23class QskFontRole;
24
26
27class QVariant;
28template< typename Key, typename T > class QHash;
29
30class QSK_EXPORT QskSkin : public QObject
31{
32 Q_OBJECT
33
34 using Inherited = QObject;
35
36 public:
37#if 1
38 // Use Qt::ColorScheme once minimum version is Qt 6.5
39 enum ColorScheme
40 {
41 UnknownScheme,
42
43 LightScheme,
44 DarkScheme
45 };
46 Q_ENUM( ColorScheme )
47#endif
48
49 QskSkin( QObject* parent = nullptr );
50 ~QskSkin() override;
51
52 template< typename Control, typename Skinlet >
53 void declareSkinlet();
54
55 void setSkinHint( QskAspect, const QVariant& hint );
56 const QVariant& skinHint( QskAspect ) const;
57
58 void setGraphicFilter( int graphicRole, const QskColorFilter& );
59 void resetGraphicFilter( int graphicRole );
60 QskColorFilter graphicFilter( int graphicRole ) const;
61
62 void setFont( const QskFontRole&, const QFont& );
63 void resetFont( const QskFontRole& );
64 QFont font( const QskFontRole& ) const;
65
66 void addGraphicProvider( const QString& providerId, QskGraphicProvider* );
67 QskGraphicProvider* graphicProvider( const QString& providerId ) const;
68 bool hasGraphicProvider() const;
69
70 virtual const int* dialogButtonLayout( Qt::Orientation ) const;
71 virtual QString dialogButtonText( int button ) const;
72
73 QskSkinlet* skinlet( const QMetaObject* );
74 const QMetaObject* skinletMetaObject( const QMetaObject* ) const;
75
76 const QskSkinHintTable& hintTable() const;
77 QskSkinHintTable& hintTable();
78
79 const QHash< QskFontRole, QFont >& fontTable() const;
80 const QHash< int, QskColorFilter >& graphicFilters() const;
81
82 ColorScheme colorScheme() const;
83
84 public Q_SLOTS:
85 void setColorScheme( ColorScheme );
86
87 Q_SIGNALS:
88 void colorSchemeChanged( ColorScheme );
89
90 protected:
91 void clearHints();
92 virtual void initHints() = 0;
93
94 void setupFontTable( const QString& family, bool italic = false );
95 void completeFontTable();
96
97 private:
98 void declareSkinlet( const QMetaObject* metaObject,
99 const QMetaObject* skinletMetaObject );
100
101 class PrivateData;
102 std::unique_ptr< PrivateData > m_data;
103};
104
105template< typename Skinnable, typename Skinlet >
106inline void QskSkin::declareSkinlet()
107{
108 Q_STATIC_ASSERT( ( std::is_base_of< QskSkinnable, Skinnable >::value ) );
109 Q_STATIC_ASSERT( ( std::is_base_of< QskSkinlet, Skinlet >::value ) );
110 declareSkinlet( &Skinnable::staticMetaObject, &Skinlet::staticMetaObject );
111}
112
113#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15
A paint device for scalable graphics.
Definition QskGraphic.h:28
Describes the rendering interface of a QskControl. Change the skinlet to change the appearance of the...
Definition QskSkinlet.h:34