| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2017 Malte Veerman <[email protected]> * |
| 3 |
* * |
| 4 |
* This program is free software; you can redistribute it and/or modify it under * |
| 5 |
* the terms of the GNU General Public License as published by the Free Software * |
| 6 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 7 |
* version. * |
| 8 |
* * |
| 9 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 10 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 11 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 12 |
* * |
| 13 |
* You should have received a copy of the GNU General Public License along with * |
| 14 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 15 |
****************************************************************************************/ |
| 16 |
|
| 17 |
import QtQuick 2.15 |
| 18 |
import QtQuick.Controls 2.15 |
| 19 |
import QtQuick.Layouts 1.15 |
| 20 |
import org.kde.kirigami 2.14 as Kirigami |
| 21 |
|
| 22 |
|
| 23 |
ListView { |
| 24 |
id: root |
| 25 |
|
| 26 |
Rectangle { |
| 27 |
z: -1 |
| 28 |
anchors.fill: parent |
| 29 |
color: palette.window |
| 30 |
radius: Kirigami.Units.smallSpacing |
| 31 |
opacity: 0.9 |
| 32 |
} |
| 33 |
Rectangle { |
| 34 |
z: 1 |
| 35 |
color: "#00000000" |
| 36 |
anchors.fill: parent |
| 37 |
border.color: palette.windowText |
| 38 |
border.width: 1 |
| 39 |
radius: Kirigami.Units.smallSpacing |
| 40 |
opacity: 0.9 |
| 41 |
} |
| 42 |
|
| 43 |
orientation: ListView.Horizontal |
| 44 |
leftMargin: Kirigami.Units.smallSpacing |
| 45 |
rightMargin: Kirigami.Units.smallSpacing |
| 46 |
spacing: Kirigami.Units.smallSpacing |
| 47 |
|
| 48 |
model: AppletModel |
| 49 |
|
| 50 |
ScrollBar.horizontal: ScrollBar { id: scrollBar } |
| 51 |
|
| 52 |
delegate: Rectangle { |
| 53 |
readonly property bool appletEnabled: AppletProxyModel.enabledApplets.indexOf(appletId) != -1 |
| 54 |
|
| 55 |
anchors { |
| 56 |
verticalCenter: parent.verticalCenter |
| 57 |
} |
| 58 |
height: root.height - 2 * Kirigami.Units.smallSpacing |
| 59 |
width: height |
| 60 |
radius: Kirigami.Units.smallSpacing |
| 61 |
color: delegateMouseArea.pressed ? palette.highlight : appletEnabled ? palette.highlight : "transparent" |
| 62 |
border.color: delegateMouseArea.containsMouse ? palette.highlight : "transparent" |
| 63 |
border.width: 2 |
| 64 |
|
| 65 |
ColumnLayout { |
| 66 |
anchors.fill: parent |
| 67 |
|
| 68 |
Image { |
| 69 |
source: icon |
| 70 |
Layout.fillHeight: true |
| 71 |
Layout.fillWidth: true |
| 72 |
Layout.alignment: Qt.AlignTop |
| 73 |
Layout.margins: Kirigami.Units.smallSpacing |
| 74 |
sourceSize.width: 256 |
| 75 |
sourceSize.height: 256 |
| 76 |
fillMode: Image.PreserveAspectFit |
| 77 |
} |
| 78 |
Label { |
| 79 |
Layout.alignment: Qt.AlignBottom |
| 80 |
Layout.margins: Kirigami.Units.smallSpacing |
| 81 |
Layout.fillWidth: true |
| 82 |
color: Kirigami.Theme.textColor |
| 83 |
text: name |
| 84 |
wrapMode: Text.Wrap |
| 85 |
horizontalAlignment: Text.AlignHCenter |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
MouseArea { |
| 90 |
id: delegateMouseArea |
| 91 |
|
| 92 |
anchors.fill: parent |
| 93 |
hoverEnabled: true |
| 94 |
acceptedButtons: Qt.LeftButton |
| 95 |
|
| 96 |
onClicked: AppletProxyModel.setAppletEnabled(appletId, !appletEnabled); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
SystemPalette { |
| 101 |
id: palette |
| 102 |
} |
| 103 |
} |