Warning, /plasma-mobile/mycroft-plasmoid-mobile/plasmoid/contents/ui/BookDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* Copyright 2016 Aditya Mehra <aix.m@outlook.com> 0002 0003 This library is free software; you can redistribute it and/or 0004 modify it under the terms of the GNU Lesser General Public 0005 License as published by the Free Software Foundation; either 0006 version 2.1 of the License, or (at your option) version 3, or any 0007 later version accepted by the membership of KDE e.V. (or its 0008 successor approved by the membership of KDE e.V.), which shall 0009 act as a proxy defined in Section 6 of version 3 of the license. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Lesser General Public License for more details. 0015 0016 You should have received a copy of the GNU Lesser General Public 0017 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 import QtQuick 2.9 0021 import QtQml.Models 2.2 0022 import QtQuick.Controls 2.2 0023 import QtQuick.Layouts 1.3 0024 import org.kde.plasma.core 2.0 as PlasmaCore 0025 import org.kde.plasma.plasmoid 2.0 0026 import org.kde.plasma.components 2.0 as PlasmaComponents 0027 import QtGraphicalEffects 1.0 0028 0029 Rectangle { 0030 id: bookDelegateItem 0031 height: bookContentDelegateItem.height 0032 width: cbwidth 0033 border.width: 1 0034 border.color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) 0035 color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) 0036 layer.enabled: true 0037 layer.effect: DropShadow { 0038 horizontalOffset: 0 0039 verticalOffset: 1 0040 radius: 10 0041 samples: 32 0042 spread: 0.1 0043 color: Qt.rgba(0, 0, 0, 0.3) 0044 } 0045 0046 Item { 0047 id: bookContentDelegateItem 0048 width: parent.width - units.gridUnit * 0.05 0049 height: topRowLayout.height + bookHeaderItemSeparator.height + bookContentInnerItem.height + buttnRow.height 0050 0051 Rectangle { 0052 id: topRowLayout 0053 anchors.top: parent.top 0054 anchors.left: parent.left 0055 anchors.right: parent.right 0056 implicitHeight: bookContentHeader.implicitHeight + units.gridUnit * 0.5 0057 color: theme.linkColor 0058 0059 Text { 0060 id: bookContentHeader 0061 anchors.left: parent.left 0062 anchors.leftMargin: units.gridUnit * 0.25 0063 anchors.verticalCenter: parent.verticalCenter 0064 width: parent.width 0065 wrapMode: Text.Wrap; 0066 font.bold: true; 0067 font.capitalization: Font.SmallCaps 0068 font.pointSize: theme.defaultFont.pointSize 0069 font.letterSpacing: theme.defaultFont.letterSpacing 0070 font.wordSpacing: theme.defaultFont.wordSpacing 0071 font.family: theme.defaultFont.family 0072 renderType: Text.NativeRendering 0073 color: PlasmaCore.ColorScope.textColor 0074 text: i18n(model.booktitle) 0075 0076 MouseArea { 0077 anchors.fill: parent 0078 hoverEnabled: true 0079 0080 onEntered: { 0081 bookContentHeader.color = PlasmaCore.ColorScope.backgroundColor 0082 bookContentHeader.font.underline = true 0083 } 0084 onExited: { 0085 bookContentHeader.color = PlasmaCore.ColorScope.textColor 0086 bookContentHeader.font.underline = false 0087 } 0088 onClicked: { 0089 Qt.openUrlExternally(bookurl) 0090 } 0091 } 0092 } 0093 } 0094 0095 Rectangle { 0096 id: bookHeaderItemSeparator 0097 width: parent.width 0098 anchors.top: topRowLayout.bottom 0099 anchors.topMargin: 1 0100 height: 2 0101 color: theme.linkColor 0102 } 0103 0104 Item { 0105 id: bookContentInnerItem 0106 width: parent.width 0107 height: cbheight / 2.75 0108 anchors.top: bookHeaderItemSeparator.bottom 0109 anchors.topMargin: 1 0110 0111 Image { 0112 id: bookImageItem 0113 anchors.left: parent.left 0114 source: model.bookcover 0115 width: parent.width / 2.75 0116 height: parent.height 0117 } 0118 0119 Item { 0120 id: bookContentAddInfo 0121 anchors.left: bookImageItem.right 0122 anchors.leftMargin: units.gridUnit * 2 0123 anchors.right: parent.right 0124 height: parent.height 0125 0126 Column { 0127 id: additionalInfoColumn 0128 width: parent.width 0129 height: parent.height 0130 spacing: 1.5 0131 0132 PlasmaComponents.Label { 0133 id: bookAuthorLabel 0134 font.capitalization: Font.Capitalize 0135 text: i18n("Author: %1", bookauthor) 0136 } 0137 0138 PlasmaComponents.Label { 0139 id: bookPublisherLabel 0140 font.capitalization: Font.Capitalize 0141 text: i18n("Publisher: %1", bookpublisher) 0142 } 0143 0144 PlasmaComponents.Label { 0145 id: bookYearLabel 0146 font.capitalization: Font.Capitalize 0147 text: i18n("Release Year: %1", bookdate) 0148 } 0149 0150 PlasmaComponents.Label { 0151 id: bookAvailableLabel 0152 font.capitalization: Font.Capitalize 0153 text: i18n("Availability: %1", bookstatus) 0154 } 0155 } 0156 } 0157 } 0158 0159 Row { 0160 id: buttnRow 0161 height: units.gridUnit * 2 0162 anchors.top: bookContentInnerItem.bottom 0163 0164 PlasmaComponents.Button { 0165 id: bookReadOnlineBtn 0166 width: cbwidth / 2 0167 height: units.gridUnit * 2 0168 text: i18n("Read Online") 0169 0170 onClicked: { 0171 Qt.openUrlExternally(bookurl); 0172 } 0173 } 0174 0175 PlasmaComponents.Button { 0176 id: bookDownloadBtn 0177 width: cbwidth / 2 0178 height: units.gridUnit * 2 0179 text: i18n("Download") 0180 0181 onClicked: { 0182 var socketmessage = {}; 0183 socketmessage.type = "recognizer_loop:utterance"; 0184 socketmessage.data = {}; 0185 socketmessage.data.utterances = ["download available book"]; 0186 socket.sendTextMessage(JSON.stringify(socketmessage)); 0187 } 0188 } 0189 } 0190 } 0191 }