chiark / gitweb /
Remember which quickprint profile was used.
authordaid <daid303@gmail.com>
Tue, 23 Dec 2014 11:20:59 +0000 (12:20 +0100)
committerdaid <daid303@gmail.com>
Tue, 23 Dec 2014 11:20:59 +0000 (12:20 +0100)
Cura/gui/simpleMode.py
Cura/util/profile.py

index 725a7aec18a7d9f8dd91afcc3c237306b0448a4a..7b9e116e2428f63a97590ab7b41eb2e0e4383c63 100644 (file)
@@ -20,23 +20,32 @@ class simpleModePanel(wx.Panel):
                for filename in resources.getSimpleModeProfiles():
                        cp = configparser.ConfigParser()
                        cp.read(filename)
-                       name = os.path.basename(filename)
+                       base_filename = os.path.splitext(os.path.basename(filename))[0]
+                       name = base_filename
                        if cp.has_option('info', 'name'):
                                name = cp.get('info', 'name')
                        button = wx.RadioButton(printTypePanel, -1, name, style=wx.RB_GROUP if len(self._print_profile_options) == 0 else 0)
+                       button.base_filename = base_filename
                        button.filename = filename
                        self._print_profile_options.append(button)
+                       if profile.getPreference('simpleModeProfile') == base_filename:
+                               button.SetValue(True)
 
                printMaterialPanel = wx.Panel(self)
                for filename in resources.getSimpleModeMaterials():
                        cp = configparser.ConfigParser()
                        cp.read(filename)
-                       name = os.path.basename(filename)
+                       base_filename = os.path.splitext(os.path.basename(filename))[0]
+                       name = base_filename
                        if cp.has_option('info', 'name'):
                                name = cp.get('info', 'name')
                        button = wx.RadioButton(printMaterialPanel, -1, name, style=wx.RB_GROUP if len(self._print_material_options) == 0 else 0)
+                       button.base_filename = base_filename
                        button.filename = filename
                        self._print_material_options.append(button)
+                       if profile.getPreference('simpleModeMaterial') == base_filename:
+                               button.SetValue(True)
+
                if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
                        printMaterialPanel.Show(False)
                
@@ -67,11 +76,20 @@ class simpleModePanel(wx.Panel):
                sizer.Add(boxsizer, (2,0), flag=wx.EXPAND)
 
                for button in self._print_profile_options:
-                       button.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+                       button.Bind(wx.EVT_RADIOBUTTON, self._update)
                for button in self._print_material_options:
-                       button.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+                       button.Bind(wx.EVT_RADIOBUTTON, self._update)
+
+               self.printSupport.Bind(wx.EVT_CHECKBOX, self._update)
 
-               self.printSupport.Bind(wx.EVT_CHECKBOX, lambda e: self._callback())
+       def _update(self, e):
+               for button in self._print_profile_options:
+                       if button.GetValue():
+                               profile.putPreference('simpleModeProfile', button.base_filename)
+               for button in self._print_material_options:
+                       if button.GetValue():
+                               profile.putPreference('simpleModeMaterial', button.base_filename)
+               self._callback()
 
        def getSettingOverrides(self):
                settings = {}
index 4b765493bc9402dc4088267d5a8462f7dadeed0b..7007cb3d1773cc36333f2160ea30bc05ae22c8a2 100644 (file)
@@ -477,6 +477,8 @@ setting('postSwitchExtruder.gcode', """;Switch between the current extruder and
 """, str, 'alteration', 'alteration')
 
 setting('startMode', 'Simple', ['Simple', 'Normal'], 'preference', 'hidden')
+setting('simpleModeProfile', '2_normal', str, 'preference', 'hidden')
+setting('simpleModeMaterial', '1_pla', str, 'preference', 'hidden')
 setting('oneAtATime', 'True', bool, 'preference', 'hidden')
 setting('lastFile', os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'resources', 'example', 'UltimakerRobot_support.stl')), str, 'preference', 'hidden')
 setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel(_("Save profile on slice"), _("When slicing save the profile as [stl_file]_profile.ini next to the model."))