Warning, /plasma/plasma-sdk/themeexplorer/package/contents/ui/fakecontrols/CheckBox.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.3
0008 import Qt5Compat.GraphicalEffects
0009 import QtQuick.Controls 2.15
0010 import QtQuick.Layouts 1.1
0011 import org.kde.kirigami 2.20 as Kirigami
0012 
0013 MouseArea {
0014     id: buttonMouse
0015     hoverEnabled: true
0016     implicitWidth: parent.width/1.2
0017     implicitHeight: layout.height 
0018 
0019     property bool checked: true
0020     //in real controls this is done by the color scope
0021     property bool complementary: false
0022 
0023     onClicked: {
0024         buttonMouse.focus = true
0025         checked = !checked
0026     }
0027     RowLayout {
0028         id: layout
0029         height: Kirigami.Units.gridUnit * 1.6
0030         Rectangle {
0031             id: button
0032             radius: Kirigami.Units.smallSpacing/2
0033             color: buttonMouse.pressed ? Qt.darker(buttonBackgroundColor, 1.5) : buttonBackgroundColor
0034             height: parent.height / 1.2
0035             width: height
0036             Rectangle {
0037                 anchors.fill: parent
0038                 radius: Kirigami.Units.smallSpacing/2
0039                 visible: buttonMouse.containsMouse || buttonMouse.focus
0040                 color: "transparent"
0041                 border {
0042                     color: {
0043                         if (buttonMouse.checked) {
0044                             return buttonMouse.complementary ? complementaryHoverColor : highlightColor;
0045                         } else if (buttonMouse.containsMouse) {
0046                             return buttonHoverColor;
0047                         } else {
0048                            return buttonFocusColor;
0049                         }
0050                     }
0051                 }
0052             }
0053             Rectangle {
0054                 anchors {
0055                     fill: parent
0056                     margins: Kirigami.Units.smallSpacing
0057                 }
0058                 radius: Kirigami.Units.smallSpacing/2
0059                 visible: buttonMouse.checked
0060                 color: buttonMouse.complementary ? complementaryHoverColor : highlightColor
0061             }
0062         }
0063         DropShadow {
0064             anchors.fill: button
0065             horizontalOffset: 0
0066             verticalOffset: Kirigami.Units.smallSpacing/4
0067             radius: Kirigami.Units.smallSpacing
0068             samples: 16
0069             color: buttonMouse.pressed ? Qt.rgba(0, 0, 0, 0) : Qt.rgba(0, 0, 0, 0.5)
0070             source: button
0071         }
0072         Label {
0073             anchors.centerIn: parent
0074             text: i18n("Checkbox")
0075             color: buttonMouse.complementary ? complementaryTextColor : textColor
0076         }
0077     }
0078 }