diff --git a/resources/qml/Preferences/MaterialView.qml b/resources/qml/Preferences/MaterialView.qml index 6d5f218c06..67a149f446 100644 --- a/resources/qml/Preferences/MaterialView.qml +++ b/resources/qml/Preferences/MaterialView.qml @@ -45,7 +45,7 @@ TabView property real rowHeight: textField.height; Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") } - TextField + ReadOnlyTextField { id: textField; width: base.secondColumnWidth; @@ -55,7 +55,7 @@ TabView } Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") } - TextField + ReadOnlyTextField { width: base.secondColumnWidth; text: properties.material_type; @@ -85,7 +85,7 @@ TabView MouseArea { anchors.fill: parent; onClicked: colorDialog.open(); enabled: base.editingEnabled } } - TextField + ReadOnlyTextField { id: colorLabel; text: properties.color_name; @@ -167,7 +167,7 @@ TabView Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Description") } - TextArea + ReadOnlyTextArea { text: properties.description; width: base.firstColumnWidth + base.secondColumnWidth @@ -180,13 +180,14 @@ TabView Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Adhesion Information") } - TextArea + ReadOnlyTextArea { text: properties.adhesion_info; width: base.firstColumnWidth + base.secondColumnWidth wrapMode: Text.WordWrap readOnly: !base.editingEnabled; + onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "adhesion_info", text) } } diff --git a/resources/qml/Preferences/ReadOnlySpinBox.qml b/resources/qml/Preferences/ReadOnlySpinBox.qml index 5c1a3cbe19..8692f55708 100644 --- a/resources/qml/Preferences/ReadOnlySpinBox.qml +++ b/resources/qml/Preferences/ReadOnlySpinBox.qml @@ -5,19 +5,48 @@ 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 +Item { id: base + + property alias value: spinBox.value + property alias minimumValue: spinBox.minimumValue + property alias maximumValue: spinBox.maximumValue + property alias stepSize: spinBox.stepSize + property alias prefix: spinBox.prefix + property alias suffix: spinBox.suffix + property alias decimals: spinBox.decimals + + signal editingFinished(); + property bool readOnly: false - Keys.enabled: !readOnly - MouseArea + width: spinBox.width + height: spinBox.height + + SpinBox { - acceptedButtons: Qt.AllButtons; - anchors.fill: parent; - enabled: parent.readOnly; - onWheel: wheel.accepted = true; - cursorShape: enabled ? Qt.ArrowCursor : Qt.IBeamCursor; + id: spinBox + + enabled: !base.readOnly + opacity: base.readOnly ? 0.5 : 1.0 + + anchors.fill: parent + + onEditingFinished: base.editingFinished() } + + Label + { + visible: base.readOnly + text: base.prefix + base.value.toFixed(spinBox.decimals) + base.suffix + + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: spinBox.__style ? spinBox.__style.padding.left : 0 + + color: palette.buttonText + } + + SystemPalette { id: palette } } diff --git a/resources/qml/Preferences/ReadOnlyTextArea.qml b/resources/qml/Preferences/ReadOnlyTextArea.qml new file mode 100644 index 0000000000..cbef8fa46b --- /dev/null +++ b/resources/qml/Preferences/ReadOnlyTextArea.qml @@ -0,0 +1,46 @@ +// 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 + +Item +{ + id: base + + property alias text: textArea.text + property alias wrapMode: textArea.wrapMode + + signal editingFinished(); + + property bool readOnly: false + + width: textArea.width + height: textArea.height + + TextArea + { + id: textArea + + enabled: !base.readOnly + opacity: base.readOnly ? 0.5 : 1.0 + + anchors.fill: parent + + onEditingFinished: base.editingFinished() + } + + Label + { + visible: base.readOnly + text: textArea.text + + anchors.fill: parent + anchors.margins: textArea.__style ? textArea.__style.textMargin : 4 + + color: palette.buttonText + } + + SystemPalette { id: palette } +} diff --git a/resources/qml/Preferences/ReadOnlyTextField.qml b/resources/qml/Preferences/ReadOnlyTextField.qml new file mode 100644 index 0000000000..28c714259b --- /dev/null +++ b/resources/qml/Preferences/ReadOnlyTextField.qml @@ -0,0 +1,46 @@ +// 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 + +Item +{ + id: base + + property alias text: textField.text + + signal editingFinished(); + + property bool readOnly: false + + width: textField.width + height: textField.height + + TextField + { + id: textField + + enabled: !base.readOnly + opacity: base.readOnly ? 0.5 : 1.0 + + anchors.fill: parent + + onEditingFinished: base.editingFinished() + } + + Label + { + visible: base.readOnly + text: textField.text + + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: textField.__panel ? textField.__panel.leftMargin : 0 + + color: palette.buttonText + } + + SystemPalette { id: palette } +}