1/* 2 * SPDX-FileCopyrightText: 2017 Sebastian Gottfried <sebastian.gottfried@posteo.de> 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7import QtQuick 2.9 8import QtQuick.Layouts 1.3 9import ktouch 1.0 10import '../common' 11 12Item { 13 id: root 14 property Lesson lesson 15 property bool selected 16 property bool editable: false 17 property alias background: background 18 19 signal clicked 20 signal doubleClicked 21 signal deleteButtonClicked 22 signal editButtonClicked 23 signal statButtonClicked 24 25 clip: true 26 27 KColorScheme { 28 id: selectionColorScheme 29 colorGroup: KColorScheme.Active 30 colorSet: KColorScheme.Selection 31 } 32 33 Rectangle { 34 id: background 35 anchors.fill: parent 36 color: selected? Qt.tint(selectionColorScheme.normalBackground, "#a0ffffff"): "#ffffff" 37 } 38 39 MouseArea { 40 anchors.fill: parent 41 onClicked: { 42 root.clicked() 43 } 44 onDoubleClicked: { 45 root.doubleClicked() 46 } 47 } 48 49 GridLayout { 50 id: content 51 anchors.fill: parent 52 anchors.margins: Units.largeSpacing 53 54 Label { 55 id: titleLabel 56 Layout.column: 0 57 Layout.row: 0 58 Layout.fillWidth: true 59 Layout.preferredHeight: buttonRow.implicitHeight 60 text: lesson? lesson.title: "" 61 color: "#000000" 62 font.bold: true 63 elide: Label.ElideRight 64 verticalAlignment: Qt.AlignVCenter 65 66 ToolTip { 67 parent: titleLabel 68 text: titleLabel.text 69 visible: titleMouseArea.containsMouse 70 } 71 72 MouseArea { 73 id: titleMouseArea 74 anchors.fill: parent 75 acceptedButtons: Qt.NoButton 76 hoverEnabled: titleLabel.truncated 77 } 78 } 79 80 Row { 81 id: buttonRow 82 Layout.column: 1 83 Layout.row: 0 84 visible: root.selected 85 86 IconToolButton { 87 id: editButton 88 visible: root.editable 89 iconName: 'edit-entry' 90 color: "#000000" 91 backgroundColor: "#c0c0c0c0" 92 onClicked: { 93 root.editButtonClicked(); 94 } 95 } 96 97 IconToolButton { 98 id: deleteButton 99 visible: root.editable 100 iconName: 'edit-delete' 101 color: "#000000" 102 backgroundColor: "#c0c0c0c0" 103 onClicked: { 104 root.deleteButtonClicked(); 105 } 106 } 107 108 IconToolButton { 109 iconName: 'view-statistics' 110 color: "#000000" 111 backgroundColor: "#c0c0c0c0" 112 onClicked: { 113 root.statButtonClicked(); 114 } 115 } 116 } 117 118 Item { 119 Layout.column: 0 120 Layout.row: 1 121 Layout.columnSpan: 2 122 Layout.fillHeight: true 123 Layout.fillWidth: true 124 clip: true 125 126 Label { 127 id: textLabel 128 anchors.fill: parent 129 text: lesson? lesson.text: "" 130 color: "#000000" 131 font.family: 'monospace' 132 lineHeight: 1.5 133 scale: Math.min(1, width / implicitWidth) 134 transformOrigin: Item.TopLeft 135 } 136 137 Rectangle { 138 anchors.fill: parent 139 gradient: Gradient { 140 GradientStop { position: 0.0; color: "#00000000" } 141 GradientStop { position: 0.8; color: Qt.rgba(background.color.r, background.color.g, background.color.b, 0) } 142 GradientStop { position: 1.0; color: background.color } 143 } 144 } 145 } 146 } 147} 148 149