diff --git a/qmlUiKirigami/AlbumDelegate.qml b/qmlUiKirigami/AlbumDelegate.qml --- a/qmlUiKirigami/AlbumDelegate.qml +++ b/qmlUiKirigami/AlbumDelegate.qml @@ -33,15 +33,16 @@ Image { id: image - source: model.cover + source: model.cover ? model.cover: model.modelData anchors.centerIn: parent width: gridView.cellWidth - (Kirigami.Units.largeSpacing ) height: gridView.cellHeight - (Kirigami.Units.largeSpacing ) fillMode: Image.PreserveAspectCrop } Kirigami.BasicListItem { + visible: isCollection label: model.fileCount == 1 ? qsTr(" %1 \n 1 Image").arg(model.display) : qsTr(" %1 \n %2 Images").arg(model.display).arg(model.fileCount); reserveSpaceForIcon: false width: image.width @@ -69,16 +70,16 @@ anchors.fill: parent hoverEnabled: true onClicked: { - imageClicked(model.files, model.display) + isCollection ? collectionSelected(model.files, model.display): imageSelected(model.index) gridView.currentIndex = model.index } } Keys.onPressed: { switch (event.key) { case Qt.Key_Enter: case Qt.Key_Return: case Qt.Key_Space: - imageClicked(model.files, model.display) + isCollection ? collectionSelected(model.files, model.display): imageSelected(model.index) gridView.currentIndex = model.index break; default: diff --git a/qmlUiKirigami/AlbumView.qml b/qmlUiKirigami/AlbumView.qml --- a/qmlUiKirigami/AlbumView.qml +++ b/qmlUiKirigami/AlbumView.qml @@ -28,7 +28,10 @@ id: page property alias model: gridView.model - signal imageClicked(var files, string cover) + property bool isCollection + signal collectionSelected(var files, string cover) + signal imageSelected(int currentIndex) + keyboardNavigationEnabled: true focus: true diff --git a/qmlUiKirigami/AutomaticSpacingGrid.qml b/qmlUiKirigami/AutomaticSpacingGrid.qml deleted file mode 100644 --- a/qmlUiKirigami/AutomaticSpacingGrid.qml +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2017 Atul Sharma - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3, or any - * later version accepted by the membership of KDE e.V. (or its - * successor approved by the membership of KDE e.V.), which shall - * act as a proxy defined in Section 6 of version 3 of the license. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - */ - -import QtQuick 2.1 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.1 as Controls -import org.kde.kirigami 2.0 as Kirigami - -GridView { - id: gridView - - property int iconSize: Kirigami.Units.iconSizes.huge - signal imageClicked(int index) - - cellWidth: gridView.width / Math.floor(gridView.width / (iconSize + Kirigami.Units.largeSpacing*2)) - cellHeight: iconSize + Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing*2 - - focus: true - highlight: Rectangle { color: Kirigami.Theme.highlightColor } - - delegate: Item { - width: gridView.cellWidth - height: gridView.cellHeight - Image { - source: model.modelData - anchors.centerIn: parent - width: gridView.cellWidth - Kirigami.Units.smallSpacing - height: gridView.cellHeight - Kirigami.Units.smallSpacing - - fillMode: Image.PreserveAspectCrop - - MouseArea { - anchors.fill: parent - onClicked: { - imageClicked( model.index) - gridView.currentIndex = model.index - } - } - } - Keys.onPressed: { - switch (event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - case Qt.Key_Space: - imageClicked(model.files, model.display) - gridView.currentIndex = model.index - break; - default: - break; - } - } - } -} diff --git a/qmlUiKirigami/OverviewPage.qml b/qmlUiKirigami/OverviewPage.qml deleted file mode 100644 --- a/qmlUiKirigami/OverviewPage.qml +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2017 Atul Sharma - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3, or any - * later version accepted by the membership of KDE e.V. (or its - * successor approved by the membership of KDE e.V.), which shall - * act as a proxy defined in Section 6 of version 3 of the license. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - * - */ - -import QtQuick 2.1 -import QtQuick.Controls 2.1 as Controls -import QtQuick.Layouts 1.3 - -import org.kde.kirigami 2.0 as Kirigami - -Kirigami.ScrollablePage { - id: overview - - property alias model: automaticSpacingGrid.model - signal imageSelected(int currentIndex) - keyboardNavigationEnabled: true - focus: true - - AutomaticSpacingGrid { - id: automaticSpacingGrid - onImageClicked: imageSelected( index) - } -} diff --git a/qmlUiKirigami/main.qml b/qmlUiKirigami/main.qml --- a/qmlUiKirigami/main.qml +++ b/qmlUiKirigami/main.qml @@ -37,9 +37,7 @@ pageStack.initialPage: AlbumView { id: albumView - model: imageFolderModel - title: "Folders" - onImageClicked: pageStack.push(overviewPage, { "model": files, "title": cover}) + onCollectionSelected: pageStack.push(overviewPage, { "model": files, "title": cover}) } globalDrawer: Sidebar { @@ -142,7 +140,8 @@ Component { id: overviewPage - OverviewPage { + AlbumView { + isCollection: false onImageSelected: { currentImage.model = model currentImage.index = currentIndex @@ -163,4 +162,9 @@ imageWidth: root.width } + Component.onCompleted: { + albumView.model = imageFolderModel + albumView.title = "Folders" + albumView.isCollection = true + } }