From 1cb836aea5f55ac1778e005609a94c456180ef73 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 17:33:55 +0200 Subject: [PATCH] Add a ReadOnlySpinBox control that provides a spinBox with a readOnly property Contributes to CURA-342 --- resources/qml/Preferences/ReadOnlySpinBox.qml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 resources/qml/Preferences/ReadOnlySpinBox.qml diff --git a/resources/qml/Preferences/ReadOnlySpinBox.qml b/resources/qml/Preferences/ReadOnlySpinBox.qml new file mode 100644 index 0000000000..5c1a3cbe19 --- /dev/null +++ b/resources/qml/Preferences/ReadOnlySpinBox.qml @@ -0,0 +1,23 @@ +// Copyright (c) 2016 Ultimaker B.V. +// Uranium is released under the terms of the AGPLv3 or higher. + +import QtQuick 2.1 +import QtQuick.Controls 1.1 +import QtQuick.Dialogs 1.2 + +// Provides a SpinBox with the same readOnly property as a TextField +SpinBox +{ + id: base + property bool readOnly: false + + Keys.enabled: !readOnly + MouseArea + { + acceptedButtons: Qt.AllButtons; + anchors.fill: parent; + enabled: parent.readOnly; + onWheel: wheel.accepted = true; + cursorShape: enabled ? Qt.ArrowCursor : Qt.IBeamCursor; + } +}