aerothemeplasma/plasma/plasmoids/io.gitgud.wackyideas.SevenStart/contents/ui/ListDelegate.qml

106 lines
2.9 KiB
QML
Raw Permalink Normal View History

2023-09-27 17:50:10 +00:00
/*
* Copyright 2015 Kai Uwe Broulik <kde@privat.broulik.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
2024-08-09 01:20:25 +00:00
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami as Kirigami
2023-09-27 17:50:10 +00:00
Item {
id: item
signal clicked
signal iconClicked
property alias text: label.text
// property alias subText: sublabel.text
property alias icon: icon.source
// "enabled" also affects all children
property bool interactive: true
property bool interactiveIcon: false
property bool showIcon: false
2024-08-09 01:20:25 +00:00
//property alias usesPlasmaTheme: icon.usesPlasmaTheme
2023-09-27 17:50:10 +00:00
property alias containsMouse: area.containsMouse
property alias size: icon.height
property Item highlight
Layout.fillWidth: true
2024-08-09 01:20:25 +00:00
height: size + 2 * Kirigami.Units.smallSpacing
2023-09-27 17:50:10 +00:00
width: height
MouseArea {
id: area
anchors.fill: parent
enabled: item.interactive
hoverEnabled: true
onClicked: item.clicked()
onContainsMouseChanged: {
if (!highlight) {
return
}
if (containsMouse) {
highlight.parent = item
highlight.width = item.width
highlight.height = item.height
}
highlight.visible = containsMouse
}
}
2024-08-09 01:20:25 +00:00
Kirigami.Icon {
2023-09-27 17:50:10 +00:00
id: icon
width: icon.height
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
2024-08-09 01:20:25 +00:00
anchors.leftMargin: Kirigami.Units.smallSpacing * 2
//usesPlasmaTheme: true
2023-09-27 17:50:10 +00:00
visible: showIcon
MouseArea {
anchors.fill: parent
visible: item.interactiveIcon
cursorShape: Qt.PointingHandCursor
onClicked: item.iconClicked()
}
}
PlasmaComponents.Label {
id: label
wrapMode: Text.NoWrap
elide: Text.ElideRight
anchors.left: showIcon ? icon.right : parent.left
2024-08-09 01:20:25 +00:00
anchors.leftMargin: Kirigami.Units.smallSpacing * 2
2023-09-27 17:50:10 +00:00
anchors.verticalCenter: icon.verticalCenter
2024-08-09 01:20:25 +00:00
style: Text.Sunken
styleColor: "transparent"
2023-09-27 17:50:10 +00:00
}
}