opaque/ToggleSwitch.qml

33 lines
988 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 {
2020-12-15 01:16:49 +00:00
//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
2020-12-15 01:16:49 +00:00
border.color: checked ? Theme.toggleOnColor :Theme.toggleOffColor
2020-05-19 19:49:52 +00:00
border.width:5
}
groove: Rectangle {
implicitWidth: 50
implicitHeight: 25
radius: 25*0.5
2020-12-15 01:16:49 +00:00
color: checked ? Theme.toggleOnColor :Theme.toggleOffColor
2020-05-19 19:49:52 +00:00
}
}
2020-12-15 01:16:49 +00:00
//onClicked: function() {onToggled()}
2020-05-19 19:49:52 +00:00
}