summaryrefslogtreecommitdiff
path: root/Bootstrap.hxx
blob: 57fa3aaecfa2f90b3465a269b82f5e24030ba528 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
#ifndef BOOTSTRAP_HXX
#define BOOTSTRAP_HXX

#include <QtQml>
#include <QColor>

class Qootstrap : public QQmlEngineExtensionPlugin
{
	Q_OBJECT
	Q_PLUGIN_METADATA(IID "org.darapsa.Qootstrap")
};

class Bootstrap : public QObject
{
	Q_OBJECT
	Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
	Q_PROPERTY(bool darkMode READ darkMode WRITE setDarkMode NOTIFY darkModeChanged)
	Q_PROPERTY(QColor bodyColor READ bodyColor NOTIFY bodyColorChanged)
	Q_PROPERTY(QColor bodyBg READ bodyBg NOTIFY bodyBgChanged)
	Q_PROPERTY(QColor borderColor READ borderColor NOTIFY borderColorChanged)
	QML_ELEMENT
	QML_UNCREATABLE("Bootstrap is an attached property")

	public:
		explicit Bootstrap(QObject *parent = nullptr);
		static Bootstrap *qmlAttachedProperties(QObject *object);

		enum Theme {
			None,
			Primary,
			Secondary,
			Success,
			Danger,
			Warning,
			Info,
			Light,
			Dark,
			Link
		};
		Q_ENUM(Theme)
		Theme theme() const;
		void setTheme(Theme theme);
		bool darkMode() const;
		void setDarkMode(bool darkMode);
		QColor bodyColor() const;
		QColor bodyBg() const;
		QColor borderColor() const;

	signals:
		void themeChanged();
		void darkModeChanged();
		void bodyColorChanged();
		void bodyBgChanged();
		void borderColorChanged();

	private:
		Theme bsTheme;
		bool bsDarkMode;
		QColor bsLightBodyColor;
		QColor bsDarkBodyColor;
		QColor bsLightBodyBg;
		QColor bsDarkBodyBg;
		QColor bsLightBorderColor;
		QColor bsDarkBorderColor;
};

QML_DECLARE_TYPEINFO(Bootstrap, QML_HAS_ATTACHED_PROPERTIES)

#endif