Warning, /graphics/peruse/src/app/qml/listcomponents/CategoryTileTall.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 import QtQuick 2.12 0023 import QtQuick.Controls 2.12 as QtControls 0024 import QtQuick.Layouts 1.2 0025 import org.kde.kirigami 2.14 as Kirigami 0026 0027 /** 0028 * @brief A button to select a category to show the categories and books inside. 0029 * 0030 * It distinguishes itself from a book by drawing two rectangles behind the thumbnail, 0031 * to indicate 'multiple books'. 0032 */ 0033 FocusScope { 0034 id: root; 0035 property bool selected: false; 0036 property alias count: categoryCount.text; 0037 property alias title: categoryTitle.text 0038 property QtObject entriesModel; 0039 property int neededHeight: categoryImage.height + categoryTitle.height + Kirigami.Units.largeSpacing; 0040 visible: height > 0; 0041 enabled: visible; 0042 clip: true; 0043 MouseArea { 0044 anchors.fill: parent; 0045 onClicked: { 0046 applicationWindow().pageStack.push(bookshelf, { focus: true, headerText: root.title, model: root.entriesModel }) 0047 } 0048 0049 TextMetrics { 0050 id: categoryTitleSize 0051 font: categoryTitle.font 0052 text: categoryTitle.text 0053 } 0054 0055 ColumnLayout { 0056 spacing: 0; 0057 anchors { 0058 fill: parent; 0059 margins: Kirigami.Units.largeSpacing 0060 } 0061 Item { 0062 id: categoryImage; 0063 Layout.fillHeight: true 0064 Layout.fillWidth: true 0065 Layout.alignment: Qt.AlignHCenter 0066 Rectangle { 0067 anchors.centerIn: coverImage; 0068 width: tileBg.width; 0069 height: tileBg.height; 0070 color: root.selected ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor; 0071 border { 0072 width: 2; 0073 color: root.selected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor; 0074 } 0075 radius: 2; 0076 rotation: 16; 0077 Rectangle { 0078 anchors { 0079 fill: parent; 0080 margins: Kirigami.Units.smallSpacing; 0081 } 0082 color: root.selected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor; 0083 } 0084 } 0085 Rectangle { 0086 anchors.centerIn: coverImage; 0087 width: tileBg.width; 0088 height: tileBg.height; 0089 color: root.selected ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor; 0090 border { 0091 width: 2; 0092 color: root.selected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor; 0093 } 0094 radius: 2; 0095 rotation: 8; 0096 Rectangle { 0097 anchors { 0098 fill: parent; 0099 margins: Kirigami.Units.smallSpacing; 0100 } 0101 color: root.selected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor; 0102 } 0103 } 0104 Rectangle { 0105 id: tileBg; 0106 anchors.centerIn: coverImage; 0107 width: Math.max(coverImage.paintedWidth, Kirigami.Units.iconSizes.large) + Kirigami.Units.smallSpacing * 2; 0108 height: Math.max(coverImage.paintedHeight, Kirigami.Units.iconSizes.large) + Kirigami.Units.smallSpacing * 2; 0109 color: root.selected ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor; 0110 border { 0111 width: 2; 0112 color: root.selected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor; 0113 } 0114 radius: 2; 0115 } 0116 Kirigami.Icon { 0117 id: coverImage; 0118 anchors { 0119 fill: parent; 0120 margins: Kirigami.Units.largeSpacing; 0121 } 0122 source: root.entriesModel ? root.entriesModel.get(0).readProperty("thumbnail") : ""; 0123 placeholder: "application-vnd.oasis.opendocument.text"; 0124 fallback: "folder-documents-symbolic" 0125 } 0126 Rectangle { 0127 anchors { 0128 fill: categoryCount; 0129 margins: -Kirigami.Units.smallSpacing; 0130 } 0131 radius: height / 2; 0132 color: Kirigami.Theme.highlightColor; 0133 } 0134 QtControls.Label { 0135 id: categoryCount; 0136 anchors { 0137 bottom: tileBg.bottom; 0138 right: tileBg.right; 0139 } 0140 height: paintedHeight; 0141 width: paintedWidth; 0142 color: Kirigami.Theme.highlightedTextColor; 0143 } 0144 } 0145 0146 QtControls.Label { 0147 id: categoryTitle; 0148 elide: Text.ElideMiddle; 0149 horizontalAlignment: Text.AlignHCenter 0150 Layout.maximumHeight: categoryTitleSize.boundingRect.height 0151 Layout.minimumHeight: Layout.maximumHeight 0152 Layout.fillWidth: true 0153 Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom 0154 Layout.bottomMargin: Kirigami.Units.smallSpacing 0155 } 0156 } 0157 } 0158 }