← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~crichter/openlp/testing into lp:openlp

 

rimach has proposed merging lp:~crichter/openlp/testing into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


I added the possibility to use an external database. Please review and commit if it is ok.
-- 
https://code.launchpad.net/~crichter/openlp/testing/+merge/25728
Your team OpenLP Core is requested to review the proposed merge of lp:~crichter/openlp/testing into lp:openlp.
=== modified file 'openlp/core/ui/generaltab.py'
--- openlp/core/ui/generaltab.py	2010-05-05 17:35:11 +0000
+++ openlp/core/ui/generaltab.py	2010-05-20 22:27:24 +0000
@@ -98,6 +98,27 @@
         self.ShowSplashCheckBox.setObjectName(u'ShowSplashCheckBox')
         self.StartupLayout.addWidget(self.ShowSplashCheckBox)
         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.setObjectName(u'SettingsGroupBox')
         self.SettingsLayout = QtGui.QVBoxLayout(self.SettingsGroupBox)
@@ -164,6 +185,11 @@
         QtCore.QObject.connect(self.ShowSplashCheckBox,
             QtCore.SIGNAL(u'stateChanged(int)'),
             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.SIGNAL(u'stateChanged(int)'),
             self.onSaveCheckServiceCheckBox)
@@ -188,6 +214,12 @@
             self.trUtf8('Automatically open the last service'))
         self.ShowSplashCheckBox.setText(self.trUtf8('Show the splash screen'))
         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.trUtf8('Prompt to save Service before starting New'))
         self.AutoPreviewCheckBox.setText(
@@ -215,6 +247,19 @@
     def onSaveCheckServiceCheckBox(self, value):
         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):
         self.AutoPreview = (value == QtCore.Qt.Checked)
 
@@ -239,6 +284,10 @@
         # Get the configs
         self.Warning = settings.value(
             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(
             u'auto open', QtCore.QVariant(False)).toBool()
         self.ShowSplash = settings.value(
@@ -259,6 +308,9 @@
         self.MonitorComboBox.setCurrentIndex(self.MonitorNumber)
         self.DisplayOnMonitorCheck.setChecked(self.DisplayOnMonitor)
         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.ShowSplashCheckBox.setChecked(self.ShowSplash)
         self.AutoPreviewCheckBox.setChecked(self.AutoPreview)
@@ -273,6 +325,8 @@
         settings.setValue(u'display on monitor',
             QtCore.QVariant(self.DisplayOnMonitor))
         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'show splash', QtCore.QVariant(self.ShowSplash))
         settings.setValue(u'save prompt',

=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2010-04-30 19:23:02 +0000
+++ openlp/core/utils/__init__.py	2010-05-20 22:27:24 +0000
@@ -70,7 +70,13 @@
                     path = os.path.join(os.getenv(u'HOME'), u'.openlp')
             return path
         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')
             elif sys.platform == u'darwin':
                 path = os.path.join(os.getenv(u'HOME'), u'Library',


Follow ups