Browse Source

Move sidebar action button style into styles.qml

fieldOfView 8 years ago
parent
commit
4bfa0f3bb1
2 changed files with 57 additions and 104 deletions
  1. 2 104
      resources/qml/MonitorButton.qml
  2. 55 0
      resources/themes/cura/styles.qml

+ 2 - 104
resources/qml/MonitorButton.qml

@@ -226,58 +226,7 @@ Rectangle
                 }
             }
 
-            style: ButtonStyle
-            {
-                background: Rectangle
-                {
-                    border.width: UM.Theme.getSize("default_lining").width
-                    border.color:
-                    {
-                        if(!control.enabled)
-                            return UM.Theme.getColor("action_button_disabled_border");
-                        else if(control.pressed)
-                            return UM.Theme.getColor("action_button_active_border");
-                        else if(control.hovered)
-                            return UM.Theme.getColor("action_button_hovered_border");
-                        else
-                            return UM.Theme.getColor("action_button_border");
-                    }
-                    color:
-                    {
-                        if(!control.enabled)
-                            return UM.Theme.getColor("action_button_disabled");
-                        else if(control.pressed)
-                            return UM.Theme.getColor("action_button_active");
-                        else if(control.hovered)
-                            return UM.Theme.getColor("action_button_hovered");
-                        else
-                            return UM.Theme.getColor("action_button");
-                    }
-                    Behavior on color { ColorAnimation { duration: 50; } }
-
-                    implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
-
-                    Label
-                    {
-                        id: actualLabel
-                        anchors.centerIn: parent
-                        color:
-                        {
-                            if(!control.enabled)
-                                return UM.Theme.getColor("action_button_disabled_text");
-                            else if(control.pressed)
-                                return UM.Theme.getColor("action_button_active_text");
-                            else if(control.hovered)
-                                return UM.Theme.getColor("action_button_hovered_text");
-                            else
-                                return UM.Theme.getColor("action_button_text");
-                        }
-                        font: UM.Theme.getFont("action_button")
-                        text: control.text
-                    }
-                }
-            label: Item { }
-            }
+            style: UM.Theme.styles.sidebar_action_button
         }
 
         Button
@@ -293,58 +242,7 @@ Rectangle
             text: catalog.i18nc("@label:", "Abort Print")
             onClicked: confirmationDialog.visible = true
 
-            style: ButtonStyle
-            {
-                background: Rectangle
-                {
-                    border.width: UM.Theme.getSize("default_lining").width
-                    border.color:
-                    {
-                        if(!control.enabled)
-                            return UM.Theme.getColor("action_button_disabled_border");
-                        else if(control.pressed)
-                            return UM.Theme.getColor("action_button_active_border");
-                        else if(control.hovered)
-                            return UM.Theme.getColor("action_button_hovered_border");
-                        else
-                            return UM.Theme.getColor("action_button_border");
-                    }
-                    color:
-                    {
-                        if(!control.enabled)
-                            return UM.Theme.getColor("action_button_disabled");
-                        else if(control.pressed)
-                            return UM.Theme.getColor("action_button_active");
-                        else if(control.hovered)
-                            return UM.Theme.getColor("action_button_hovered");
-                        else
-                            return UM.Theme.getColor("action_button");
-                    }
-                    Behavior on color { ColorAnimation { duration: 50; } }
-
-                    implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
-
-                    Label
-                    {
-                        id: actualLabel
-                        anchors.centerIn: parent
-                        color:
-                        {
-                            if(!control.enabled)
-                                return UM.Theme.getColor("action_button_disabled_text");
-                            else if(control.pressed)
-                                return UM.Theme.getColor("action_button_active_text");
-                            else if(control.hovered)
-                                return UM.Theme.getColor("action_button_hovered_text");
-                            else
-                                return UM.Theme.getColor("action_button_text");
-                        }
-                        font: UM.Theme.getFont("action_button")
-                        text: control.text;
-                    }
-                }
-            label: Item { }
-            }
+            style: UM.Theme.styles.sidebar_action_button
         }
 
         MessageDialog

+ 55 - 0
resources/themes/cura/styles.qml

@@ -506,4 +506,59 @@ QtObject {
             }
         }
     }
+
+    property Component sidebar_action_button: Component {
+        ButtonStyle
+        {
+            background: Rectangle
+            {
+                border.width: UM.Theme.getSize("default_lining").width
+                border.color:
+                {
+                    if(!control.enabled)
+                        return UM.Theme.getColor("action_button_disabled_border");
+                    else if(control.pressed)
+                        return UM.Theme.getColor("action_button_active_border");
+                    else if(control.hovered)
+                        return UM.Theme.getColor("action_button_hovered_border");
+                    else
+                        return UM.Theme.getColor("action_button_border");
+                }
+                color:
+                {
+                    if(!control.enabled)
+                        return UM.Theme.getColor("action_button_disabled");
+                    else if(control.pressed)
+                        return UM.Theme.getColor("action_button_active");
+                    else if(control.hovered)
+                        return UM.Theme.getColor("action_button_hovered");
+                    else
+                        return UM.Theme.getColor("action_button");
+                }
+                Behavior on color { ColorAnimation { duration: 50; } }
+
+                implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
+
+                Label
+                {
+                    id: actualLabel
+                    anchors.centerIn: parent
+                    color:
+                    {
+                        if(!control.enabled)
+                            return UM.Theme.getColor("action_button_disabled_text");
+                        else if(control.pressed)
+                            return UM.Theme.getColor("action_button_active_text");
+                        else if(control.hovered)
+                            return UM.Theme.getColor("action_button_hovered_text");
+                        else
+                            return UM.Theme.getColor("action_button_text");
+                    }
+                    font: UM.Theme.getFont("action_button")
+                    text: control.text
+                }
+            }
+            label: Item { }
+        }
+    }
 }