mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-10 01:22:36 +02:00
Switch moved
This commit is contained in:
parent
55add3746d
commit
09c3f93c74
1 changed files with 36 additions and 32 deletions
|
@ -8,9 +8,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 1.4 as Original
|
import QtQuick.Controls 2.2 as Original
|
||||||
import QtQuick.Controls.Styles 1.4
|
|
||||||
|
|
||||||
import "../styles-uit"
|
import "../styles-uit"
|
||||||
|
|
||||||
|
@ -33,44 +32,49 @@ Item {
|
||||||
|
|
||||||
Original.Switch {
|
Original.Switch {
|
||||||
id: originalSwitch;
|
id: originalSwitch;
|
||||||
activeFocusOnPress: true;
|
focusPolicy: Qt.ClickFocus
|
||||||
anchors.top: rootSwitch.top;
|
anchors.top: rootSwitch.top;
|
||||||
anchors.left: rootSwitch.left;
|
anchors.left: rootSwitch.left;
|
||||||
anchors.leftMargin: rootSwitch.width/2 - rootSwitch.switchWidth/2;
|
anchors.leftMargin: rootSwitch.width/2 - rootSwitch.switchWidth/2;
|
||||||
onCheckedChanged: rootSwitch.onCheckedChanged();
|
onCheckedChanged: rootSwitch.onCheckedChanged();
|
||||||
onClicked: rootSwitch.clicked();
|
onClicked: rootSwitch.clicked();
|
||||||
|
hoverEnabled: true
|
||||||
|
|
||||||
style: SwitchStyle {
|
topPadding: 3;
|
||||||
|
leftPadding: 3;
|
||||||
|
rightPadding: 3;
|
||||||
|
bottomPadding: 3;
|
||||||
|
|
||||||
padding {
|
onHoveredChanged: {
|
||||||
top: 3;
|
if (hovered) {
|
||||||
left: 3;
|
switchHandle.color = hifi.colors.blueHighlight;
|
||||||
right: 3;
|
} else {
|
||||||
bottom: 3;
|
switchHandle.color = hifi.colors.lightGray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: "#252525";
|
||||||
|
implicitWidth: rootSwitch.switchWidth;
|
||||||
|
implicitHeight: rootSwitch.height;
|
||||||
|
radius: rootSwitch.switchRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
indicator: Rectangle {
|
||||||
|
id: switchHandle;
|
||||||
|
implicitWidth: rootSwitch.height - originalSwitch.topPadding - originalSwitch.bottomPadding;
|
||||||
|
implicitHeight: implicitWidth;
|
||||||
|
radius: implicitWidth/2;
|
||||||
|
border.color: hifi.colors.lightGrayText;
|
||||||
|
color: hifi.colors.lightGray;
|
||||||
|
//x: originalSwitch.leftPadding
|
||||||
|
x: Math.max(0, Math.min(parent.width - width, originalSwitch.visualPosition * parent.width - (width / 2)))
|
||||||
|
y: parent.height / 2 - height / 2
|
||||||
|
Behavior on x {
|
||||||
|
enabled: !originalSwitch.down
|
||||||
|
SmoothedAnimation { velocity: 200 }
|
||||||
}
|
}
|
||||||
|
|
||||||
groove: Rectangle {
|
|
||||||
color: "#252525";
|
|
||||||
implicitWidth: rootSwitch.switchWidth;
|
|
||||||
implicitHeight: rootSwitch.height;
|
|
||||||
radius: rootSwitch.switchRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle: Rectangle {
|
|
||||||
id: switchHandle;
|
|
||||||
implicitWidth: rootSwitch.height - padding.top - padding.bottom;
|
|
||||||
implicitHeight: implicitWidth;
|
|
||||||
radius: implicitWidth/2;
|
|
||||||
border.color: hifi.colors.lightGrayText;
|
|
||||||
color: hifi.colors.lightGray;
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent;
|
|
||||||
hoverEnabled: true;
|
|
||||||
onEntered: parent.color = hifi.colors.blueHighlight;
|
|
||||||
onExited: parent.color = hifi.colors.lightGray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue