feat(Storybook): Initial project config and main qml/cpp

Closes: #7547
This commit is contained in:
Michał Cieślak 2022-10-04 22:25:14 +02:00 committed by Michał
parent 95c0721578
commit 38299f7169
4 changed files with 143 additions and 0 deletions

49
storybook/CMakeLists.txt Normal file
View File

@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.19)
project(Storybook)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(
Qt5
COMPONENTS Core Quick QuickControls2
REQUIRED)
file(GLOB_RECURSE QML_FILES "stubs/*.qml" "../ui/StatusQ/*.qml" "../ui/app/*.qml")
file(GLOB_RECURSE JS_FILES "../ui/StatusQ/*.js" "../ui/app/*.js")
file(GLOB_RECURSE HEADERS *.h)
if(APPLE)
file(GLOB_RECURSE SOURCES *.cpp *.mm)
else()
file(GLOB_RECURSE SOURCES *.cpp)
endif()
add_executable(
${PROJECT_NAME}
qml.qrc
${HEADERS}
${SOURCES}
${QML_FILES}
${JS_FILES}
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE SRC_DIR="${CMAKE_CURRENT_LIST_DIR}")
target_link_libraries(
${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::QuickControls2
SortFilterProxyModel)
if (APPLE)
find_library(AppKit AppKit)
find_library(Foundation Foundation)
target_link_libraries(${PROJECT_NAME} PRIVATE ${AppKit} ${Foundation})
endif()
add_subdirectory(../ui/StatusQ/vendor/SortFilterProxyModel ./SortFilterProxyModel)

32
storybook/main.cpp Normal file
View File

@ -0,0 +1,32 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
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);
app.setOrganizationName("Status");
app.setOrganizationDomain("status.im");
app.setApplicationName("Status Desktop Storybook");
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral(":/"));
engine.addImportPath(SRC_DIR + QStringLiteral("/../ui/StatusQ/src"));
engine.addImportPath(SRC_DIR + QStringLiteral("/../ui/app"));
engine.addImportPath(SRC_DIR + QStringLiteral("/../ui/imports"));
engine.addImportPath(SRC_DIR + QStringLiteral("/stubs"));
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);
return app.exec();
}

57
storybook/main.qml Normal file
View File

@ -0,0 +1,57 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Layout 0.1
import Qt.labs.settings 1.0
ApplicationWindow {
id: rootWindow
width: 1450
height: 840
visible: true
StatusSectionLayout {
id: mainPageView
anchors.fill: parent
showHeader: false
function page(name, fillPage) {
viewLoader.source = Qt.resolvedUrl("./pages/" + name + "Page.qml");
storeSettings.selected = viewLoader.source
}
leftPanel: StatusScrollView {
anchors.fill: parent
anchors.topMargin: 48
Column {
id: navigation
spacing: 0
}
}
centerPanel: Item {
id: centerPanel
anchors.fill: parent
Loader {
id: viewLoader
anchors.fill: parent
clip: true
source: storeSettings.selected
}
}
}
Settings {
id: storeSettings
property string selected: ""
}
}

5
storybook/qml.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>