Browse Source

Merge branch 'feature_light_colours_icons'
CURA-4148

alekseisasin 7 years ago
parent
commit
24c9dc9bee

+ 2 - 0
cura/CuraApplication.py

@@ -205,6 +205,8 @@ class CuraApplication(QtApplication):
         super().__init__(name = "cura", version = CuraVersion, buildtype = CuraBuildType,
                          tray_icon_name = "cura-icon-32.png")
 
+        self.default_theme = "cura-light"
+
         self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
 
         self.setRequiredPlugins([

+ 17 - 0
cura/Settings/MachineManager.py

@@ -649,6 +649,23 @@ class MachineManager(QObject):
                 return Util.parseBool(quality.getMetaDataEntry("supported", True))
         return False
 
+    ##  Returns whether there is anything unsupported in the current set-up.
+    #
+    #   The current set-up signifies the global stack and all extruder stacks,
+    #   so this indicates whether there is any container in any of the container
+    #   stacks that is not marked as supported.
+    @pyqtProperty(bool, notify = activeQualityChanged)
+    def isCurrentSetupSupported(self) -> bool:
+        if not self._global_container_stack:
+            return False
+        for stack in [self._global_container_stack] + list(self._global_container_stack.extruders.values()):
+            for container in stack.getContainers():
+                if not container:
+                    return False
+                if not Util.parseBool(container.getMetaDataEntry("supported", True)):
+                    return False
+        return True
+
     ##  Get the Quality ID associated with the currently active extruder
     #   Note that this only returns the "quality", not the "quality_changes"
     #   \returns QualityID (string) if found, empty string otherwise

+ 5 - 1
plugins/LayerView/LayerView.qml

@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Ultimaker B.V.
+// Copyright (c) 2017 Ultimaker B.V.
 // Cura is released under the terms of the AGPLv3 or higher.
 
 import QtQuick 2.2
@@ -492,6 +492,8 @@ Item
                 anchors.horizontalCenter: parent.horizontalCenter
                 radius: parent.handleRadius
                 color: parent.upperHandleColor
+                border.width: UM.Theme.getSize("default_lining").width
+                border.color: UM.Theme.getColor("slider_handle_border")
 
                 visible: slider.layersVisible
 
@@ -531,6 +533,8 @@ Item
                 anchors.horizontalCenter: parent.horizontalCenter
                 radius: parent.handleRadius
                 color: parent.lowerHandleColor
+                border.width: UM.Theme.getSize("default_lining").width
+                border.color: UM.Theme.getColor("slider_handle_border")
 
                 visible: slider.layersVisible
 

+ 56 - 0
plugins/VersionUpgrade/VersionUpgrade27to30/VersionUpgrade27to30.py

@@ -0,0 +1,56 @@
+# Copyright (c) 2017 Ultimaker B.V.
+# Cura is released under the terms of the AGPLv3 or higher.
+
+import configparser #To parse preference files.
+import io #To serialise the preference files afterwards.
+
+from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
+
+_renamed_themes = {
+    "cura": "cura-light"
+}
+
+class VersionUpgrade27to30(VersionUpgrade):
+    ##  Gets the version number from a CFG file in Uranium's 2.7 format.
+    #
+    #   Since the format may change, this is implemented for the 2.7 format only
+    #   and needs to be included in the version upgrade system rather than
+    #   globally in Uranium.
+    #
+    #   \param serialised The serialised form of a CFG file.
+    #   \return The version number stored in the CFG file.
+    #   \raises ValueError The format of the version number in the file is
+    #   incorrect.
+    #   \raises KeyError The format of the file is incorrect.
+    def getCfgVersion(self, serialised):
+        parser = configparser.ConfigParser(interpolation = None)
+        parser.read_string(serialised)
+        format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
+        setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
+        return format_version * 1000000 + setting_version
+
+    ##  Upgrades a preferences file from version 2.7 to 3.0.
+    #
+    #   \param serialised The serialised form of a preferences file.
+    #   \param filename The name of the file to upgrade.
+    def upgradePreferences(self, serialised, filename):
+        parser = configparser.ConfigParser(interpolation=None)
+        parser.read_string(serialised)
+
+        # Update version numbers
+        if "general" not in parser:
+            parser["general"] = {}
+        parser["general"]["version"] = "5"
+        if "metadata" not in parser:
+            parser["metadata"] = {}
+        parser["metadata"]["setting_version"] = "2"
+
+        #Renamed themes.
+        if "theme" in parser["general"]:
+            if parser["general"]["theme"] in _renamed_themes:
+                parser["general"]["theme"] = _renamed_themes[parser["general"]["theme"]]
+
+        # Re-serialise the file.
+        output = io.StringIO()
+        parser.write(output)
+        return [filename], [output.getvalue()]

+ 23 - 0
plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py

@@ -0,0 +1,23 @@
+# Copyright (c) 2017 Ultimaker B.V.
+# Cura is released under the terms of the AGPLv3 or higher.
+
+from . import VersionUpgrade27to30
+
+upgrade = VersionUpgrade27to30.VersionUpgrade27to30()
+
+def getMetaData():
+    return {
+        "version_upgrade": {
+            # From                    To                       Upgrade function
+            ("preferences", 4000002): ("preferences", 5000002, upgrade.upgradePreferences),
+        },
+        "sources": {
+            "preferences": {
+                "get_version": upgrade.getCfgVersion,
+                "location": {"."}
+            },
+        }
+    }
+
+def register(app):
+    return { "version_upgrade": upgrade }

+ 8 - 0
plugins/VersionUpgrade/VersionUpgrade27to30/plugin.json

@@ -0,0 +1,8 @@
+ {
+    "name": "Version Upgrade 2.7 to 3.0",
+    "author": "Ultimaker B.V.",
+    "version": "1.0.0",
+    "description": "Upgrades configurations from Cura 2.7 to Cura 3.0.",
+    "api": 4,
+    "i18n-catalog": "cura"
+}

+ 171 - 0
plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py

@@ -0,0 +1,171 @@
+# Copyright (c) 2017 Ultimaker B.V.
+# Cura is released under the terms of the AGPLv3 or higher.
+
+import configparser #To parse the resulting config files.
+import pytest #To register tests with.
+
+import VersionUpgrade27to30 #The module we're testing.
+
+##  Creates an instance of the upgrader to test with.
+@pytest.fixture
+def upgrader():
+    return VersionUpgrade27to30.VersionUpgrade27to30()
+
+test_cfg_version_good_data = [
+    {
+        "test_name": "Simple",
+        "file_data": """[general]
+version = 1
+""",
+        "version": 1000000
+    },
+    {
+        "test_name": "Other Data Around",
+        "file_data": """[nonsense]
+life = good
+
+[general]
+version = 3
+
+[values]
+layer_height = 0.12
+infill_sparse_density = 42
+""",
+        "version": 3000000
+    },
+    {
+        "test_name": "Negative Version", #Why not?
+        "file_data": """[general]
+version = -20
+""",
+        "version": -20000000
+    },
+    {
+        "test_name": "Setting Version",
+        "file_data": """[general]
+version = 1
+[metadata]
+setting_version = 1
+""",
+        "version": 1000001
+    },
+    {
+        "test_name": "Negative Setting Version",
+        "file_data": """[general]
+version = 1
+[metadata]
+setting_version = -3
+""",
+        "version": 999997
+    }
+]
+
+##  Tests the technique that gets the version number from CFG files.
+#
+#   \param data The parametrised data to test with. It contains a test name
+#   to debug with, the serialised contents of a CFG file and the correct
+#   version number in that CFG file.
+#   \param upgrader The instance of the upgrade class to test.
+@pytest.mark.parametrize("data", test_cfg_version_good_data)
+def test_cfgVersionGood(data, upgrader):
+    version = upgrader.getCfgVersion(data["file_data"])
+    assert version == data["version"]
+
+test_cfg_version_bad_data = [
+    {
+        "test_name": "Empty",
+        "file_data": "",
+        "exception": configparser.Error #Explicitly not specified further which specific error we're getting, because that depends on the implementation of configparser.
+    },
+    {
+        "test_name": "No General",
+        "file_data": """[values]
+layer_height = 0.1337
+""",
+        "exception": configparser.Error
+    },
+    {
+        "test_name": "No Version",
+        "file_data": """[general]
+true = false
+""",
+        "exception": configparser.Error
+    },
+    {
+        "test_name": "Not a Number",
+        "file_data": """[general]
+version = not-a-text-version-number
+""",
+        "exception": ValueError
+    },
+    {
+        "test_name": "Setting Value NaN",
+        "file_data": """[general]
+version = 4
+[metadata]
+setting_version = latest_or_something
+""",
+        "exception": ValueError
+    },
+    {
+        "test_name": "Major-Minor",
+        "file_data": """[general]
+version = 1.2
+""",
+        "exception": ValueError
+    }
+]
+
+##  Tests whether getting a version number from bad CFG files gives an
+#   exception.
+#
+#   \param data The parametrised data to test with. It contains a test name
+#   to debug with, the serialised contents of a CFG file and the class of
+#   exception it needs to throw.
+#   \param upgrader The instance of the upgrader to test.
+@pytest.mark.parametrize("data", test_cfg_version_bad_data)
+def test_cfgVersionBad(data, upgrader):
+    with pytest.raises(data["exception"]):
+        upgrader.getCfgVersion(data["file_data"])
+
+test_translate_theme_data = [
+    (
+        "Original Cura theme",
+        """[general]
+version = 4
+theme = cura
+[metadata]
+setting_version = 2
+""",
+        "cura-light"
+    ),
+    (
+        "No theme",
+        """[general]
+version = 4
+[metadata]
+setting_version = 2
+""",
+        None #Indicates that the theme should be absent in the new file.
+    )
+]
+
+##  Tests whether the theme is properly translated.
+@pytest.mark.parametrize("test_name, file_data, new_theme", test_translate_theme_data)
+def test_translateTheme(test_name, file_data, new_theme, upgrader):
+    #Read old file.
+    original_parser = configparser.ConfigParser(interpolation = None)
+    original_parser.read_string(file_data)
+
+    #Perform the upgrade.
+    _, upgraded_stacks = upgrader.upgradePreferences(file_data, "<string>")
+    upgraded_stack = upgraded_stacks[0]
+    parser = configparser.ConfigParser(interpolation = None)
+    parser.read_string(upgraded_stack)
+
+    #Check whether the theme was properly translated.
+    if not new_theme:
+        assert "theme" not in parser["general"]
+    else:
+        assert "theme" in parser["general"]
+        assert parser["general"]["theme"] == new_theme

+ 1 - 1
resources/qml/Cura.qml

@@ -447,7 +447,7 @@ UM.MainWindow
                     right: sidebar.left
                 }
                 visible: opacity > 0
-                opacity: base.showPrintMonitor ? 0.75 : 0
+                opacity: base.showPrintMonitor ? 1 : 0
 
                 Behavior on opacity { NumberAnimation { duration: 100; } }
 

+ 3 - 3
resources/qml/JobSpecs.qml

@@ -86,7 +86,7 @@ Item {
                             height: UM.Theme.getSize("save_button_specs_icons").height;
                             sourceSize.width: width;
                             sourceSize.height: width;
-                            color: control.hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("text");
+                            color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene");
                             source: UM.Theme.getIcon("pencil");
                         }
                     }
@@ -116,7 +116,7 @@ Item {
                     regExp: /^[^\\ \/ \*\?\|\[\]]*$/
                 }
                 style: TextFieldStyle{
-                    textColor: UM.Theme.getColor("setting_control_text");
+                    textColor: UM.Theme.getColor("text_scene");
                     font: UM.Theme.getFont("default_bold");
                     background: Rectangle {
                         opacity: 0
@@ -135,7 +135,7 @@ Item {
         height: UM.Theme.getSize("jobspecs_line").height
         verticalAlignment: Text.AlignVCenter
         font: UM.Theme.getFont("small")
-        color: UM.Theme.getColor("text_subtext")
+        color: UM.Theme.getColor("text_scene")
         text: CuraApplication.getSceneBoundingBoxString
     }
 }

+ 8 - 8
resources/qml/MonitorButton.qml

@@ -1,4 +1,4 @@
-// Copyright (c) 2016 Ultimaker B.V.
+// Copyright (c) 2017 Ultimaker B.V.
 // Cura is released under the terms of the AGPLv3 or higher.
 
 import QtQuick 2.2
@@ -119,10 +119,10 @@ Item
     Label
     {
         id: statusLabel
-        width: parent.width - 2 * UM.Theme.getSize("default_margin").width
+        width: parent.width - 2 * UM.Theme.getSize("sidebar_margin").width
         anchors.top: parent.top
         anchors.left: parent.left
-        anchors.leftMargin: UM.Theme.getSize("default_margin").width
+        anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
 
         color: base.statusColor
         font: UM.Theme.getFont("large")
@@ -177,21 +177,21 @@ Item
         property string backgroundColor: UM.Theme.getColor("progressbar_background");
         property string controlColor: base.statusColor;
 
-        width: parent.width - 2 * UM.Theme.getSize("default_margin").width;
+        width: parent.width - 2 * UM.Theme.getSize("sidebar_margin").width;
         height: UM.Theme.getSize("progressbar").height;
         anchors.top: statusLabel.bottom;
-        anchors.topMargin: UM.Theme.getSize("default_margin").height / 4;
+        anchors.topMargin: UM.Theme.getSize("sidebar_margin").height / 4;
         anchors.left: parent.left;
-        anchors.leftMargin: UM.Theme.getSize("default_margin").width;
+        anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width;
     }
 
     Row {
         id: buttonsRow
         height: abortButton.height
         anchors.top: progressBar.bottom
-        anchors.topMargin: UM.Theme.getSize("default_margin").height
+        anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
         anchors.right: parent.right
-        anchors.rightMargin: UM.Theme.getSize("default_margin").width
+        anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
         spacing: UM.Theme.getSize("default_margin").width
 
         Row {

Some files were not shown because too many files changed in this diff