From ce18ee8e7ace1964ca90ed09a0d8d411b6908c8a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 2 Oct 2009 00:43:16 +0100 Subject: [PATCH] Dialogs, Exceptions and PushButtons --- openlp/core/lib/__init__.py | 12 +++++++++++- openlp/core/lib/baselistwithdnd.py | 2 -- openlp/core/lib/toolbar.py | 12 ++++++++++++ openlp/core/ui/alertform.py | 2 +- openlp/core/ui/amendthemedialog.py | 2 -- openlp/core/ui/plugindialoglistform.py | 6 ++++-- openlp/core/ui/slidecontroller.py | 10 +++++----- openlp/plugins/presentations/lib/presentationtab.py | 1 - 8 files changed, 33 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 8552b66f9..cdbd6446a 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -54,7 +54,17 @@ def file_to_xml(xmlfile): ``xmlfile`` The name of the file. """ - return open(xmlfile).read() + file = None + xml = None + try: + file = open(xmlfile, u'r') + xml = file.read() + except IOError: + log.exception(u'Failed to open XML file') + finally: + if file: + file.close() + return xml def str_to_bool(stringvalue): """ diff --git a/openlp/core/lib/baselistwithdnd.py b/openlp/core/lib/baselistwithdnd.py index 60b001402..258b54422 100644 --- a/openlp/core/lib/baselistwithdnd.py +++ b/openlp/core/lib/baselistwithdnd.py @@ -24,8 +24,6 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib.toolbar import * - class BaseListWithDnD(QtGui.QListWidget): """ Please put a short description of what this class does in here. diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 4ed30d57d..81ee3e667 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -125,3 +125,15 @@ class OpenLPToolbar(QtGui.QToolBar): """ for widget in widgets: self.actions[widget].setVisible(True) + + def addPushButton(self, imageFile=None, text=u''): + """ + Adds a push button to the toolbar. + + Returns the push button + """ + pushButton = QtGui.QPushButton(buildIcon(imageFile), text) + pushButton.setCheckable(True) + pushButton.setFlat(True) + self.addWidget(pushButton) + return pushButton \ No newline at end of file diff --git a/openlp/core/ui/alertform.py b/openlp/core/ui/alertform.py index c7a51bdd5..fdc6066d1 100644 --- a/openlp/core/ui/alertform.py +++ b/openlp/core/ui/alertform.py @@ -31,7 +31,7 @@ class AlertForm(QtGui.QDialog): log = logging.getLogger(u'AlertForm') def __init__(self, parent=None): - QtGui.QDialog.__init__(self, None) + QtGui.QDialog.__init__(self, parent) self.parent = parent self.setupUi(self) log.debug(u'Defined') diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index 807beba69..63ffea5d8 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -120,8 +120,6 @@ class Ui_AmendThemeDialog(object): self.ImageToolButton.setObjectName(u'ImageToolButton') self.horizontalLayout_2.addWidget(self.ImageToolButton) self.BackgroundLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.ImageFilenameWidget) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - #self.BackgroundLayout.addItem(spacerItem, 7, 1, 1, 1) self.ThemeTabWidget.addTab(self.BackgroundTab, u'') self.FontMainTab = QtGui.QWidget() self.FontMainTab.setObjectName(u'FontMainTab') diff --git a/openlp/core/ui/plugindialoglistform.py b/openlp/core/ui/plugindialoglistform.py index afcc776ca..f501ebb44 100644 --- a/openlp/core/ui/plugindialoglistform.py +++ b/openlp/core/ui/plugindialoglistform.py @@ -9,14 +9,14 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, PluginStatus +from openlp.core.lib import translate, PluginStatus, buildIcon class PluginForm(QtGui.QDialog): global log log = logging.getLogger(u'PluginForm') def __init__(self, parent=None): - QtGui.QDialog.__init__(self, None) + QtGui.QDialog.__init__(self, parent) self.parent = parent self.setupUi(self) log.debug(u'Defined') @@ -24,6 +24,8 @@ class PluginForm(QtGui.QDialog): def setupUi(self, PluginForm): PluginForm.setObjectName(u'PluginForm') PluginForm.resize(400, 393) + icon = buildIcon(u':/icon/openlp-logo-16x16.png') + PluginForm.setWindowIcon(icon) self.PluginViewList = QtGui.QTableWidget(PluginForm) self.PluginViewList.setGeometry(QtCore.QRect(20, 10, 371, 331)) self.PluginViewList.setObjectName(u'PluginViewList') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e7a9cf52e..03782ebe7 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -131,10 +131,8 @@ class SlideController(QtGui.QWidget): self.onSlideSelectedLast) if self.isLive: self.Toolbar.addToolbarSeparator(u'Close Separator') - self.Toolbar.addToolbarButton(u'Close Screen', - u':/slides/slide_close.png', - translate(u'SlideController', u'Close Screen'), - self.onBlankScreen) + self.blackPushButton = self.Toolbar.addPushButton( + u':/slides/slide_close.png') if not self.isLive: self.Toolbar.addToolbarSeparator(u'Close Separator') self.Toolbar.addToolbarButton(u'Go Live', @@ -190,6 +188,8 @@ class SlideController(QtGui.QWidget): QtCore.QObject.connect(self.PreviewListWidget, QtCore.SIGNAL(u'activated(QModelIndex)'), self.onSlideSelected) if isLive: + QtCore.QObject.connect(self.blackPushButton, + QtCore.SIGNAL(u'toggled(bool)'), self.onBlankScreen) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_spin_delay'), self.receiveSpinDelay) Receiver().send_message(u'request_spin_delay') @@ -337,7 +337,7 @@ class SlideController(QtGui.QWidget): """ row = self.PreviewListWidget.currentRow() if row > -1 and row < self.PreviewListWidget.rowCount(): - label = self.PreviewListWidget.cellWidget(row, 0) + #label = self.PreviewListWidget.cellWidget(row, 0) frame = self.serviceitem.frames[row][u'image'] before = time.time() if frame is None: diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 8eb04d44d..307cb8c76 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -22,7 +22,6 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import os from PyQt4 import QtGui from openlp.core.lib import SettingsTab, translate