From bf4dcdde925eec005a0ec3988591abacd5f25333 Mon Sep 17 00:00:00 2001 From: Samuel Findlay Date: Mon, 7 May 2012 20:36:39 +1000 Subject: [PATCH] Added getFolder to OpenLPWizard --- openlp/core/ui/wizard.py | 23 +++++++++++++++++--- openlp/plugins/songs/forms/songexportform.py | 10 ++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 500d958fd..5f81e670d 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -254,7 +254,7 @@ class OpenLPWizard(QtGui.QWizard): The title of the dialog (unicode). ``editbox`` - A editbox (QLineEdit). + An editbox (QLineEdit). ``filters`` The file extension filters. It should contain the file description @@ -265,11 +265,28 @@ class OpenLPWizard(QtGui.QWizard): if filters: filters += u';;' filters += u'%s (*)' % UiStrings().AllFiles - filename = QtGui.QFileDialog.getOpenFileName(self, title, + filename = unicode(QtGui.QFileDialog.getOpenFileName(self, title, os.path.dirname(SettingsManager.get_last_dir( - self.plugin.settingsSection, 1)), filters) + self.plugin.settingsSection, 1)), filters)) if filename: editbox.setText(filename) SettingsManager.set_last_dir(self.plugin.settingsSection, filename, 1) + def getFolder(self, title, editbox): + """ + Opens a QFileDialog and saves the selected folder to the given editbox. + + ``title`` + The title of the dialog (unicode). + + ``editbox`` + An editbox (QLineEdit). + """ + folder = unicode(QtGui.QFileDialog.getExistingDirectory(self, title, + os.path.dirname(SettingsManager.get_last_dir( + self.plugin.settingsSection, 1)), QtGui.QFileDialog.ShowDirsOnly)) + if folder: + editbox.setText(folder) + SettingsManager.set_last_dir(self.plugin.settingsSection, + folder, 1) \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 397b52cfc..dcca098dc 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -363,11 +363,5 @@ class SongExportForm(OpenLPWizard): Called when the *directoryButton* was clicked. Opens a dialog and writes the path to *directoryLineEdit*. """ - path = unicode(QtGui.QFileDialog.getExistingDirectory(self, - translate('SongsPlugin.ExportWizardForm', - 'Select Destination Folder'), - SettingsManager.get_last_dir(self.plugin.settingsSection, 1), - options=QtGui.QFileDialog.ShowDirsOnly)) - SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) - self.directoryLineEdit.setText(path) - + self.getFolder(translate('SongsPlugin.ExportWizardForm', + 'Select Destination Folder'), self.directoryLineEdit)