From a543d8b9bc49b87e831e32c1c71bc352483d88b3 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 12 Mar 2023 06:32:25 -0500 Subject: [PATCH] add proper fileDialog This makes it so the editor page can change the image you are using. --- src/qml/presenter/ImageEditor.qml | 92 +++++++++++++++++++------------ 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/src/qml/presenter/ImageEditor.qml b/src/qml/presenter/ImageEditor.qml index f56b652..65b8a92 100644 --- a/src/qml/presenter/ImageEditor.qml +++ b/src/qml/presenter/ImageEditor.qml @@ -56,42 +56,42 @@ Item { text: "Select Image" icon.name: "fileopen" hoverEnabled: true - onClicked: backgroundType.open() + onClicked: fileDialog.open() } - Controls.Popup { - id: backgroundType - x: backgroundButton.x - y: backgroundButton.y + backgroundButton.height + 20 - modal: true - focus: true - dim: false - background: Rectangle { - Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip - color: Kirigami.Theme.backgroundColor - radius: 10 - border.color: Kirigami.Theme.activeBackgroundColor - border.width: 2 - } - closePolicy: Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutsideParent - ColumnLayout { - anchors.fill: parent - Controls.ToolButton { - Layout.fillHeight: true - Layout.fillWidth: true - text: "Image" - icon.name: "emblem-images-symbolic" - onClicked: imageFileDialog.open() & backgroundType.close() - } - Controls.ToolButton { - Layout.fillWidth: true - Layout.fillHeight: true - text: "Image" - icon.name: "folder-pictures-symbolic" - onClicked: imageFileDialog.open() & backgroundType.close() - } - } - } + /* Controls.Popup { */ + /* id: backgroundType */ + /* x: backgroundButton.x */ + /* y: backgroundButton.y + backgroundButton.height + 20 */ + /* modal: true */ + /* focus: true */ + /* dim: false */ + /* background: Rectangle { */ + /* Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip */ + /* color: Kirigami.Theme.backgroundColor */ + /* radius: 10 */ + /* border.color: Kirigami.Theme.activeBackgroundColor */ + /* border.width: 2 */ + /* } */ + /* closePolicy: Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutsideParent */ + /* ColumnLayout { */ + /* anchors.fill: parent */ + /* Controls.ToolButton { */ + /* Layout.fillHeight: true */ + /* Layout.fillWidth: true */ + /* text: "Image" */ + /* icon.name: "emblem-images-symbolic" */ + /* onClicked: imageFileDialog.open() & backgroundType.close() */ + /* } */ + /* Controls.ToolButton { */ + /* Layout.fillWidth: true */ + /* Layout.fillHeight: true */ + /* text: "Image" */ + /* icon.name: "folder-pictures-symbolic" */ + /* onClicked: imageFileDialog.open() & backgroundType.close() */ + /* } */ + /* } */ + /* } */ } } @@ -134,7 +134,21 @@ Item { cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor } } + } + } + FileDialog { + id: fileDialog + title: "Please choose a background" + folder: shortcuts.home + selectMultiple: false + nameFilters: ["Image files (*.jpg *.jpeg *.png *.JPG *.JPEG *.PNG *.webp *.gif)"] + onAccepted: { + updateImage(fileDialog.fileUrls[0]); + console.log("image background = " + fileDialog.fileUrls[0]); + } + onRejected: { + console.log("Canceled") } } @@ -146,8 +160,8 @@ Item { function updateTitle(text) { changeTitle(text, false); - imagesqlmodel.updateTitle(image.id, text); - showPassiveNotification(image.title); + imageProxyModel.imageModel.updateTitle(root.image.id, text); + showPassiveNotification(root.image.title); } function changeTitle(text, updateBox) { @@ -155,4 +169,10 @@ Item { imageTitleField.text = text; image.title = text; } + + function updateImage(image) { + imageProxyModel.imageModel.updateFilePath(root.image.id, image); + root.image.filePath = image; + console.log(image); + } }