Browse Source

Fix the alignment of the MachineSelectorButton

Sometimes it was creating a button with width zero. Now it expands to the width of the container.

Also fixing a small issue with the buttons and the link not being correctly aligned to the vertical center.

Contributes to CURA-6057.
Diego Prado Gesto 6 years ago
parent
commit
3bfe7df044
2 changed files with 15 additions and 18 deletions
  1. 14 18
      resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml
  2. 1 0
      resources/qml/qmldir

+ 14 - 18
resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml

@@ -7,9 +7,6 @@ import QtQuick.Controls 2.3
 import UM 1.3 as UM
 import Cura 1.1 as Cura
 
-import "../PrinterSelector"
-
-
 //
 // This is the widget for adding a network printer. There are 2 parts in this widget. One is a scroll view of a list
 // of discovered network printers. Beneath the scroll view is a container with 3 buttons: "Refresh", "Add by IP", and
@@ -84,13 +81,11 @@ Item
                     }
                 }
 
-                delegate: MachineSelectorButton
+                delegate: Cura.MachineSelectorButton
                 {
                     text: modelData.device.name
 
-                    anchors.left: parent.left
-                    anchors.right: parent.right
-                    anchors.rightMargin: UM.Theme.getSize("default_margin").width
+                    width: networkPrinterListView.width
                     outputDevice: modelData.device
 
                     enabled: !modelData.isUnknownMachineType
@@ -119,22 +114,23 @@ Item
         }
     }
 
+    // Horizontal line separating the buttons (below) and the discovered network printers (above)
+    Rectangle
+    {
+        id: separator
+        anchors.left: parent.left
+        anchors.top: networkPrinterInfo.bottom
+        anchors.right: parent.right
+        height: UM.Theme.getSize("default_lining").height
+        color: UM.Theme.getColor("lining")
+    }
+
     Item
     {
         id: controlsRectangle
         anchors.left: parent.left
         anchors.right: parent.right
-        anchors.top: networkPrinterInfo.bottom
-
-        // Horizontal line separating the buttons (below) and the discovered network printers (above)
-        Rectangle
-        {
-            anchors.left: parent.left
-            anchors.top: parent.top
-            anchors.right: parent.right
-            height: UM.Theme.getSize("default_lining").width
-            color: UM.Theme.getColor("lining")
-        }
+        anchors.top: separator.bottom
 
         height: UM.Theme.getSize("message_action_button").height + UM.Theme.getSize("default_margin").height
 

+ 1 - 0
resources/qml/qmldir

@@ -1,6 +1,7 @@
 module Cura
 
 MachineSelector 1.0 MachineSelector.qml
+MachineSelectorButton 1.0 MachineSelectorButton.qml
 CustomConfigurationSelector 1.0 CustomConfigurationSelector.qml
 PrintSetupSelector 1.0 PrintSetupSelector.qml
 ActionButton 1.0 ActionButton.qml