diff --git a/qmlUiKirigami/AlbumView.qml b/qmlUiKirigami/AlbumView.qml --- a/qmlUiKirigami/AlbumView.qml +++ b/qmlUiKirigami/AlbumView.qml @@ -130,7 +130,7 @@ onImageSelected: { currentImage.model = model.sourceModel currentImage.index = currentIndex - imageViewer.state = "open"; + applicationWindow().pageStack.layers.push(imageViewerComponent); } } diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -30,7 +30,8 @@ Kirigami.Page { id: root - + + title: i18n("Details") property alias sourceModel: imagesListModel.sourceModel property int indexValue @@ -43,135 +44,66 @@ KQA.MimeDatabase { id: mimeDB } - - Kirigami.Action { - id: backAction - iconName: "view-close" - tooltip: i18n("Close Image") - onTriggered: root.state = "closed" - } - - Kirigami.Action { - id: shareAction - iconName: "document-share" - tooltip: i18n("Share Image") - onTriggered: { - shareDialog.sheetOpen = true - shareDialog.inputData = { - "urls": [ listView.currentItem.currentImageSource.toString() ], - "mimeType": mimeDB.mimeTypeForUrl( listView.currentItem.currentImageSource).name - } - } - } - - Kirigami.Action { - id: editAction - iconName: "editimage" - tooltip: i18n("Edit Image") - } - - mainAction: root.state == "open" ? shareAction : null - leftAction: root.state == "open" ? backAction : null - rightAction: root.state == "open" ? editAction : null - states: [ - State { - name: "open" - PropertyChanges { - target: root - visible: true - } - PropertyChanges { - target: root - opacity: 1 - } - PropertyChanges { - target: root - focus: true - } - PropertyChanges { - target: listView - focus: true - } - PropertyChanges { - target: applicationWindow() - visibility: Window.Windowed - } - }, - State { - name: "closed" - PropertyChanges { - target: root - opacity: 0 - } - PropertyChanges { - target: root - visible: false - } - PropertyChanges { - target: shareDialog - sheetOpen: false - } - }, - State { - name: "fullscreen" - PropertyChanges { - target: root - focus: true - } - PropertyChanges { - target: listView - focus: true - } - PropertyChanges { - target: applicationWindow() - visibility: Window.FullScreen - } + actions { + left: Kirigami.Action { + id: backAction + iconName: "view-close" + tooltip: i18n("Close Image") + onTriggered: root.close(); } - ] - - transitions: [ - Transition { - from: "*" - to: "closed" - SequentialAnimation { - OpacityAnimator { - target: root - duration: Kirigami.Units.longDuration - easing.type: Easing.InQuad - } - PropertyAnimation { - target: root - property: "visible" - duration: Kirigami.Units.longDuration - } - ScriptAction { - script: applicationWindow().pageStack.forceActiveFocus(); + main: Kirigami.Action { + id: shareAction + iconName: "document-share" + tooltip: i18n("Share Image") + onTriggered: { + shareDialog.open(); + shareDialog.inputData = { + "urls": [ listView.currentItem.currentImageSource.toString() ], + "mimeType": mimeDB.mimeTypeForUrl( listView.currentItem.currentImageSource).name } } - }, - Transition { - from: "closed" - to: "open" - OpacityAnimator { - target: root - duration: Kirigami.Units.longDuration - easing.type: Easing.OutQuad - } } - ] + right: Kirigami.Action { + id: editAction + iconName: "editimage" + tooltip: i18n("Edit Image") + } + } + + //FIXME: HACK + property bool wasDrawerOpen + Component.onCompleted: { + applicationWindow().controlsVisible = false; + listView.forceActiveFocus(); + applicationWindow().header.visible = false; + applicationWindow().footer.visible = false; + wasDrawerOpen = applicationWindow().globalDrawer.visible; + applicationWindow().globalDrawer.visible = false; + applicationWindow().globalDrawer.enabled = false; + } + function close() { + applicationWindow().controlsVisible = true; + applicationWindow().header.visible = true; + applicationWindow().footer.visible = true; + applicationWindow().globalDrawer.visible = wasDrawerOpen; + applicationWindow().globalDrawer.enabled = true; + applicationWindow().visibility = Window.Windowed; + applicationWindow().pageStack.layers.pop(); + } + background: Rectangle { color: "black" } Keys.onPressed: { switch(event.key) { case Qt.Key_Escape: - root.state = "closed" + root.close(); break; case Qt.Key_F: - root.state = root.state == "open" ? "fullscreen" : "open" + applicationWindow().visibility = applicationWindow().visibility == Window.FullScreen ? Window.Windowed : Window.FullScreen break; default: break; @@ -192,20 +124,11 @@ } currentIndex: model.proxyIndex( indexValue) - Timer { - id: timer - interval: 2000 - onTriggered: footerList.opacity = 0 - } - onCurrentIndexChanged: { currentImage.index = model.sourceIndex( currentIndex) listView.positionViewAtIndex(currentIndex, ListView.Beginning) - if( footerList.visible == true) { - footerList.opacity = 1.0 - } - timer.restart() - shareDialog.sheetOpen = false + + shareDialog.close(); } delegate: Flickable { @@ -308,9 +231,19 @@ autoTransform: true sourceSize.width: imageWidth * 2 sourceSize.height: imageHeight * 2 + Timer { + id: doubleClickTimer + interval: 150 + onTriggered: applicationWindow().controlsVisible = !applicationWindow().controlsVisible + } MouseArea { anchors.fill: parent + onClicked: { + doubleClickTimer.restart(); + } onDoubleClicked: { + doubleClickTimer.running = false; + applicationWindow().controlsVisible = false; if (flick.interactive) { zoomAnim.x = 0; zoomAnim.y = 0; @@ -355,54 +288,11 @@ } } - PathView { - id: footerList - visible: root.state == "open" ? true : false - height: Kirigami.Units.gridUnit * 4 - model: listView.model - currentIndex: listView.currentIndex - pathItemCount: applicationWindow().width / (Kirigami.Units.gridUnit * 5) - interactive: false - - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlightRangeMode: PathView.StrictlyEnforceRange - - Behavior on opacity { OpacityAnimator { duration: 500}} - - path: Path { - startX: 0 - startY: applicationWindow().height - (Kirigami.Units.gridUnit * 5) - PathAttribute { name: "iconScale"; value: 0.5 } - PathLine { - x: applicationWindow().width / 2 - y: applicationWindow().height - (Kirigami.Units.gridUnit * 5) - } - PathAttribute { name: "iconScale"; value: 1.5 } - PathLine { - x: applicationWindow().width - y: applicationWindow().height - (Kirigami.Units.gridUnit * 5) - } - PathAttribute { name: "iconScale"; value: 0.5 } - } - - delegate: Item { - scale: PathView.iconScale - height: Kirigami.Units.gridUnit * 4 - width: height - KQA.QImageItem { - height: Kirigami.Units.gridUnit * 3.8 - width: height - anchors.centerIn: parent - image: model.thumbnail - } - } - } - ShareDialog { id: shareDialog + x: (root.width - width) / 2 + y: root.height - height - Kirigami.Units.gridUnit * 3 inputData: { urls: [] } - sheetOpen: false onFinished: { if (error==0 && output.url !== "") { console.assert(output.url !== undefined); diff --git a/qmlUiKirigami/Main.qml b/qmlUiKirigami/Main.qml --- a/qmlUiKirigami/Main.qml +++ b/qmlUiKirigami/Main.qml @@ -187,20 +187,19 @@ Koko.ImageListModel { id: imageListModel } - - ImageViewer { - id: imageViewer - //go on top of the overlay drawer - //HACK on the parent and z to go on top of the handle as well - z: 1999999 - parent: root.overlay.parent - width: overlay.width - height: overlay.height - indexValue: currentImage.index - sourceModel: currentImage.model - imageWidth: root.width - imageHeight: root.height - state: imagePathArgument == "" ? "closed" : "open" + Component { + id: imageViewerComponent + ImageViewer { + id: imageViewer + indexValue: currentImage.index + sourceModel: currentImage.model + imageWidth: root.width + imageHeight: root.height + } + } + Component.onCompleted: { + if (imagePathArgument != "") { + pageStack.layers.push(imageViewerComponent); + } } - } diff --git a/qmlUiKirigami/ShareDialog.qml b/qmlUiKirigami/ShareDialog.qml --- a/qmlUiKirigami/ShareDialog.qml +++ b/qmlUiKirigami/ShareDialog.qml @@ -19,34 +19,36 @@ import QtQuick 2.7 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.1 as Controls +import QtQuick.Controls 2.0 as Controls import org.kde.purpose 1.0 as Purpose import org.kde.kirigami 2.1 as Kirigami -Kirigami.OverlaySheet -{ +Controls.Popup { id: window + modal: true + focus: true property alias inputData: view.inputData property bool running: false signal finished(var output, int error, string message) + width: Kirigami.Units.gridUnit * 25 + height: Kirigami.Units.gridUnit * 28 Controls.BusyIndicator { visible: window.running anchors.fill: parent } - - contentItem: ColumnLayout { - height: Kirigami.Units.gridUnit * 16 - - Kirigami.Heading { - text: window.inputData.mimeType ? i18n("Shares for '%1'", window.inputData.mimeType) : "" - } + + Rectangle { + anchors.fill: parent + color: Kirigami.Theme.viewBackgroundColor Purpose.AlternativesView { id: view - Layout.fillWidth: true - Layout.fillHeight: true + anchors.fill:parent + clip: true pluginType: "Export" - + header: Kirigami.Heading { + text: window.inputData.mimeType ? i18n("Shares for '%1'", window.inputData.mimeType) : "" + } delegate: Kirigami.BasicListItem { label: model.display icon: "arrow-right"