Code style: Brackets on new line

Contributes to issue CURA-4606.
This commit is contained in:
Ghostkeeper 2018-03-13 09:23:40 +01:00
parent 69dc4fa5e0
commit b4a40915bb
No known key found for this signature in database
GPG Key ID: 5252B696FB5E7C7A

View File

@ -19,14 +19,17 @@ Item
UM.I18nCatalog { id: catalog; name: "cura"; } UM.I18nCatalog { id: catalog; name: "cura"; }
Cura.MaterialManagementModel { Cura.MaterialManagementModel
{
id: materialsModel id: materialsModel
} }
Label { Label
{
id: titleLabel id: titleLabel
anchors { anchors
{
top: parent.top top: parent.top
left: parent.left left: parent.left
right: parent.right right: parent.right
@ -170,22 +173,27 @@ Item
Connections Connections
{ {
target: materialsModel target: materialsModel
onItemsChanged: { onItemsChanged:
{
var currentItemId = base.currentItem == null ? "" : base.currentItem.root_material_id; var currentItemId = base.currentItem == null ? "" : base.currentItem.root_material_id;
var position = Cura.ExtruderManager.activeExtruderIndex; var position = Cura.ExtruderManager.activeExtruderIndex;
// try to pick the currently selected item; it may have been moved // try to pick the currently selected item; it may have been moved
if (base.newRootMaterialIdToSwitchTo == "") { if (base.newRootMaterialIdToSwitchTo == "")
{
base.newRootMaterialIdToSwitchTo = currentItemId; base.newRootMaterialIdToSwitchTo = currentItemId;
} }
for (var idx = 0; idx < materialsModel.rowCount(); ++idx) { for (var idx = 0; idx < materialsModel.rowCount(); ++idx)
{
var item = materialsModel.getItem(idx); var item = materialsModel.getItem(idx);
if (item.root_material_id == base.newRootMaterialIdToSwitchTo) { if (item.root_material_id == base.newRootMaterialIdToSwitchTo)
{
// Switch to the newly created profile if needed // Switch to the newly created profile if needed
materialListView.currentIndex = idx; materialListView.currentIndex = idx;
materialListView.activateDetailsWithIndex(materialListView.currentIndex); materialListView.activateDetailsWithIndex(materialListView.currentIndex);
if (base.toActivateNewMaterial) { if (base.toActivateNewMaterial)
{
Cura.MachineManager.setMaterial(position, item.container_node); Cura.MachineManager.setMaterial(position, item.container_node);
} }
base.newRootMaterialIdToSwitchTo = ""; base.newRootMaterialIdToSwitchTo = "";
@ -196,7 +204,8 @@ Item
materialListView.currentIndex = 0; materialListView.currentIndex = 0;
materialListView.activateDetailsWithIndex(materialListView.currentIndex); materialListView.activateDetailsWithIndex(materialListView.currentIndex);
if (base.toActivateNewMaterial) { if (base.toActivateNewMaterial)
{
Cura.MachineManager.setMaterial(position, materialsModel.getItem(0).container_node); Cura.MachineManager.setMaterial(position, materialsModel.getItem(0).container_node);
} }
base.newRootMaterialIdToSwitchTo = ""; base.newRootMaterialIdToSwitchTo = "";
@ -233,14 +242,17 @@ Item
messageDialog.title = catalog.i18nc("@title:window", "Import Material"); messageDialog.title = catalog.i18nc("@title:window", "Import Material");
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> or <message>!", "Could not import material <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message); messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> or <message>!", "Could not import material <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message);
if (result.status == "success") { if (result.status == "success")
{
messageDialog.icon = StandardIcon.Information; messageDialog.icon = StandardIcon.Information;
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully imported material <filename>%1</filename>").arg(fileUrl); messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully imported material <filename>%1</filename>").arg(fileUrl);
} }
else if (result.status == "duplicate") { else if (result.status == "duplicate")
{
messageDialog.icon = StandardIcon.Warning; messageDialog.icon = StandardIcon.Warning;
} }
else { else
{
messageDialog.icon = StandardIcon.Critical; messageDialog.icon = StandardIcon.Critical;
} }
messageDialog.open(); messageDialog.open();
@ -260,12 +272,14 @@ Item
var result = Cura.ContainerManager.exportContainer(base.currentItem.root_material_id, selectedNameFilter, fileUrl); var result = Cura.ContainerManager.exportContainer(base.currentItem.root_material_id, selectedNameFilter, fileUrl);
messageDialog.title = catalog.i18nc("@title:window", "Export Material"); messageDialog.title = catalog.i18nc("@title:window", "Export Material");
if (result.status == "error") { if (result.status == "error")
{
messageDialog.icon = StandardIcon.Critical; messageDialog.icon = StandardIcon.Critical;
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> and <message>!", "Failed to export material to <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message); messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> and <message>!", "Failed to export material to <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message);
messageDialog.open(); messageDialog.open();
} }
else if (result.status == "success") { else if (result.status == "success")
{
messageDialog.icon = StandardIcon.Information; messageDialog.icon = StandardIcon.Information;
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully exported material to <filename>%1</filename>").arg(result.path); messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully exported material to <filename>%1</filename>").arg(result.path);
messageDialog.open(); messageDialog.open();
@ -283,7 +297,8 @@ Item
Item { Item {
id: contentsItem id: contentsItem
anchors { anchors
{
top: titleLabel.bottom top: titleLabel.bottom
left: parent.left left: parent.left
right: parent.right right: parent.right
@ -297,7 +312,8 @@ Item
Item Item
{ {
anchors { anchors
{
top: buttonRow.bottom top: buttonRow.bottom
topMargin: UM.Theme.getSize("default_margin").height topMargin: UM.Theme.getSize("default_margin").height
left: parent.left left: parent.left
@ -310,12 +326,14 @@ Item
Label Label
{ {
id: captionLabel id: captionLabel
anchors { anchors
{
top: parent.top top: parent.top
left: parent.left left: parent.left
} }
visible: text != "" visible: text != ""
text: { text:
{
var caption = catalog.i18nc("@action:label", "Printer") + ": " + Cura.MachineManager.activeMachineName; var caption = catalog.i18nc("@action:label", "Printer") + ": " + Cura.MachineManager.activeMachineName;
if (Cura.MachineManager.hasVariants) if (Cura.MachineManager.hasVariants)
{ {
@ -330,14 +348,16 @@ Item
ScrollView ScrollView
{ {
id: materialScrollView id: materialScrollView
anchors { anchors
{
top: captionLabel.visible ? captionLabel.bottom : parent.top top: captionLabel.visible ? captionLabel.bottom : parent.top
topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0 topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0
bottom: parent.bottom bottom: parent.bottom
left: parent.left left: parent.left
} }
Rectangle { Rectangle
{
parent: viewport parent: viewport
anchors.fill: parent anchors.fill: parent
color: palette.light color: palette.light
@ -418,13 +438,15 @@ Item
MouseArea MouseArea
{ {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked:
{
parent.ListView.view.currentIndex = model.index; parent.ListView.view.currentIndex = model.index;
} }
} }
} }
function activateDetailsWithIndex(index) { function activateDetailsWithIndex(index)
{
var model = materialsModel.getItem(index); var model = materialsModel.getItem(index);
base.currentItem = model; base.currentItem = model;
materialDetailsView.containerId = model.container_id; materialDetailsView.containerId = model.container_id;
@ -446,7 +468,8 @@ Item
{ {
id: detailsPanel id: detailsPanel
anchors { anchors
{
left: materialScrollView.right left: materialScrollView.right
leftMargin: UM.Theme.getSize("default_margin").width leftMargin: UM.Theme.getSize("default_margin").width
top: parent.top top: parent.top