diff --git a/.gitignore b/.gitignore index e43b0f98..906dfe61 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,12 @@ .DS_Store +moc_* +*.pro.user +qrc_* +*.o +build-* +*.qmlc +bin +*.app +*.autosave +Makefile +.qmake.stash diff --git a/sandbox/Icons.qml b/sandbox/Icons.qml new file mode 100644 index 00000000..51658a0f --- /dev/null +++ b/sandbox/Icons.qml @@ -0,0 +1,22 @@ +import QtQuick 2.14 +import QtQuick.Layouts 1.14 +import StatusQ.Core 0.1 + +GridLayout { + columns: 6 + columnSpacing: 5 + rowSpacing: 5 + property color iconColor + + Repeater { + model: ["activity", "add-circle", "add-contact", "add", + "address", "admin", "airdrop", "animals-and-nature", + "browser", "arbitrator", "camera", "chat", "channel", + "chatbot", "checkmark", "clear", "code", "communities"] + + delegate: StatusIcon { + icon: modelData + color: iconColor + } + } +} diff --git a/sandbox/handler.cpp b/sandbox/handler.cpp new file mode 100644 index 00000000..60401c69 --- /dev/null +++ b/sandbox/handler.cpp @@ -0,0 +1,6 @@ +#include "handler.h" + +Handler::Handler(QObject *parent) : QObject(parent) +{ + +} diff --git a/sandbox/handler.h b/sandbox/handler.h new file mode 100644 index 00000000..aacbb27a --- /dev/null +++ b/sandbox/handler.h @@ -0,0 +1,16 @@ +#ifndef HANDLER_H +#define HANDLER_H + +#include + +class Handler : public QObject +{ + Q_OBJECT +public: + explicit Handler(QObject *parent = nullptr); + +signals: + void restartQml(); +}; + +#endif // HANDLER_H diff --git a/sandbox/main.cpp b/sandbox/main.cpp new file mode 100644 index 00000000..10d731a2 --- /dev/null +++ b/sandbox/main.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +#include "sandboxapp.h" + +int main(int argc, char *argv[]) +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + + SandboxApp app(argc, argv); + app.startEngine(); + + return app.exec(); +} diff --git a/sandbox/main.qml b/sandbox/main.qml new file mode 100644 index 00000000..d8f3e7f6 --- /dev/null +++ b/sandbox/main.qml @@ -0,0 +1,135 @@ +import QtQuick 2.14 +import QtQuick.Window 2.14 +import QtQuick.Controls 2.14 + +import StatusQ.Core 0.1 +import StatusQ.Core.Theme 0.1 + +Window { + id: rootWindow + width: 640 + height: 480 + visible: true + title: qsTr("Status App Sandbox") + + ButtonGroup { + id: topicsGroup + buttons: tabs.children + } + + Flow { + id: tabs + width: parent.width + Button { + text: "Reload QML" + onClicked: app.restartQml() + } + Button { + id: iconsTab + checkable: true + text: "Icons" + } + } + + ScrollView { + width: parent.width + anchors.top: tabs.bottom + anchors.bottom: parent.bottom + contentHeight: rootWindow.height * rootWindow.factor + contentWidth: rootWindow.width * rootWindow.factor + clip: true + SplitView { + width: parent.width + height: rootWindow.height + handle: Item {} + + scale: rootWindow.factor + + Rectangle { + id: lightThemeBg + + SplitView.minimumWidth: rootWindow.width / 2 + height: parent.height + color: lightTheme.baseColor5 + clip: true + + Loader { + active: true + anchors.centerIn: parent + property var currentTheme: StatusLightTheme { id: lightTheme } + + sourceComponent: { + switch(topicsGroup.checkedButton) { + case iconsTab: + return iconsComponent; + default: + return null; + } + } + } + + } + + Rectangle { + id: darkThemeBg + + SplitView.fillWidth: true + SplitView.minimumWidth: rootWindow.width / 2 + height: parent.height + color: darkTheme.baseColor5 + clip: true + + Loader { + active: true + anchors.centerIn: parent + property var currentTheme: StatusDarkTheme { id: darkTheme } + + sourceComponent: { + switch(topicsGroup.checkedButton) { + case iconsTab: + return iconsComponent; + default: + return null; + } + } + } + + } + } + } + + readonly property real maxFactor: 2.0 + readonly property real minFactor: 0.5 + + property real factor: 1.0 + Action { + shortcut: "CTRL+=" + onTriggered: { + if (rootWindow.factor < 2.0) + rootWindow.factor += 0.2 + } + } + + Action { + shortcut: "CTRL+-" + onTriggered: { + if (rootWindow.factor > 0.5) + rootWindow.factor -= 0.2 + } + } + + Action { + shortcut: "CTRL+0" + onTriggered: { + rootWindow.factor = 1.0 + } + } + + Component { + id: iconsComponent + Icons { + anchors.centerIn: parent + iconColor: parent? parent.currentTheme.primaryColor1 : "#ffffff" + } + } +} diff --git a/sandbox/qml.qrc b/sandbox/qml.qrc new file mode 100644 index 00000000..b53ca9e7 --- /dev/null +++ b/sandbox/qml.qrc @@ -0,0 +1,6 @@ + + + main.qml + Icons.qml + + diff --git a/sandbox/sandbox.pro b/sandbox/sandbox.pro new file mode 100644 index 00000000..45d95690 --- /dev/null +++ b/sandbox/sandbox.pro @@ -0,0 +1,28 @@ +QT += quick + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + handler.cpp \ + main.cpp \ + sandboxapp.cpp + +RESOURCES += qml.qrc + +DESTDIR = $$PWD/bin +CONFIG -= app_bundle + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +OTHER_FILES += $$files($$PWD/../src/*, true) + +HEADERS += \ + handler.h \ + sandboxapp.h diff --git a/sandbox/sandboxapp.cpp b/sandbox/sandboxapp.cpp new file mode 100644 index 00000000..43db4827 --- /dev/null +++ b/sandbox/sandboxapp.cpp @@ -0,0 +1,36 @@ +#include "sandboxapp.h" + +#include + +#include + +SandboxApp::SandboxApp(int &argc, char **argv) + : QGuiApplication(argc, argv), + m_handler(new Handler(this)) +{ + connect(m_handler, &Handler::restartQml, this, &SandboxApp::restartEngine, Qt::QueuedConnection); +} + +void SandboxApp::startEngine() +{ + const QUrl url(applicationDirPath() + "/../main.qml"); + + m_engine.rootContext()->setContextProperty("app", m_handler); + + m_engine.addImportPath(applicationDirPath() + "/../../src"); + qDebug() << m_engine.importPathList(); + QObject::connect(&m_engine, &QQmlApplicationEngine::objectCreated, + this, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + m_engine.load(url); +} + +void SandboxApp::restartEngine() +{ + const QUrl url(applicationDirPath() + "/../main.qml"); + m_engine.rootObjects().at(0)->deleteLater(); + m_engine.clearComponentCache(); + m_engine.load(url); +} diff --git a/sandbox/sandboxapp.h b/sandbox/sandboxapp.h new file mode 100644 index 00000000..8589baab --- /dev/null +++ b/sandbox/sandboxapp.h @@ -0,0 +1,24 @@ +#ifndef SANDBOXAPP_H +#define SANDBOXAPP_H + +#include +#include + +#include "handler.h" + +class SandboxApp : public QGuiApplication +{ +public: + SandboxApp(int &argc, char **argv); + + void startEngine(); + +public slots: + void restartEngine(); + +private: + QQmlApplicationEngine m_engine; + Handler *m_handler; +}; + +#endif // SANDBOXAPP_H diff --git a/src/StatusQ/Core/Theme/qmldir b/src/StatusQ/Core/Theme/qmldir index 085e6108..0fab64e2 100644 --- a/src/StatusQ/Core/Theme/qmldir +++ b/src/StatusQ/Core/Theme/qmldir @@ -1,3 +1,5 @@ +module StatusQ.Core.Theme + singleton StatusColors 0.1 StatusColors.qml ThemePalette 0.1 ThemePalette.qml StatusLightTheme 0.1 StatusLightTheme.qml diff --git a/src/StatusQ/Core/qmldir b/src/StatusQ/Core/qmldir index 02db2e8d..4aa7135c 100644 --- a/src/StatusQ/Core/qmldir +++ b/src/StatusQ/Core/qmldir @@ -1,2 +1,4 @@ +module StatusQ.Core + StatusIcon 0.1 StatusIcon.qml diff --git a/src/StatusQ/qmldir b/src/StatusQ/qmldir new file mode 100644 index 00000000..87c1ed38 --- /dev/null +++ b/src/StatusQ/qmldir @@ -0,0 +1,2 @@ +module StatusQ +