Warning, /utilities/kweather/src/qml/components/ListDelegate.qml is written in an unsupported language. File is not indexed.

0001 // Copyright 2022 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls
0006 import QtQuick.Layouts
0007 
0008 import org.kde.kirigami as Kirigami
0009 
0010 Control {
0011     id: root
0012     
0013     property bool showSeparator: false
0014     
0015     signal clicked()
0016     signal rightClicked()
0017     signal released()
0018     signal pressAndHold()
0019     
0020     property alias mouseArea: mouseArea
0021     
0022     leftPadding: Kirigami.Units.largeSpacing
0023     topPadding: Kirigami.Units.largeSpacing
0024     bottomPadding: Kirigami.Units.largeSpacing
0025     rightPadding: Kirigami.Units.largeSpacing
0026     
0027     hoverEnabled: true
0028     background: Rectangle {
0029         color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, mouseArea.pressed ? 0.2 : (!Kirigami.Settings.tabletMode && hoverHandler.hovered) ? 0.1 : 0)
0030         
0031         HoverHandler {
0032             id: hoverHandler
0033         }
0034         
0035         Kirigami.Separator {
0036             anchors.bottom: parent.bottom
0037             anchors.left: parent.left
0038             anchors.right: parent.right
0039             anchors.leftMargin: root.leftPadding
0040             anchors.rightMargin: root.rightPadding
0041             visible: root.showSeparator
0042             opacity: 0.5
0043         }
0044     }
0045     
0046     MouseArea {
0047         id: mouseArea
0048         anchors.fill: parent
0049         acceptedButtons: Qt.LeftButton | Qt.RightButton
0050         
0051         onPressAndHold: root.pressAndHold()
0052         onReleased: root.released()
0053         onClicked: mouse => {
0054             if (mouse.button === Qt.RightButton) {
0055                 root.rightClicked();
0056             } else if (mouse.button === Qt.LeftButton) {
0057                 root.clicked();
0058             }
0059         }
0060     }
0061 }