diff --git a/SepantaUIKit.pro b/SepantaUIKit.pro index b86ec65..a125270 100644 --- a/SepantaUIKit.pro +++ b/SepantaUIKit.pro @@ -5,6 +5,7 @@ QT += quick #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + app.cpp \ main.cpp RESOURCES += qml.qrc @@ -19,3 +20,6 @@ QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +HEADERS += \ + app.h diff --git a/SepantaUiKit/Colors.qml b/SepantaUiKit/Colors.qml index 877a885..c8c77a8 100644 --- a/SepantaUiKit/Colors.qml +++ b/SepantaUiKit/Colors.qml @@ -2,22 +2,21 @@ import QtQuick 2.15 Item { //Primary - property var primaryEnable: "#B2F7EF" - property var primaryPressed: "#3CFCE6" + property string primaryEnable: "#B2F7EF" + property string primaryPressed: "#3CFCE6" //Secondary - property var secondaryEnable: "#007dff" + property string secondaryEnable: "#007dff" - property var secondaryPressed: "#abb5be" + property string secondaryPressed: "#abb5be" //Tertiary - property var tertiaryEnable: "#E9E8E8" - property var tertiaryPressed: "#D0D0d0 -" + property string tertiaryEnable: "#E9E8E8" + property string tertiaryPressed: "#D0D0d0" //Other - property var white: "#f8f8f8" - property var balck: "#0b0b0b" - property var success: "#28a745" - property var danger: "#dc3545" - property var warning: "#ffc107" - property var info: "#17a2b8" - property var gray: "#ced4da" + property string white: "#f8f8f8" + property string balck: "#0b0b0b" + property string success: "#28a745" + property string danger: "#dc3545" + property string warning: "#ffc107" + property string info: "#17a2b8" + property string gray: "#ced4da" } diff --git a/app.cpp b/app.cpp new file mode 100644 index 0000000..7cfc2e6 --- /dev/null +++ b/app.cpp @@ -0,0 +1,14 @@ +#include "app.h" +#include +App::App(QObject *parent): QObject (parent) +{ + +} + +App::~App(){} + +void App::loadQml() +{ + m_engine->load(""); + m_engine->load("qrc:/main.qml"); +} diff --git a/app.h b/app.h new file mode 100644 index 0000000..e72856a --- /dev/null +++ b/app.h @@ -0,0 +1,21 @@ +#ifndef APP_H +#define APP_H +#include +#include + +class App: public QObject +{ + + Q_OBJECT +public: + App(QObject* parent = Q_NULLPTR); + ~App(); + + Q_INVOKABLE void loadQml(); + void setEngine(QQmlApplicationEngine *engine) { m_engine = engine; } + +private: + QQmlApplicationEngine* m_engine; +}; + +#endif // APP_H diff --git a/main.cpp b/main.cpp index c2c84fc..201e3fd 100644 --- a/main.cpp +++ b/main.cpp @@ -1,25 +1,19 @@ #include #include +#include +#include "app.h" int main(int argc, char *argv[]) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - const QUrl url(QStringLiteral("qrc:/main.qml")); - QObject::connect( - &engine, - &QQmlApplicationEngine::objectCreated, - &app, - [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) - QCoreApplication::exit(-1); - }, - Qt::QueuedConnection); - engine.load(url); + + engine.load("qrc:/main.qml"); + App appy; + appy.setEngine(&engine); + engine.rootContext()->setContextProperty("app",&appy); return app.exec(); } diff --git a/main.qml b/main.qml index a6a8997..c40877c 100644 --- a/main.qml +++ b/main.qml @@ -1,10 +1,21 @@ import QtQuick 2.13 import QtQuick.Window 2.13 +import "./SepantaUiKit/SKBtn" +import QtQuick.Window 2.11 Window { - width: 1700 - height: 900 + id: window + width: 1600 + height: 800 visible: true title: "SepantaUiKit" color: "black" + + Shortcut { + sequence: "F5" + onActivated: { + window.close() + app.loadQml() + } + } }