diff options
-rw-r--r-- | ApplicationWindow.qml | 16 | ||||
-rw-r--r-- | Bootstrap.qml | 104 | ||||
-rw-r--r-- | bootstrap.cxx | 19 | ||||
-rw-r--r-- | bootstrap.hxx | 19 | ||||
-rw-r--r-- | bootstrap.pro | 20 | ||||
-rw-r--r-- | qmldir | 7 | ||||
-rw-r--r-- | qtquickcontrols2bootstrapstyleplugin_metatypes.json | 1 |
7 files changed, 144 insertions, 42 deletions
diff --git a/ApplicationWindow.qml b/ApplicationWindow.qml new file mode 100644 index 0000000..72df372 --- /dev/null +++ b/ApplicationWindow.qml @@ -0,0 +1,16 @@ +import QtQuick 2.15 +import QtQuick.Templates 2.15 +import Bootstrap 5.3 + +ApplicationWindow { + id: window + color: Bootstrap.bodyBg + overlay { + modal: Rectangle { + color: Color.transparent(window.palette.shadow, .5) + } + modeless: Rectangle { + color: Color.transparent(window.palette.shadow, .15) + } + } +} diff --git a/Bootstrap.qml b/Bootstrap.qml new file mode 100644 index 0000000..1738816 --- /dev/null +++ b/Bootstrap.qml @@ -0,0 +1,104 @@ +pragma Singleton +import QtQuick 2.15 + +QtObject { + enum Theme { + Light = 0, + Dark + } + property int theme: Bootstrap.Theme.Light + + property color accordionBg: bodyBg + + property real badgeFontSize: 13.6 + + property color bodyColor: theme ? "#a1a1a8" : "#747579" + property color bodyBg: theme ? "#222529" : "#ffffff" + + property color borderColor: theme ? "#12ffffff" : gray200 + property real borderRadius: 5.2 + + property real boxShadowOffsetX: 0 + property real boxShadowOffsetY: 0 + property int boxShadowBlurRadius: 40 + property color boxShadowColor: "#261d3a53" + + property real btnPaddingX: 16 + property real btnPaddingY: 8 + + property color btnColor: "#747579" + property color btnBg: "transparent" + property color btnBorderColor: btnBg + property real btnBorderWidth: 1 + property real btnBorderRadius: 5.2 + property real btnLgFontSize: 16 + property real btnLgBorderRadius: 8 + + property color primary: "#066ac9" + property color secondary: "#9a9ea4" + property color success: "#0cbc87" + property color danger: "#d6293e" + property color light: theme ? "#2a2c31" : "#f5f7f9" + property color dark: theme ? "#0f0f10" : "#24292d" + property color tertiaryBg: theme ? "#2b3035" : "#f8f9fa" + + property color btnPrimaryColor: "#ffffff" + property color btnPrimaryBg: primary + property color btnPrimaryBorderColor: primary + property color btnPrimaryActiveColor: btnPrimaryColor + property color btnPrimaryActiveBg: "#0555a1" + property color btnPrimaryActiveBorderColor: "#055097" + property color btnPrimaryDisabledColor: "#a6ffffff" + property color btnPrimaryDisabledBg: "#a6066ac9" + property color btnPrimaryDisabledBorderColor: btnPrimaryDisabledBg + + property color btnOutlinePrimaryColor: primary + property color btnOutlinePrimaryBg: btnBg + property color btnOutlinePrimaryBorderColor: primary + property color btnOutlinePrimaryActiveColor: btnPrimaryColor + property color btnOutlinePrimaryActiveBg: primary + property color btnOutlinePrimaryActiveBorderColor: primary + property color btnOutlinePrimaryDisabledColor: + btnPrimaryDisabledColor + property color btnOutlinePrimaryDisabledBg: btnBg + property color btnOutlinePrimaryDisabledBorderColor: + btnPrimaryDisabledColor + + property color btnSuccessColor: btnPrimaryColor + property color btnSuccessBg: success + property color btnSuccessBorderColor: success + property color btnSuccessActiveColor: btnSuccessColor + property color btnSuccessActiveBg: "#0a966c" + property color btnSuccessActiveBorderColor: "#098d65" + property color btnSuccessDisabledColor: btnPrimaryDisabledColor + property color btnSuccessDisabledBg: "#a60cbc87" + property color btnSuccessDisabledBorderColor: btnSuccessDisabledBg + + property color btnLightColor: "#000000" + property color btnLightBg: "#f5f7f9" + property color btnLightBorderColor: btnLightBg + property color btnLightActiveColor: btnLightColor + property color btnLightActiveBg: "#c4c6c7" + property color btnLightActiveBorderColor: "#b8b9bb" + property color btnLightDisabledColor: "#a6000000" + property color btnLightDisabledBg: "#a6f5f7f9" + property color btnLightDisabledBorderColor: btnLightDisabledBg + + property color cardBg: theme ? "#1b1e21" : "#ffffff" + property color cardTitleColor: theme ? "#f7f5f5" : "#24292d" + + property color dropdownColor: "#747579" + property color dropdownLinkColor: theme ? "#c5c6cc" : "#747579" + property color dropdownLinkHoverColor: "#066ac9" + property color dropdownLinkHoverBg: "#1a066ac9" + + property color headingColor: theme ? "#ffffff" : "#24292d" + + property color gray200: theme ? "#464950" : "#eff1f2" + property color gray300: theme ? "#3e3e40" : "#dde0e3" + property color gray500: theme ? "#bfc0c9" : "#9a9ea4" + property color gray600: theme ? "#c5c6cc" : "#747579" + property color gray700: theme ? "#f3f1f1" : "#404448" + property color gray800: theme ? "#f7f5f5" : "#24292d" + property color gray900: theme ? "#ffffff" : "#0b0f13" +} diff --git a/bootstrap.cxx b/bootstrap.cxx index 22ba9cd..bf9a499 100644 --- a/bootstrap.cxx +++ b/bootstrap.cxx @@ -1,9 +1,8 @@ #include "bootstrap.hxx" Bootstrap::Bootstrap(QObject *parent): - QObject(parent), - m_theme(Theme::Light), - m_purpose(Purpose::None) + QQmlEngineExtensionPlugin(parent), + m_purpose(None) { } @@ -12,24 +11,12 @@ Bootstrap *Bootstrap::qmlAttachedProperties(QObject *object) return new Bootstrap(object); } -Bootstrap::Theme Bootstrap::theme() const -{ - return m_theme; -} - -void Bootstrap::setTheme(Bootstrap::Theme theme) -{ - if (theme == m_theme) return; - m_theme = theme; - emit themeChanged(); -} - Bootstrap::Purpose Bootstrap::purpose() const { return m_purpose; } -void Bootstrap::setPurpose(Bootstrap::Purpose purpose) +void Bootstrap::setPurpose(Purpose purpose) { if (purpose == m_purpose) return; m_purpose = purpose; diff --git a/bootstrap.hxx b/bootstrap.hxx index a0eccc3..dc1a1dd 100644 --- a/bootstrap.hxx +++ b/bootstrap.hxx @@ -1,25 +1,19 @@ #ifndef BOOTSTRAP_HXX #define BOOTSTRAP_HXX -#include <QObject> #include <QtQml> -class Bootstrap : public QObject +class Bootstrap : public QQmlEngineExtensionPlugin { Q_OBJECT - Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged) + Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) Q_PROPERTY(Purpose purpose READ purpose WRITE setPurpose NOTIFY purposeChanged) public: explicit Bootstrap(QObject *parent = nullptr); static Bootstrap *qmlAttachedProperties(QObject *object); - enum class Theme { - Light, - Dark - }; - - enum class Purpose { + enum Purpose { None, Primary, Secondary, @@ -31,21 +25,14 @@ class Bootstrap : public QObject Dark, Link }; - - Q_ENUM(Theme) Q_ENUM(Purpose) - - Theme theme() const; - void setTheme(Theme theme); Purpose purpose() const; void setPurpose(Purpose purpose); signals: - void themeChanged(); void purposeChanged(); private: - Theme m_theme; Purpose m_purpose; }; diff --git a/bootstrap.pro b/bootstrap.pro index cdf6b18..d5cf36e 100644 --- a/bootstrap.pro +++ b/bootstrap.pro @@ -1,13 +1,23 @@ TEMPLATE = lib -CONFIG += qt plugin qmltypes +CONFIG += plugin qmltypes QT += qml QML_IMPORT_NAME = Bootstrap QML_IMPORT_MAJOR_VERSION = 5 QML_IMPORT_MINOR_VERSION = 3 -DESTDIR = imports/$$QML_IMPORT_NAME -TARGET = qtquickcontrols2bootstrapstyleplugin +import.files = \ + qmldir \ + $${QML_IMPORT_NAME}.qml +import.path = $$[QT_INSTALL_QML]/$$QML_IMPORT_NAME -HEADERS += bootstrap.hxx -SOURCES += bootstrap.cxx +style.files = \ + ApplicationWindow.qml +style.path = $$[QT_INSTALL_QML]/QtQuick/Controls.2/$$QML_IMPORT_NAME + +HEADERS += $${TARGET}.hxx +SOURCES += $${TARGET}.cxx +TARGET = qqc2$$TARGET +target.path = $$[QT_INSTALL_QML]/$$QML_IMPORT_NAME + +INSTALLS += import style target @@ -1,4 +1,3 @@ -module QtQuick.Controls.Bootstrap -plugin qtquickcontrols2bootstrapstyleplugin -classname QtQuickControls2BootstrapStylePlugin -depends QtQuick.Controls 2.5 +module Bootstrap +singleton Bootstrap 5.3 Bootstrap.qml +plugin qqc2bootstrap diff --git a/qtquickcontrols2bootstrapstyleplugin_metatypes.json b/qtquickcontrols2bootstrapstyleplugin_metatypes.json deleted file mode 100644 index 61840ed..0000000 --- a/qtquickcontrols2bootstrapstyleplugin_metatypes.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys" : [ "bootstrapstyleplugin" ] } |