From 9239c0cdf3bdc52137701516c79d01fdbb5f5782 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 24 Jan 2010 23:16:15 +0000 Subject: [PATCH 01/25] Cleanups --- openlp/core/lib/rendermanager.py | 2 +- openlp/core/ui/__init__.py | 2 +- openlp/core/ui/aboutform.py | 1 - openlp/core/ui/maindisplay.py | 1 - openlp/core/ui/servicemanager.py | 4 ++-- openlp/core/ui/thememanager.py | 4 ++-- openlp/plugins/bibles/forms/importwizardform.py | 1 - openlp/plugins/bibles/lib/bibleOpenSongimpl.py | 4 +--- openlpcnv.pyw | 2 +- 9 files changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 78e99506a..b47eaa313 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -25,7 +25,7 @@ import logging -from PyQt4 import QtGui, QtCore +from PyQt4 import QtCore from renderer import Renderer from openlp.core.lib import ThemeLevel, resize_image diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 42f232638..5d4c798d8 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -42,4 +42,4 @@ from mainwindow import MainWindow __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', - 'AmendThemeForm', 'MediaDockManager', 'ThemeLevel'] + 'AmendThemeForm', 'MediaDockManager'] diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index d6a97e2c9..c3eb7bdcb 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -25,7 +25,6 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon from aboutdialog import Ui_AboutDialog class AboutForm(QtGui.QDialog, Ui_AboutDialog): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index a4ff53567..11b89743d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -25,7 +25,6 @@ import logging import os -import time from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 44170e616..514e39077 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -30,8 +30,8 @@ import zipfile from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ - ServiceItemType, contextMenuAction, contextMenuSeparator, contextMenu, \ - Receiver, contextMenu, str_to_bool + contextMenuAction, contextMenuSeparator, contextMenu, Receiver, \ + contextMenu, str_to_bool class ServiceManagerList(QtGui.QTreeWidget): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b2288f75a..298f5ab23 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -34,8 +34,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AmendThemeForm from openlp.core.theme import Theme from openlp.core.lib import PluginConfig, OpenLPToolbar, contextMenuAction, \ - ThemeXML, ThemeLevel, str_to_bool, get_text_file_string, build_icon, \ - Receiver, contextMenuSeparator + ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ + contextMenuSeparator from openlp.core.utils import ConfigHelper class ThemeManager(QtGui.QWidget): diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 7e82b6b7f..da95d968f 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -26,7 +26,6 @@ import logging import os import os.path -from time import sleep from PyQt4 import QtCore, QtGui diff --git a/openlp/plugins/bibles/lib/bibleOpenSongimpl.py b/openlp/plugins/bibles/lib/bibleOpenSongimpl.py index 4d171d57c..575d1bf0b 100644 --- a/openlp/plugins/bibles/lib/bibleOpenSongimpl.py +++ b/openlp/plugins/bibles/lib/bibleOpenSongimpl.py @@ -23,13 +23,11 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import os -import os.path import logging import chardet import codecs -from lxml import objectify +from lxml import objectify from PyQt4 import QtCore from openlp.core.lib import Receiver diff --git a/openlpcnv.pyw b/openlpcnv.pyw index 877e74744..8c3a8bcf5 100755 --- a/openlpcnv.pyw +++ b/openlpcnv.pyw @@ -147,4 +147,4 @@ if __name__ == u'__main__': newdb = os.path.join(newpath, u'songs.sqlite') mig.convert_sqlite2_to_3(olddb, newdb) mig.process() - #mig.move_log_file() \ No newline at end of file + #mig.move_log_file() From 508f68e175e72db25e52659d9403055d086a8484 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 9 Feb 2010 12:36:41 +0000 Subject: [PATCH 02/25] Rename forms to correct name. Refactor UI to simplify it --- .../forms/{auditdeletedialog.ui => songusagedeletedialog.ui} | 0 .../forms/{auditdetaildialog.ui => songusagedetaildialog.ui} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename resources/forms/{auditdeletedialog.ui => songusagedeletedialog.ui} (100%) rename resources/forms/{auditdetaildialog.ui => songusagedetaildialog.ui} (100%) diff --git a/resources/forms/auditdeletedialog.ui b/resources/forms/songusagedeletedialog.ui similarity index 100% rename from resources/forms/auditdeletedialog.ui rename to resources/forms/songusagedeletedialog.ui diff --git a/resources/forms/auditdetaildialog.ui b/resources/forms/songusagedetaildialog.ui similarity index 100% rename from resources/forms/auditdetaildialog.ui rename to resources/forms/songusagedetaildialog.ui From 643801ae05531985bdbaab2f27c8e81b51b413d1 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 9 Feb 2010 14:44:36 +0000 Subject: [PATCH 03/25] New alert tag features and song usage dialog --- openlp/core/ui/alertstab.py | 45 +- .../songusage/forms/songusagedetaildialog.py | 228 +++------- resources/forms/songusagedetaildialog.ui | 392 +++--------------- 3 files changed, 158 insertions(+), 507 deletions(-) diff --git a/openlp/core/ui/alertstab.py b/openlp/core/ui/alertstab.py index d2e38e048..c5dc1976d 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/core/ui/alertstab.py @@ -83,6 +83,22 @@ class AlertsTab(SettingsTab): self.BackgroundColorButton.setObjectName(u'BackgroundColorButton') self.ColorLayout.addWidget(self.BackgroundColorButton) self.FontLayout.addWidget(self.ColorWidget) + self.FontSizeWidget = QtGui.QWidget(self.FontGroupBox) + self.FontSizeWidget.setObjectName(u'FontSizeWidget') + self.FontSizeLayout = QtGui.QHBoxLayout(self.FontSizeWidget) + self.FontSizeLayout.setSpacing(8) + self.FontSizeLayout.setMargin(0) + self.FontSizeLayout.setObjectName(u'FontSizeLayout') + self.FontSizeLabel = QtGui.QLabel(self.FontSizeWidget) + self.FontSizeLabel.setObjectName(u'FontSizeLabel') + self.FontSizeLayout.addWidget(self.FontSizeLabel) + self.FontSizeSpinBox = QtGui.QSpinBox(self.FontSizeWidget) + self.FontSizeSpinBox.setObjectName(u'FontSizeSpinBox') + self.FontSizeLayout.addWidget(self.FontSizeSpinBox) + self.FontSizeSpacer = QtGui.QSpacerItem(147, 20, + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.FontSizeLayout.addItem(self.FontSizeSpacer) + self.FontLayout.addWidget(self.FontSizeWidget) self.TimeoutWidget = QtGui.QWidget(self.FontGroupBox) self.TimeoutWidget.setObjectName(u'TimeoutWidget') self.TimeoutLayout = QtGui.QHBoxLayout(self.TimeoutWidget) @@ -100,6 +116,22 @@ class AlertsTab(SettingsTab): QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.TimeoutLayout.addItem(self.TimeoutSpacer) self.FontLayout.addWidget(self.TimeoutWidget) + self.LocationWidget = QtGui.QWidget(self.FontGroupBox) + self.LocationWidget.setObjectName(u'LocationWidget') + self.LocationLayout = QtGui.QHBoxLayout(self.LocationWidget) + self.LocationLayout.setSpacing(8) + self.LocationLayout.setMargin(0) + self.LocationLayout.setObjectName(u'LocationLayout') + self.LocationLabel = QtGui.QLabel(self.LocationWidget) + self.LocationLabel.setObjectName(u'LocationLabel') + self.LocationLayout.addWidget(self.LocationLabel) + self.LocationComboBox = QtGui.QComboBox(self.LocationWidget) + self.LocationComboBox.setObjectName(u'LocationComboBox') + self.LocationLayout.addWidget(self.LocationComboBox) + self.LocationSpacer = QtGui.QSpacerItem(147, 20, + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.LocationLayout.addItem(self.LocationSpacer) + self.FontLayout.addWidget(self.LocationWidget) self.SlideLeftLayout.addWidget(self.FontGroupBox) self.SlideLeftSpacer = QtGui.QSpacerItem(20, 94, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) @@ -152,10 +184,15 @@ class AlertsTab(SettingsTab): self.FontLabel.setText(self.trUtf8('Font Name:')) self.FontColorLabel.setText(self.trUtf8('Font Color:')) self.BackgroundColorLabel.setText(self.trUtf8('Background Color:')) + self.FontSizeLabel.setText(self.trUtf8('Font Size:')) + self.FontSizeSpinBox.setSuffix(self.trUtf8('pt')) self.TimeoutLabel.setText(self.trUtf8('Alert timeout:')) self.TimeoutSpinBox.setSuffix(self.trUtf8('s')) + self.LocationLabel.setText(self.trUtf8('Location:')) self.PreviewGroupBox.setTitle(self.trUtf8('Preview')) self.FontPreview.setText(self.trUtf8('openlp.org 2.0 rocks!')) + self.LocationComboBox.addItem(self.trUtf8('Top')) + self.LocationComboBox.addItem(self.trUtf8('Bottom')) def onBackgroundColorButtonClicked(self): self.bg_color = QtGui.QColorDialog.getColor( @@ -181,15 +218,19 @@ class AlertsTab(SettingsTab): self.timeout = int(self.config.get_config(u'timeout', 5)) self.font_color = unicode( self.config.get_config(u'font color', u'#ffffff')) + self.font_size = int(self.config.get_config(u'font size', 40)) self.bg_color = unicode( self.config.get_config(u'background color', u'#660000')) self.font_face = unicode( self.config.get_config(u'font face', QtGui.QFont().family())) + self.location = int(self.config.get_config(u'location', 0)) + self.FontSizeSpinBox.setValue(self.font_size) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet( u'background-color: %s' % self.font_color) self.BackgroundColorButton.setStyleSheet( u'background-color: %s' % self.bg_color) + self.LocationComboBox.setCurrentIndex(self.location) font = QtGui.QFont() font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) @@ -199,8 +240,10 @@ class AlertsTab(SettingsTab): self.font_face = self.FontComboBox.currentFont().family() self.config.set_config(u'background color', unicode(self.bg_color)) self.config.set_config(u'font color', unicode(self.font_color)) + self.config.set_config(u'font size', unicode(self.font_size)) self.config.set_config(u'font face', unicode(self.font_face)) self.config.set_config(u'timeout', unicode(self.timeout)) + self.config.set_config(u'location', unicode(self.FontComboBox.currentIndex())) def updateDisplay(self): font = QtGui.QFont() @@ -209,4 +252,4 @@ class AlertsTab(SettingsTab): font.setPointSize(16) self.FontPreview.setFont(font) self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % \ - (self.bg_color, self.font_color)) \ No newline at end of file + (self.bg_color, self.font_color)) diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index bfb2efcaf..a191b8f08 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -1,197 +1,71 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # -# Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### +# Form implementation generated from reading ui file 'songusagedetaildialog.ui' +# +# Created: Tue Feb 9 07:34:05 2010 +# by: PyQt4 UI code generator 4.6.2 +# +# WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui -class Ui_SongUsageDetailDialog(object): +class Ui_AuditDetailDialog(object): def setupUi(self, AuditDetailDialog): - AuditDetailDialog.setObjectName(u'AuditDetailDialog') - AuditDetailDialog.resize(593, 501) - self.buttonBox = QtGui.QDialogButtonBox(AuditDetailDialog) - self.buttonBox.setGeometry(QtCore.QRect(420, 470, 170, 25)) - self.buttonBox.setStandardButtons( - QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(u'buttonBox') - self.FileGroupBox = QtGui.QGroupBox(AuditDetailDialog) - self.FileGroupBox.setGeometry(QtCore.QRect(10, 370, 571, 70)) - self.FileGroupBox.setObjectName(u'FileGroupBox') + AuditDetailDialog.setObjectName("AuditDetailDialog") + AuditDetailDialog.resize(609, 413) + self.verticalLayout = QtGui.QVBoxLayout(AuditDetailDialog) + self.verticalLayout.setObjectName("verticalLayout") + self.DateRangeGroupBox = QtGui.QGroupBox(AuditDetailDialog) + self.DateRangeGroupBox.setObjectName("DateRangeGroupBox") + self.verticalLayout_2 = QtGui.QVBoxLayout(self.DateRangeGroupBox) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.DateHorizontalLayout = QtGui.QHBoxLayout() + self.DateHorizontalLayout.setObjectName("DateHorizontalLayout") + self.FromDate = QtGui.QCalendarWidget(self.DateRangeGroupBox) + self.FromDate.setObjectName("FromDate") + self.DateHorizontalLayout.addWidget(self.FromDate) + self.ToLabel = QtGui.QLabel(self.DateRangeGroupBox) + self.ToLabel.setScaledContents(False) + self.ToLabel.setAlignment(QtCore.Qt.AlignCenter) + self.ToLabel.setObjectName("ToLabel") + self.DateHorizontalLayout.addWidget(self.ToLabel) + self.ToDate = QtGui.QCalendarWidget(self.DateRangeGroupBox) + self.ToDate.setObjectName("ToDate") + self.DateHorizontalLayout.addWidget(self.ToDate) + self.verticalLayout_2.addLayout(self.DateHorizontalLayout) + self.FileGroupBox = QtGui.QGroupBox(self.DateRangeGroupBox) + self.FileGroupBox.setObjectName("FileGroupBox") self.verticalLayout_4 = QtGui.QVBoxLayout(self.FileGroupBox) - self.verticalLayout_4.setObjectName(u'verticalLayout_4') + self.verticalLayout_4.setObjectName("verticalLayout_4") self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(u'horizontalLayout') + self.horizontalLayout.setObjectName("horizontalLayout") self.FileLineEdit = QtGui.QLineEdit(self.FileGroupBox) - self.FileLineEdit.setObjectName(u'FileLineEdit') + self.FileLineEdit.setObjectName("FileLineEdit") self.horizontalLayout.addWidget(self.FileLineEdit) self.SaveFilePushButton = QtGui.QPushButton(self.FileGroupBox) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/exports/export_load.png'), - QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(":/exports/export_load.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.SaveFilePushButton.setIcon(icon) - self.SaveFilePushButton.setObjectName(u'SaveFilePushButton') + self.SaveFilePushButton.setObjectName("SaveFilePushButton") self.horizontalLayout.addWidget(self.SaveFilePushButton) self.verticalLayout_4.addLayout(self.horizontalLayout) - self.layoutWidget = QtGui.QWidget(AuditDetailDialog) - self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 561, 361)) - self.layoutWidget.setObjectName(u'layoutWidget') - self.verticalLayout_3 = QtGui.QVBoxLayout(self.layoutWidget) - self.verticalLayout_3.setObjectName(u'verticalLayout_3') - self.ReportTypeGroup = QtGui.QGroupBox(self.layoutWidget) - self.ReportTypeGroup.setObjectName(u'ReportTypeGroup') - self.layoutWidget1 = QtGui.QWidget(self.ReportTypeGroup) - self.layoutWidget1.setGeometry(QtCore.QRect(50, 40, 481, 23)) - self.layoutWidget1.setObjectName(u'layoutWidget1') - self.ReportHorizontalLayout = QtGui.QHBoxLayout(self.layoutWidget1) - self.ReportHorizontalLayout.setObjectName(u'ReportHorizontalLayout') - self.SummaryReport = QtGui.QRadioButton(self.layoutWidget1) - self.SummaryReport.setObjectName(u'SummaryReport') - self.ReportHorizontalLayout.addWidget(self.SummaryReport) - self.DetailedReport = QtGui.QRadioButton(self.layoutWidget1) - self.DetailedReport.setChecked(True) - self.DetailedReport.setObjectName(u'DetailedReport') - self.ReportHorizontalLayout.addWidget(self.DetailedReport) - self.verticalLayout_3.addWidget(self.ReportTypeGroup) - self.DateRangeGroupBox = QtGui.QGroupBox(self.layoutWidget) - self.DateRangeGroupBox.setObjectName(u'DateRangeGroupBox') - self.verticalLayout_2 = QtGui.QVBoxLayout(self.DateRangeGroupBox) - self.verticalLayout_2.setObjectName(u'verticalLayout_2') - self.DateHorizontalLayout = QtGui.QHBoxLayout() - self.DateHorizontalLayout.setObjectName(u'DateHorizontalLayout') - self.FromDateEdit = QtGui.QDateEdit(self.DateRangeGroupBox) - self.FromDateEdit.setCalendarPopup(True) - self.FromDateEdit.setObjectName(u'FromDateEdit') - self.DateHorizontalLayout.addWidget(self.FromDateEdit) - self.To = QtGui.QLabel(self.DateRangeGroupBox) - self.To.setObjectName(u'To') - self.DateHorizontalLayout.addWidget(self.To) - self.ToDateEdit = QtGui.QDateEdit(self.DateRangeGroupBox) - self.ToDateEdit.setCalendarPopup(True) - self.ToDateEdit.setObjectName(u'ToDateEdit') - self.DateHorizontalLayout.addWidget(self.ToDateEdit) - self.verticalLayout_2.addLayout(self.DateHorizontalLayout) - self.verticalLayout_3.addWidget(self.DateRangeGroupBox) - self.TimePeriodGroupBox = QtGui.QGroupBox(self.layoutWidget) - self.TimePeriodGroupBox.setObjectName(u'TimePeriodGroupBox') - self.verticalLayout = QtGui.QVBoxLayout(self.TimePeriodGroupBox) - self.verticalLayout.setObjectName(u'verticalLayout') - self.FirstHorizontalLayout = QtGui.QHBoxLayout() - self.FirstHorizontalLayout.setObjectName(u'FirstHorizontalLayout') - self.FirstCheckBox = QtGui.QCheckBox(self.TimePeriodGroupBox) - self.FirstCheckBox.setChecked(True) - self.FirstCheckBox.setObjectName(u'FirstCheckBox') - self.FirstHorizontalLayout.addWidget(self.FirstCheckBox) - self.FirstFromTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) - self.FirstFromTimeEdit.setTime(QtCore.QTime(9, 0, 0)) - self.FirstFromTimeEdit.setObjectName(u'FirstFromTimeEdit') - self.FirstHorizontalLayout.addWidget(self.FirstFromTimeEdit) - self.FirstTo = QtGui.QLabel(self.TimePeriodGroupBox) - self.FirstTo.setObjectName(u'FirstTo') - self.FirstHorizontalLayout.addWidget(self.FirstTo) - self.FirstToTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) - self.FirstToTimeEdit.setCalendarPopup(True) - self.FirstToTimeEdit.setTime(QtCore.QTime(10, 0, 0)) - self.FirstToTimeEdit.setObjectName(u'FirstToTimeEdit') - self.FirstHorizontalLayout.addWidget(self.FirstToTimeEdit) - self.verticalLayout.addLayout(self.FirstHorizontalLayout) - self.SecondHorizontalLayout = QtGui.QHBoxLayout() - self.SecondHorizontalLayout.setObjectName(u'SecondHorizontalLayout') - self.SecondCheckBox = QtGui.QCheckBox(self.TimePeriodGroupBox) - self.SecondCheckBox.setChecked(True) - self.SecondCheckBox.setObjectName(u'SecondCheckBox') - self.SecondHorizontalLayout.addWidget(self.SecondCheckBox) - self.SecondFromTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) - self.SecondFromTimeEdit.setTime(QtCore.QTime(10, 45, 0)) - self.SecondFromTimeEdit.setObjectName(u'SecondFromTimeEdit') - self.SecondHorizontalLayout.addWidget(self.SecondFromTimeEdit) - self.SecondTo = QtGui.QLabel(self.TimePeriodGroupBox) - self.SecondTo.setObjectName(u'SecondTo') - self.SecondHorizontalLayout.addWidget(self.SecondTo) - self.SecondToTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) - self.SecondToTimeEdit.setObjectName(u'SecondToTimeEdit') - self.SecondHorizontalLayout.addWidget(self.SecondToTimeEdit) - self.verticalLayout.addLayout(self.SecondHorizontalLayout) - self.ThirdHorizontalLayout = QtGui.QHBoxLayout() - self.ThirdHorizontalLayout.setObjectName(u'ThirdHorizontalLayout') - self.ThirdCheckBox = QtGui.QCheckBox(self.TimePeriodGroupBox) - self.ThirdCheckBox.setChecked(True) - self.ThirdCheckBox.setObjectName(u'ThirdCheckBox') - self.ThirdHorizontalLayout.addWidget(self.ThirdCheckBox) - self.ThirdFromTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) - self.ThirdFromTimeEdit.setTime(QtCore.QTime(18, 30, 0)) - self.ThirdFromTimeEdit.setObjectName(u'ThirdFromTimeEdit') - self.ThirdHorizontalLayout.addWidget(self.ThirdFromTimeEdit) - self.ThirdTo = QtGui.QLabel(self.TimePeriodGroupBox) - self.ThirdTo.setObjectName(u'ThirdTo') - self.ThirdHorizontalLayout.addWidget(self.ThirdTo) - self.ThirdToTimeEdit = QtGui.QTimeEdit(self.TimePeriodGroupBox) - self.ThirdToTimeEdit.setTime(QtCore.QTime(19, 30, 0)) - self.ThirdToTimeEdit.setObjectName(u'ThirdToTimeEdit') - self.ThirdHorizontalLayout.addWidget(self.ThirdToTimeEdit) - self.verticalLayout.addLayout(self.ThirdHorizontalLayout) - self.verticalLayout_3.addWidget(self.TimePeriodGroupBox) + self.verticalLayout_2.addWidget(self.FileGroupBox) + self.verticalLayout.addWidget(self.DateRangeGroupBox) + self.buttonBox = QtGui.QDialogButtonBox(AuditDetailDialog) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(AuditDetailDialog) - QtCore.QObject.connect( - self.buttonBox, QtCore.SIGNAL(u'accepted()'), - AuditDetailDialog.accept) - QtCore.QObject.connect( - self.buttonBox, QtCore.SIGNAL(u'rejected()'), - AuditDetailDialog.close) - QtCore.QObject.connect( - self.FirstCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - AuditDetailDialog.changeFirstService) - QtCore.QObject.connect( - self.SecondCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - AuditDetailDialog.changeSecondService) - QtCore.QObject.connect( - self.ThirdCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), - AuditDetailDialog.changeThirdService) - QtCore.QObject.connect( - self.SaveFilePushButton, QtCore.SIGNAL(u'pressed()'), - AuditDetailDialog.defineOutputLocation) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), AuditDetailDialog.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), AuditDetailDialog.close) + QtCore.QObject.connect(self.SaveFilePushButton, QtCore.SIGNAL("pressed()"), AuditDetailDialog.defineOutputLocation) QtCore.QMetaObject.connectSlotsByName(AuditDetailDialog) def retranslateUi(self, AuditDetailDialog): - AuditDetailDialog.setWindowTitle(self.trUtf8('Audit Detail Extraction')) - self.FileGroupBox.setTitle(self.trUtf8('Report Location')) - self.ReportTypeGroup.setTitle(self.trUtf8('Report Type')) - self.SummaryReport.setText(self.trUtf8('Summary')) - self.DetailedReport.setText(self.trUtf8('Detailed')) - self.DateRangeGroupBox.setTitle(self.trUtf8('Select Date Range')) - self.FromDateEdit.setDisplayFormat(self.trUtf8('dd/MM/yyyy')) - self.To.setText(self.trUtf8('to')) - self.ToDateEdit.setDisplayFormat(self.trUtf8('dd/MM/yyyy')) - self.TimePeriodGroupBox.setTitle(self.trUtf8('Select Time Periods')) - self.FirstCheckBox.setText(self.trUtf8('First Service')) - self.FirstFromTimeEdit.setDisplayFormat(self.trUtf8('hh:mm AP')) - self.FirstTo.setText(self.trUtf8('to')) - self.FirstToTimeEdit.setDisplayFormat(self.trUtf8('hh:mm AP')) - self.SecondCheckBox.setText(self.trUtf8('Second Service')) - self.SecondFromTimeEdit.setDisplayFormat(self.trUtf8('hh:mm AP')) - self.SecondTo.setText(self.trUtf8('to')) - self.SecondToTimeEdit.setDisplayFormat(self.trUtf8('hh:mm AP')) - self.ThirdCheckBox.setText(self.trUtf8('Third Service')) - self.ThirdFromTimeEdit.setDisplayFormat(self.trUtf8('hh:mm AP')) - self.ThirdTo.setText(self.trUtf8('to')) - self.ThirdToTimeEdit.setDisplayFormat(self.trUtf8('hh:mm AP')) \ No newline at end of file + AuditDetailDialog.setWindowTitle(QtGui.QApplication.translate("AuditDetailDialog", "Audit Detail Extraction", None, QtGui.QApplication.UnicodeUTF8)) + self.DateRangeGroupBox.setTitle(QtGui.QApplication.translate("AuditDetailDialog", "Select Date Range", None, QtGui.QApplication.UnicodeUTF8)) + self.ToLabel.setText(QtGui.QApplication.translate("AuditDetailDialog", "to", None, QtGui.QApplication.UnicodeUTF8)) + self.FileGroupBox.setTitle(QtGui.QApplication.translate("AuditDetailDialog", "Report Location", None, QtGui.QApplication.UnicodeUTF8)) + +import openlp-2_rc diff --git a/resources/forms/songusagedetaildialog.ui b/resources/forms/songusagedetaildialog.ui index bafcfd535..a32b63899 100644 --- a/resources/forms/songusagedetaildialog.ui +++ b/resources/forms/songusagedetaildialog.ui @@ -6,299 +6,81 @@ 0 0 - 593 - 501 + 609 + 413 Audit Detail Extraction - - - - 420 - 470 - 170 - 25 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 370 - 571 - 70 - - - - Report Location - - - - + + + + + Select Date Range + + - + + + + + + + + to + + + false + + + Qt::AlignCenter + + + + + + + - - - - - - - :/exports/export_load.png:/exports/export_load.png + + + Report Location + + + + + + + + + + + + + + :/exports/export_load.png:/exports/export_load.png + + + + + + - - - - - - - 10 - 10 - 561 - 361 - - - - - - - Report Type - - - - - 50 - 40 - 481 - 23 - - - - - - - Summary - - - - - - - Detailed - - - true - - - - - - - - - - - Select Date Range - - - - - - - - dd/MM/yyyy - - - true - - - - - - - to - - - - - - - dd/MM/yyyy - - - true - - - - - - - - - - - - Select Time Periods - - - - - - - - First Service - - - true - - - - - - - hh:mm AP - - - - - - - - - - to - - - - - - - hh:mm AP - - - true - - - - - - - - - - - - - - Second Service - - - true - - - - - - - hh:mm AP - - - - - - - - - - to - - - - - - - hh:mm AP - - - - - - - - - - - Third Service - - - true - - - - - - - hh:mm AP - - - - - - - - - - to - - - - - - - hh:mm AP - - - - - - - - - - - - - + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + @@ -336,54 +118,6 @@ - - FirstCheckBox - stateChanged(int) - AuditDetailDialog - changeFirstService(int) - - - 26 - 285 - - - 136 - 483 - - - - - SecondCheckBox - stateChanged(int) - AuditDetailDialog - changeSecondService(int) - - - 41 - 323 - - - 103 - 494 - - - - - ThirdCheckBox - stateChanged(int) - AuditDetailDialog - changeThirdService(int) - - - 38 - 351 - - - 155 - 463 - - - SaveFilePushButton pressed() From 73d6a24792ee02e8d547d5d1cc4c221525e6972f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 9 Feb 2010 14:56:31 +0000 Subject: [PATCH 04/25] Add Fontsize and location to alerts settings --- openlp/core/ui/alertstab.py | 18 +++++++++++++----- .../songusage/forms/songusagedetaildialog.py | 2 -- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/alertstab.py b/openlp/core/ui/alertstab.py index c5dc1976d..bf4b9a004 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/core/ui/alertstab.py @@ -126,6 +126,8 @@ class AlertsTab(SettingsTab): self.LocationLabel.setObjectName(u'LocationLabel') self.LocationLayout.addWidget(self.LocationLabel) self.LocationComboBox = QtGui.QComboBox(self.LocationWidget) + self.LocationComboBox.addItem(QtCore.QString()) + self.LocationComboBox.addItem(QtCore.QString()) self.LocationComboBox.setObjectName(u'LocationComboBox') self.LocationLayout.addWidget(self.LocationComboBox) self.LocationSpacer = QtGui.QSpacerItem(147, 20, @@ -178,6 +180,8 @@ class AlertsTab(SettingsTab): QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked) QtCore.QObject.connect(self.TimeoutSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) + QtCore.QObject.connect(self.FontSizeSpinBox, + QtCore.SIGNAL(u'valueChanged(int)'), self.onFontSizeSpinBoxChanged) def retranslateUi(self): self.FontGroupBox.setTitle(self.trUtf8('Font')) @@ -190,9 +194,9 @@ class AlertsTab(SettingsTab): self.TimeoutSpinBox.setSuffix(self.trUtf8('s')) self.LocationLabel.setText(self.trUtf8('Location:')) self.PreviewGroupBox.setTitle(self.trUtf8('Preview')) - self.FontPreview.setText(self.trUtf8('openlp.org 2.0 rocks!')) - self.LocationComboBox.addItem(self.trUtf8('Top')) - self.LocationComboBox.addItem(self.trUtf8('Bottom')) + self.FontPreview.setText(self.trUtf8('openlp.org')) + self.LocationComboBox.setItemText(0, self.trUtf8('Top')) + self.LocationComboBox.setItemText(1, self.trUtf8('Bottom')) def onBackgroundColorButtonClicked(self): self.bg_color = QtGui.QColorDialog.getColor( @@ -214,6 +218,10 @@ class AlertsTab(SettingsTab): def onTimeoutSpinBoxChanged(self): self.timeout = self.TimeoutSpinBox.value() + def onFontSizeSpinBoxChanged(self): + self.font_size = self.FontSizeSpinBox.value() + self.updateDisplay() + def load(self): self.timeout = int(self.config.get_config(u'timeout', 5)) self.font_color = unicode( @@ -243,13 +251,13 @@ class AlertsTab(SettingsTab): self.config.set_config(u'font size', unicode(self.font_size)) self.config.set_config(u'font face', unicode(self.font_face)) self.config.set_config(u'timeout', unicode(self.timeout)) - self.config.set_config(u'location', unicode(self.FontComboBox.currentIndex())) + self.config.set_config(u'location', unicode(self.LocationComboBox.currentIndex())) def updateDisplay(self): font = QtGui.QFont() font.setFamily(self.FontComboBox.currentFont().family()) font.setBold(True) - font.setPointSize(16) + font.setPointSize(self.font_size) self.FontPreview.setFont(font) self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % \ (self.bg_color, self.font_color)) diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index a191b8f08..a4bb2e906 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -67,5 +67,3 @@ class Ui_AuditDetailDialog(object): self.DateRangeGroupBox.setTitle(QtGui.QApplication.translate("AuditDetailDialog", "Select Date Range", None, QtGui.QApplication.UnicodeUTF8)) self.ToLabel.setText(QtGui.QApplication.translate("AuditDetailDialog", "to", None, QtGui.QApplication.UnicodeUTF8)) self.FileGroupBox.setTitle(QtGui.QApplication.translate("AuditDetailDialog", "Report Location", None, QtGui.QApplication.UnicodeUTF8)) - -import openlp-2_rc From 944f45c8c855cf9fd7d5e7b35d8585dbbd78b533 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 11 Feb 2010 18:39:28 +0000 Subject: [PATCH 05/25] Fix up song usage extract processing --- openlp/core/ui/__init__.py | 2 - openlp/core/ui/maindisplay.py | 66 ++----------- openlp/core/ui/mainwindow.py | 22 +---- openlp/core/ui/settingsform.py | 7 +- openlp/plugins/alerts/__init__.py | 24 +++++ openlp/plugins/alerts/alertsplugin.py | 98 +++++++++++++++++++ openlp/plugins/alerts/forms/__init__.py | 27 +++++ .../ui => plugins/alerts/forms}/alertform.py | 8 +- .../ui => plugins/alerts/forms}/alertstab.py | 8 +- openlp/plugins/alerts/lib/__init__.py | 25 +++++ openlp/plugins/alerts/lib/alertmanager.py | 75 ++++++++++++++ .../songusage/forms/songusagedeleteform.py | 3 +- .../songusage/forms/songusagedetaildialog.py | 2 +- .../songusage/forms/songusagedetailform.py | 63 ++---------- openlp/plugins/songusage/lib/manager.py | 10 +- 15 files changed, 280 insertions(+), 160 deletions(-) create mode 100644 openlp/plugins/alerts/__init__.py create mode 100644 openlp/plugins/alerts/alertsplugin.py create mode 100644 openlp/plugins/alerts/forms/__init__.py rename openlp/{core/ui => plugins/alerts/forms}/alertform.py (98%) rename openlp/{core/ui => plugins/alerts/forms}/alertstab.py (98%) create mode 100644 openlp/plugins/alerts/lib/__init__.py create mode 100644 openlp/plugins/alerts/lib/alertmanager.py diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 5d4c798d8..6e37afc7f 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -28,11 +28,9 @@ from maindisplay import MainDisplay from amendthemeform import AmendThemeForm from slidecontroller import SlideController from splashscreen import SplashScreen -from alertstab import AlertsTab from generaltab import GeneralTab from themestab import ThemesTab from aboutform import AboutForm -from alertform import AlertForm from pluginform import PluginForm from settingsform import SettingsForm from mediadockmanager import MediaDockManager diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index bf0e11cb3..43cb0d848 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -120,8 +120,6 @@ class MainDisplay(DisplayWidget): self.hasTransition = False self.alertList = [] self.mediaBackground = False - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'alert_text'), self.displayAlert) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), @@ -218,6 +216,12 @@ class MainDisplay(DisplayWidget): self.screen[u'size'].height() ) self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame)) + def addAlertImage(self, frame, blank=False): + if blank: + self.display_alert.setPixmap(self.transparent) + else: + self.display_alert.setPixmap(frame) + def frameView(self, frame, transition=False): """ Called from a slide controller to display a frame @@ -257,64 +261,6 @@ class MainDisplay(DisplayWidget): if self.display_frame: self.frameView(self.display_frame) - - def displayAlert(self, text=u''): - """ - Called from the Alert Tab to display an alert - - ``text`` - display text - """ - log.debug(u'display alert called %s' % text) - self.parent.StatusBar.showMessage(self.trUtf8(u'')) - self.alertList.append(text) - if self.timer_id != 0 or self.mediaLoaded: - self.parent.StatusBar.showMessage(\ - self.trUtf8(u'Alert message created and delayed')) - return - self.generateAlert() - - def generateAlert(self): - log.debug(u'Generate Alert called') - if len(self.alertList) == 0: - return - text = self.alertList.pop(0) - alertTab = self.parent.settingsForm.AlertsTab - alertframe = \ - QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight) - alertframe.fill(QtCore.Qt.transparent) - painter = QtGui.QPainter(alertframe) - painter.fillRect(alertframe.rect(), QtCore.Qt.transparent) - painter.setRenderHint(QtGui.QPainter.Antialiasing) - painter.fillRect( - QtCore.QRect( - 0, 0, alertframe.rect().width(), - alertframe.rect().height()), - QtGui.QColor(alertTab.bg_color)) - font = QtGui.QFont() - font.setFamily(alertTab.font_face) - font.setBold(True) - font.setPointSize(40) - painter.setFont(font) - painter.setPen(QtGui.QColor(alertTab.font_color)) - x, y = (0, 0) - metrics = QtGui.QFontMetrics(font) - painter.drawText( - x, y + metrics.height() - metrics.descent() - 1, text) - painter.end() - self.display_alert.setPixmap(alertframe) - self.display_alert.setVisible(True) - # check to see if we have a timer running - if self.timer_id == 0: - self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) - - def timerEvent(self, event): - if event.timerId() == self.timer_id: - self.display_alert.setPixmap(self.transparent) - self.killTimer(self.timer_id) - self.timer_id = 0 - self.generateAlert() - def onMediaQueue(self, message): log.debug(u'Queue new media message %s' % message) self.display_image.close() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 36f427d13..2ec93ce79 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -29,7 +29,7 @@ import time from PyQt4 import QtCore, QtGui -from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ +from openlp.core.ui import AboutForm, SettingsForm, \ ServiceManager, ThemeManager, MainDisplay, SlideController, \ PluginForm, MediaDockManager from openlp.core.lib import RenderManager, PluginConfig, build_icon, \ @@ -227,13 +227,8 @@ class Ui_MainWindow(object): self.settingsmanager.showServiceManager) self.ViewServiceManagerItem.setIcon(ServiceManagerIcon) self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') - self.ToolsAlertItem = QtGui.QAction(MainWindow) - AlertIcon = build_icon(u':/tools/tools_alert.png') - self.ToolsAlertItem.setIcon(AlertIcon) - self.ToolsAlertItem.setObjectName(u'ToolsAlertItem') self.PluginItem = QtGui.QAction(MainWindow) - #PluginIcon = build_icon(u':/tools/tools_alert.png') - self.PluginItem.setIcon(AlertIcon) + #self.PluginItem.setIcon(AlertIcon) self.PluginItem.setObjectName(u'PluginItem') self.HelpDocumentationItem = QtGui.QAction(MainWindow) ContentsIcon = build_icon(u':/system/system_help_contents.png') @@ -292,7 +287,6 @@ class Ui_MainWindow(object): self.OptionsMenu.addAction(self.OptionsViewMenu.menuAction()) self.OptionsMenu.addSeparator() self.OptionsMenu.addAction(self.OptionsSettingsItem) - self.ToolsMenu.addAction(self.ToolsAlertItem) self.ToolsMenu.addAction(self.PluginItem) self.ToolsMenu.addSeparator() self.ToolsMenu.addAction(self.ToolsAddToolItem) @@ -394,9 +388,6 @@ class Ui_MainWindow(object): self.action_Preview_Panel.setStatusTip( self.trUtf8('Toggle the visibility of the Preview Panel')) self.action_Preview_Panel.setShortcut(self.trUtf8('F11')) - self.ToolsAlertItem.setText(self.trUtf8('&Alert')) - self.ToolsAlertItem.setStatusTip(self.trUtf8('Show an alert message')) - self.ToolsAlertItem.setShortcut(self.trUtf8('F7')) self.PluginItem.setText(self.trUtf8('&Plugin List')) self.PluginItem.setStatusTip(self.trUtf8('List the Plugins')) self.PluginItem.setShortcut(self.trUtf8('Alt+F7')) @@ -440,7 +431,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.settingsmanager = SettingsManager(screens) self.generalConfig = PluginConfig(u'General') self.mainDisplay = MainDisplay(self, screens) - self.alertForm = AlertForm(self) self.aboutForm = AboutForm(self, applicationVersion) self.settingsForm = SettingsForm(self.screens, self, self) # Set up the path with plugins @@ -485,8 +475,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.action_Preview_Panel.setChecked) QtCore.QObject.connect(self.HelpAboutItem, QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked) - QtCore.QObject.connect(self.ToolsAlertItem, - QtCore.SIGNAL(u'triggered()'), self.onToolsAlertItemClicked) QtCore.QObject.connect(self.PluginItem, QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.QObject.connect(self.OptionsSettingsItem, @@ -605,12 +593,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.aboutForm.applicationVersion = self.applicationVersion self.aboutForm.exec_() - def onToolsAlertItemClicked(self): - """ - Show the Alert form - """ - self.alertForm.exec_() - def onPluginItemClicked(self): """ Show the Plugin form diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index ed5bd9d76..c8989625d 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtGui -from openlp.core.ui import GeneralTab, ThemesTab, AlertsTab +from openlp.core.ui import GeneralTab, ThemesTab from openlp.core.lib import Receiver from settingsdialog import Ui_SettingsDialog @@ -44,9 +44,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): # Themes tab self.ThemesTab = ThemesTab(mainWindow) self.addTab(u'Themes', self.ThemesTab) - # Alert tab - self.AlertsTab = AlertsTab() - self.addTab(u'Alerts', self.AlertsTab) def addTab(self, name, tab): log.info(u'Adding %s tab' % tab.tabTitle) @@ -73,4 +70,4 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def postSetUp(self): for tab_index in range(0, self.SettingsTabWidget.count()): - self.SettingsTabWidget.widget(tab_index).postSetUp() \ No newline at end of file + self.SettingsTabWidget.widget(tab_index).postSetUp() diff --git a/openlp/plugins/alerts/__init__.py b/openlp/plugins/alerts/__init__.py new file mode 100644 index 000000000..a78b7d0d7 --- /dev/null +++ b/openlp/plugins/alerts/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py new file mode 100644 index 000000000..f18f1b9b7 --- /dev/null +++ b/openlp/plugins/alerts/alertsplugin.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from datetime import datetime +import logging + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus +#from openlp.plugins.alerts.lib import alertsManager +from openlp.plugins.alerts.forms import AlertsTab, AlertForm +#from openlp.plugins.alerts.lib.models import alertsItem + +class alertsPlugin(Plugin): + global log + log = logging.getLogger(u'alertsPlugin') + log.info(u'alerts Plugin loaded') + + def __init__(self, plugin_helpers): + Plugin.__init__(self, u'alerts', u'1.9.1', plugin_helpers) + self.weight = -3 + self.icon = build_icon(u':/media/media_image.png') + self.alertsmanager = None + self.alertForm = AlertForm(self) + self.status = PluginStatus.Active + + def get_settings_tab(self): + return AlertsTab(self.name) + + def add_tools_menu_item(self, tools_menu): + """ + Give the alerts plugin the opportunity to add items to the + **Tools** menu. + + ``tools_menu`` + The actual **Tools** menu item, so that your actions can + use it as their parent. + """ + log.info(u'add tools menu') + self.toolsAlertItem = QtGui.QAction(tools_menu) + AlertIcon = build_icon(u':/tools/tools_alert.png') + self.toolsAlertItem.setIcon(AlertIcon) + self.toolsAlertItem.setObjectName(u'toolsAlertItem') + self.toolsAlertItem.setText(self.trUtf8('&Alert')) + self.toolsAlertItem.setStatusTip(self.trUtf8('Show an alert message')) + self.toolsAlertItem.setShortcut(self.trUtf8('F7')) + self.service_manager.parent.ToolsMenu.addAction(self.toolsAlertItem) + QtCore.QObject.connect(self.toolsAlertItem, + QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger) + self.toolsAlertItem.setVisible(False) + + def initialise(self): + log.info(u'alerts Initialising') + Plugin.initialise(self) + self.toolsAlertItem.setVisible(True) + + def finalise(self): + log.info(u'Plugin Finalise') + self.toolsAlertItem.setVisible(False) + #stop any events being processed + + def togglealertsState(self): + self.alertsActive = not self.alertsActive + self.config.set_config(u'active', self.alertsActive) + + def onAlertsTrigger(self): + self.alertForm.exec_() + + def onalertsReport(self): + self.alertsdetailform.initialise() + self.alertsdetailform.exec_() + + def about(self): + about_text = self.trUtf8('Alerts Plugin
This plugin ' + 'controls the displaying of alerts on the presentations screen') + return about_text diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py new file mode 100644 index 000000000..dba3abc93 --- /dev/null +++ b/openlp/plugins/alerts/forms/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from alertstab import AlertsTab +from alertform import AlertForm diff --git a/openlp/core/ui/alertform.py b/openlp/plugins/alerts/forms/alertform.py similarity index 98% rename from openlp/core/ui/alertform.py rename to openlp/plugins/alerts/forms/alertform.py index beae62a53..86724c99c 100644 --- a/openlp/core/ui/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -31,11 +31,11 @@ class AlertForm(QtGui.QDialog): global log log = logging.getLogger(u'AlertForm') - def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + def __init__(self, parent): + QtGui.QDialog.__init__(self, None) self.parent = parent self.setupUi(self) - log.debug(u'Defined') + log.debug(u'AlertForm Defined') def setupUi(self, AlertForm): AlertForm.setObjectName(u'AlertForm') @@ -85,9 +85,7 @@ class AlertForm(QtGui.QDialog): self.CancelButton.setObjectName(u'CancelButton') self.horizontalLayout.addWidget(self.CancelButton) self.AlertFormLayout.addWidget(self.ButtonBoxWidget) - self.retranslateUi(AlertForm) - QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL(u'clicked()'), AlertForm.close) QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) QtCore.QMetaObject.connectSlotsByName(AlertForm) diff --git a/openlp/core/ui/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py similarity index 98% rename from openlp/core/ui/alertstab.py rename to openlp/plugins/alerts/forms/alertstab.py index bf4b9a004..2bb9beed3 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -31,10 +31,8 @@ class AlertsTab(SettingsTab): """ AlertsTab is the alerts settings tab in the settings dialog. """ - def __init__(self): - SettingsTab.__init__(self, u'Alerts') - self.font_color = '#ffffff' - self.bg_color = '#660000' + def __init__(self, title, section=None): + SettingsTab.__init__(self, title, section) def setupUi(self): self.setObjectName(u'AlertsTab') @@ -159,7 +157,7 @@ class AlertsTab(SettingsTab): self.PreviewLayout.setMargin(8) self.PreviewLayout.setObjectName(u'PreviewLayout') self.FontPreview = QtGui.QLineEdit(self.PreviewGroupBox) - self.FontPreview.setMinimumSize(QtCore.QSize(280, 100)) + self.FontPreview.setFixedSize(QtCore.QSize(350, 100)) self.FontPreview.setReadOnly(True) self.FontPreview.setFocusPolicy(QtCore.Qt.NoFocus) self.FontPreview.setAlignment( diff --git a/openlp/plugins/alerts/lib/__init__.py b/openlp/plugins/alerts/lib/__init__.py new file mode 100644 index 000000000..bf7bc5074 --- /dev/null +++ b/openlp/plugins/alerts/lib/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +from alertmanager import AlertManager diff --git a/openlp/plugins/alerts/lib/alertmanager.py b/openlp/plugins/alerts/lib/alertmanager.py new file mode 100644 index 000000000..34dc2622c --- /dev/null +++ b/openlp/plugins/alerts/lib/alertmanager.py @@ -0,0 +1,75 @@ + +import logging + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import str_to_bool, Receiver +from openlp.core.lib import SettingsTab + +class AlertManager(self): + """ + BiblesTab is the Bibles settings tab in the settings dialog. + """ + global log + log = logging.getLogger(u'AlertManager') + log.info(u'Alert Manager loaded') + + def __init__(self): + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'alert_text'), self.displayAlert) + + def displayAlert(self, text=u''): + """ + Called from the Alert Tab to display an alert + + ``text`` + display text + """ + log.debug(u'display alert called %s' % text) + self.parent.StatusBar.showMessage(self.trUtf8(u'')) + self.alertList.append(text) + if self.timer_id != 0 or self.mediaLoaded: + self.parent.StatusBar.showMessage(\ + self.trUtf8(u'Alert message created and delayed')) + return + self.generateAlert() + + def generateAlert(self): + log.debug(u'Generate Alert called') + if len(self.alertList) == 0: + return + text = self.alertList.pop(0) + alertTab = self.parent.settingsForm.AlertsTab + alertframe = \ + QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight) + alertframe.fill(QtCore.Qt.transparent) + painter = QtGui.QPainter(alertframe) + painter.fillRect(alertframe.rect(), QtCore.Qt.transparent) + painter.setRenderHint(QtGui.QPainter.Antialiasing) + painter.fillRect( + QtCore.QRect( + 0, 0, alertframe.rect().width(), + alertframe.rect().height()), + QtGui.QColor(alertTab.bg_color)) + font = QtGui.QFont() + font.setFamily(alertTab.font_face) + font.setBold(True) + font.setPointSize(alertTab.font_size) + painter.setFont(font) + painter.setPen(QtGui.QColor(alertTab.font_color)) + x, y = (0, 0) + metrics = QtGui.QFontMetrics(font) + painter.drawText( + x, y + metrics.height() - metrics.descent() - 1, text) + painter.end() + self.display_alert.setPixmap(alertframe) + # check to see if we have a timer running + if self.timer_id == 0: + self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) + + def timerEvent(self, event): + if event.timerId() == self.timer_id: + self.display_alert.setPixmap(self.transparent) + self.killTimer(self.timer_id) + self.timer_id = 0 + self.generateAlert() diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 98faf26ad..26fe2b7e2 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -50,7 +50,6 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): QtGui.QMessageBox.Cancel), QtGui.QMessageBox.Cancel) if ret == QtGui.QMessageBox.Ok: - qDeleteDate = self.DeleteCalendar.selectedDate() - deleteDate = date(qDeleteDate.year(), qDeleteDate.month(), qDeleteDate.day()) + deleteDate = self.DeleteCalendar.selectedDate().toPyDate() self.songusagemanager.delete_to_date(deleteDate) self.close() diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index a4bb2e906..63866d1fd 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -9,7 +9,7 @@ from PyQt4 import QtCore, QtGui -class Ui_AuditDetailDialog(object): +class Ui_SongUsageDetailDialog(object): def setupUi(self, AuditDetailDialog): AuditDetailDialog.setObjectName("AuditDetailDialog") AuditDetailDialog.resize(609, 413) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index ead6b5166..df749d8c0 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -45,33 +45,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.setupUi(self) def initialise(self): - self.FirstCheckBox.setCheckState( - int(self.parent.config.get_config(u'first service', QtCore.Qt.Checked))) - self.SecondCheckBox.setCheckState( - int(self.parent.config.get_config(u'second service', QtCore.Qt.Checked))) - self.ThirdCheckBox.setCheckState( - int(self.parent.config.get_config(u'third service', QtCore.Qt.Checked))) year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 toDate = QtCore.QDate(year, 8, 31) fromDate = QtCore.QDate(year - 1, 9, 1) - self.FromDateEdit.setDate(fromDate) - self.ToDateEdit.setDate(toDate) + self.FromDate.setSelectedDate(fromDate) + self.ToDate.setSelectedDate(toDate) self.FileLineEdit.setText(self.parent.config.get_last_dir(1)) - self.resetWindow() - - def changeFirstService(self, value): - self.parent.config.set_config(u'first service', value) - self.resetWindow() - - def changeSecondService(self, value): - self.parent.config.set_config(u'second service', value) - self.resetWindow() - - def changeThirdService(self, value): - self.parent.config.set_config(u'third service', value) - self.resetWindow() def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, @@ -82,39 +63,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): self.parent.config.set_last_dir(path, 1) self.FileLineEdit.setText(path) - def resetWindow(self): - if self.FirstCheckBox.checkState() == QtCore.Qt.Unchecked: - self.FirstFromTimeEdit.setEnabled(False) - self.FirstToTimeEdit.setEnabled(False) - else: - self.FirstFromTimeEdit.setEnabled(True) - self.FirstToTimeEdit.setEnabled(True) - if self.SecondCheckBox.checkState() == QtCore.Qt.Unchecked: - self.SecondFromTimeEdit.setEnabled(False) - self.SecondToTimeEdit.setEnabled(False) - else: - self.SecondFromTimeEdit.setEnabled(True) - self.SecondToTimeEdit.setEnabled(True) - if self.ThirdCheckBox.checkState() == QtCore.Qt.Unchecked: - self.ThirdFromTimeEdit.setEnabled(False) - self.ThirdToTimeEdit.setEnabled(False) - else: - self.ThirdFromTimeEdit.setEnabled(True) - self.ThirdToTimeEdit.setEnabled(True) - def accept(self): - if self.DetailedReport.isChecked(): - self.detailedReport() - else: - self.summaryReport() - self.close() - - def detailedReport(self): log.debug(u'Detailed report generated') filename = u'usage_detail_%s_%s.txt' % \ - (self.FromDateEdit.date().toString(u'ddMMyyyy'), - self.ToDateEdit.date().toString(u'ddMMyyyy')) - usage = self.parent.songusagemanager.get_all_songusage() + (self.FromDate.selectedDate().toString(u'ddMMyyyy'), + self.ToDate.selectedDate().toString(u'ddMMyyyy')) + usage = self.parent.songusagemanager.get_all_songusage(\ + self.FromDate.selectedDate(), \ + self.ToDate.selectedDate()) outname = os.path.join(unicode(self.FileLineEdit.text()), filename) file = None try: @@ -130,8 +86,3 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): if file: file.close() - def summaryReport(self): - log.debug(u'Summary report generated') - filename = u'audit_sum_%s_%s.txt' % \ - (self.FromDateEdit.date().toString(u'ddMMyyyy'), - self.ToDateEdit.date().toString(u'ddMMyyyy')) diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index cf286d37f..0b29d6c98 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -60,12 +60,14 @@ class SongUsageManager(): log.debug(u'SongUsage Initialised') - def get_all_songusage(self): + def get_all_songusage(self, start_date, end_date): """ Returns the details of SongUsage """ - return self.session.query(SongUsageItem).\ - order_by(SongUsageItem.usagedate, SongUsageItem.usagetime ).all() + return self.session.query(SongUsageItem) \ + .filter(SongUsageItem.usagedate >= start_date.toPyDate()) \ + .filter(SongUsageItem.usagedate < end_date.toPyDate()) \ + .order_by(SongUsageItem.usagedate, SongUsageItem.usagetime ).all() def insert_songusage(self, songusageitem): """ @@ -133,4 +135,4 @@ class SongUsageManager(): except: self.session.rollback() log.exception(u'Failed to delete all Song Usage items to %s' % date) - return False \ No newline at end of file + return False From 47a61a65812069f8014fbc0f00a290ef11f6e88a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 12 Feb 2010 18:42:09 +0000 Subject: [PATCH 06/25] Finished moving alert code to plugin structure --- openlp/core/lib/plugin.py | 3 ++- openlp/core/lib/pluginmanager.py | 2 +- openlp/core/ui/maindisplay.py | 2 -- openlp/core/ui/mainwindow.py | 1 + openlp/plugins/alerts/alertsplugin.py | 7 ++++--- openlp/plugins/alerts/forms/alertform.py | 3 ++- openlp/plugins/alerts/lib/__init__.py | 2 +- .../lib/{alertmanager.py => alertsmanager.py} | 21 ++++++++++++------- 8 files changed, 24 insertions(+), 17 deletions(-) rename openlp/plugins/alerts/lib/{alertmanager.py => alertsmanager.py} (76%) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 598c594fd..ca291d578 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -127,6 +127,7 @@ class Plugin(QtCore.QObject): self.service_manager = plugin_helpers[u'service'] self.settings = plugin_helpers[u'settings'] self.mediadock = plugin_helpers[u'toolbox'] + self.maindisplay = plugin_helpers[u'maindisplay'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), self.process_add_service_event) @@ -252,4 +253,4 @@ class Plugin(QtCore.QObject): if self.media_item: self.mediadock.insert_dock(self.media_item, self.icon, self.weight) if self.settings_tab: - self.settings.insertTab(self.settings_tab, self.weight) \ No newline at end of file + self.settings.insertTab(self.settings_tab, self.weight) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 4d4da144a..b06f23953 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -101,7 +101,7 @@ class PluginManager(object): log.debug(u'Loaded plugin %s with helpers', unicode(p)) plugin_objects.append(plugin) except TypeError: - log.error(u'loaded plugin %s has no helpers', unicode(p)) + log.exception(u'loaded plugin %s has no helpers', unicode(p)) plugins_list = sorted(plugin_objects, self.order_by_weight) for plugin in plugins_list: if plugin.check_pre_conditions(): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 43cb0d848..7846b58d5 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -114,11 +114,9 @@ class MainDisplay(DisplayWidget): self.displayBlank = False self.blankFrame = None self.frame = None - self.timer_id = 0 self.firstTime = True self.mediaLoaded = False self.hasTransition = False - self.alertList = [] self.mediaBackground = False QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 2ec93ce79..df66d5e97 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -510,6 +510,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.plugin_helpers[u'service'] = self.ServiceManagerContents self.plugin_helpers[u'settings'] = self.settingsForm self.plugin_helpers[u'toolbox'] = self.mediaDockManager + self.plugin_helpers[u'maindisplay'] = self.mainDisplay self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) # hook methods have to happen after find_plugins. Find plugins needs # the controllers hence the hooks have moved from setupUI() to here diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index f18f1b9b7..1163f70ee 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus -#from openlp.plugins.alerts.lib import alertsManager +from openlp.plugins.alerts.lib import AlertsManager from openlp.plugins.alerts.forms import AlertsTab, AlertForm #from openlp.plugins.alerts.lib.models import alertsItem @@ -42,12 +42,13 @@ class alertsPlugin(Plugin): Plugin.__init__(self, u'alerts', u'1.9.1', plugin_helpers) self.weight = -3 self.icon = build_icon(u':/media/media_image.png') - self.alertsmanager = None + self.alertsmanager = AlertsManager(self) self.alertForm = AlertForm(self) self.status = PluginStatus.Active def get_settings_tab(self): - return AlertsTab(self.name) + self.alertsTab = AlertsTab(self.name) + return self.alertsTab def add_tools_menu_item(self, tools_menu): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 86724c99c..68549eaee 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -26,6 +26,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon +from openlp.plugins.alerts.lib import alertmanager class AlertForm(QtGui.QDialog): global log @@ -97,4 +98,4 @@ class AlertForm(QtGui.QDialog): self.CancelButton.setText(self.trUtf8('Cancel')) def onDisplayClicked(self): - self.parent.mainDisplay.displayAlert(unicode(self.AlertEntryEditItem.text())) + self.parent.alertsmanager.displayAlert(unicode(self.AlertEntryEditItem.text())) diff --git a/openlp/plugins/alerts/lib/__init__.py b/openlp/plugins/alerts/lib/__init__.py index bf7bc5074..f6fb2c0d7 100644 --- a/openlp/plugins/alerts/lib/__init__.py +++ b/openlp/plugins/alerts/lib/__init__.py @@ -22,4 +22,4 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from alertmanager import AlertManager +from alertsmanager import AlertsManager diff --git a/openlp/plugins/alerts/lib/alertmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py similarity index 76% rename from openlp/plugins/alerts/lib/alertmanager.py rename to openlp/plugins/alerts/lib/alertsmanager.py index 34dc2622c..977614b86 100644 --- a/openlp/plugins/alerts/lib/alertmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -6,7 +6,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import str_to_bool, Receiver from openlp.core.lib import SettingsTab -class AlertManager(self): +class AlertsManager(QtCore.QObject): """ BiblesTab is the Bibles settings tab in the settings dialog. """ @@ -14,7 +14,11 @@ class AlertManager(self): log = logging.getLogger(u'AlertManager') log.info(u'Alert Manager loaded') - def __init__(self): + def __init__(self, parent): + QtCore.QObject.__init__(self) + self.parent = parent + self.timer_id = 0 + self.alertList = [] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alert_text'), self.displayAlert) @@ -26,9 +30,10 @@ class AlertManager(self): display text """ log.debug(u'display alert called %s' % text) - self.parent.StatusBar.showMessage(self.trUtf8(u'')) + self.screen = self.parent.maindisplay.screen + self.parent.maindisplay.parent.StatusBar.showMessage(self.trUtf8(u'')) self.alertList.append(text) - if self.timer_id != 0 or self.mediaLoaded: + if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded: self.parent.StatusBar.showMessage(\ self.trUtf8(u'Alert message created and delayed')) return @@ -39,9 +44,9 @@ class AlertManager(self): if len(self.alertList) == 0: return text = self.alertList.pop(0) - alertTab = self.parent.settingsForm.AlertsTab + alertTab = self.parent.alertsTab alertframe = \ - QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight) + QtGui.QPixmap(self.screen[u'size'].width(), self.parent.maindisplay.alertHeight) alertframe.fill(QtCore.Qt.transparent) painter = QtGui.QPainter(alertframe) painter.fillRect(alertframe.rect(), QtCore.Qt.transparent) @@ -62,14 +67,14 @@ class AlertManager(self): painter.drawText( x, y + metrics.height() - metrics.descent() - 1, text) painter.end() - self.display_alert.setPixmap(alertframe) + self.parent.maindisplay.display_alert.setPixmap(alertframe) # check to see if we have a timer running if self.timer_id == 0: self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) def timerEvent(self, event): if event.timerId() == self.timer_id: - self.display_alert.setPixmap(self.transparent) + self.parent.maindisplay.display_alert.setPixmap(self.parent.maindisplay.transparent) self.killTimer(self.timer_id) self.timer_id = 0 self.generateAlert() From 973d5e3dd87daabeb6827e02ecd3ffeed5990b30 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 13 Feb 2010 07:30:00 +0000 Subject: [PATCH 07/25] Alerts move to top and bottom --- openlp/core/ui/maindisplay.py | 6 +++ openlp/plugins/alerts/lib/alertsmanager.py | 45 ++++++++++++++-------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 7846b58d5..4f46ccbe4 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -190,6 +190,7 @@ class MainDisplay(DisplayWidget): else: self.setVisible(False) self.primary = True + Receiver.send_message(u'screen_changed') def resetDisplay(self): if self.primary: @@ -214,6 +215,11 @@ class MainDisplay(DisplayWidget): self.screen[u'size'].height() ) self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame)) + def setAlertSize(self, top, height): + self.display_alert.setGeometry( + QtCore.QRect(0, top, + self.screen[u'size'].width(), height)) + def addAlertImage(self, frame, blank=False): if blank: self.display_alert.setPixmap(self.transparent) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 977614b86..1f4369588 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -21,6 +21,27 @@ class AlertsManager(QtCore.QObject): self.alertList = [] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alert_text'), self.displayAlert) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'screen_changed'), self.screenChanged) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'config_updated'), self.screenChanged) + + def screenChanged(self): + log.debug(u'screen changed') + self.screen = self.parent.maindisplay.screen + self.alertTab = self.parent.alertsTab + self.font = QtGui.QFont() + self.font.setFamily(self.alertTab.font_face) + self.font.setBold(True) + self.font.setPointSize(self.alertTab.font_size) + self.metrics = QtGui.QFontMetrics(self.font) + self.alertHeight = self.metrics.height() + 4 + if self.alertTab.location == 0: + self.alertScreenPosition = 0 + else: + self.alertScreenPosition = self.screen[u'size'].height() - self.alertHeight + self.alertHeight = self.screen[u'size'].height() - self.alertScreenPosition + self.parent.maindisplay.setAlertSize(self.alertScreenPosition, self.alertHeight) def displayAlert(self, text=u''): """ @@ -30,11 +51,10 @@ class AlertsManager(QtCore.QObject): display text """ log.debug(u'display alert called %s' % text) - self.screen = self.parent.maindisplay.screen self.parent.maindisplay.parent.StatusBar.showMessage(self.trUtf8(u'')) self.alertList.append(text) if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded: - self.parent.StatusBar.showMessage(\ + self.parent.maindisplay.parent.StatusBar.showMessage(\ self.trUtf8(u'Alert message created and delayed')) return self.generateAlert() @@ -46,7 +66,7 @@ class AlertsManager(QtCore.QObject): text = self.alertList.pop(0) alertTab = self.parent.alertsTab alertframe = \ - QtGui.QPixmap(self.screen[u'size'].width(), self.parent.maindisplay.alertHeight) + QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight) alertframe.fill(QtCore.Qt.transparent) painter = QtGui.QPainter(alertframe) painter.fillRect(alertframe.rect(), QtCore.Qt.transparent) @@ -55,26 +75,21 @@ class AlertsManager(QtCore.QObject): QtCore.QRect( 0, 0, alertframe.rect().width(), alertframe.rect().height()), - QtGui.QColor(alertTab.bg_color)) - font = QtGui.QFont() - font.setFamily(alertTab.font_face) - font.setBold(True) - font.setPointSize(alertTab.font_size) - painter.setFont(font) - painter.setPen(QtGui.QColor(alertTab.font_color)) - x, y = (0, 0) - metrics = QtGui.QFontMetrics(font) + QtGui.QColor(self.alertTab.bg_color)) + painter.setFont(self.font) + painter.setPen(QtGui.QColor(self.alertTab.font_color)) + x, y = (0, 2) painter.drawText( - x, y + metrics.height() - metrics.descent() - 1, text) + x, y + self.metrics.height() - self.metrics.descent() - 1, text) painter.end() - self.parent.maindisplay.display_alert.setPixmap(alertframe) + self.parent.maindisplay.addAlertImage(alertframe) # check to see if we have a timer running if self.timer_id == 0: self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) def timerEvent(self, event): if event.timerId() == self.timer_id: - self.parent.maindisplay.display_alert.setPixmap(self.parent.maindisplay.transparent) + self.parent.maindisplay.addAlertImage(None, True) self.killTimer(self.timer_id) self.timer_id = 0 self.generateAlert() From 9c97660b73c79cf3e064e14c9164ffffc16249e5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 13 Feb 2010 07:37:03 +0000 Subject: [PATCH 08/25] Alerts now move between top and bottom --- openlp/core/ui/maindisplay.py | 6 +----- openlp/plugins/alerts/forms/alertstab.py | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 4f46ccbe4..1ba31ea62 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -143,11 +143,7 @@ class MainDisplay(DisplayWidget): self.screen = self.screens.current #Sort out screen locations and sizes self.setGeometry(self.screen[u'size']) - self.alertScreenPosition = self.screen[u'size'].height() * 0.9 - self.alertHeight = self.screen[u'size'].height() - self.alertScreenPosition - self.display_alert.setGeometry( - QtCore.QRect(0, self.alertScreenPosition, - self.screen[u'size'].width(),self.alertHeight)) + self.display_alert.setGeometry(self.screen[u'size']) self.video.setGeometry(self.screen[u'size']) self.display_image.resize(self.screen[u'size'].width(), self.screen[u'size'].height()) diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 2bb9beed3..a6653d152 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -176,6 +176,8 @@ class AlertsTab(SettingsTab): QtCore.SIGNAL(u'pressed()'), self.onFontColorButtonClicked) QtCore.QObject.connect(self.FontComboBox, QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked) + QtCore.QObject.connect(self.LocationComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onLocationComboBoxClicked) QtCore.QObject.connect(self.TimeoutSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) QtCore.QObject.connect(self.FontSizeSpinBox, @@ -206,6 +208,9 @@ class AlertsTab(SettingsTab): def onFontComboBoxClicked(self): self.updateDisplay() + def onLocationComboBoxClicked(self, location): + self.location = location + def onFontColorButtonClicked(self): self.font_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.font_color), self).name() From acc97f3c79ea91b82cde108d983eb862307aaf96 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 14 Feb 2010 13:27:32 +0000 Subject: [PATCH 09/25] Alerts now have history --- openlp/plugins/alerts/alertsplugin.py | 7 +- openlp/plugins/alerts/forms/alertdialog.py | 70 +++++++++ .../plugins/alerts/forms/alerteditdialog.py | 63 ++++++++ openlp/plugins/alerts/forms/alertform.py | 141 +++++++++--------- openlp/plugins/alerts/forms/alertstab.py | 52 ++++++- openlp/plugins/alerts/lib/__init__.py | 1 + openlp/plugins/alerts/lib/classes.py | 46 ++++++ openlp/plugins/alerts/lib/manager.py | 108 ++++++++++++++ openlp/plugins/alerts/lib/meta.py | 38 +++++ openlp/plugins/alerts/lib/models.py | 39 +++++ openlp/plugins/alerts/lib/tables.py | 33 ++++ openlp/plugins/bibles/lib/biblestab.py | 5 +- openlp/plugins/custom/lib/tables.py | 4 +- resources/forms/alertdialog.ui | 116 ++++++++++++++ resources/forms/alerteditdialog.ui | 94 ++++++++++++ resources/forms/alertform.ui | 133 ----------------- 16 files changed, 738 insertions(+), 212 deletions(-) create mode 100644 openlp/plugins/alerts/forms/alertdialog.py create mode 100644 openlp/plugins/alerts/forms/alerteditdialog.py create mode 100644 openlp/plugins/alerts/lib/classes.py create mode 100644 openlp/plugins/alerts/lib/manager.py create mode 100644 openlp/plugins/alerts/lib/meta.py create mode 100644 openlp/plugins/alerts/lib/models.py create mode 100644 openlp/plugins/alerts/lib/tables.py create mode 100644 resources/forms/alertdialog.ui create mode 100644 resources/forms/alerteditdialog.ui delete mode 100644 resources/forms/alertform.ui diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 1163f70ee..7214618d7 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -29,9 +29,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus -from openlp.plugins.alerts.lib import AlertsManager +from openlp.plugins.alerts.lib import AlertsManager, DBManager from openlp.plugins.alerts.forms import AlertsTab, AlertForm -#from openlp.plugins.alerts.lib.models import alertsItem class alertsPlugin(Plugin): global log @@ -43,7 +42,8 @@ class alertsPlugin(Plugin): self.weight = -3 self.icon = build_icon(u':/media/media_image.png') self.alertsmanager = AlertsManager(self) - self.alertForm = AlertForm(self) + self.manager = DBManager(self.config) + self.alertForm = AlertForm(self.manager, self) self.status = PluginStatus.Active def get_settings_tab(self): @@ -87,6 +87,7 @@ class alertsPlugin(Plugin): self.config.set_config(u'active', self.alertsActive) def onAlertsTrigger(self): + self.alertForm.loadList() self.alertForm.exec_() def onalertsReport(self): diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py new file mode 100644 index 000000000..4756a318f --- /dev/null +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'alertform.ui' +# +# Created: Sat Feb 13 08:19:51 2010 +# by: PyQt4 UI code generator 4.6.2 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_AlertDialog(object): + def setupUi(self, AlertForm): + AlertForm.setObjectName("AlertDialog") + AlertForm.resize(430, 320) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + AlertForm.setWindowIcon(icon) + self.AlertFormLayout = QtGui.QVBoxLayout(AlertForm) + self.AlertFormLayout.setSpacing(8) + self.AlertFormLayout.setMargin(8) + self.AlertFormLayout.setObjectName("AlertFormLayout") + self.AlertEntryWidget = QtGui.QWidget(AlertForm) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.AlertEntryWidget.sizePolicy().hasHeightForWidth()) + self.AlertEntryWidget.setSizePolicy(sizePolicy) + self.AlertEntryWidget.setObjectName("AlertEntryWidget") + self.verticalLayout_2 = QtGui.QVBoxLayout(self.AlertEntryWidget) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.AlertEntryLabel = QtGui.QLabel(self.AlertEntryWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth()) + self.AlertEntryLabel.setSizePolicy(sizePolicy) + self.AlertEntryLabel.setObjectName("AlertEntryLabel") + self.verticalLayout.addWidget(self.AlertEntryLabel) + self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget) + self.AlertEntryEditItem.setObjectName("AlertEntryEditItem") + self.verticalLayout.addWidget(self.AlertEntryEditItem) + self.AlertListWidget = QtGui.QListWidget(self.AlertEntryWidget) + self.AlertListWidget.setObjectName("AlertListWidget") + self.verticalLayout.addWidget(self.AlertListWidget) + self.verticalLayout_2.addLayout(self.verticalLayout) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + spacerItem = QtGui.QSpacerItem(181, 38, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.DisplayButton = QtGui.QPushButton(self.AlertEntryWidget) + self.DisplayButton.setObjectName("DisplayButton") + self.horizontalLayout.addWidget(self.DisplayButton) + self.CancelButton = QtGui.QPushButton(self.AlertEntryWidget) + self.CancelButton.setObjectName("CancelButton") + self.horizontalLayout.addWidget(self.CancelButton) + self.verticalLayout_2.addLayout(self.horizontalLayout) + self.AlertFormLayout.addWidget(self.AlertEntryWidget) + + self.retranslateUi(AlertForm) + QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close) + QtCore.QMetaObject.connectSlotsByName(AlertForm) + + def retranslateUi(self, AlertForm): + AlertForm.setWindowTitle(QtGui.QApplication.translate("AlertForm", "Alert Message", None, QtGui.QApplication.UnicodeUTF8)) + self.AlertEntryLabel.setText(QtGui.QApplication.translate("AlertForm", "Alert Text:", None, QtGui.QApplication.UnicodeUTF8)) + self.DisplayButton.setText(QtGui.QApplication.translate("AlertForm", "Display", None, QtGui.QApplication.UnicodeUTF8)) + self.CancelButton.setText(QtGui.QApplication.translate("AlertForm", "Cancel", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/plugins/alerts/forms/alerteditdialog.py b/openlp/plugins/alerts/forms/alerteditdialog.py new file mode 100644 index 000000000..53985d82b --- /dev/null +++ b/openlp/plugins/alerts/forms/alerteditdialog.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'alerteditdialog.ui' +# +# Created: Sat Feb 13 08:20:09 2010 +# by: PyQt4 UI code generator 4.6.2 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_AlertList(object): + def setupUi(self, AlertList): + AlertList.setObjectName("AlertList") + AlertList.resize(400, 300) + self.buttonBox = QtGui.QDialogButtonBox(AlertList) + self.buttonBox.setGeometry(QtCore.QRect(220, 270, 173, 27)) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel) + self.buttonBox.setObjectName("buttonBox") + self.widget = QtGui.QWidget(AlertList) + self.widget.setGeometry(QtCore.QRect(20, 10, 361, 251)) + self.widget.setObjectName("widget") + self.verticalLayout_2 = QtGui.QVBoxLayout(self.widget) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.lineEdit = QtGui.QLineEdit(self.widget) + self.lineEdit.setObjectName("lineEdit") + self.horizontalLayout_2.addWidget(self.lineEdit) + self.SaveButton = QtGui.QPushButton(self.widget) + self.SaveButton.setObjectName("SaveButton") + self.horizontalLayout_2.addWidget(self.SaveButton) + self.verticalLayout_2.addLayout(self.horizontalLayout_2) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.listWidget = QtGui.QListWidget(self.widget) + self.listWidget.setAlternatingRowColors(True) + self.listWidget.setObjectName("listWidget") + self.horizontalLayout.addWidget(self.listWidget) + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.AddButton = QtGui.QPushButton(self.widget) + self.AddButton.setObjectName("AddButton") + self.verticalLayout.addWidget(self.AddButton) + self.EdirButton = QtGui.QPushButton(self.widget) + self.EdirButton.setObjectName("EdirButton") + self.verticalLayout.addWidget(self.EdirButton) + self.DeleteButton = QtGui.QPushButton(self.widget) + self.DeleteButton.setObjectName("DeleteButton") + self.verticalLayout.addWidget(self.DeleteButton) + self.horizontalLayout.addLayout(self.verticalLayout) + self.verticalLayout_2.addLayout(self.horizontalLayout) + + self.retranslateUi(AlertList) + QtCore.QMetaObject.connectSlotsByName(AlertList) + + def retranslateUi(self, AlertList): + AlertList.setWindowTitle(QtGui.QApplication.translate("AlertList", "Form", None, QtGui.QApplication.UnicodeUTF8)) + self.SaveButton.setText(QtGui.QApplication.translate("AlertList", "Save", None, QtGui.QApplication.UnicodeUTF8)) + self.AddButton.setText(QtGui.QApplication.translate("AlertList", "Add", None, QtGui.QApplication.UnicodeUTF8)) + self.EdirButton.setText(QtGui.QApplication.translate("AlertList", "Edit", None, QtGui.QApplication.UnicodeUTF8)) + self.DeleteButton.setText(QtGui.QApplication.translate("AlertList", "Delete", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 68549eaee..882da7cfa 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -23,79 +23,82 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import logging -from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon -from openlp.plugins.alerts.lib import alertmanager +from datetime import date -class AlertForm(QtGui.QDialog): - global log - log = logging.getLogger(u'AlertForm') +from PyQt4 import QtGui, QtCore +from openlp.plugins.alerts.lib.models import AlertItem - def __init__(self, parent): - QtGui.QDialog.__init__(self, None) +from alertdialog import Ui_AlertDialog + +class AlertForm(QtGui.QDialog, Ui_AlertDialog): + """ + Class documentation goes here. + """ + def __init__(self, manager, parent): + """ + Constructor + """ + self.manager = manager self.parent = parent + self.history_required = True + QtGui.QDialog.__init__(self, None) self.setupUi(self) - log.debug(u'AlertForm Defined') + QtCore.QObject.connect(self.CancelButton, + QtCore.SIGNAL(u'clicked()'), + AlertForm.close) + QtCore.QObject.connect(self.DisplayButton, + QtCore.SIGNAL(u'clicked()'), + self.onDisplayClicked) + QtCore.QObject.connect(self.AlertEntryEditItem, + QtCore.SIGNAL(u'textChanged(const QString&)'), + self.onTextChanged) + QtCore.QObject.connect(self.AlertListWidget, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.onDoubleClick) + QtCore.QObject.connect(self.AlertListWidget, + QtCore.SIGNAL(u'clicked(QModelIndex)'), + self.onSingleClick) - def setupUi(self, AlertForm): - AlertForm.setObjectName(u'AlertForm') - AlertForm.resize(370, 110) - icon = build_icon(u':/icon/openlp-logo-16x16.png') - AlertForm.setWindowIcon(icon) - self.AlertFormLayout = QtGui.QVBoxLayout(AlertForm) - self.AlertFormLayout.setSpacing(8) - self.AlertFormLayout.setMargin(8) - self.AlertFormLayout.setObjectName(u'AlertFormLayout') - self.AlertEntryWidget = QtGui.QWidget(AlertForm) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.AlertEntryWidget.sizePolicy().hasHeightForWidth()) - self.AlertEntryWidget.setSizePolicy(sizePolicy) - self.AlertEntryWidget.setObjectName(u'AlertEntryWidget') - self.AlertEntryLabel = QtGui.QLabel(self.AlertEntryWidget) - self.AlertEntryLabel.setGeometry(QtCore.QRect(0, 0, 353, 16)) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth()) - self.AlertEntryLabel.setSizePolicy(sizePolicy) - self.AlertEntryLabel.setObjectName(u'AlertEntryLabel') - self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget) - self.AlertEntryEditItem.setGeometry(QtCore.QRect(0, 20, 353, 26)) - self.AlertEntryEditItem.setObjectName(u'AlertEntryEditItem') - self.AlertFormLayout.addWidget(self.AlertEntryWidget) - self.ButtonBoxWidget = QtGui.QWidget(AlertForm) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.ButtonBoxWidget.sizePolicy().hasHeightForWidth()) - self.ButtonBoxWidget.setSizePolicy(sizePolicy) - self.ButtonBoxWidget.setObjectName(u'ButtonBoxWidget') - self.horizontalLayout = QtGui.QHBoxLayout(self.ButtonBoxWidget) - self.horizontalLayout.setSpacing(8) - self.horizontalLayout.setMargin(0) - self.horizontalLayout.setObjectName(u'horizontalLayout') - spacerItem = QtGui.QSpacerItem(267, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.DisplayButton = QtGui.QPushButton(self.ButtonBoxWidget) - self.DisplayButton.setObjectName(u'DisplayButton') - self.horizontalLayout.addWidget(self.DisplayButton) - self.CancelButton = QtGui.QPushButton(self.ButtonBoxWidget) - self.CancelButton.setObjectName(u'CancelButton') - self.horizontalLayout.addWidget(self.CancelButton) - self.AlertFormLayout.addWidget(self.ButtonBoxWidget) - self.retranslateUi(AlertForm) - QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL(u'clicked()'), AlertForm.close) - QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) - QtCore.QMetaObject.connectSlotsByName(AlertForm) - - def retranslateUi(self, AlertForm): - AlertForm.setWindowTitle(self.trUtf8('Alert Message')) - self.AlertEntryLabel.setText(self.trUtf8('Alert Text:')) - self.DisplayButton.setText(self.trUtf8('Display')) - self.CancelButton.setText(self.trUtf8('Cancel')) + def loadList(self): + self.AlertListWidget.clear() + alerts = self.manager.get_all_alerts() + for alert in alerts: + item_name = QtGui.QListWidgetItem(alert.text) + self.AlertListWidget.addItem(item_name) def onDisplayClicked(self): - self.parent.alertsmanager.displayAlert(unicode(self.AlertEntryEditItem.text())) + self.triggerAlert(unicode(self.AlertEntryEditItem.text())) + if self.parent.alertsTab.save_history and self.history_required: + alert = AlertItem() + alert.text = unicode(self.AlertEntryEditItem.text()) + self.manager.save_alert(alert) + self.history_required = False + self.loadList() + + def onTextChanged(self): + #Data has changed by editing it so potential storage + self.history_required = True + + def onDoubleClick(self): + """ + List item has been double clicked to display it + """ + items = self.AlertListWidget.selectedIndexes() + for item in items: + bitem = self.AlertListWidget.item(item.row()) + self.triggerAlert(bitem.text()) + self.history_required = False + + def onSingleClick(self): + """ + List item has been single clicked to add it to + the edit field so it can be changed. + """ + items = self.AlertListWidget.selectedIndexes() + for item in items: + bitem = self.AlertListWidget.item(item.row()) + self.AlertEntryEditItem.setText(bitem.text()) + self.history_required = False + + def triggerAlert(self, text): + self.parent.alertsmanager.displayAlert(text) diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index a6653d152..7c50ccc19 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -25,7 +25,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab +from openlp.core.lib import SettingsTab, str_to_bool class AlertsTab(SettingsTab): """ @@ -132,6 +132,38 @@ class AlertsTab(SettingsTab): QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.LocationLayout.addItem(self.LocationSpacer) self.FontLayout.addWidget(self.LocationWidget) + self.HistoryWidget = QtGui.QWidget(self.FontGroupBox) + self.HistoryWidget.setObjectName(u'HistoryWidget') + self.HistoryLayout = QtGui.QHBoxLayout(self.HistoryWidget) + self.HistoryLayout.setSpacing(8) + self.HistoryLayout.setMargin(0) + self.HistoryLayout.setObjectName(u'HistoryLayout') + self.HistoryLabel = QtGui.QLabel(self.HistoryWidget) + self.HistoryLabel.setObjectName(u'HistoryLabel') + self.HistoryLayout.addWidget(self.HistoryLabel) + self.HistoryCheckBox = QtGui.QCheckBox(self.HistoryWidget) + self.HistoryCheckBox.setObjectName(u'HistoryCheckBox') + self.HistoryLayout.addWidget(self.HistoryCheckBox) + self.HistorySpacer = QtGui.QSpacerItem(147, 20, + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.HistoryLayout.addItem(self.HistorySpacer) + self.FontLayout.addWidget(self.HistoryWidget) + self.HistoryEditWidget = QtGui.QWidget(self.FontGroupBox) + self.HistoryEditWidget.setObjectName(u'HistoryEditWidget') + self.HistoryEditLayout = QtGui.QHBoxLayout(self.HistoryEditWidget) + self.HistoryEditLayout.setSpacing(8) + self.HistoryEditLayout.setMargin(0) + self.HistoryEditLayout.setObjectName(u'HistoryEditLayout') + self.HistoryEditLabel = QtGui.QLabel(self.HistoryEditWidget) + self.HistoryEditLabel.setObjectName(u'HistoryEditLabel') + self.HistoryEditLayout.addWidget(self.HistoryEditLabel) + self.HistoryEditPushButton = QtGui.QPushButton(self.HistoryEditWidget) + self.HistoryEditPushButton.setObjectName(u'HistoryEditPushButton') + self.HistoryEditLayout.addWidget(self.HistoryEditPushButton) + self.HistoryEditSpacer = QtGui.QSpacerItem(147, 20, + QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.HistoryEditLayout.addItem(self.HistoryEditSpacer) + self.FontLayout.addWidget(self.HistoryEditWidget) self.SlideLeftLayout.addWidget(self.FontGroupBox) self.SlideLeftSpacer = QtGui.QSpacerItem(20, 94, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) @@ -170,6 +202,9 @@ class AlertsTab(SettingsTab): self.SlideRightLayout.addItem(self.SlideRightSpacer) self.AlertsLayout.addWidget(self.AlertRightColumn) # Signals and slots + QtCore.QObject.connect(self.HistoryCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onHistoryCheckBoxChanged) QtCore.QObject.connect(self.BackgroundColorButton, QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked) QtCore.QObject.connect(self.FontColorButton, @@ -193,6 +228,8 @@ class AlertsTab(SettingsTab): self.TimeoutLabel.setText(self.trUtf8('Alert timeout:')) self.TimeoutSpinBox.setSuffix(self.trUtf8('s')) self.LocationLabel.setText(self.trUtf8('Location:')) + self.HistoryLabel.setText(self.trUtf8('Keep History:')) + self.HistoryEditLabel.setText(self.trUtf8('Edit History:')) self.PreviewGroupBox.setTitle(self.trUtf8('Preview')) self.FontPreview.setText(self.trUtf8('openlp.org')) self.LocationComboBox.setItemText(0, self.trUtf8('Top')) @@ -211,6 +248,12 @@ class AlertsTab(SettingsTab): def onLocationComboBoxClicked(self, location): self.location = location + def onHistoryCheckBoxChanged(self, check_state): + self.save_history = False + # we have a set value convert to True/False + if check_state == QtCore.Qt.Checked: + self.save_history = True + def onFontColorButtonClicked(self): self.font_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.font_color), self).name() @@ -235,6 +278,8 @@ class AlertsTab(SettingsTab): self.font_face = unicode( self.config.get_config(u'font face', QtGui.QFont().family())) self.location = int(self.config.get_config(u'location', 0)) + self.save_history = str_to_bool( + self.config.get_config(u'save history', u'False')) self.FontSizeSpinBox.setValue(self.font_size) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet( @@ -242,6 +287,7 @@ class AlertsTab(SettingsTab): self.BackgroundColorButton.setStyleSheet( u'background-color: %s' % self.bg_color) self.LocationComboBox.setCurrentIndex(self.location) + self.HistoryCheckBox.setChecked(self.save_history) font = QtGui.QFont() font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) @@ -254,7 +300,9 @@ class AlertsTab(SettingsTab): self.config.set_config(u'font size', unicode(self.font_size)) self.config.set_config(u'font face', unicode(self.font_face)) self.config.set_config(u'timeout', unicode(self.timeout)) - self.config.set_config(u'location', unicode(self.LocationComboBox.currentIndex())) + self.config.set_config(u'location', + unicode(self.LocationComboBox.currentIndex())) + self.config.set_config(u'save history', unicode(self.save_history)) def updateDisplay(self): font = QtGui.QFont() diff --git a/openlp/plugins/alerts/lib/__init__.py b/openlp/plugins/alerts/lib/__init__.py index f6fb2c0d7..c39574719 100644 --- a/openlp/plugins/alerts/lib/__init__.py +++ b/openlp/plugins/alerts/lib/__init__.py @@ -23,3 +23,4 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### from alertsmanager import AlertsManager +from manager import DBManager diff --git a/openlp/plugins/alerts/lib/classes.py b/openlp/plugins/alerts/lib/classes.py new file mode 100644 index 000000000..eec21300c --- /dev/null +++ b/openlp/plugins/alerts/lib/classes.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +class BaseModel(object): + """ + BaseModel provides a base object with a set of generic functions + """ + + @classmethod + def populate(cls, **kwargs): + """ + Creates an instance of a class and populates it, returning the instance + """ + me = cls() + keys = kwargs.keys() + for key in keys: + me.__setattr__(key, kwargs[key]) + return me + +class AlertItem(BaseModel): + """ + Custom Slide model + """ + pass diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py new file mode 100644 index 000000000..79ed928e1 --- /dev/null +++ b/openlp/plugins/alerts/lib/manager.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +import logging + +from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem + +class DBManager(): + """ + The Song Manager provides a central location for all database code. This + class takes care of connecting to the database and running all the queries. + """ + + global log + log = logging.getLogger(u'AlertsDBManager') + log.info(u'Alerts DB loaded') + + def __init__(self, config): + """ + Creates the connection to the database, and creates the tables if they + don't exist. + """ + self.config = config + log.debug(u'Alerts Initialising') + self.db_url = u'' + db_type = self.config.get_config(u'db type', u'sqlite') + if db_type == u'sqlite': + self.db_url = u'sqlite:///%s/alerts.sqlite' % \ + self.config.get_data_path() + else: + self.db_url = u'%s://%s:%s@%s/%s' % \ + (db_type, self.config.get_config(u'db username'), + self.config.get_config(u'db password'), + self.config.get_config(u'db hostname'), + self.config.get_config(u'db database')) + self.session = init_models(self.db_url) + metadata.create_all(checkfirst=True) + + log.debug(u'Alerts Initialised') + + def get_all_alerts(self): + """ + Returns the details of a Alert Show + """ + return self.session.query(AlertItem).order_by(AlertItem.text).all() + + def save_alert(self, AlertItem): + """ + Saves a Alert show to the database + """ + log.debug(u'Alert added') + try: + self.session.add(AlertItem) + self.session.commit() + log.debug(u'Alert saved') + return True + except: + self.session.rollback() + log.excertion(u'Alert save failed') + return False + + def get_alerts(self, id=None): + """ + Returns the details of a Alert + """ + if id is None: + return AlertItem() + else: + return self.session.query(AlertItem).get(id) + + def delete_alert(self, id): + """ + Delete a Alert show + """ + if id !=0: + Alerts = self.get_Alert(id) + try: + self.session.delete(AlertItem) + self.session.commit() + return True + except: + self.session.rollback() + log.excertion(u'Alert deleton failed') + return False + else: + return True diff --git a/openlp/plugins/alerts/lib/meta.py b/openlp/plugins/alerts/lib/meta.py new file mode 100644 index 000000000..38b0f7206 --- /dev/null +++ b/openlp/plugins/alerts/lib/meta.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from sqlalchemy import MetaData + +__all__ = ['session', 'metadata', 'engine'] + +# SQLAlchemy database engine. Updated by model.init_model() +engine = None + +# SQLAlchemy session manager. Updated by model.init_model() +session = None + +# Global metadata. If you have multiple databases with overlapping table +# names, you'll need a metadata for each database +metadata = MetaData() \ No newline at end of file diff --git a/openlp/plugins/alerts/lib/models.py b/openlp/plugins/alerts/lib/models.py new file mode 100644 index 000000000..4f556cd23 --- /dev/null +++ b/openlp/plugins/alerts/lib/models.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from sqlalchemy import create_engine +from sqlalchemy.orm import scoped_session, sessionmaker, mapper + +from openlp.plugins.alerts.lib.meta import metadata +from openlp.plugins.alerts.lib.tables import * +from openlp.plugins.alerts.lib.classes import * + +def init_models(url): + engine = create_engine(url) + metadata.bind = engine + session = scoped_session(sessionmaker(autoflush=True, autocommit=False, + bind=engine)) + mapper(AlertItem, alerts_table) + return session diff --git a/openlp/plugins/alerts/lib/tables.py b/openlp/plugins/alerts/lib/tables.py new file mode 100644 index 000000000..0a731fb13 --- /dev/null +++ b/openlp/plugins/alerts/lib/tables.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from sqlalchemy import Column, Table, types + +from openlp.plugins.alerts.lib.meta import metadata + +# Definition of the "alerts" table +alerts_table = Table(u'alerts', metadata, + Column(u'id', types.Integer(), primary_key=True), + Column(u'text', types.UnicodeText, nullable=False)) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 9c7e6b280..ef8e6a090 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -27,8 +27,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import str_to_bool, Receiver -from openlp.core.lib import SettingsTab +from openlp.core.lib import str_to_bool, Receiver, SettingsTab class BiblesTab(SettingsTab): """ @@ -226,4 +225,4 @@ class BiblesTab(SettingsTab): # Not Found id = 0 self.bible_theme = u'' - self.BibleThemeComboBox.setCurrentIndex(id) \ No newline at end of file + self.BibleThemeComboBox.setCurrentIndex(id) diff --git a/openlp/plugins/custom/lib/tables.py b/openlp/plugins/custom/lib/tables.py index 061c6d5c3..13c9de5b9 100644 --- a/openlp/plugins/custom/lib/tables.py +++ b/openlp/plugins/custom/lib/tables.py @@ -27,11 +27,11 @@ from sqlalchemy import Column, Table, types from openlp.plugins.custom.lib.meta import metadata -# Definition of the "songs" table +# Definition of the "custom slide" table custom_slide_table = Table(u'custom_slide', metadata, Column(u'id', types.Integer(), primary_key=True), Column(u'title', types.Unicode(255), nullable=False), Column(u'text', types.UnicodeText, nullable=False), Column(u'credits', types.UnicodeText), Column(u'theme_name', types.Unicode(128)) -) \ No newline at end of file +) diff --git a/resources/forms/alertdialog.ui b/resources/forms/alertdialog.ui new file mode 100644 index 000000000..c3bfdaf8e --- /dev/null +++ b/resources/forms/alertdialog.ui @@ -0,0 +1,116 @@ + + + AlertForm + + + + 0 + 0 + 430 + 320 + + + + Alert Message + + + + :/icon/openlp.org-icon-32.bmp:/icon/openlp.org-icon-32.bmp + + + + 8 + + + 8 + + + + + + 0 + 0 + + + + + + + + + + 0 + 0 + + + + Alert Text: + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 181 + 38 + + + + + + + + Display + + + + + + + Cancel + + + + + + + + + + + + + + + + CancelButton + clicked() + AlertForm + close() + + + 294 + 66 + + + 257 + 3 + + + + + diff --git a/resources/forms/alerteditdialog.ui b/resources/forms/alerteditdialog.ui new file mode 100644 index 000000000..a4b63ccb7 --- /dev/null +++ b/resources/forms/alerteditdialog.ui @@ -0,0 +1,94 @@ + + + AlertList + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 220 + 270 + 173 + 27 + + + + QDialogButtonBox::Cancel + + + + + + 20 + 10 + 361 + 251 + + + + + + + + + + + + Save + + + + + + + + + + + true + + + + + + + + + Add + + + + + + + Edit + + + + + + + Delete + + + + + + + + + + + + + diff --git a/resources/forms/alertform.ui b/resources/forms/alertform.ui deleted file mode 100644 index 1caf4a356..000000000 --- a/resources/forms/alertform.ui +++ /dev/null @@ -1,133 +0,0 @@ - - AlertForm - - - - 0 - 0 - 370 - 105 - - - - Alert Message - - - - :/icon/openlp.org-icon-32.bmp:/icon/openlp.org-icon-32.bmp - - - - 8 - - - 8 - - - - - - 0 - 0 - - - - - - 0 - 0 - 353 - 16 - - - - - 0 - 0 - - - - Alert Text: - - - - - - 0 - 20 - 353 - 21 - - - - - - - - - - 0 - 0 - - - - - 8 - - - 0 - - - - - Qt::Horizontal - - - - 267 - 20 - - - - - - - - Display - - - - - - - Cancel - - - - - - - - - - - - - - CancelButton - clicked() - AlertForm - close() - - - 294 - 66 - - - 257 - 3 - - - - - From 2fefcef09d58137300037842d367360d19298d3d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 14 Feb 2010 20:19:57 +0000 Subject: [PATCH 10/25] Alerts editing now work - history and pre determined --- openlp/plugins/alerts/alertsplugin.py | 11 +- openlp/plugins/alerts/forms/__init__.py | 1 + openlp/plugins/alerts/forms/alertdialog.py | 3 +- .../plugins/alerts/forms/alerteditdialog.py | 70 ++++---- openlp/plugins/alerts/forms/alerteditform.py | 168 ++++++++++++++++++ openlp/plugins/alerts/forms/alertform.py | 3 - openlp/plugins/alerts/forms/alertstab.py | 10 +- openlp/plugins/alerts/lib/manager.py | 10 +- openlp/plugins/custom/lib/manager.py | 8 +- openlp/plugins/songusage/lib/manager.py | 2 +- resources/forms/alertdialog.ui | 6 +- resources/forms/alerteditdialog.ui | 33 ++-- 12 files changed, 257 insertions(+), 68 deletions(-) create mode 100644 openlp/plugins/alerts/forms/alerteditform.py diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 7214618d7..169e4b506 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus from openlp.plugins.alerts.lib import AlertsManager, DBManager -from openlp.plugins.alerts.forms import AlertsTab, AlertForm +from openlp.plugins.alerts.forms import AlertsTab, AlertForm, AlertEditForm class alertsPlugin(Plugin): global log @@ -44,10 +44,11 @@ class alertsPlugin(Plugin): self.alertsmanager = AlertsManager(self) self.manager = DBManager(self.config) self.alertForm = AlertForm(self.manager, self) + self.alertEditForm = AlertEditForm(self.manager, self) self.status = PluginStatus.Active def get_settings_tab(self): - self.alertsTab = AlertsTab(self.name) + self.alertsTab = AlertsTab(self) return self.alertsTab def add_tools_menu_item(self, tools_menu): @@ -90,9 +91,9 @@ class alertsPlugin(Plugin): self.alertForm.loadList() self.alertForm.exec_() - def onalertsReport(self): - self.alertsdetailform.initialise() - self.alertsdetailform.exec_() + def onAlertsEdit(self): + self.alertEditForm.loadList() + self.alertEditForm.exec_() def about(self): about_text = self.trUtf8('Alerts Plugin
This plugin ' diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py index dba3abc93..14c30d73b 100644 --- a/openlp/plugins/alerts/forms/__init__.py +++ b/openlp/plugins/alerts/forms/__init__.py @@ -25,3 +25,4 @@ from alertstab import AlertsTab from alertform import AlertForm +from alerteditform import AlertEditForm diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 4756a318f..3e467dd0e 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -43,6 +43,7 @@ class Ui_AlertDialog(object): self.AlertEntryEditItem.setObjectName("AlertEntryEditItem") self.verticalLayout.addWidget(self.AlertEntryEditItem) self.AlertListWidget = QtGui.QListWidget(self.AlertEntryWidget) + self.AlertListWidget.setAlternatingRowColors(True) self.AlertListWidget.setObjectName("AlertListWidget") self.verticalLayout.addWidget(self.AlertListWidget) self.verticalLayout_2.addLayout(self.verticalLayout) @@ -60,7 +61,7 @@ class Ui_AlertDialog(object): self.AlertFormLayout.addWidget(self.AlertEntryWidget) self.retranslateUi(AlertForm) - QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close) + QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), self.close) QtCore.QMetaObject.connectSlotsByName(AlertForm) def retranslateUi(self, AlertForm): diff --git a/openlp/plugins/alerts/forms/alerteditdialog.py b/openlp/plugins/alerts/forms/alerteditdialog.py index 53985d82b..c382d5352 100644 --- a/openlp/plugins/alerts/forms/alerteditdialog.py +++ b/openlp/plugins/alerts/forms/alerteditdialog.py @@ -2,62 +2,66 @@ # Form implementation generated from reading ui file 'alerteditdialog.ui' # -# Created: Sat Feb 13 08:20:09 2010 +# Created: Sun Feb 14 16:45:10 2010 # by: PyQt4 UI code generator 4.6.2 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui -class Ui_AlertList(object): - def setupUi(self, AlertList): - AlertList.setObjectName("AlertList") - AlertList.resize(400, 300) - self.buttonBox = QtGui.QDialogButtonBox(AlertList) +class Ui_AlertEditDialog(object): + def setupUi(self, AlertEditDialog): + AlertEditDialog.setObjectName("AlertEditDialog") + AlertEditDialog.resize(400, 300) + self.buttonBox = QtGui.QDialogButtonBox(AlertEditDialog) self.buttonBox.setGeometry(QtCore.QRect(220, 270, 173, 27)) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel) self.buttonBox.setObjectName("buttonBox") - self.widget = QtGui.QWidget(AlertList) - self.widget.setGeometry(QtCore.QRect(20, 10, 361, 251)) - self.widget.setObjectName("widget") - self.verticalLayout_2 = QtGui.QVBoxLayout(self.widget) + self.layoutWidget = QtGui.QWidget(AlertEditDialog) + self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 361, 251)) + self.layoutWidget.setObjectName("layoutWidget") + self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.lineEdit = QtGui.QLineEdit(self.widget) - self.lineEdit.setObjectName("lineEdit") - self.horizontalLayout_2.addWidget(self.lineEdit) - self.SaveButton = QtGui.QPushButton(self.widget) - self.SaveButton.setObjectName("SaveButton") - self.horizontalLayout_2.addWidget(self.SaveButton) + self.AlertLineEdit = QtGui.QLineEdit(self.layoutWidget) + self.AlertLineEdit.setObjectName("AlertLineEdit") + self.horizontalLayout_2.addWidget(self.AlertLineEdit) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") - self.listWidget = QtGui.QListWidget(self.widget) - self.listWidget.setAlternatingRowColors(True) - self.listWidget.setObjectName("listWidget") - self.horizontalLayout.addWidget(self.listWidget) + self.AlertListWidget = QtGui.QListWidget(self.layoutWidget) + self.AlertListWidget.setAlternatingRowColors(True) + self.AlertListWidget.setObjectName("AlertListWidget") + self.horizontalLayout.addWidget(self.AlertListWidget) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") - self.AddButton = QtGui.QPushButton(self.widget) + self.SaveButton = QtGui.QPushButton(self.layoutWidget) + self.SaveButton.setObjectName("SaveButton") + self.verticalLayout.addWidget(self.SaveButton) + self.ClearButton = QtGui.QPushButton(self.layoutWidget) + self.ClearButton.setObjectName("ClearButton") + self.verticalLayout.addWidget(self.ClearButton) + self.AddButton = QtGui.QPushButton(self.layoutWidget) self.AddButton.setObjectName("AddButton") self.verticalLayout.addWidget(self.AddButton) - self.EdirButton = QtGui.QPushButton(self.widget) - self.EdirButton.setObjectName("EdirButton") - self.verticalLayout.addWidget(self.EdirButton) - self.DeleteButton = QtGui.QPushButton(self.widget) + self.EditButton = QtGui.QPushButton(self.layoutWidget) + self.EditButton.setObjectName("EditButton") + self.verticalLayout.addWidget(self.EditButton) + self.DeleteButton = QtGui.QPushButton(self.layoutWidget) self.DeleteButton.setObjectName("DeleteButton") self.verticalLayout.addWidget(self.DeleteButton) self.horizontalLayout.addLayout(self.verticalLayout) self.verticalLayout_2.addLayout(self.horizontalLayout) - self.retranslateUi(AlertList) - QtCore.QMetaObject.connectSlotsByName(AlertList) + self.retranslateUi(AlertEditDialog) + QtCore.QMetaObject.connectSlotsByName(AlertEditDialog) - def retranslateUi(self, AlertList): - AlertList.setWindowTitle(QtGui.QApplication.translate("AlertList", "Form", None, QtGui.QApplication.UnicodeUTF8)) - self.SaveButton.setText(QtGui.QApplication.translate("AlertList", "Save", None, QtGui.QApplication.UnicodeUTF8)) - self.AddButton.setText(QtGui.QApplication.translate("AlertList", "Add", None, QtGui.QApplication.UnicodeUTF8)) - self.EdirButton.setText(QtGui.QApplication.translate("AlertList", "Edit", None, QtGui.QApplication.UnicodeUTF8)) - self.DeleteButton.setText(QtGui.QApplication.translate("AlertList", "Delete", None, QtGui.QApplication.UnicodeUTF8)) + def retranslateUi(self, AlertEditDialog): + AlertEditDialog.setWindowTitle(QtGui.QApplication.translate("AlertEditDialog", "Maintain Alerts", None, QtGui.QApplication.UnicodeUTF8)) + self.SaveButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Save", None, QtGui.QApplication.UnicodeUTF8)) + self.ClearButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8)) + self.AddButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Add", None, QtGui.QApplication.UnicodeUTF8)) + self.EditButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8)) + self.DeleteButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/plugins/alerts/forms/alerteditform.py b/openlp/plugins/alerts/forms/alerteditform.py new file mode 100644 index 000000000..fef8a04e5 --- /dev/null +++ b/openlp/plugins/alerts/forms/alerteditform.py @@ -0,0 +1,168 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from datetime import date + +from PyQt4 import QtGui, QtCore +from openlp.plugins.alerts.lib.models import AlertItem + +from alerteditdialog import Ui_AlertEditDialog + +class AlertEditForm(QtGui.QDialog, Ui_AlertEditDialog): + """ + Class documentation goes here. + """ + def __init__(self, manager, parent): + """ + Constructor + """ + self.manager = manager + self.parent = parent + QtGui.QDialog.__init__(self, None) + self.setupUi(self) + QtCore.QObject.connect(self.DeleteButton, + QtCore.SIGNAL(u'clicked()'), + self.onDeleteClick) + QtCore.QObject.connect(self.ClearButton, + QtCore.SIGNAL(u'clicked()'), + self.onClearClick) + QtCore.QObject.connect(self.EditButton, + QtCore.SIGNAL(u'clicked()'), + self.onEditClick) + QtCore.QObject.connect(self.AddButton, + QtCore.SIGNAL(u'clicked()'), + self.onAddClick) + QtCore.QObject.connect(self.SaveButton, + QtCore.SIGNAL(u'clicked()'), + self.onSaveClick) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'rejected()'), self.close) + QtCore.QObject.connect(self.AlertLineEdit, + QtCore.SIGNAL(u'textChanged(const QString&)'), + self.onTextChanged) + QtCore.QObject.connect(self.AlertListWidget, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + self.onItemSelected) + QtCore.QObject.connect(self.AlertListWidget, + QtCore.SIGNAL(u'clicked(QModelIndex)'), + self.onItemSelected) + + def loadList(self): + self.AlertListWidget.clear() + alerts = self.manager.get_all_alerts() + for alert in alerts: + item_name = QtGui.QListWidgetItem(alert.text) + item_name.setData( + QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) + self.AlertListWidget.addItem(item_name) + self.AddButton.setEnabled(True) + self.ClearButton.setEnabled(False) + self.SaveButton.setEnabled(False) + self.EditButton.setEnabled(False) + self.DeleteButton.setEnabled(False) + + def onItemSelected(self): + if len(self.AlertLineEdit.text()) > 0: + QtGui.QMessageBox.information(self, + self.trUtf8('Item selected to Edit'), + self.trUtf8('Please Save or Clear seletced item')) + else: + self.EditButton.setEnabled(True) + self.DeleteButton.setEnabled(True) + + def onDeleteClick(self): + item = self.AlertListWidget.currentItem() + if item: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.parent.manager.delete_alert(item_id) + row = self.AlertListWidget.row(item) + self.AlertListWidget.takeItem(row) + self.AddButton.setEnabled(True) + self.SaveButton.setEnabled(False) + self.DeleteButton.setEnabled(False) + self.EditButton.setEnabled(False) + + def onEditClick(self): + item = self.AlertListWidget.currentItem() + if item: + self.item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.AlertLineEdit.setText(unicode(item.text())) + self.AddButton.setEnabled(True) + self.ClearButton.setEnabled(True) + self.SaveButton.setEnabled(True) + self.DeleteButton.setEnabled(True) + self.EditButton.setEnabled(False) + + def onClearClick(self): + self.AlertLineEdit.setText(u'') + self.AddButton.setEnabled(False) + self.ClearButton.setEnabled(True) + self.SaveButton.setEnabled(False) + self.DeleteButton.setEnabled(False) + self.EditButton.setEnabled(False) + + def onAddClick(self): + if len(self.AlertLineEdit.text()) == 0: + QtGui.QMessageBox.information(self, + self.trUtf8('Item selected to Add'), + self.trUtf8('Missing data')) + else: + alert = AlertItem() + alert.text = unicode(self.AlertLineEdit.text()) + self.manager.save_alert(alert) + self.onClearClick() + self.loadList() + + def onSaveClick(self): + alert = self.manager.get_alert(self.item_id) + alert.text = unicode(self.AlertLineEdit.text()) + self.manager.save_alert(alert) + self.onClearClick() + self.loadList() + + def onTextChanged(self): + self.AddButton.setEnabled(True) + + def onDoubleClick(self): + """ + List item has been double clicked to display it + """ + items = self.AlertListWidget.selectedIndexes() + for item in items: + bitem = self.AlertListWidget.item(item.row()) + self.triggerAlert(bitem.text()) + + def onSingleClick(self): + """ + List item has been single clicked to add it to + the edit field so it can be changed. + """ + items = self.AlertListWidget.selectedIndexes() + for item in items: + bitem = self.AlertListWidget.item(item.row()) + self.AlertEntryEditItem.setText(bitem.text()) + + def triggerAlert(self, text): + self.parent.alertsmanager.displayAlert(text) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 882da7cfa..26f78e9b2 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -43,9 +43,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.history_required = True QtGui.QDialog.__init__(self, None) self.setupUi(self) - QtCore.QObject.connect(self.CancelButton, - QtCore.SIGNAL(u'clicked()'), - AlertForm.close) QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 7c50ccc19..c842c2e20 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -31,8 +31,9 @@ class AlertsTab(SettingsTab): """ AlertsTab is the alerts settings tab in the settings dialog. """ - def __init__(self, title, section=None): - SettingsTab.__init__(self, title, section) + def __init__(self, parent, section=None): + self.parent = parent + SettingsTab.__init__(self, parent.name, section) def setupUi(self): self.setObjectName(u'AlertsTab') @@ -209,6 +210,8 @@ class AlertsTab(SettingsTab): QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked) QtCore.QObject.connect(self.FontColorButton, QtCore.SIGNAL(u'pressed()'), self.onFontColorButtonClicked) + QtCore.QObject.connect(self.HistoryEditPushButton, + QtCore.SIGNAL(u'pressed()'), self.onHistoryEditButtonClicked) QtCore.QObject.connect(self.FontComboBox, QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked) QtCore.QObject.connect(self.LocationComboBox, @@ -268,6 +271,9 @@ class AlertsTab(SettingsTab): self.font_size = self.FontSizeSpinBox.value() self.updateDisplay() + def onHistoryEditButtonClicked(self): + self.parent.onAlertsEdit() + def load(self): self.timeout = int(self.config.get_config(u'timeout', 5)) self.font_color = unicode( diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py index 79ed928e1..3480b3103 100644 --- a/openlp/plugins/alerts/lib/manager.py +++ b/openlp/plugins/alerts/lib/manager.py @@ -78,10 +78,10 @@ class DBManager(): return True except: self.session.rollback() - log.excertion(u'Alert save failed') + log.exception(u'Alert save failed') return False - def get_alerts(self, id=None): + def get_alert(self, id=None): """ Returns the details of a Alert """ @@ -94,15 +94,15 @@ class DBManager(): """ Delete a Alert show """ - if id !=0: - Alerts = self.get_Alert(id) + if id != 0: + AlertItem = self.get_alert(id) try: self.session.delete(AlertItem) self.session.commit() return True except: self.session.rollback() - log.excertion(u'Alert deleton failed') + log.exception(u'Alert deleton failed') return False else: return True diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index 387368016..95ac873bd 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -78,7 +78,7 @@ class CustomManager(): return True except: self.session.rollback() - log.excertion(u'Custom Slide save failed') + log.exceptiontion(u'Custom Slide save failed') return False def get_custom(self, id=None): @@ -94,7 +94,7 @@ class CustomManager(): """ Delete a Custom slide show """ - if id !=0: + if id != 0: customslide = self.get_custom(id) try: self.session.delete(customslide) @@ -102,7 +102,7 @@ class CustomManager(): return True except: self.session.rollback() - log.excertion(u'Custom Slide deleton failed') + log.exception(u'Custom Slide deleton failed') return False else: - return True \ No newline at end of file + return True diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index 0b29d6c98..6cae4c372 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -96,7 +96,7 @@ class SongUsageManager(): """ Delete a SongUsage record """ - if id !=0: + if id != 0: songusageitem = self.get_songusage(id) try: self.session.delete(songusageitem) diff --git a/resources/forms/alertdialog.ui b/resources/forms/alertdialog.ui index c3bfdaf8e..da56f3847 100644 --- a/resources/forms/alertdialog.ui +++ b/resources/forms/alertdialog.ui @@ -52,7 +52,11 @@ - + + + true + + diff --git a/resources/forms/alerteditdialog.ui b/resources/forms/alerteditdialog.ui index a4b63ccb7..352e3d7b1 100644 --- a/resources/forms/alerteditdialog.ui +++ b/resources/forms/alerteditdialog.ui @@ -1,7 +1,7 @@ - AlertList - + AlertEditDialog + 0 @@ -11,7 +11,7 @@ - Form + Maintain Alerts @@ -26,7 +26,7 @@ QDialogButtonBox::Cancel - + 20 @@ -39,21 +39,14 @@ - - - - - - Save - - + - + true @@ -61,6 +54,20 @@ + + + + Save + + + + + + + Clear + + + From fef898655057d982973103bb19df2cebfe70cb67 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 16 Feb 2010 17:40:41 +0000 Subject: [PATCH 11/25] Fix theme import bug --- openlp/core/ui/alertstab.py | 2 +- openlp/core/ui/thememanager.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/alertstab.py b/openlp/core/ui/alertstab.py index d2e38e048..7efd6acfc 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/core/ui/alertstab.py @@ -209,4 +209,4 @@ class AlertsTab(SettingsTab): font.setPointSize(16) self.FontPreview.setFont(font) self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % \ - (self.bg_color, self.font_color)) \ No newline at end of file + (self.bg_color, self.font_color)) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 0bf005891..8ece41ac2 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -236,7 +236,7 @@ class ThemeManager(QtGui.QWidget): log.info(u'New Themes %s', unicode(files)) if len(files) > 0: for file in files: - self.config.set_last_dir(filename) + self.config.set_last_dir(unicode(file)) self.unzipTheme(file, self.path) self.loadThemes() @@ -343,7 +343,7 @@ class ThemeManager(QtGui.QWidget): self, self.trUtf8('Error'), self.trUtf8('File is not a valid theme!'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) - log.exception(u'Importing theme from zip file failed') + log.exception(u'Importing theme from zip file failed %s' % filename) finally: if zip: zip.close() @@ -400,7 +400,7 @@ class ThemeManager(QtGui.QWidget): newtheme.add_display(unicode(shadow), unicode(theme.ShadowColor.name()), unicode(outline), unicode(theme.OutlineColor.name()), unicode(theme.HorizontalAlign), unicode(theme.VerticalAlign), - unicode(theme.WrapStyle), 0) + unicode(theme.WrapStyle), unicode(0)) return newtheme.extract_xml() def saveTheme(self, name, theme_xml, theme_pretty_xml, image_from, From e0b7c54ddc95ff1c8a34122bab27588339dab741 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 16 Feb 2010 18:47:26 +0000 Subject: [PATCH 12/25] Minor fixes and unicode changes --- openlp/plugins/alerts/alertsplugin.py | 8 ++-- openlp/plugins/alerts/forms/alertdialog.py | 34 ++++++++-------- .../plugins/alerts/forms/alerteditdialog.py | 40 +++++++++---------- openlp/plugins/custom/lib/manager.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediaitem.py | 2 +- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 169e4b506..60e718bb3 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -34,11 +34,11 @@ from openlp.plugins.alerts.forms import AlertsTab, AlertForm, AlertEditForm class alertsPlugin(Plugin): global log - log = logging.getLogger(u'alertsPlugin') - log.info(u'alerts Plugin loaded') + log = logging.getLogger(u'AlertsPlugin') + log.info(u'Alerts Plugin loaded') def __init__(self, plugin_helpers): - Plugin.__init__(self, u'alerts', u'1.9.1', plugin_helpers) + Plugin.__init__(self, u'Alerts', u'1.9.1', plugin_helpers) self.weight = -3 self.icon = build_icon(u':/media/media_image.png') self.alertsmanager = AlertsManager(self) @@ -74,7 +74,7 @@ class alertsPlugin(Plugin): self.toolsAlertItem.setVisible(False) def initialise(self): - log.info(u'alerts Initialising') + log.info(u'Alerts Initialising') Plugin.initialise(self) self.toolsAlertItem.setVisible(True) diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 3e467dd0e..53fc1fff5 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -11,61 +11,61 @@ from PyQt4 import QtCore, QtGui class Ui_AlertDialog(object): def setupUi(self, AlertForm): - AlertForm.setObjectName("AlertDialog") + AlertForm.setObjectName(u'AlertDialog') AlertForm.resize(430, 320) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off) AlertForm.setWindowIcon(icon) self.AlertFormLayout = QtGui.QVBoxLayout(AlertForm) self.AlertFormLayout.setSpacing(8) self.AlertFormLayout.setMargin(8) - self.AlertFormLayout.setObjectName("AlertFormLayout") + self.AlertFormLayout.setObjectName(u'AlertFormLayout') self.AlertEntryWidget = QtGui.QWidget(AlertForm) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.AlertEntryWidget.sizePolicy().hasHeightForWidth()) self.AlertEntryWidget.setSizePolicy(sizePolicy) - self.AlertEntryWidget.setObjectName("AlertEntryWidget") + self.AlertEntryWidget.setObjectName(u'AlertEntryWidget') self.verticalLayout_2 = QtGui.QVBoxLayout(self.AlertEntryWidget) - self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout_2.setObjectName(u'verticalLayout_2') self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") + self.verticalLayout.setObjectName(u'verticalLayout') self.AlertEntryLabel = QtGui.QLabel(self.AlertEntryWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth()) self.AlertEntryLabel.setSizePolicy(sizePolicy) - self.AlertEntryLabel.setObjectName("AlertEntryLabel") + self.AlertEntryLabel.setObjectName(u'AlertEntryLabel') self.verticalLayout.addWidget(self.AlertEntryLabel) self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget) - self.AlertEntryEditItem.setObjectName("AlertEntryEditItem") + self.AlertEntryEditItem.setObjectName(u'AlertEntryEditItem') self.verticalLayout.addWidget(self.AlertEntryEditItem) self.AlertListWidget = QtGui.QListWidget(self.AlertEntryWidget) self.AlertListWidget.setAlternatingRowColors(True) - self.AlertListWidget.setObjectName("AlertListWidget") + self.AlertListWidget.setObjectName(u'AlertListWidget') self.verticalLayout.addWidget(self.AlertListWidget) self.verticalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") + self.horizontalLayout.setObjectName(u'horizontalLayout') spacerItem = QtGui.QSpacerItem(181, 38, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.DisplayButton = QtGui.QPushButton(self.AlertEntryWidget) - self.DisplayButton.setObjectName("DisplayButton") + self.DisplayButton.setObjectName(u'DisplayButton') self.horizontalLayout.addWidget(self.DisplayButton) self.CancelButton = QtGui.QPushButton(self.AlertEntryWidget) - self.CancelButton.setObjectName("CancelButton") + self.CancelButton.setObjectName(u'CancelButton') self.horizontalLayout.addWidget(self.CancelButton) self.verticalLayout_2.addLayout(self.horizontalLayout) self.AlertFormLayout.addWidget(self.AlertEntryWidget) self.retranslateUi(AlertForm) - QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), self.close) + QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL(u'clicked()'), self.close) QtCore.QMetaObject.connectSlotsByName(AlertForm) def retranslateUi(self, AlertForm): - AlertForm.setWindowTitle(QtGui.QApplication.translate("AlertForm", "Alert Message", None, QtGui.QApplication.UnicodeUTF8)) - self.AlertEntryLabel.setText(QtGui.QApplication.translate("AlertForm", "Alert Text:", None, QtGui.QApplication.UnicodeUTF8)) - self.DisplayButton.setText(QtGui.QApplication.translate("AlertForm", "Display", None, QtGui.QApplication.UnicodeUTF8)) - self.CancelButton.setText(QtGui.QApplication.translate("AlertForm", "Cancel", None, QtGui.QApplication.UnicodeUTF8)) + AlertForm.setWindowTitle(self.trUtf8('Alert Message')) + self.AlertEntryLabel.setText(self.trUtf8('Alert Text:')) + self.DisplayButton.setText(self.trUtf8('Display')) + self.CancelButton.setText(self.trUtf8('Cancel')) diff --git a/openlp/plugins/alerts/forms/alerteditdialog.py b/openlp/plugins/alerts/forms/alerteditdialog.py index c382d5352..6cf4769ef 100644 --- a/openlp/plugins/alerts/forms/alerteditdialog.py +++ b/openlp/plugins/alerts/forms/alerteditdialog.py @@ -11,45 +11,45 @@ from PyQt4 import QtCore, QtGui class Ui_AlertEditDialog(object): def setupUi(self, AlertEditDialog): - AlertEditDialog.setObjectName("AlertEditDialog") + AlertEditDialog.setObjectName(u'AlertEditDialog') AlertEditDialog.resize(400, 300) self.buttonBox = QtGui.QDialogButtonBox(AlertEditDialog) self.buttonBox.setGeometry(QtCore.QRect(220, 270, 173, 27)) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel) - self.buttonBox.setObjectName("buttonBox") + self.buttonBox.setObjectName(u'buttonBox') self.layoutWidget = QtGui.QWidget(AlertEditDialog) self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 361, 251)) - self.layoutWidget.setObjectName("layoutWidget") + self.layoutWidget.setObjectName(u'layoutWidget') self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget) - self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout_2.setObjectName(u'verticalLayout_2') self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.horizontalLayout_2.setObjectName(u'horizontalLayout_2') self.AlertLineEdit = QtGui.QLineEdit(self.layoutWidget) - self.AlertLineEdit.setObjectName("AlertLineEdit") + self.AlertLineEdit.setObjectName(u'AlertLineEdit') self.horizontalLayout_2.addWidget(self.AlertLineEdit) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") + self.horizontalLayout.setObjectName(u'horizontalLayout') self.AlertListWidget = QtGui.QListWidget(self.layoutWidget) self.AlertListWidget.setAlternatingRowColors(True) - self.AlertListWidget.setObjectName("AlertListWidget") + self.AlertListWidget.setObjectName(u'AlertListWidget') self.horizontalLayout.addWidget(self.AlertListWidget) self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") + self.verticalLayout.setObjectName(u'verticalLayout') self.SaveButton = QtGui.QPushButton(self.layoutWidget) - self.SaveButton.setObjectName("SaveButton") + self.SaveButton.setObjectName(u'SaveButton') self.verticalLayout.addWidget(self.SaveButton) self.ClearButton = QtGui.QPushButton(self.layoutWidget) - self.ClearButton.setObjectName("ClearButton") + self.ClearButton.setObjectName(u'ClearButton') self.verticalLayout.addWidget(self.ClearButton) self.AddButton = QtGui.QPushButton(self.layoutWidget) - self.AddButton.setObjectName("AddButton") + self.AddButton.setObjectName(u'AddButton') self.verticalLayout.addWidget(self.AddButton) self.EditButton = QtGui.QPushButton(self.layoutWidget) - self.EditButton.setObjectName("EditButton") + self.EditButton.setObjectName(u'EditButton') self.verticalLayout.addWidget(self.EditButton) self.DeleteButton = QtGui.QPushButton(self.layoutWidget) - self.DeleteButton.setObjectName("DeleteButton") + self.DeleteButton.setObjectName(u'DeleteButton') self.verticalLayout.addWidget(self.DeleteButton) self.horizontalLayout.addLayout(self.verticalLayout) self.verticalLayout_2.addLayout(self.horizontalLayout) @@ -58,10 +58,10 @@ class Ui_AlertEditDialog(object): QtCore.QMetaObject.connectSlotsByName(AlertEditDialog) def retranslateUi(self, AlertEditDialog): - AlertEditDialog.setWindowTitle(QtGui.QApplication.translate("AlertEditDialog", "Maintain Alerts", None, QtGui.QApplication.UnicodeUTF8)) - self.SaveButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Save", None, QtGui.QApplication.UnicodeUTF8)) - self.ClearButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8)) - self.AddButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Add", None, QtGui.QApplication.UnicodeUTF8)) - self.EditButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8)) - self.DeleteButton.setText(QtGui.QApplication.translate("AlertEditDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8)) + AlertEditDialog.setWindowTitle(self.trUtf8('Maintain Alerts')) + self.SaveButton.setText(self.trUtf8('Save')) + self.ClearButton.setText(self.trUtf8('Clear')) + self.AddButton.setText(self.trUtf8('Add')) + self.EditButton.setText(self.trUtf8('Edit')) + self.DeleteButton.setText(self.trUtf8('Delete')) diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index 95ac873bd..d1d3e0349 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -78,7 +78,7 @@ class CustomManager(): return True except: self.session.rollback() - log.exceptiontion(u'Custom Slide save failed') + log.exception(u'Custom Slide save failed') return False def get_custom(self, id=None): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 8ea1df64b..05d55ddb6 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -172,6 +172,6 @@ class ImageMediaItem(MediaManagerItem): filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) self.OverrideLabel.setText(bitem.text()) frame = QtGui.QImage(unicode(filename)) - self.parent.live_controller.parent.mainDisplay.addImageWithText(frame) + self.parent.mainDisplay.addImageWithText(frame) else: MediaManagerItem.onPreviewClick(self) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index c2dbc5d93..e8a4da198 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -54,7 +54,7 @@ class MediaMediaItem(MediaManagerItem): self.PreviewFunction = self.video_get_preview MediaManagerItem.__init__(self, parent, icon, title) self.ServiceItemIconName = u':/media/media_video.png' - self.MainDisplay = self.parent.live_controller.parent.mainDisplay + self.MainDisplay = self.parent.mainDisplay def initPluginNameVisible(self): self.PluginNameVisible = self.trUtf8('Media') From 04d79f72a1aeef20659ac4216254733c2d5e92ee Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 16 Feb 2010 18:51:41 +0000 Subject: [PATCH 13/25] Fix typos --- openlp/plugins/images/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediaitem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 05d55ddb6..145e07f04 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -172,6 +172,6 @@ class ImageMediaItem(MediaManagerItem): filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) self.OverrideLabel.setText(bitem.text()) frame = QtGui.QImage(unicode(filename)) - self.parent.mainDisplay.addImageWithText(frame) + self.parent.maindisplay.addImageWithText(frame) else: MediaManagerItem.onPreviewClick(self) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index e8a4da198..46b059c01 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -54,7 +54,7 @@ class MediaMediaItem(MediaManagerItem): self.PreviewFunction = self.video_get_preview MediaManagerItem.__init__(self, parent, icon, title) self.ServiceItemIconName = u':/media/media_video.png' - self.MainDisplay = self.parent.mainDisplay + self.MainDisplay = self.parent.maindisplay def initPluginNameVisible(self): self.PluginNameVisible = self.trUtf8('Media') From 959c2469a5c751b4c81169cb4e32d88ad491997f Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Tue, 16 Feb 2010 22:28:35 +0000 Subject: [PATCH 14/25] Fix PowerPoint and PowerPoint viewer screen lookup --- openlp/plugins/presentations/lib/powerpointcontroller.py | 2 +- openlp/plugins/presentations/lib/pptviewcontroller.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 18b644112..a9775e086 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -208,7 +208,7 @@ class PowerpointController(PresentationController): self.presentation.SlideShowSettings.Run() self.presentation.SlideShowWindow.View.GotoSlide(1) rendermanager = self.plugin.render_manager - rect = rendermanager.screen_list[rendermanager.current_display][u'size'] + rect = rendermanager.screens.current[u'size'] self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 0cf2405f1..2ed457fc0 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -108,7 +108,7 @@ class PptviewController(PresentationController): if self.pptid >= 0: self.close_presentation() rendermanager = self.plugin.render_manager - rect = rendermanager.screen_list[rendermanager.current_display][u'size'] + rect = rendermanager.screens.current[u'size'] rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom()) filepath = str(presentation.replace(u'/', u'\\')); try: From 711bd3cf00fc1e4afeb3d9382992ea797b9f550c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 17 Feb 2010 19:13:04 +0000 Subject: [PATCH 15/25] Import fixes and copyright insertion --- openlp/plugins/alerts/alertsplugin.py | 3 +-- openlp/plugins/alerts/forms/alerteditform.py | 2 -- openlp/plugins/alerts/forms/alertform.py | 3 +-- openlp/plugins/alerts/lib/alertsmanager.py | 27 +++++++++++++++++-- .../songusage/forms/songusagedeleteform.py | 2 -- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 60e718bb3..5bf268394 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -23,12 +23,11 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from datetime import datetime import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon, PluginStatus +from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.plugins.alerts.lib import AlertsManager, DBManager from openlp.plugins.alerts.forms import AlertsTab, AlertForm, AlertEditForm diff --git a/openlp/plugins/alerts/forms/alerteditform.py b/openlp/plugins/alerts/forms/alerteditform.py index fef8a04e5..4abc8a660 100644 --- a/openlp/plugins/alerts/forms/alerteditform.py +++ b/openlp/plugins/alerts/forms/alerteditform.py @@ -23,8 +23,6 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from datetime import date - from PyQt4 import QtGui, QtCore from openlp.plugins.alerts.lib.models import AlertItem diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 26f78e9b2..2d7dd1c21 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -23,9 +23,8 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from datetime import date - from PyQt4 import QtGui, QtCore + from openlp.plugins.alerts.lib.models import AlertItem from alertdialog import Ui_AlertDialog diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 1f4369588..5ed48f939 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -1,10 +1,33 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import str_to_bool, Receiver -from openlp.core.lib import SettingsTab +from openlp.core.lib import Receiver class AlertsManager(QtCore.QObject): """ diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 26fe2b7e2..56eb1954a 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -23,8 +23,6 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from datetime import date - from PyQt4 import QtGui from songusagedeletedialog import Ui_SongUsageDeleteDialog From 516b05e0ad526a5fec72875a327a6fd1e3719cf5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 17 Feb 2010 20:17:33 +0000 Subject: [PATCH 16/25] Fix URF8, copyright and alert error --- openlp/core/ui/maindisplay.py | 2 +- openlp/plugins/alerts/lib/alertsmanager.py | 2 + .../songusage/forms/songusagedetaildialog.py | 78 ++++++++++++------- 3 files changed, 53 insertions(+), 29 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 1ba31ea62..00470c9f6 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -203,7 +203,7 @@ class MainDisplay(DisplayWidget): if not self.primary: self.setVisible(True) self.showFullScreen() - self.generateAlert() + Receiver.send_message(u'flush_alert') def addImageWithText(self, frame): frame = resize_image(frame, diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 1f4369588..759edb12c 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -19,6 +19,8 @@ class AlertsManager(QtCore.QObject): self.parent = parent self.timer_id = 0 self.alertList = [] + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'flush_alert'), self.generateAlert) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alert_text'), self.displayAlert) QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 63866d1fd..d6ba2ecfb 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -1,69 +1,91 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -# Form implementation generated from reading ui file 'songusagedetaildialog.ui' -# -# Created: Tue Feb 9 07:34:05 2010 -# by: PyQt4 UI code generator 4.6.2 -# -# WARNING! All changes made in this file will be lost! +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### from PyQt4 import QtCore, QtGui class Ui_SongUsageDetailDialog(object): def setupUi(self, AuditDetailDialog): - AuditDetailDialog.setObjectName("AuditDetailDialog") + AuditDetailDialog.setObjectName(u'AuditDetailDialog') AuditDetailDialog.resize(609, 413) self.verticalLayout = QtGui.QVBoxLayout(AuditDetailDialog) - self.verticalLayout.setObjectName("verticalLayout") + self.verticalLayout.setObjectName(u'verticalLayout') self.DateRangeGroupBox = QtGui.QGroupBox(AuditDetailDialog) - self.DateRangeGroupBox.setObjectName("DateRangeGroupBox") + self.DateRangeGroupBox.setObjectName(u'DateRangeGroupBox') self.verticalLayout_2 = QtGui.QVBoxLayout(self.DateRangeGroupBox) - self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout_2.setObjectName(u'verticalLayout_2') self.DateHorizontalLayout = QtGui.QHBoxLayout() - self.DateHorizontalLayout.setObjectName("DateHorizontalLayout") + self.DateHorizontalLayout.setObjectName(u'DateHorizontalLayout') self.FromDate = QtGui.QCalendarWidget(self.DateRangeGroupBox) - self.FromDate.setObjectName("FromDate") + self.FromDate.setObjectName(u'FromDate') self.DateHorizontalLayout.addWidget(self.FromDate) self.ToLabel = QtGui.QLabel(self.DateRangeGroupBox) self.ToLabel.setScaledContents(False) self.ToLabel.setAlignment(QtCore.Qt.AlignCenter) - self.ToLabel.setObjectName("ToLabel") + self.ToLabel.setObjectName(u'ToLabel') self.DateHorizontalLayout.addWidget(self.ToLabel) self.ToDate = QtGui.QCalendarWidget(self.DateRangeGroupBox) - self.ToDate.setObjectName("ToDate") + self.ToDate.setObjectName(u'ToDate') self.DateHorizontalLayout.addWidget(self.ToDate) self.verticalLayout_2.addLayout(self.DateHorizontalLayout) self.FileGroupBox = QtGui.QGroupBox(self.DateRangeGroupBox) - self.FileGroupBox.setObjectName("FileGroupBox") + self.FileGroupBox.setObjectName(u'FileGroupBox') self.verticalLayout_4 = QtGui.QVBoxLayout(self.FileGroupBox) - self.verticalLayout_4.setObjectName("verticalLayout_4") + self.verticalLayout_4.setObjectName(u'verticalLayout_4') self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") + self.horizontalLayout.setObjectName(u'horizontalLayout') self.FileLineEdit = QtGui.QLineEdit(self.FileGroupBox) - self.FileLineEdit.setObjectName("FileLineEdit") + self.FileLineEdit.setObjectName(u'FileLineEdit') self.horizontalLayout.addWidget(self.FileLineEdit) self.SaveFilePushButton = QtGui.QPushButton(self.FileGroupBox) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/exports/export_load.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/exports/export_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.SaveFilePushButton.setIcon(icon) - self.SaveFilePushButton.setObjectName("SaveFilePushButton") + self.SaveFilePushButton.setObjectName(u'SaveFilePushButton') self.horizontalLayout.addWidget(self.SaveFilePushButton) self.verticalLayout_4.addLayout(self.horizontalLayout) self.verticalLayout_2.addWidget(self.FileGroupBox) self.verticalLayout.addWidget(self.DateRangeGroupBox) self.buttonBox = QtGui.QDialogButtonBox(AuditDetailDialog) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") + self.buttonBox.setObjectName(u'buttonBox') self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(AuditDetailDialog) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), AuditDetailDialog.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), AuditDetailDialog.close) - QtCore.QObject.connect(self.SaveFilePushButton, QtCore.SIGNAL("pressed()"), AuditDetailDialog.defineOutputLocation) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'accepted()'), + AuditDetailDialog.accept) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'rejected()'), + AuditDetailDialog.close) + QtCore.QObject.connect(self.SaveFilePushButton, + QtCore.SIGNAL(u'pressed()'), + AuditDetailDialog.defineOutputLocation) QtCore.QMetaObject.connectSlotsByName(AuditDetailDialog) def retranslateUi(self, AuditDetailDialog): - AuditDetailDialog.setWindowTitle(QtGui.QApplication.translate("AuditDetailDialog", "Audit Detail Extraction", None, QtGui.QApplication.UnicodeUTF8)) - self.DateRangeGroupBox.setTitle(QtGui.QApplication.translate("AuditDetailDialog", "Select Date Range", None, QtGui.QApplication.UnicodeUTF8)) - self.ToLabel.setText(QtGui.QApplication.translate("AuditDetailDialog", "to", None, QtGui.QApplication.UnicodeUTF8)) - self.FileGroupBox.setTitle(QtGui.QApplication.translate("AuditDetailDialog", "Report Location", None, QtGui.QApplication.UnicodeUTF8)) + AuditDetailDialog.setWindowTitle(self.trUtf8('Audit Detail Extraction')) + self.DateRangeGroupBox.setTitle(self.trUtf8('ASelect Date Range')) + self.ToLabel.setText(self.trUtf8('to')) + self.FileGroupBox.setTitle(self.trUtf8('Report Location')) From cf62d6187f75353e41d4a7ca5653fc2f38ef98cf Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 17 Feb 2010 22:57:59 +0000 Subject: [PATCH 17/25] More presentation fixes/tidies --- .../presentations/lib/impresscontroller.py | 6 +++--- .../presentations/lib/messagelistener.py | 20 ++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index b58a9affc..31b3ac5f6 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -201,7 +201,7 @@ class ImpressController(PresentationController): try: ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') except: - log.exception(u'Unable to fine running instance ') + log.exception(u'Unable to find running instance ') self.start_process() loop += 1 try: @@ -233,8 +233,8 @@ class ImpressController(PresentationController): def close_presentation(self): """ Close presentation and clean up objects - Triggerent by new object being added to SlideController orOpenLP - being shut down + Triggered by new object being added to SlideController or OpenLP + being shutdown """ log.debug(u'close Presentation OpenOffice') if self.document: diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 0b2fd6003..3c665004b 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -67,8 +67,8 @@ class Controller(object): def slide(self, slide, live): log.debug(u'Live = %s, slide' % live) -# if not isLive: -# return + if not live: + return self.activate() self.controller.goto_slide(int(slide) + 1) self.controller.poll_slidenumber(live) @@ -136,11 +136,13 @@ class Controller(object): self.controller.blank_screen() def unblank(self): - if not self.is_live: + if not self.isLive: return self.activate() self.controller.unblank_screen() + def poll(self): + self.controller.poll_slidenumber(self.isLive) class MessageListener(object): """ @@ -229,16 +231,10 @@ class MessageListener(object): self.previewHandler.shutdown() def blank(self): - if self.isLive: - self.liveHandler.blank() - else: - self.previewHandler.blank() + self.liveHandler.blank() def unblank(self): - if self.isLive: - self.liveHandler.unblank() - else: - self.previewHandler.unblank() + self.liveHandler.unblank() def splitMessage(self, message): """ @@ -263,4 +259,4 @@ class MessageListener(object): return message[0], file, message[4] def timeout(self): - self.controller.poll_slidenumber(self.is_live) + self.liveHandler.poll() From 8182b418b732f8b97dda16d5dd68f000ce40c819 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 19 Feb 2010 21:39:52 +0200 Subject: [PATCH 18/25] Updated version.txt to the latest revision. bzr-revno: 709 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 97fc2f582..6fbb27109 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.0-707 +1.9.0-709 From 70251a4321ebe8150eb620141d6df026c3e0a2df Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 21 Feb 2010 08:32:43 +0200 Subject: [PATCH 19/25] - Created independant "get_config_directory" and "get_data_directory" methods. - Moved log file to configuration file location for non-root/administrator users. --- openlp.pyw | 4 +-- openlp/core/utils/__init__.py | 46 ++++++++++++++++++++++++++----- openlp/core/utils/confighelper.py | 33 ++++------------------ 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index d35591a1c..5c18486b6 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, str_to_bool from openlp.core.resources import qInitResources from openlp.core.ui import MainWindow, SplashScreen, ScreenList -from openlp.core.utils import ConfigHelper +from openlp.core.utils import get_config_directory, ConfigHelper log = logging.getLogger() @@ -158,7 +158,7 @@ def main(): parser.add_option("-s", "--style", dest="style", help="Set the Qt4 style (passed directly to Qt4).") # Set up logging - filename = u'openlp.log' + filename = os.path.join(get_config_directory(), u'openlp.log') logfile = FileHandler(filename, u'w') logfile.setFormatter(logging.Formatter( u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s')) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9504c771e..e85b2d939 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -22,17 +22,12 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### + +import os import logging import urllib2 from datetime import datetime -from registry import Registry -from confighelper import ConfigHelper - -log = logging.getLogger(__name__) - -__all__ = ['Registry', 'ConfigHelper'] - log = logging.getLogger(__name__) def check_latest_version(config, current_version): @@ -54,3 +49,40 @@ def check_latest_version(config, current_version): if hasattr(e, u'reason'): log.exception(u'Reason for failure: %s', e.reason) return version_string + +def get_config_directory(): + path = u'' + if os.name == u'nt': + path = os.path.join(os.getenv(u'APPDATA'), u'openlp') + elif os.name == u'mac': + path = os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp') + else: + try: + from xdg import BaseDirectory + path = os.path.join(BaseDirectory.xdg_config_home, u'openlp') + except ImportError: + path = os.path.join(os.getenv(u'HOME'), u'.openlp') + return path + +def get_data_directory(): + path = u'' + if os.name == u'nt': + # ask OS for path to application data, set on Windows XP and Vista + path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data') + elif os.name == u'mac': + path = os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp', u'Data') + else: + try: + from xdg import BaseDirectory + path = os.path.join(BaseDirectory.xdg_data_home, u'openlp') + except ImportError: + path = os.path.join(os.getenv(u'HOME'), u'.openlp', u'data') + return path + +from registry import Registry +from confighelper import ConfigHelper + +__all__ = [u'Registry', u'ConfigHelper', u'get_config_directory', + u'get_data_directory', u'check_latest_version'] diff --git a/openlp/core/utils/confighelper.py b/openlp/core/utils/confighelper.py index 112712675..d49157f55 100644 --- a/openlp/core/utils/confighelper.py +++ b/openlp/core/utils/confighelper.py @@ -24,6 +24,8 @@ ############################################################################### import os + +from openlp.core.utils import get_data_directory, get_config_directory from openlp.core.utils.registry import Registry class ConfigHelper(object): @@ -34,20 +36,7 @@ class ConfigHelper(object): @staticmethod def get_data_path(): - if os.name == u'nt': - # ask OS for path to application data, set on Windows XP and Vista - path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data') - elif os.name == u'mac': - path = os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp', u'Data') - else: - try: - from xdg import BaseDirectory - path = os.path.join(BaseDirectory.xdg_data_home, u'openlp') - except ImportError: - path = os.path.join(os.getenv(u'HOME'), u'.openlp', u'data') - #reg = ConfigHelper.get_registry() - #path = ConfigHelper.get_config(u'main', 'data path', path) + path = get_data_directory() if not os.path.exists(path): os.makedirs(path) return path @@ -81,17 +70,7 @@ class ConfigHelper(object): current operating system, and returns an instantiation of that class. """ if ConfigHelper.__registry__ is None: - config_path = u'' - if os.name == u'nt': - config_path = os.path.join(os.getenv(u'APPDATA'), u'openlp') - elif os.name == u'mac': - config_path = os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp') - else: - try: - from xdg import BaseDirectory - config_path = os.path.join(BaseDirectory.xdg_config_home, u'openlp') - except ImportError: - config_path = os.path.join(os.getenv(u'HOME'), u'.openlp') + config_path = get_config_directory() ConfigHelper.__registry__ = Registry(config_path) - return ConfigHelper.__registry__ \ No newline at end of file + return ConfigHelper.__registry__ + From f7d95a8fdb41da2a5f4a878fd9cd8a4c6260770d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 21 Feb 2010 21:41:30 +0000 Subject: [PATCH 20/25] Remove debug prints --- openlp/core/ui/thememanager.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 18744187f..9e2a8ecce 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -237,8 +237,6 @@ class ThemeManager(QtGui.QWidget): if len(files) > 0: for file in files: self.config.set_last_dir(unicode(file)) - print file - print self.path self.unzipTheme(file, self.path) self.loadThemes() From 962f1364e47b61ef1777927fd6aee0631f2f00c1 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 21 Feb 2010 23:05:03 +0000 Subject: [PATCH 21/25] Fix v2 theme importing --- openlp/core/ui/thememanager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9e2a8ecce..a0168324f 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -314,6 +314,7 @@ class ThemeManager(QtGui.QWidget): themename = None for file in zip.namelist(): osfile = unicode(QtCore.QDir.toNativeSeparators(file)) + theme_dir = None if osfile.endswith(os.path.sep): theme_dir = os.path.join(dir, osfile) if not os.path.exists(theme_dir): @@ -325,6 +326,10 @@ class ThemeManager(QtGui.QWidget): # not preview file if themename is None: themename = names[0] + if theme_dir is None: + theme_dir = os.path.join(dir, names[0]) + if not os.path.exists(theme_dir): + os.mkdir(os.path.join(dir, names[0])) xml_data = zip.read(file) if os.path.splitext(file)[1].lower() in [u'.xml']: if self.checkVersion1(xml_data): From 45c7fad1d6f6f71ef0cc85c21a7b0f30b93aa9aa Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 21 Feb 2010 23:40:16 +0000 Subject: [PATCH 22/25] Fix theme import colours --- openlp/core/theme/theme.py | 2 +- openlp/core/ui/thememanager.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 92ffbfed2..0295912fa 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -136,7 +136,7 @@ class Theme(object): if (element.tag.find(u'Color') > 0 or (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): # convert to a wx.Colour - val = QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF) + val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) setattr(self, element.tag, val) def __str__(self): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a0168324f..dff0723c7 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -390,7 +390,6 @@ class ThemeManager(QtGui.QWidget): unicode(theme.BackgroundParameter2.name()), direction) else: newtheme.add_background_image(unicode(theme.BackgroundParameter1)) - newtheme.add_font(unicode(theme.FontName), unicode(theme.FontColor.name()), unicode(theme.FontProportion * 3), u'False') From 03371279854059a22add6c554463c42da060bac5 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 22 Feb 2010 15:53:23 +0000 Subject: [PATCH 23/25] Fix theme import alignment --- openlp/core/ui/thememanager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index dff0723c7..630b1a485 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -402,9 +402,14 @@ class ThemeManager(QtGui.QWidget): shadow = True if theme.Outline == 1: outline = True + vAlignCorrection = 0 + if theme.VerticalAlign == 2: + vAlignCorrection = 1 + elif theme.VerticalAlign == 1: + vAlignCorrection = 2 newtheme.add_display(unicode(shadow), unicode(theme.ShadowColor.name()), unicode(outline), unicode(theme.OutlineColor.name()), - unicode(theme.HorizontalAlign), unicode(theme.VerticalAlign), + unicode(theme.HorizontalAlign), unicode(vAlignCorrection), unicode(theme.WrapStyle), unicode(0)) return newtheme.extract_xml() From 61c7b6479fed352d8853dc6159447e4ff24942cd Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 22 Feb 2010 16:42:10 +0000 Subject: [PATCH 24/25] Fix theme import font colours --- openlp/core/theme/theme.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 0295912fa..27969c9d9 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -30,7 +30,7 @@ from PyQt4 import QtGui DelphiColors={"clRed":0xFF0000, "clBlue":0x0000FF, - "clYellow":0x0FFFF00, + "clYellow":0xFFFF00, "clBlack":0x000000, "clWhite":0xFFFFFF} @@ -113,6 +113,7 @@ class Theme(object): root = ElementTree(element=XML(xml)) iter = root.getiterator() for element in iter: + delphiColorChange = False if element.tag != u'Theme': t = element.text val = 0 @@ -128,6 +129,7 @@ class Theme(object): pass elif DelphiColors.has_key(t): val = DelphiColors[t] + delphiColorChange = True else: try: val = int(t) @@ -136,7 +138,10 @@ class Theme(object): if (element.tag.find(u'Color') > 0 or (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): # convert to a wx.Colour - val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) + if not delphiColorChange: + val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) + else: + val = QtGui.QColor((val>>16)&0xFF, (val>>8)&0xFF, val&0xFF) setattr(self, element.tag, val) def __str__(self): From d02fc68a721bf8b1996e2c8f19ccce4d72ae8522 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 22 Feb 2010 16:57:08 +0000 Subject: [PATCH 25/25] Fix unzipping theme files --- openlp/core/ui/thememanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 630b1a485..577021418 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -341,7 +341,7 @@ class ThemeManager(QtGui.QWidget): outfile = open(fullpath, u'w') outfile.write(filexml) else: - outfile = open(fullpath, u'w') + outfile = open(fullpath, u'wb') outfile.write(zip.read(file)) self.generateAndSaveImage(dir, themename, filexml) except: