feat(Storybook): Button for opening pages directory

Closes: #12271
This commit is contained in:
Michał Cieślak 2023-09-27 14:09:20 +02:00 committed by Michał
parent e94554b209
commit d5317a91ba
2 changed files with 55 additions and 39 deletions

View File

@ -1,5 +1,6 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext>
#include "cachecleaner.h" #include "cachecleaner.h"
#include "directorieswatcher.h" #include "directorieswatcher.h"
@ -42,6 +43,9 @@ int main(int argc, char *argv[])
for (const auto& path : additionalImportPaths) for (const auto& path : additionalImportPaths)
engine.addImportPath(path); engine.addImportPath(path);
engine.rootContext()->setContextProperty(
"pagesFolder", QML_IMPORT_ROOT + QStringLiteral("/pages"));
qmlRegisterType<FigmaDecoratorModel>("Storybook", 1, 0, "FigmaDecoratorModel"); qmlRegisterType<FigmaDecoratorModel>("Storybook", 1, 0, "FigmaDecoratorModel");
qmlRegisterType<FigmaLinksSource>("Storybook", 1, 0, "FigmaLinksSource"); qmlRegisterType<FigmaLinksSource>("Storybook", 1, 0, "FigmaLinksSource");
qmlRegisterType<PagesModelInitialized>("Storybook", 1, 0, "PagesModel"); qmlRegisterType<PagesModelInitialized>("Storybook", 1, 0, "PagesModel");

View File

@ -102,59 +102,71 @@ ApplicationWindow {
SplitView { SplitView {
anchors.fill: parent anchors.fill: parent
Pane { ColumnLayout {
SplitView.preferredWidth: 270 SplitView.preferredWidth: 270
ColumnLayout { Pane {
width: parent.width Layout.fillWidth: true
height: parent.height Layout.fillHeight: true
Button { ColumnLayout {
Layout.fillWidth: true width: parent.width
height: parent.height
text: "Settings" Button {
Layout.fillWidth: true
onClicked: settingsPopup.open() text: "Settings"
}
CheckBox { onClicked: settingsPopup.open()
id: darkModeCheckBox }
Layout.fillWidth: true CheckBox {
id: darkModeCheckBox
text: "Dark mode" Layout.fillWidth: true
StatusLightTheme { id: lightTheme } text: "Dark mode"
StatusDarkTheme { id: darkTheme }
Binding { StatusLightTheme { id: lightTheme }
target: Theme StatusDarkTheme { id: darkTheme }
property: "palette"
value: darkModeCheckBox.checked ? darkTheme : lightTheme Binding {
target: Theme
property: "palette"
value: darkModeCheckBox.checked ? darkTheme : lightTheme
}
}
HotReloaderControls {
id: hotReloaderControls
Layout.fillWidth: true
onForceReloadClicked: reloader.forceReload()
}
MenuSeparator {
Layout.fillWidth: true
}
FilteredPagesList {
Layout.fillWidth: true
Layout.fillHeight: true
currentPage: root.currentPage
model: pagesModel
onPageSelected: root.currentPage = page
} }
} }
}
HotReloaderControls { Button {
id: hotReloaderControls Layout.fillWidth: true
text: "Open pages directory"
Layout.fillWidth: true onClicked: Qt.openUrlExternally(Qt.resolvedUrl(pagesFolder))
onForceReloadClicked: reloader.forceReload()
}
MenuSeparator {
Layout.fillWidth: true
}
FilteredPagesList {
Layout.fillWidth: true
Layout.fillHeight: true
currentPage: root.currentPage
model: pagesModel
onPageSelected: root.currentPage = page
}
} }
} }