opaque/ToggleSwitch.qml

33 lines
984 B
QML
Raw Normal View History

2020-05-19 19:49:52 +00:00
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick 2.12
2020-05-19 20:25:56 +00:00
import "theme"
2020-05-19 19:49:52 +00:00
// ToggleSwtch implements a stylized toggle switch. It requires the user create a function called onToggled to
// perform any additional operations needed to define the behavior of the toggle switch
Switch {
property bool isToggled
property var onToggled: function () { console.log("In Superclass") };
checked: isToggled
2020-05-19 19:49:52 +00:00
style: SwitchStyle {
handle: Rectangle {
implicitWidth: 25
implicitHeight: 25
radius: width*0.5
color: Theme.toggleColor
border.color: isToggled ? Theme.toggleOnColor :Theme.toggleOffColor
border.width:5
}
groove: Rectangle {
implicitWidth: 50
implicitHeight: 25
radius: 25*0.5
color: isToggled ? Theme.toggleOnColor :Theme.toggleOffColor
}
}
onClicked: function() {onToggled()}
2020-05-19 19:49:52 +00:00
}