From d5317a91bac4970825ce83be90c943f2f5c87995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Wed, 27 Sep 2023 14:09:20 +0200 Subject: [PATCH] feat(Storybook): Button for opening pages directory Closes: #12271 --- storybook/main.cpp | 4 +++ storybook/main.qml | 90 ++++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/storybook/main.cpp b/storybook/main.cpp index 99491f59b6..116776c337 100644 --- a/storybook/main.cpp +++ b/storybook/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "cachecleaner.h" #include "directorieswatcher.h" @@ -42,6 +43,9 @@ int main(int argc, char *argv[]) for (const auto& path : additionalImportPaths) engine.addImportPath(path); + engine.rootContext()->setContextProperty( + "pagesFolder", QML_IMPORT_ROOT + QStringLiteral("/pages")); + qmlRegisterType("Storybook", 1, 0, "FigmaDecoratorModel"); qmlRegisterType("Storybook", 1, 0, "FigmaLinksSource"); qmlRegisterType("Storybook", 1, 0, "PagesModel"); diff --git a/storybook/main.qml b/storybook/main.qml index dc854e42da..284b182a68 100644 --- a/storybook/main.qml +++ b/storybook/main.qml @@ -102,59 +102,71 @@ ApplicationWindow { SplitView { anchors.fill: parent - Pane { + ColumnLayout { SplitView.preferredWidth: 270 - ColumnLayout { - width: parent.width - height: parent.height + Pane { + Layout.fillWidth: true + Layout.fillHeight: true - Button { - Layout.fillWidth: true + ColumnLayout { + width: parent.width + height: parent.height - text: "Settings" + Button { + Layout.fillWidth: true - onClicked: settingsPopup.open() - } + text: "Settings" - CheckBox { - id: darkModeCheckBox + onClicked: settingsPopup.open() + } - Layout.fillWidth: true + CheckBox { + id: darkModeCheckBox - text: "Dark mode" + Layout.fillWidth: true - StatusLightTheme { id: lightTheme } - StatusDarkTheme { id: darkTheme } + text: "Dark mode" - Binding { - target: Theme - property: "palette" - value: darkModeCheckBox.checked ? darkTheme : lightTheme + StatusLightTheme { id: lightTheme } + StatusDarkTheme { id: darkTheme } + + 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 { - id: hotReloaderControls + Button { + Layout.fillWidth: true + text: "Open pages directory" - 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 - } + onClicked: Qt.openUrlExternally(Qt.resolvedUrl(pagesFolder)) } }