Added getFolder to OpenLPWizard

This commit is contained in:
Samuel Findlay 2012-05-07 20:36:39 +10:00
parent be26adc0b8
commit bf4dcdde92
2 changed files with 22 additions and 11 deletions

View File

@ -254,7 +254,7 @@ class OpenLPWizard(QtGui.QWizard):
The title of the dialog (unicode). The title of the dialog (unicode).
``editbox`` ``editbox``
A editbox (QLineEdit). An editbox (QLineEdit).
``filters`` ``filters``
The file extension filters. It should contain the file description The file extension filters. It should contain the file description
@ -265,11 +265,28 @@ class OpenLPWizard(QtGui.QWizard):
if filters: if filters:
filters += u';;' filters += u';;'
filters += u'%s (*)' % UiStrings().AllFiles 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( os.path.dirname(SettingsManager.get_last_dir(
self.plugin.settingsSection, 1)), filters) self.plugin.settingsSection, 1)), filters))
if filename: if filename:
editbox.setText(filename) editbox.setText(filename)
SettingsManager.set_last_dir(self.plugin.settingsSection, SettingsManager.set_last_dir(self.plugin.settingsSection,
filename, 1) 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)

View File

@ -363,11 +363,5 @@ class SongExportForm(OpenLPWizard):
Called when the *directoryButton* was clicked. Opens a dialog and writes Called when the *directoryButton* was clicked. Opens a dialog and writes
the path to *directoryLineEdit*. the path to *directoryLineEdit*.
""" """
path = unicode(QtGui.QFileDialog.getExistingDirectory(self, self.getFolder(translate('SongsPlugin.ExportWizardForm',
translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), self.directoryLineEdit)
'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)