From: daid Date: Fri, 30 Jan 2015 07:56:10 +0000 (+0100) Subject: Merge pull request #1113 from pmsimard/15.01_RC10_SDFolderStructure X-Git-Tag: 15.01~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f2f9f6d1d97eec136acfc7f88a1b6d906371bd39;hp=35786cf94be2e835b36049bd5d6b31c9c6e25100;p=cura.git Merge pull request #1113 from pmsimard/15.01_RC10_SDFolderStructure SD replication Default path to MyDocuments & browse button --- diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 3f9acd21..708d30b5 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -1,6 +1,7 @@ __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License" import wx +import os from Cura.gui import configWizard from Cura.gui import configBase @@ -48,7 +49,12 @@ class preferencesDialog(wx.Dialog): configBase.TitleRow(right, 'SD Card settings') configBase.SettingRow(right, 'auto_detect_sd') configBase.SettingRow(right, 'sdcard_rootfolder') - + #same as the expert settings button. + self.browseButton = wx.Button(right, -1, '...', style=wx.BU_EXACTFIT) + self.browseButton.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize() * 0.8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL)) + self.browseButton.Bind(wx.EVT_BUTTON, self.OnBrowseSDRootFolder) + right.GetSizer().Add(self.browseButton, (right.GetSizer().GetRows()-1, 2), flag=wx.ALIGN_CENTER_VERTICAL) + configBase.TitleRow(right, _("Cura settings")) configBase.SettingRow(right, 'check_for_updates') configBase.SettingRow(right, 'submit_slice_information') @@ -64,6 +70,28 @@ class preferencesDialog(wx.Dialog): #self.parent.reloadSettingPanels() self.Destroy() + def OnBrowseSDRootFolder(self, e): + path = profile.getPreference('sdcard_rootfolder') + if path == '': + path = os.path.expanduser('~/Documents') + if not os.path.exists(path): + path = '' + + dlg=wx.DirDialog(self, _("Select replication root folder"), path) + if dlg.ShowModal() != wx.ID_OK: + dlg.Destroy() + return + + profile.putPreference('sdcard_rootfolder', dlg.GetPath()) + dlg.Destroy() + self.Close() + self.parent.OnPreferences(None) + + + + + + class machineSettingsDialog(wx.Dialog): def __init__(self, parent): super(machineSettingsDialog, self).__init__(None, title=_("Machine settings")) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index d7d75b35..d94ed3f8 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -487,7 +487,15 @@ setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel(_("Save setting('filament_cost_kg', '0', float, 'preference', 'hidden').setLabel(_("Cost (price/kg)"), _("Cost of your filament per kg, to estimate the cost of the final print.")) setting('filament_cost_meter', '0', float, 'preference', 'hidden').setLabel(_("Cost (price/m)"), _("Cost of your filament per meter, to estimate the cost of the final print.")) setting('auto_detect_sd', 'True', bool, 'preference', 'hidden').setLabel(_("Auto detect SD card drive"), _("Auto detect the SD card. You can disable this because on some systems external hard-drives or USB sticks are detected as SD card.")) -setting('sdcard_rootfolder', '', str, 'preference', 'hidden').setLabel(_("Base folder to replicate on SD card"), _("The specified folder will be used as a base path. Any gcode generated from object coming from within that folder will be automatically saved on the SD card at the same sub-folder. Any object coming from outside of this path will save the gcode on the root folder of the card.")) + +def _getMyDocumentsFolder(): + path = os.path.expanduser('~/Documents') + if not os.path.exists(path): + path = '' + + return path + +setting('sdcard_rootfolder', _getMyDocumentsFolder(), str, 'preference', 'hidden').setLabel(_("Base folder to replicate on SD card"), _("The specified folder will be used as a base path. Any gcode generated from object coming from within that folder will be automatically saved on the SD card at the same sub-folder. Any object coming from outside of this path will save the gcode on the root folder of the card.")) setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel(_("Check for updates"), _("Check for newer versions of Cura on startup")) setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel(_("Send usage statistics"), _("Submit anonymous usage information to improve future versions of Cura")) setting('youmagine_token', '', str, 'preference', 'hidden')