chiark / gitweb /
Add language selection.
[cura.git] / Cura / gui / preferencesDialog.py
index 8f28fe6610f30487479412fb58cc8c6a9f011dcb..8dc0199d0a1f23774db7593944b8b77af58b9300 100644 (file)
@@ -3,9 +3,11 @@ __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AG
 
 import wx
 
+from Cura.gui import configWizard
 from Cura.gui import configBase
 from Cura.util import machineCom
 from Cura.util import profile
+from Cura.util import resources
 
 class preferencesDialog(wx.Dialog):
        def __init__(self, parent):
@@ -25,6 +27,9 @@ class preferencesDialog(wx.Dialog):
                for i in xrange(1, extruderCount):
                        configBase.SettingRow(left, 'model_colour%d' % (i+1), wx.Colour)
 
+               configBase.TitleRow(left, _("Language"))
+               configBase.SettingRow(left, 'language', map(lambda n: n[1], resources.getLanguageOptions()))
+
                configBase.TitleRow(right, _("Filament settings"))
                configBase.SettingRow(right, 'filament_physical_density')
                configBase.SettingRow(right, 'filament_cost_kg')
@@ -94,17 +99,58 @@ class machineSettingsDialog(wx.Dialog):
                        configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList(), index=idx)
                        configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)
 
-                       self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx))
+                       self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx).title())
 
                self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))
 
-               self.okButton = wx.Button(self.panel, -1, 'Ok')
-               self.panel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)
+               self.buttonPanel = wx.Panel(self.panel)
+               self.panel.GetSizer().Add(self.buttonPanel)
+
+               self.buttonPanel.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
+               self.okButton = wx.Button(self.buttonPanel, -1, 'Ok')
                self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
+               self.buttonPanel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)
+
+               self.addButton = wx.Button(self.buttonPanel, -1, 'Add new machine')
+               self.addButton.Bind(wx.EVT_BUTTON, self.OnAddMachine)
+               self.buttonPanel.GetSizer().Add(self.addButton, flag=wx.ALL, border=5)
+
+               self.remButton = wx.Button(self.buttonPanel, -1, 'Remove machine')
+               self.remButton.Bind(wx.EVT_BUTTON, self.OnRemoveMachine)
+               self.buttonPanel.GetSizer().Add(self.remButton, flag=wx.ALL, border=5)
 
                main.Fit()
                self.Fit()
 
+       def OnAddMachine(self, e):
+               self.Hide()
+               self.parent.Hide()
+               profile.setActiveMachine(profile.getMachineCount())
+               configWizard.configWizard(True)
+               self.parent.Show()
+               self.parent.reloadSettingPanels()
+               self.parent.updateMachineMenu()
+
+               prefDialog = machineSettingsDialog(self.parent)
+               prefDialog.Centre()
+               prefDialog.Show()
+               wx.CallAfter(self.Close)
+
+       def OnRemoveMachine(self, e):
+               if profile.getMachineCount() < 2:
+                       wx.MessageBox(_("Cannot remove the last machine configuration in Cura"), _("Machine remove error"), wx.OK | wx.ICON_ERROR)
+                       return
+
+               self.Hide()
+               profile.removeMachine(self.nb.GetSelection())
+               self.parent.reloadSettingPanels()
+               self.parent.updateMachineMenu()
+
+               prefDialog = machineSettingsDialog(self.parent)
+               prefDialog.Centre()
+               prefDialog.Show()
+               wx.CallAfter(self.Close)
+
        def OnClose(self, e):
                self.parent.reloadSettingPanels()
                self.Destroy()