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 <QQmlApplicationEngine>
#include <QQmlContext>
#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<FigmaDecoratorModel>("Storybook", 1, 0, "FigmaDecoratorModel");
qmlRegisterType<FigmaLinksSource>("Storybook", 1, 0, "FigmaLinksSource");
qmlRegisterType<PagesModelInitialized>("Storybook", 1, 0, "PagesModel");

View File

@ -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))
}
}