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
|
2021-02-10 18:52:42 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
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
|
2021-02-13 21:29:42 +03:00
|
|
|
|
2023-03-10 04:07:19 +03:00
|
|
|
state: checked ? "on" : "off"
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "off"
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: track
|
|
|
|
border.color: "#767676"
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: handle
|
|
|
|
x: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "on"
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: track
|
|
|
|
border.color: Nheko.colors.highlight
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: handle
|
|
|
|
x: indicatorItem.width - handle.width
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
to: "off"
|
|
|
|
reversible: true
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
NumberAnimation {
|
|
|
|
target: handle
|
|
|
|
property: "x"
|
|
|
|
duration: 200
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
|
|
|
|
ColorAnimation {
|
|
|
|
target: track
|
|
|
|
properties: "color,border.color"
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2021-02-20 04:53:14 +03:00
|
|
|
indicator: Item {
|
2021-02-16 19:52:55 +03:00
|
|
|
id: indicatorItem
|
2021-02-20 04:53:14 +03:00
|
|
|
|
2021-02-13 21:29:42 +03:00
|
|
|
implicitWidth: 48
|
2021-02-16 09:22:03 +03:00
|
|
|
implicitHeight: 24
|
|
|
|
y: parent.height / 2 - height / 2
|
2021-02-13 21:29:42 +03:00
|
|
|
|
|
|
|
Rectangle {
|
2023-03-10 04:07:19 +03:00
|
|
|
id: track
|
|
|
|
|
|
|
|
height: parent.height * 0.6
|
2021-02-20 04:53:14 +03:00
|
|
|
radius: height / 2
|
2021-02-13 21:29:42 +03:00
|
|
|
width: parent.width - height
|
|
|
|
x: radius
|
|
|
|
y: parent.height / 2 - height / 2
|
2023-03-10 04:07:19 +03:00
|
|
|
color: Qt.rgba(border.color.r, border.color.g, border.color.b, 0.6)
|
2021-02-13 19:19:21 +03:00
|
|
|
}
|
2021-02-20 04:53:14 +03:00
|
|
|
|
2021-02-13 21:29:42 +03:00
|
|
|
Rectangle {
|
2023-03-10 04:07:19 +03:00
|
|
|
id: handle
|
|
|
|
|
2021-02-16 09:22:03 +03:00
|
|
|
y: parent.height / 2 - height / 2
|
2023-03-10 04:07:19 +03:00
|
|
|
width: parent.height * 0.9
|
2021-02-13 21:29:42 +03:00
|
|
|
height: width
|
2021-02-20 04:53:14 +03:00
|
|
|
radius: width / 2
|
2023-03-10 04:07:19 +03:00
|
|
|
color: Nheko.colors.button
|
|
|
|
border.color: "#767676"
|
2021-02-13 19:19:21 +03:00
|
|
|
}
|
2021-02-20 04:53:14 +03:00
|
|
|
|
2021-02-13 19:19:21 +03:00
|
|
|
}
|
2021-02-20 04:53:14 +03:00
|
|
|
|
|
|
|
}
|