diff --git a/qml/AlbumDelegate.qml b/qml/AlbumDelegate.qml index 046b5d6..217a977 100644 --- a/qml/AlbumDelegate.qml +++ b/qml/AlbumDelegate.qml @@ -1,128 +1,167 @@ /* * 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.7 import QtQuick.Controls 2.1 as Controls import org.kde.kquickcontrolsaddons 2.0 as KQA import org.kde.kirigami 2.1 as Kirigami import org.kde.koko 0.1 as Koko Item { id: albumDelegate width: gridView.cellWidth height: gridView.cellHeight + Rectangle { + anchors.fill: image + color: Kirigami.Theme.textColor + opacity: 0.2 + visible: model.itemType != Koko.Types.Folder && model.itemType != Koko.Types.Album + } KQA.QImageItem { id: image anchors.centerIn: parent width: gridView.cellWidth - (Kirigami.Units.smallSpacing * 2 ) height: width smooth: true image: model.thumbnail fillMode: KQA.QImageItem.PreserveAspectCrop } Rectangle { - visible: model.itemType == Koko.Types.Folder || model.itemType == Koko.Types.Album + anchors { + top: image.top + left: image.left + right: image.right + } + visible: textLabel.visible width: image.width height: textLabel.contentHeight + (Kirigami.Units.smallSpacing * 2) color: Kirigami.Theme.viewBackgroundColor - anchors.top: image.top - anchors.left: image.left opacity: 0.8 + } + Controls.Label { + id: textLabel + anchors { + left: image.left + right: image.right + top: image.top + bottom: countRect.visible ? countRect.top : image.bottom + } + visible: model.itemType == Koko.Types.Folder || model.itemType == Koko.Types.Album + verticalAlignment: Text.AlignTop + padding: Kirigami.Units.smallSpacing + elide: Text.ElideRight + maximumLineCount: 4 + wrapMode: Text.WordWrap + color: Kirigami.Theme.textColor + text: model.display + } + + Rectangle { + id: countRect + anchors { + bottom: image.bottom + left: image.left + right: image.right + } + visible: model.fileCount && model.itemType == Koko.Types.Folder || model.itemType == Koko.Types.Album + height: countLabel.contentHeight + (Kirigami.Units.smallSpacing * 2) + color: Kirigami.Theme.viewBackgroundColor + opacity: 0.8 + Controls.Label { - id: textLabel - anchors.fill: parent + id: countLabel padding: Kirigami.Units.smallSpacing + elide: Text.ElideRight + maximumLineCount: 4 wrapMode: Text.WordWrap color: Kirigami.Theme.textColor - text: model.fileCount - ? i18np("%2 \n 1 Image", "%2 \n %1 Images", model.fileCount, model.display) - : model.display + text: i18np("1 Image", "%1 Images", model.fileCount) } } SelectionButton { id: selectionButton visible: ( albumThumbnailMouseArea.containsMouse || iconMouseArea.containsMouse || page.state == "selecting") && !(model.itemType == Koko.Types.Folder || model.itemType == Koko.Types.Album) } SelectionDelegateHighlight { id: selectionHighlight visible: model.selected } MouseArea { id: albumThumbnailMouseArea anchors.fill: parent hoverEnabled: true onPressAndHold: { gridView.model.toggleSelected(model.index) } onClicked: { if (page.state == "selecting" || (mouse.modifiers & Qt.ControlModifier ) && (model.itemType == Koko.Types.Image)) { gridView.model.toggleSelected(model.index) } else { activate(); } } } Keys.onPressed: { switch (event.key) { case Qt.Key_Enter: case Qt.Key_Return: case Qt.Key_Space: activate(); break; default: break; } } function activate( ) { gridView.model.clearSelections() gridView.currentIndex = model.index; switch( model.itemType) { case Koko.Types.Album: { imageListModel.query = imageListModel.queryForIndex( model.sourceIndex) sortedListModel.sourceModel = imageListModel collectionSelected( sortedListModel, model.display) break; } case Koko.Types.Folder: { imageFolderModel.url = model.imageurl sortedListModel.sourceModel = imageFolderModel folderSelected( sortedListModel, model.display) break; } case Koko.Types.Image: { imageSelected( model.sourceIndex) break; } default: { console.log("Unknown") break; } } } }