diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 224ad81c32..4b945c2523 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -522,6 +522,10 @@ class CuraApplication(QtApplication): preferences.addPreference("cura/use_multi_build_plate", False) preferences.addPreference("view/settings_list_height", 400) preferences.addPreference("view/settings_visible", False) + preferences.addPreference("view/settings_xpos", 0) + preferences.addPreference("view/settings_ypos", 56) + preferences.addPreference("view/colorscheme_xpos", 0) + preferences.addPreference("view/colorscheme_ypos", 56) preferences.addPreference("cura/currency", "€") preferences.addPreference("cura/material_settings", "{}") diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 6a035cc624..b94cf029f0 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -15,6 +15,8 @@ Cura.ExpandableComponent { id: base + dragPreferencesNamePrefix: "view/colorscheme" + contentHeaderTitle: catalog.i18nc("@label", "Color scheme") Connections diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 936b2e0b22..0eb27b97b2 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -78,6 +78,9 @@ Item property int shadowOffset: 2 + // Prefix used for the dragged position preferences. Preferences not used if empty. Don't translate! + property var dragPreferencesNamePrefix: "" + function toggleContent() { contentContainer.visible = !expanded @@ -202,17 +205,19 @@ Item Cura.RoundedRectangle { id: contentContainer + property string dragPreferencesNameX: "_xpos" + property string dragPreferencesNameY: "_ypos" visible: false width: childrenRect.width height: childrenRect.height // Ensure that the content is located directly below the headerItem - y: background.height + base.shadowOffset + base.contentSpacingY + y: dragPreferencesNamePrefix === "" ? (background.height + base.shadowOffset + base.contentSpacingY) : UM.Preferences.getValue(dragPreferencesNamePrefix + dragPreferencesNameY) // Make the content aligned with the rest, using the property contentAlignment to decide whether is right or left. // In case of right alignment, the 3x padding is due to left, right and padding between the button & text. - x: contentAlignment == ExpandableComponent.ContentAlignment.AlignRight ? -width + collapseButton.width + headerItemLoader.width + 3 * background.padding : 0 + x: dragPreferencesNamePrefix === "" ? (contentAlignment == ExpandableComponent.ContentAlignment.AlignRight ? -width + collapseButton.width + headerItemLoader.width + 3 * background.padding : 0) : UM.Preferences.getValue(dragPreferencesNamePrefix + dragPreferencesNameX) cornerSide: Cura.RoundedRectangle.Direction.All color: contentBackgroundColor @@ -231,6 +236,12 @@ Item contentContainer.x = Math.max(minPt.x, Math.min(maxPt.x, posNewX)); contentContainer.y = Math.max(initialY, Math.min(maxPt.y, posNewY)); + + if (dragPreferencesNamePrefix !== "") + { + UM.Preferences.setValue(dragPreferencesNamePrefix + dragPreferencesNameX, contentContainer.x); + UM.Preferences.setValue(dragPreferencesNamePrefix + dragPreferencesNameY, contentContainer.y); + } } ExpandableComponentHeader @@ -309,6 +320,11 @@ Item } } + Component.onCompleted: + { + updateDragPosition(); + } + // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the content item. // Apparently the order in which these are handled matters and so the height is correctly updated if this is here. Connections diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index 48b6d191c2..1a9bd9f109 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -11,6 +11,8 @@ Cura.ExpandableComponent { id: printSetupSelector + dragPreferencesNamePrefix: "view/settings" + property bool preSlicedData: PrintInformation.preSliced contentPadding: UM.Theme.getSize("default_lining").width