mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 22:35:03 -06:00
Merge branch 'feature_light_colours_icons'
CURA-4148
This commit is contained in:
commit
24c9dc9bee
116 changed files with 1909 additions and 1461 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py
Normal file
23
plugins/VersionUpgrade/VersionUpgrade27to30/__init__.py
Normal file
|
@ -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
plugins/VersionUpgrade/VersionUpgrade27to30/plugin.json
Normal file
8
plugins/VersionUpgrade/VersionUpgrade27to30/plugin.json
Normal file
|
@ -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"
|
||||
}
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue