Warning, /education/marble/src/apps/marble-maps/CircularButton.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2015 Gábor Péterffy <peterffy95@gmail.com>
0004 //
0005 
0006 import QtQuick 2.3
0007 import QtQuick.Controls 1.3
0008 import QtQuick.Controls.Styles 1.3
0009 import QtQuick.Window 2.2
0010 
0011 Item {
0012     id: root
0013 
0014     readonly property int diameter: Screen.pixelDensity * 9
0015     property alias iconSource: icon.source
0016     property bool highlight: false
0017 
0018     signal clicked()
0019 
0020     Rectangle {
0021         id: button
0022         width: root.diameter
0023         height: root.diameter
0024         radius: root.diameter / 2
0025 
0026         property color idleColor: root.highlight ? palette.highlight : palette.button
0027         property color activeColor: root.highlight ? palette.button : palette.highlight
0028         color: touchHandler.pressed && root.enabled ? activeColor : idleColor
0029 
0030         anchors {
0031             horizontalCenter: root.horizontalCenter
0032             verticalCenter: root.verticalCenter
0033         }
0034 
0035         Text {
0036             id: text
0037             anchors.fill: parent
0038             horizontalAlignment: Text.AlignHCenter
0039             verticalAlignment: Text.AlignVCenter
0040             color: palette.buttonText
0041         }
0042 
0043         Image {
0044             id: icon
0045             anchors {
0046                 horizontalCenter: button.horizontalCenter
0047                 verticalCenter: button.verticalCenter
0048             }
0049             fillMode: Image.PreserveAspectFit
0050             sourceSize.width: 0.6 * root.diameter
0051             opacity: root.enabled ? 1 : 0.5
0052         }
0053 
0054         MouseArea {
0055             id: touchHandler
0056             anchors.fill: parent
0057             onClicked: root.clicked()
0058         }
0059 
0060         border {
0061             width: Screen.pixelDensity * 0.2
0062             color: palette.shadow
0063         }
0064 
0065         SystemPalette{
0066             id: palette
0067             colorGroup: SystemPalette.Active
0068         }
0069     }
0070 
0071     width: diameter
0072     height: diameter
0073 }