Number of settings & mode are now displayed in open Project

CURA-1263
This commit is contained in:
Jaime van Kessel 2016-12-02 11:54:28 +01:00
parent ea0cbec691
commit 6bb1b7ec80
3 changed files with 141 additions and 70 deletions

View file

@ -103,8 +103,18 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
quality_changes_conflict = True quality_changes_conflict = True
break break
Job.yieldThread() Job.yieldThread()
num_visible_settings = 0
try: try:
archive.open("Cura/preferences.cfg") temp_preferences = Preferences()
temp_preferences.readFromFile(io.TextIOWrapper(archive.open("Cura/preferences.cfg"))) # We need to wrap it, else the archive parser breaks.
visible_settings_string = temp_preferences.getValue("general/visible_settings")
if visible_settings_string is not None:
num_visible_settings = len(visible_settings_string.split(";"))
active_mode = temp_preferences.getValue("cura/active_mode")
if not active_mode:
active_mode = Preferences.getInstance().getValue("cura/active_mode")
except KeyError: except KeyError:
# If there is no preferences file, it's not a workspace, so notify user of failure. # If there is no preferences file, it's not a workspace, so notify user of failure.
Logger.log("w", "File %s is not a valid workspace.", file_name) Logger.log("w", "File %s is not a valid workspace.", file_name)
@ -114,6 +124,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._dialog.setMachineConflict(machine_conflict) self._dialog.setMachineConflict(machine_conflict)
self._dialog.setQualityChangesConflict(quality_changes_conflict) self._dialog.setQualityChangesConflict(quality_changes_conflict)
self._dialog.setMaterialConflict(material_conflict) self._dialog.setMaterialConflict(material_conflict)
self._dialog.setNumVisibleSettings(num_visible_settings)
self._dialog.setActiveMode(active_mode)
self._dialog.show() self._dialog.show()
# Block until the dialog is closed. # Block until the dialog is closed.

View file

@ -3,10 +3,12 @@ from PyQt5.QtQml import QQmlComponent, QQmlContext
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Application import Application from UM.Application import Application
from UM.Logger import Logger from UM.Logger import Logger
from UM.i18n import i18nCatalog
import os import os
import threading import threading
import time import time
i18n_catalog = i18nCatalog("cura")
class WorkspaceDialog(QObject): class WorkspaceDialog(QObject):
showDialogSignal = pyqtSignal() showDialogSignal = pyqtSignal()
@ -28,10 +30,38 @@ class WorkspaceDialog(QObject):
self._has_quality_changes_conflict = False self._has_quality_changes_conflict = False
self._has_machine_conflict = False self._has_machine_conflict = False
self._has_material_conflict = False self._has_material_conflict = False
self._num_visible_settings = 0
self._active_mode = ""
machineConflictChanged = pyqtSignal() machineConflictChanged = pyqtSignal()
qualityChangesConflictChanged = pyqtSignal() qualityChangesConflictChanged = pyqtSignal()
materialConflictChanged = pyqtSignal() materialConflictChanged = pyqtSignal()
numVisibleSettingsChanged = pyqtSignal()
activeModeChanged = pyqtSignal()
@pyqtProperty(str, notify=activeModeChanged)
def activeMode(self):
return self._active_mode
def setActiveMode(self, active_mode):
if active_mode == 0:
self._active_mode = i18n_catalog.i18nc("@title:tab", "Recommended")
else:
self._active_mode = i18n_catalog.i18nc("@title:tab", "Custom")
self.activeModeChanged.emit()
@pyqtProperty(int, constant = True)
def totalNumberOfSettings(self):
# TODO: actually calculate this.
return 200
@pyqtProperty(int, notify = numVisibleSettingsChanged)
def numVisibleSettings(self):
return self._num_visible_settings
def setNumVisibleSettings(self, num_visible_settings):
self._num_visible_settings = num_visible_settings
self.numVisibleSettingsChanged.emit()
@pyqtProperty(bool, notify = machineConflictChanged) @pyqtProperty(bool, notify = machineConflictChanged)
def machineConflict(self): def machineConflict(self):

View file

@ -12,13 +12,13 @@ UM.Dialog
{ {
title: catalog.i18nc("@title:window", "Import workspace conflict") title: catalog.i18nc("@title:window", "Import workspace conflict")
width: 350 * Screen.devicePixelRatio; width: 500 * Screen.devicePixelRatio;
minimumWidth: 350 * Screen.devicePixelRatio; minimumWidth: 500 * Screen.devicePixelRatio;
maximumWidth: 350 * Screen.devicePixelRatio; maximumWidth: 500 * Screen.devicePixelRatio;
height: 250 * Screen.devicePixelRatio; height: 350 * Screen.devicePixelRatio;
minimumHeight: 250 * Screen.devicePixelRatio; minimumHeight: 350 * Screen.devicePixelRatio;
maximumHeight: 250 * Screen.devicePixelRatio; maximumHeight: 350 * Screen.devicePixelRatio;
onClosing: manager.notifyClosed() onClosing: manager.notifyClosed()
onVisibleChanged: onVisibleChanged:
@ -96,6 +96,26 @@ UM.Dialog
text: catalog.i18nc("@action:label", "TOCHANGE") text: catalog.i18nc("@action:label", "TOCHANGE")
width: parent.width / 3 width: parent.width / 3
} }
UM.TooltipArea
{
id: machineResolveTooltip
width: parent.width / 3
height: visible ? 25 : 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
ComboBox
{
model: resolveStrategiesModel
textRole: "label"
id: machineResolveComboBox
width: parent.width
enabled: manager.machineConflict
onActivated:
{
manager.setResolveStrategy("machine", resolveStrategiesModel.get(index).key)
}
}
}
} }
Label Label
@ -118,60 +138,20 @@ UM.Dialog
text: catalog.i18nc("@action:label", "TOCHANGE") text: catalog.i18nc("@action:label", "TOCHANGE")
width: parent.width / 3 width: parent.width / 3
} }
}
UM.TooltipArea UM.TooltipArea
{
id: machineResolveTooltip
width: parent.width
height: visible ? 25 : 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
visible: manager.machineConflict
Row
{ {
width: parent.width id: qualityChangesResolveTooltip
height: childrenRect.height width: parent.width / 3
Label height: visible ? 25 : 0
{ text: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?")
text: catalog.i18nc("@action:label","Machine")
width: 150
}
ComboBox
{
model: resolveStrategiesModel
textRole: "label"
id: machineResolveComboBox
width: 150
onActivated:
{
manager.setResolveStrategy("machine", resolveStrategiesModel.get(index).key)
}
}
}
}
UM.TooltipArea
{
id: qualityChangesResolveTooltip
width: parent.width
height: visible ? 25 : 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?")
visible: manager.qualityChangesConflict
Row
{
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label","Profile")
width: 150
}
ComboBox ComboBox
{ {
model: resolveStrategiesModel model: resolveStrategiesModel
textRole: "label" textRole: "label"
id: qualityChangesResolveComboBox id: qualityChangesResolveComboBox
enabled: manager.qualityChangesConflict
width: parent.width
onActivated: onActivated:
{ {
manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(index).key) manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(index).key)
@ -179,28 +159,41 @@ UM.Dialog
} }
} }
} }
UM.TooltipArea
{
id: materialResolveTooltip
width: parent.width
height: visible ? 25 : 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the material(s) be resolved?")
visible: manager.materialConflict
Row
{
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label","Material")
width: 150
}
Label
{
text: catalog.i18nc("@action:label", "Material settings")
font.bold: true
}
Row
{
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label", "Type")
width: parent.width / 3
}
Label
{
text: catalog.i18nc("@action:label", "TOCHANGE")
width: parent.width / 3
}
UM.TooltipArea
{
id: materialResolveTooltip
width: parent.width / 3
height: visible ? 25 : 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?")
ComboBox ComboBox
{ {
model: resolveStrategiesModel model: resolveStrategiesModel
textRole: "label" textRole: "label"
id: materialResolveComboBox id: materialResolveComboBox
enabled: manager.materialConflict
width: parent.width
onActivated: onActivated:
{ {
manager.setResolveStrategy("material", resolveStrategiesModel.get(index).key) manager.setResolveStrategy("material", resolveStrategiesModel.get(index).key)
@ -208,6 +201,42 @@ UM.Dialog
} }
} }
} }
Label
{
text: catalog.i18nc("@action:label", "Setting visibility")
font.bold: true
}
Row
{
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label", "Mode")
width: parent.width / 3
}
Label
{
text: manager.activeMode
width: parent.width / 3
}
}
Row
{
width: parent.width
height: childrenRect.height
Label
{
text: catalog.i18nc("@action:label", "Visible settings:")
width: parent.width / 3
}
Label
{
text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings)
width: parent.width / 3
}
}
} }
} }
rightButtons: [ rightButtons: [