2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-03-07 07:57:56 +03:00
|
|
|
//
|
2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-02-10 18:52:42 +03:00
|
|
|
import QtQuick 2.5
|
2021-02-13 21:29:42 +03:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
2024-06-24 04:24:39 +03:00
|
|
|
import im.nheko 1.0
|
2021-02-10 18:52:42 +03:00
|
|
|
|
|
|
|
Switch {
|
2021-02-13 21:29:42 +03:00
|
|
|
id: toggleButton
|
2021-02-20 04:53:14 +03:00
|
|
|
|
2021-02-16 19:52:55 +03:00
|
|
|
implicitWidth: indicatorItem.width
|
2023-03-10 04:07:19 +03:00
|
|
|
state: checked ? "on" : "off"
|
2023-06-02 02:45:24 +03:00
|
|
|
|
|
|
|
indicator: Item {
|
|
|
|
id: indicatorItem
|
|
|
|
|
|
|
|
implicitHeight: 24
|
|
|
|
implicitWidth: 48
|
|
|
|
y: parent.height / 2 - height / 2
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: track
|
|
|
|
|
|
|
|
color: Qt.rgba(border.color.r, border.color.g, border.color.b, 0.6)
|
|
|
|
height: parent.height * 0.6
|
|
|
|
radius: height / 2
|
|
|
|
width: parent.width - height
|
|
|
|
x: radius
|
|
|
|
y: parent.height / 2 - height / 2
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
id: handle
|
|
|
|
|
|
|
|
border.color: "#767676"
|
|
|
|
color: palette.button
|
|
|
|
height: width
|
|
|
|
radius: width / 2
|
|
|
|
width: parent.height * 0.9
|
|
|
|
y: parent.height / 2 - height / 2
|
|
|
|
}
|
|
|
|
}
|
2023-03-10 04:07:19 +03:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "off"
|
|
|
|
|
|
|
|
PropertyChanges {
|
2023-10-26 17:43:09 +03:00
|
|
|
track.border.color: "#767676"
|
2023-03-10 04:07:19 +03:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
2023-10-26 17:43:09 +03:00
|
|
|
handle.x: 0
|
2023-03-10 04:07:19 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "on"
|
|
|
|
|
|
|
|
PropertyChanges {
|
2023-10-26 17:43:09 +03:00
|
|
|
track.border.color: palette.highlight
|
2023-03-10 04:07:19 +03:00
|
|
|
}
|
|
|
|
PropertyChanges {
|
2023-10-26 17:43:09 +03:00
|
|
|
handle.x: indicatorItem.width - handle.width
|
2023-03-10 04:07:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
reversible: true
|
2023-06-02 02:45:24 +03:00
|
|
|
to: "off"
|
2024-06-24 04:24:39 +03:00
|
|
|
enabled: !Settings.reducedMotion
|
2023-03-10 04:07:19 +03:00
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
easing.type: Easing.InOutQuad
|
2023-06-02 02:45:24 +03:00
|
|
|
property: "x"
|
|
|
|
target: handle
|
2023-03-10 04:07:19 +03:00
|
|
|
}
|
|
|
|
ColorAnimation {
|
|
|
|
duration: 200
|
2023-06-02 02:45:24 +03:00
|
|
|
properties: "color,border.color"
|
|
|
|
target: track
|
2023-03-10 04:07:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2021-02-20 04:53:14 +03:00
|
|
|
}
|