Plasma-framework

ButtonBackground.qml
1/*
2 * SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6pragma ComponentBehavior: Bound
7
8import QtQuick
9import QtQuick.Templates as T
10import org.kde.kirigami as Kirigami
11
12Item {
13 id: root
14
15 required property T.Button button
16
17 // These should be used as the padding for the parent control
18 property real topMargin: loader.item.topMargin
19 property real leftMargin: loader.item.leftMargin
20 property real rightMargin: loader.item.rightMargin
21 property real bottomMargin: loader.item.bottomMargin
22
23 implicitWidth: Kirigami.Units.gridUnit + root.leftMargin + root.rightMargin
24 implicitHeight: Kirigami.Units.gridUnit + root.topMargin + root.bottomMargin
25
26 opacity: enabled ? 1 : 0.5
27 layer.enabled: opacity < 1
28
29 Loader {
30 id: loader
31 anchors.fill: parent
32 sourceComponent: root.button.flat ? flatButtonBackground : raisedButtonBackground
33 }
34
35 Component {
36 id: flatButtonBackground
37 FlatButtonBackground {
38 anchors.fill: parent
39 hovered: root.button.hovered
40 pressed: root.button.down
41 checked: root.button.checked
42 focused: root.button.visualFocus
43 }
44 }
45
46 Component {
47 id: raisedButtonBackground
48 RaisedButtonBackground {
49 anchors.fill: parent
50 hovered: root.button.hovered
51 pressed: root.button.down
52 checked: root.button.checked
53 focused: root.button.visualFocus
54 }
55 }
56}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.