Warning, /plasma/plasma-mobile/lookandfeel/contents/logout/ActionButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2016 David Edmundson <davidedmundson@kde.org>
0003  *   SPDX-FileCopyrightText: 2022 Seshan Ravikumar <seshan10@me.com>
0004  *
0005  *   SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 import QtQuick 2.8
0009 
0010 import org.kde.plasma.core as PlasmaCore
0011 import org.kde.plasma.components 3.0 as PlasmaComponents3
0012 import org.kde.kirigami 2.20 as Kirigami
0013 
0014 Item {
0015     id: root
0016     property alias text: label.text
0017     property alias iconSource: icon.source
0018     property alias containsMouse: mouseArea.containsMouse
0019     property alias font: label.font
0020     property alias labelRendering: label.renderType
0021     property alias circleOpacity: buttonRect.opacity
0022     property alias circleVisiblity: buttonRect.visible
0023     readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software
0024 
0025     signal clicked
0026 
0027     activeFocusOnTab: true
0028 
0029     property int iconSize: Kirigami.Units.gridUnit
0030 
0031     implicitWidth: Kirigami.Units.gridUnit * 14
0032     implicitHeight: iconSize + Kirigami.Units.smallSpacing + label.implicitHeight
0033 
0034     Rectangle {
0035         id: buttonRect
0036         width: root.width
0037         height: iconSize * 2.2
0038         radius: Kirigami.Units.smallSpacing
0039         color: Kirigami.Theme.backgroundColor
0040         opacity: mouseArea.containsPress ? 1 : 0.6
0041         border {
0042             color: Qt.rgba(255, 255, 255, 0.8)
0043             width: 1
0044         }
0045     }
0046 
0047     Kirigami.Icon {
0048         id: icon
0049         anchors {
0050             verticalCenter: buttonRect.verticalCenter
0051             left: buttonRect.left
0052             leftMargin: Kirigami.Units.mediumSpacing
0053         }
0054         width: iconSize
0055         height: iconSize
0056     }
0057 
0058     PlasmaComponents3.Label {
0059         id: label
0060         font.pointSize: Kirigami.Theme.defaultFont.pointSize + 1
0061         anchors {
0062             centerIn: buttonRect
0063         }
0064         style: softwareRendering ? Text.Outline : Text.Normal
0065         styleColor: softwareRendering ? Kirigami.Theme.backgroundColor : "transparent" //no outline, doesn't matter
0066         horizontalAlignment: Text.AlignHCenter
0067         verticalAlignment: Text.AlignTop
0068         wrapMode: Text.WordWrap
0069         font.underline: root.activeFocus
0070     }
0071 
0072     MouseArea {
0073         id: mouseArea
0074         hoverEnabled: true
0075         onClicked: root.clicked()
0076         anchors.fill: parent
0077     }
0078 
0079     Keys.onEnterPressed: clicked()
0080     Keys.onReturnPressed: clicked()
0081     Keys.onSpacePressed: clicked()
0082 
0083     Accessible.onPressAction: clicked()
0084     Accessible.role: Accessible.Button
0085     Accessible.name: label.text
0086 }