From 033d5f65d58830422af80b6629e85089c3400e19 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 8 Dec 2017 16:02:00 +0000 Subject: [PATCH] Usability tweaks for editing ratings Adjust ratings text now has mouse hover, and sliders can be clicked on the track to adjust the value directly --- src/GUI/AircraftRatingsPanel.qml | 10 +++------- src/GUI/ClickableText.qml | 16 ++++++++++++++++ src/GUI/Slider.qml | 13 +++++++++++++ src/GUI/resources.qrc | 1 + 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/GUI/ClickableText.qml diff --git a/src/GUI/AircraftRatingsPanel.qml b/src/GUI/AircraftRatingsPanel.qml index e87788007..ce7087ef9 100644 --- a/src/GUI/AircraftRatingsPanel.qml +++ b/src/GUI/AircraftRatingsPanel.qml @@ -18,17 +18,13 @@ ListHeaderBox anchors.verticalCenter: parent.verticalCenter }, - Text { + ClickableText { anchors.right: parent.right anchors.rightMargin: Style.margin text: qsTr("Adjust minimum ratings") anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors.fill: parent - onClicked: { - editRatingsPanel.visible = true - } + onClicked: { + editRatingsPanel.visible = true } }, diff --git a/src/GUI/ClickableText.qml b/src/GUI/ClickableText.qml new file mode 100644 index 000000000..a203247b3 --- /dev/null +++ b/src/GUI/ClickableText.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +import "." + +Text { + signal clicked(); + + color: mouse.containsMouse ? Style.themeColor : Style.baseTextColor + + MouseArea { + id: mouse + hoverEnabled: true + anchors.fill: parent + + onClicked: parent.clicked(); + } +} diff --git a/src/GUI/Slider.qml b/src/GUI/Slider.qml index f2a8abf4b..9bfd3f4b1 100644 --- a/src/GUI/Slider.qml +++ b/src/GUI/Slider.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 import "." Item { + id: root property alias label: labelText.text property int min: 0 @@ -39,6 +40,18 @@ Item { width: parent.width * __percentFull } + MouseArea { + id: clickTrackArea + anchors.centerIn: parent + width: parent.width + height: root.height + + onClicked: { + var frac = mouse.x / width; + root.value = min + 0.5 + (max - min) * frac; + } + } + // invisble item that moves directly with the mouse Item { id: dragThumb diff --git a/src/GUI/resources.qrc b/src/GUI/resources.qrc index 63c068d55..f0d93bd4b 100644 --- a/src/GUI/resources.qrc +++ b/src/GUI/resources.qrc @@ -55,6 +55,7 @@ UpdateAllPanel.qml Style.qml qmldir + ClickableText.qml preview-close.png