diff --git a/src/qml/ImagesView.qml b/src/qml/ImagesView.qml --- a/src/qml/ImagesView.qml +++ b/src/qml/ImagesView.qml @@ -1,29 +1,41 @@ import QtQml 2.2 import QtQuick 2.0 import QtQuick.Controls 1.2 -import QtQuick.Controls 2.0 as QQC2 -import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.5 as QQC2 +import QtQuick.Layouts 1.2 import QtQuick.Dialogs 1.2 import org.kde.kamoso 3.0 import org.kde.purpose 1.0 -import org.kde.kirigami 2.0 as Kirigami +import org.kde.kirigami 2.4 as Kirigami StackView { id: stack property string mimeFilter property alias nameFilter: view.nameFilter clip: true + function pathOrUrl(url) { + var urlstr = url.toString(); + if (urlstr.indexOf("file://") == 0) { + return urlstr.substring(7); + } + return url; + } + Component { id: headerComponent + ColumnLayout { spacing: 0 - Layout.maximumHeight: Kirigami.Units.gridUnit * 10 + Kirigami.Heading { + Layout.fillWidth: true + Layout.leftMargin: Kirigami.Units.smallSpacing + Layout.bottomMargin: Kirigami.Units.largeSpacing + level: 1 - color: Kirigami.Theme.textColor + text: i18n("Share") elide: Text.ElideRight - text: i18n("Share...") } Repeater { @@ -41,7 +53,7 @@ path: modelData } - Kirigami.Label { + QQC2.Label { Layout.fillWidth: true text: modelData.substring(modelData.lastIndexOf('/')+1); elide: Text.ElideLeft @@ -55,7 +67,6 @@ Component { id: chooseShareComponent ColumnLayout { - id: menu property var selection spacing: 0 @@ -89,12 +100,9 @@ }) } - Kirigami.Separator { - Layout.fillWidth: true - } - Kirigami.BasicListItem { label: i18n("Back") + icon: "go-previous" onClicked: stack.pop() } } @@ -115,7 +123,7 @@ Layout.fillHeight: true Layout.fillWidth: true } - TextField { + QQC2.TextField { id: field Layout.fillWidth: true readOnly: true @@ -129,7 +137,7 @@ Layout.fillHeight: true Layout.fillWidth: true } - Kirigami.Label { + QQC2.Label { Layout.fillHeight: true Layout.alignment: Qt.AlignCenter text: i18n("Media now exported") @@ -146,70 +154,141 @@ } } - initialItem: Item { + Component { + id: configureComponent + ColumnLayout { - anchors.fill: parent + property var selection spacing: 0 - Label { - font.bold: true - text: i18n("Save to...") - } - function pathOrUrl(url) { - var urlstr = url.toString(); - if (urlstr.indexOf("file://") == 0) { - return urlstr.substring(7); - } - return url; + Kirigami.Heading { + Layout.fillWidth: true + Layout.leftMargin: Kirigami.Units.smallSpacing + Layout.bottomMargin: Kirigami.Units.largeSpacing + + level: 1 + text: i18n("Configure Kamoso") + elide: Text.ElideRight } - Button { - Layout.fillWidth: true + Kirigami.FormLayout { - iconName: "folder-pictures" - text: parent.pathOrUrl(config.saveUrl) - onClicked: { - dirSelector.visible = true + Item { + Kirigami.FormData.isSection: true + Kirigami.FormData.label: i18n("Save Locations") } - FileDialog { - id: dirSelector - title: i18n("Select a directory where to save your pictures") - folder: config.saveUrl - selectMultiple: false - selectExisting: true - selectFolder: true - - onFileUrlChanged: { - config.saveUrl = dirSelector.fileUrl - config.save() + // Pictures location + RowLayout { + Layout.fillWidth: true + + Kirigami.FormData.label: i18n("Pictures:") + + QQC2.TextField { + readOnly: true + Layout.fillWidth: true + text: stack.pathOrUrl(config.saveUrl) } - } - } - Button { - Layout.fillWidth: true - iconName: "folder-videos" - text: parent.pathOrUrl(config.saveVideos) - onClicked: { - videoDirSelector.visible = true + QQC2.Button { + hoverEnabled: true + + icon.name: "document-open" + + QQC2.ToolTip { + visible: parent.hovered + text: i18n("Choose the folder where Kamoso will save pictures") + + // TODO: Remove this once Kamoso can depend on + // Frameworks 5.55, where this is fixed upstream + z: 999 + } + + onClicked: { + dirSelector.visible = true + } + + FileDialog { + id: dirSelector + title: i18n("Choose the folder where Kamoso will save pictures") + folder: config.saveUrl + selectMultiple: false + selectExisting: true + selectFolder: true + + onFileUrlChanged: { + config.saveUrl = dirSelector.fileUrl + config.save() + } + } + } } - FileDialog { - id: videoDirSelector - title: i18n("Select a directory where to save your videos") - folder: config.saveVideos - selectMultiple: false - selectExisting: true - selectFolder: true - - onFileUrlChanged: { - config.saveVideos = videoDirSelector.fileUrl - config.save() + // Videos location + RowLayout { + Layout.fillWidth: true + + Kirigami.FormData.label: i18n("Videos:") + + QQC2.TextField { + readOnly: true + Layout.fillWidth: true + text: stack.pathOrUrl(config.saveVideos) + } + + QQC2.Button { + hoverEnabled: true + + icon.name: "document-open" + + QQC2.ToolTip { + visible: parent.hovered + text: i18n("Choose the folder where Kamoso will save videos") + + // TODO: Remove this once Kamoso can depend on + // Frameworks 5.55, where this is fixed upstream + z: 999 + } + + onClicked: { + videoDirSelector.visible = true + } + } + + FileDialog { + id: videoDirSelector + title: i18n("Choose the folder where Kamoso will save videos") + folder: config.saveVideos + selectMultiple: false + selectExisting: true + selectFolder: true + + onFileUrlChanged: { + config.saveVideos = videoDirSelector.fileUrl + config.save() + } } } } + // Otherwise the back button might not always be right on the bottom + Item { + Layout.fillHeight: true + } + + Kirigami.BasicListItem { + label: i18n("Back") + icon: "go-previous" + onClicked: stack.pop() + } + } + } + + initialItem: Item { + ColumnLayout { + anchors.fill: parent + spacing: 0 + DirectoryView { id: view @@ -219,49 +298,62 @@ Layout.fillHeight: true mimeFilter: [stack.mimeFilter] } - Kirigami.Separator { + + Kirigami.Heading { Layout.fillWidth: true - } + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter - Kirigami.BasicListItem { - icon: "user-trash" - label: i18n("Move to trash... (%1)", view.selection.length) - visible: view.selection.length>0 - onClicked: { - trashDialog.visible = true - } - readonly property var p0: Dialog { - id: trashDialog - title: i18n("Move to trash...") + visible: view.count == 0 - Label { - text: i18np("Are you sure you want to remove %1 file?", "Are you sure you want to remove %1 files?", view.selection.length) - } + level: 2 + text: xi18nc("@info", "There are no images in %1", stack.pathOrUrl(config.saveUrl)) + opacity: 0.6 + } - standardButtons: StandardButton.Ok | StandardButton.Cancel - onAccepted: { - console.log("Trash, FFS!!", view.selection); - webcam.trashFiles(view.selection); - } - onVisibleChanged: if (!visible) { - view.selection = [] - } - } + Kirigami.Separator { + Layout.fillWidth: true } + Kirigami.BasicListItem { + enabled: view.selection.length > 0 + icon: "document-share" - label: i18n("Share... (%1)", view.selection.length) + label: enabled? i18np("Share %1 Item...", "Share %1 Items...", view.selection.length) : i18n("Share Item...") onClicked: stack.push({ item: chooseShareComponent, properties: { selection: view.selection } }) - visible: view.selection.length>0 } + + Kirigami.BasicListItem { + enabled: view.selection.length > 0 + + icon: "user-trash" + label: enabled ? i18np("Move %1 Item to Trash", "Move %1 Items to Trash", view.selection.length) : i18n("Move Item to Trash") + + onClicked: { + console.log("Trash, FFS!!", view.selection); + webcam.trashFiles(view.selection); + } + } + Kirigami.BasicListItem { icon: "folder-open" label: i18n("Open Pictures Folder") + onClicked: Qt.openUrlExternally(config.saveUrl) } + + Kirigami.BasicListItem { + icon: "configure" + label: i18n("Configure Kamoso...") + onClicked: stack.push({ + item: configureComponent, + properties: { selection: view.selection } + }) + } } } }