add external database setting

This commit is contained in:
rimach 2010-05-21 00:21:49 +02:00
parent d6e4f343fc
commit 7c9044e542
2 changed files with 61 additions and 1 deletions

View File

@ -98,6 +98,27 @@ class GeneralTab(SettingsTab):
self.ShowSplashCheckBox.setObjectName(u'ShowSplashCheckBox') self.ShowSplashCheckBox.setObjectName(u'ShowSplashCheckBox')
self.StartupLayout.addWidget(self.ShowSplashCheckBox) self.StartupLayout.addWidget(self.ShowSplashCheckBox)
self.GeneralLeftLayout.addWidget(self.StartupGroupBox) self.GeneralLeftLayout.addWidget(self.StartupGroupBox)
self.DataBaseGroupBox = QtGui.QGroupBox(self.GeneralLeftWidget)
self.DataBaseGroupBox.setObjectName("DataBaseGroupBox")
self.verticalLayout_2 = QtGui.QVBoxLayout(self.DataBaseGroupBox)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.DataBaseCheckBox = QtGui.QCheckBox(self.DataBaseGroupBox)
self.DataBaseCheckBox.setObjectName("DataBaseCheckBox")
self.verticalLayout_2.addWidget(self.DataBaseCheckBox)
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.DataBaseButton = QtGui.QPushButton(self.DataBaseGroupBox)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/general/general_open.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DataBaseButton.setIcon(icon1)
self.DataBaseButton.setObjectName("DataBaseButton")
self.horizontalLayout_2.addWidget(self.DataBaseButton)
self.DataBasePath = QtGui.QLineEdit(self.DataBaseGroupBox)
self.DataBasePath.setReadOnly(True)
self.DataBasePath.setObjectName("DataBasePath")
self.horizontalLayout_2.addWidget(self.DataBasePath)
self.verticalLayout_2.addLayout(self.horizontalLayout_2)
self.GeneralLeftLayout.addWidget(self.DataBaseGroupBox)
self.SettingsGroupBox = QtGui.QGroupBox(self.GeneralLeftWidget) self.SettingsGroupBox = QtGui.QGroupBox(self.GeneralLeftWidget)
self.SettingsGroupBox.setObjectName(u'SettingsGroupBox') self.SettingsGroupBox.setObjectName(u'SettingsGroupBox')
self.SettingsLayout = QtGui.QVBoxLayout(self.SettingsGroupBox) self.SettingsLayout = QtGui.QVBoxLayout(self.SettingsGroupBox)
@ -164,6 +185,11 @@ class GeneralTab(SettingsTab):
QtCore.QObject.connect(self.ShowSplashCheckBox, QtCore.QObject.connect(self.ShowSplashCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), QtCore.SIGNAL(u'stateChanged(int)'),
self.onShowSplashCheckBoxChanged) self.onShowSplashCheckBoxChanged)
QtCore.QObject.connect(self.DataBaseCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onDataBaseCheckBoxChanged)
QtCore.QObject.connect(self.DataBaseButton,
QtCore.SIGNAL(u'clicked()'), self.onDataBaseButtonClicked)
QtCore.QObject.connect(self.SaveCheckServiceCheckBox, QtCore.QObject.connect(self.SaveCheckServiceCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), QtCore.SIGNAL(u'stateChanged(int)'),
self.onSaveCheckServiceCheckBox) self.onSaveCheckServiceCheckBox)
@ -188,6 +214,12 @@ class GeneralTab(SettingsTab):
self.trUtf8('Automatically open the last service')) self.trUtf8('Automatically open the last service'))
self.ShowSplashCheckBox.setText(self.trUtf8('Show the splash screen')) self.ShowSplashCheckBox.setText(self.trUtf8('Show the splash screen'))
self.SettingsGroupBox.setTitle(self.trUtf8('Application Settings')) self.SettingsGroupBox.setTitle(self.trUtf8('Application Settings'))
self.DataBaseGroupBox.setTitle(QtGui.QApplication.translate(
"SettingsDialog", "DataBaseBox",
None, QtGui.QApplication.UnicodeUTF8))
self.DataBaseCheckBox.setText(QtGui.QApplication.translate(
"SettingsDialog", "Use external Database",
None, QtGui.QApplication.UnicodeUTF8))
self.SaveCheckServiceCheckBox.setText( self.SaveCheckServiceCheckBox.setText(
self.trUtf8('Prompt to save Service before starting New')) self.trUtf8('Prompt to save Service before starting New'))
self.AutoPreviewCheckBox.setText( self.AutoPreviewCheckBox.setText(
@ -215,6 +247,19 @@ class GeneralTab(SettingsTab):
def onSaveCheckServiceCheckBox(self, value): def onSaveCheckServiceCheckBox(self, value):
self.PromptSaveService = (value == QtCore.Qt.Checked) self.PromptSaveService = (value == QtCore.Qt.Checked)
def onDataBaseCheckBoxChanged(self, value):
self.ExtDbUsage = (value == QtCore.Qt.Checked)
self.DataBasePath.setEnabled(value == QtCore.Qt.Checked)
def onDataBaseButtonClicked(self):
options = QtGui.QFileDialog.DontResolveSymlinks | QtGui.QFileDialog.ShowDirsOnly
directory = QtGui.QFileDialog.getExistingDirectory(self,
self.trUtf8('QFileDialog.getExistingDirectory()'),
self.DataBasePath.text(), options)
if not directory.isEmpty():
self.DataBasePath.setText(directory)
self.ExtDbPath = self.DataBasePath.text()
def onAutoPreviewCheckBox(self, value): def onAutoPreviewCheckBox(self, value):
self.AutoPreview = (value == QtCore.Qt.Checked) self.AutoPreview = (value == QtCore.Qt.Checked)
@ -239,6 +284,10 @@ class GeneralTab(SettingsTab):
# Get the configs # Get the configs
self.Warning = settings.value( self.Warning = settings.value(
u'blank warning', QtCore.QVariant(False)).toBool() u'blank warning', QtCore.QVariant(False)).toBool()
self.ExtDbUsage = settings.value(
u'ext db usage', QtCore.QVariant(False)).toBool()
self.ExtDbPath = unicode(settings.value(
u'ext db path', QtCore.QVariant(u'')).toString())
self.AutoOpen = settings.value( self.AutoOpen = settings.value(
u'auto open', QtCore.QVariant(False)).toBool() u'auto open', QtCore.QVariant(False)).toBool()
self.ShowSplash = settings.value( self.ShowSplash = settings.value(
@ -259,6 +308,9 @@ class GeneralTab(SettingsTab):
self.MonitorComboBox.setCurrentIndex(self.MonitorNumber) self.MonitorComboBox.setCurrentIndex(self.MonitorNumber)
self.DisplayOnMonitorCheck.setChecked(self.DisplayOnMonitor) self.DisplayOnMonitorCheck.setChecked(self.DisplayOnMonitor)
self.WarningCheckBox.setChecked(self.Warning) self.WarningCheckBox.setChecked(self.Warning)
self.DataBaseCheckBox.setChecked(self.ExtDbUsage)
self.DataBasePath.setText(self.ExtDbPath)
self.DataBasePath.setEnabled(self.ExtDbUsage)
self.AutoOpenCheckBox.setChecked(self.AutoOpen) self.AutoOpenCheckBox.setChecked(self.AutoOpen)
self.ShowSplashCheckBox.setChecked(self.ShowSplash) self.ShowSplashCheckBox.setChecked(self.ShowSplash)
self.AutoPreviewCheckBox.setChecked(self.AutoPreview) self.AutoPreviewCheckBox.setChecked(self.AutoPreview)
@ -273,6 +325,8 @@ class GeneralTab(SettingsTab):
settings.setValue(u'display on monitor', settings.setValue(u'display on monitor',
QtCore.QVariant(self.DisplayOnMonitor)) QtCore.QVariant(self.DisplayOnMonitor))
settings.setValue(u'blank warning', QtCore.QVariant(self.Warning)) settings.setValue(u'blank warning', QtCore.QVariant(self.Warning))
settings.setValue(u'ext db usage', QtCore.QVariant(self.ExtDbUsage))
settings.setValue(u'ext db path', QtCore.QVariant(self.ExtDbPath))
settings.setValue(u'auto open', QtCore.QVariant(self.AutoOpen)) settings.setValue(u'auto open', QtCore.QVariant(self.AutoOpen))
settings.setValue(u'show splash', QtCore.QVariant(self.ShowSplash)) settings.setValue(u'show splash', QtCore.QVariant(self.ShowSplash))
settings.setValue(u'save prompt', settings.setValue(u'save prompt',

View File

@ -70,7 +70,13 @@ class AppLocation(object):
path = os.path.join(os.getenv(u'HOME'), u'.openlp') path = os.path.join(os.getenv(u'HOME'), u'.openlp')
return path return path
elif dir_type == AppLocation.DataDir: elif dir_type == AppLocation.DataDir:
if sys.platform == u'win32': settings = QtCore.QSettings()
settings.beginGroup(u'general')
extDbPath = settings.value(u'ext db path', QtCore.QVariant(u'')).toString()
if settings.value(u'ext db usage', QtCore.QVariant(False)).toBool()\
and QtCore.QDir(extDbPath).exists():
path = os.path.abspath(str(settings.value(u'ext db path', QtCore.QVariant(u'')).toString()))
elif sys.platform == u'win32':
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data') path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif sys.platform == u'darwin': elif sys.platform == u'darwin':
path = os.path.join(os.getenv(u'HOME'), u'Library', path = os.path.join(os.getenv(u'HOME'), u'Library',