forked from openlp/openlp
fixed up wizard
This commit is contained in:
parent
5b6326e2ac
commit
bf4c1dafb4
@ -177,6 +177,8 @@ class Plugin(QtCore.QObject):
|
||||
# Add the default status to the default settings.
|
||||
default_settings[name + u'/status'] = PluginStatus.Inactive
|
||||
default_settings[name + u'/last directory'] = u''
|
||||
# Append a setting for files in the mediamanager (note not all plugins
|
||||
# which have a mediamanager need this).
|
||||
if media_item_class is not None:
|
||||
default_settings[u'%s/%s files' % (name, name)] = []
|
||||
# Add settings to the dict of all settings.
|
||||
|
@ -232,10 +232,11 @@ class Settings(QtCore.QSettings):
|
||||
(u'bibles/bookname language', u'bibles/book name language', []),
|
||||
(u'general/enable slide loop', u'advanced/slide limits', [(SlideLimits.Wrap, True), (SlideLimits.End, False)]),
|
||||
(u'themes/last directory', u'themes/last directory import', []),
|
||||
(u'themes/last directory 1', u'themes/last directory export', [])
|
||||
(u'themes/last directory 1', u'themes/last directory export', []),
|
||||
(u'servicemanager/last directory', u'', [])
|
||||
# songusage/last directory 1 -> songusage/last directory export
|
||||
# bibles/last directory 1 -> bibles/last directory backup
|
||||
# songs/last directory 1 -> songs/last directory import
|
||||
# bibles/last directory 1 -> bibles/last directory import
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, Receiver, SettingsManager, translate, UiStrings
|
||||
from openlp.core.lib import build_icon, Receiver, Settings, translate, UiStrings
|
||||
from openlp.core.lib.ui import add_welcome_page
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -235,7 +235,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
self.cancelButton.setVisible(False)
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def getFileName(self, title, editbox, filters=u''):
|
||||
def getFileName(self, title, editbox, setting_name, filters=u''):
|
||||
"""
|
||||
Opens a QFileDialog and saves the filename to the given editbox.
|
||||
|
||||
@ -245,6 +245,9 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
``editbox``
|
||||
An editbox (QLineEdit).
|
||||
|
||||
``setting_name``
|
||||
The place where to save the last opened directory.
|
||||
|
||||
``filters``
|
||||
The file extension filters. It should contain the file description
|
||||
as well as the file extension. For example::
|
||||
@ -255,12 +258,12 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
filters += u';;'
|
||||
filters += u'%s (*)' % UiStrings().AllFiles
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self, title,
|
||||
os.path.dirname(Settings().value(self.plugin.settingsSection + u'/last directory 1')), filters)
|
||||
os.path.dirname(Settings().value(self.plugin.settingsSection + u'/' + setting_name)), filters)
|
||||
if filename:
|
||||
editbox.setText(filename)
|
||||
Settings().setValue(self.plugin.settingsSection + u'/last directory 1', filename)
|
||||
Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, filename)
|
||||
|
||||
def getFolder(self, title, editbox):
|
||||
def getFolder(self, title, editbox, setting_name):
|
||||
"""
|
||||
Opens a QFileDialog and saves the selected folder to the given editbox.
|
||||
|
||||
@ -269,10 +272,18 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
|
||||
``editbox``
|
||||
An editbox (QLineEdit).
|
||||
|
||||
``setting_name``
|
||||
The place where to save the last opened directory.
|
||||
"""
|
||||
print setting_name
|
||||
print u'asdf', Settings().value(self.plugin.settingsSection + u'/' + setting_name)
|
||||
|
||||
folder = QtGui.QFileDialog.getExistingDirectory(self, title,
|
||||
os.path.dirname(Settings().value(self.plugin.settingsSection + u'/last directory 1')),
|
||||
QtGui.QFileDialog.ShowDirsOnly)
|
||||
Settings().value(self.plugin.settingsSection + u'/' + setting_name),
|
||||
QtGui.QFileDialog.ShowDirsOnly)
|
||||
print os.path.dirname(Settings().value(self.plugin.settingsSection + u'/' + setting_name))
|
||||
if folder:
|
||||
editbox.setText(folder)
|
||||
Settings().setValue(self.plugin.settingsSection + u'/last directory 1', folder)
|
||||
print folder
|
||||
Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, folder)
|
||||
|
@ -61,7 +61,7 @@ __default_settings__ = {
|
||||
u'bibles/range separator': u'',
|
||||
u'bibles/list separator': u'',
|
||||
u'bibles/end separator': u'',
|
||||
u'bibles/last directory backup': u''
|
||||
u'bibles/last directory import': u''
|
||||
}
|
||||
|
||||
|
||||
|
@ -469,34 +469,34 @@ class BibleImportForm(OpenLPWizard):
|
||||
"""
|
||||
Show the file open dialog for the OSIS file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit)
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit, u'last directory import')
|
||||
|
||||
def onCsvBooksBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the books CSV file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'%s (*.csv)'
|
||||
% translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'last directory import',
|
||||
u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
|
||||
def onCsvVersesBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the verses CSV file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, u'%s (*.csv)'
|
||||
% translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, u'last directory import',
|
||||
u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
|
||||
def onOpenSongBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the OpenSong file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit)
|
||||
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, u'last directory import')
|
||||
|
||||
def onOpenlp1BrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the openlp.org 1.x file.
|
||||
"""
|
||||
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'%s (*.bible)' %
|
||||
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files'))
|
||||
self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'last directory import',
|
||||
u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files'))
|
||||
|
||||
def registerFields(self):
|
||||
"""
|
||||
|
@ -116,11 +116,9 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
Show the file open dialog for the OSIS file.
|
||||
"""
|
||||
filename = QtGui.QFileDialog.getExistingDirectory(self,
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'),
|
||||
os.path.dirname(Settings(self.plugin.settingsSection).value(u'last directory backup')))
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'), u'')
|
||||
if filename:
|
||||
self.backupDirectoryEdit.setText(filename)
|
||||
Settings(self.plugin.settingsSection).setValue(u'last directory backup', filename)
|
||||
|
||||
def onNoBackupCheckBoxToggled(self, checked):
|
||||
"""
|
||||
|
@ -331,4 +331,5 @@ class SongExportForm(OpenLPWizard):
|
||||
Called when the *directoryButton* was clicked. Opens a dialog and writes
|
||||
the path to *directoryLineEdit*.
|
||||
"""
|
||||
self.getFolder(translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), self.directoryLineEdit)
|
||||
self.getFolder(translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'),
|
||||
self.directoryLineEdit, u'last directory export')
|
||||
|
@ -276,9 +276,9 @@ class SongImportForm(OpenLPWizard):
|
||||
u'name', u'filter')
|
||||
filepathEdit = self.formatWidgets[format][u'filepathEdit']
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, filter)
|
||||
self.getFileName(WizardStrings.OpenTypeFile % format_name, filepathEdit, u'last directory import', filter)
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit)
|
||||
self.getFolder(WizardStrings.OpenTypeFolder % format_name, filepathEdit, u'last directory import')
|
||||
|
||||
def onAddButtonClicked(self):
|
||||
format = self.currentFormat
|
||||
|
@ -54,7 +54,8 @@ __default_settings__ = {
|
||||
u'songs/search as type': False,
|
||||
u'songs/add song from service': True,
|
||||
u'songs/display songbar': True,
|
||||
u'songs/last directory import': u''
|
||||
u'songs/last directory import': u'',
|
||||
u'songs/last directory export': u''
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user