diff --git a/ui/StatusQ/.gitignore b/ui/StatusQ/.gitignore index e43b0f9889..906dfe61ef 100644 --- a/ui/StatusQ/.gitignore +++ b/ui/StatusQ/.gitignore @@ -1 +1,12 @@ .DS_Store +moc_* +*.pro.user +qrc_* +*.o +build-* +*.qmlc +bin +*.app +*.autosave +Makefile +.qmake.stash diff --git a/ui/StatusQ/sandbox/Icons.qml b/ui/StatusQ/sandbox/Icons.qml new file mode 100644 index 0000000000..51658a0f01 --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/sandbox/handler.cpp b/ui/StatusQ/sandbox/handler.cpp new file mode 100644 index 0000000000..60401c69bd --- /dev/null +++ b/ui/StatusQ/sandbox/handler.cpp @@ -0,0 +1,6 @@ +#include "handler.h" + +Handler::Handler(QObject *parent) : QObject(parent) +{ + +} diff --git a/ui/StatusQ/sandbox/handler.h b/ui/StatusQ/sandbox/handler.h new file mode 100644 index 0000000000..aacbb27a8c --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/sandbox/main.cpp b/ui/StatusQ/sandbox/main.cpp new file mode 100644 index 0000000000..10d731a2d4 --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/sandbox/main.qml b/ui/StatusQ/sandbox/main.qml new file mode 100644 index 0000000000..d8f3e7f6e3 --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/sandbox/qml.qrc b/ui/StatusQ/sandbox/qml.qrc new file mode 100644 index 0000000000..b53ca9e789 --- /dev/null +++ b/ui/StatusQ/sandbox/qml.qrc @@ -0,0 +1,6 @@ + + + main.qml + Icons.qml + + diff --git a/ui/StatusQ/sandbox/sandbox.pro b/ui/StatusQ/sandbox/sandbox.pro new file mode 100644 index 0000000000..45d9569010 --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/sandbox/sandboxapp.cpp b/ui/StatusQ/sandbox/sandboxapp.cpp new file mode 100644 index 0000000000..43db482760 --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/sandbox/sandboxapp.h b/ui/StatusQ/sandbox/sandboxapp.h new file mode 100644 index 0000000000..8589baab72 --- /dev/null +++ b/ui/StatusQ/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/ui/StatusQ/src/StatusQ/Core/Theme/qmldir b/ui/StatusQ/src/StatusQ/Core/Theme/qmldir index 085e6108af..0fab64e286 100644 --- a/ui/StatusQ/src/StatusQ/Core/Theme/qmldir +++ b/ui/StatusQ/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/ui/StatusQ/src/StatusQ/Core/qmldir b/ui/StatusQ/src/StatusQ/Core/qmldir index 02db2e8d6c..4aa7135c2f 100644 --- a/ui/StatusQ/src/StatusQ/Core/qmldir +++ b/ui/StatusQ/src/StatusQ/Core/qmldir @@ -1,2 +1,4 @@ +module StatusQ.Core + StatusIcon 0.1 StatusIcon.qml diff --git a/ui/StatusQ/src/StatusQ/qmldir b/ui/StatusQ/src/StatusQ/qmldir new file mode 100644 index 0000000000..87c1ed3843 --- /dev/null +++ b/ui/StatusQ/src/StatusQ/qmldir @@ -0,0 +1,2 @@ +module StatusQ +