diff --git a/openlp.pyw b/openlp.pyw index f3455962d..017e12774 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -34,7 +34,7 @@ from subprocess import Popen, PIPE from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, check_directory_exists from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow from openlp.core.ui.exceptionform import ExceptionForm @@ -150,16 +150,16 @@ class OpenLP(QtGui.QApplication): log.info(u'Openlp version %s' % app_version[u'version']) return app_version - def notify(self, obj, evt): - #TODO needed for presentation exceptions - return QtGui.QApplication.notify(self, obj, evt) +# def notify(self, obj, evt): +# #TODO needed for presentation exceptions +# return QtGui.QApplication.notify(self, obj, evt) def run(self): """ Run the OpenLP application. """ app_version = self._get_version() - #provide a listener for widgets to reqest a screen update. + # provide a listener for widgets to reqest a screen update. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_process_events'), self.processEvents) QtCore.QObject.connect(Receiver.get_receiver(), @@ -182,7 +182,7 @@ class OpenLP(QtGui.QApplication): screens = ScreenList() # Decide how many screens we have and their size for screen in xrange(0, self.desktop().numScreens()): - size = self.desktop().screenGeometry(screen); + size = self.desktop().screenGeometry(screen) screens.add_screen({u'number': screen, u'size': size, u'primary': (self.desktop().primaryScreen() == screen)}) @@ -216,7 +216,7 @@ class OpenLP(QtGui.QApplication): def setNormalCursor(self): """ - Sets the Normal Cursor forthe Application + Sets the Normal Cursor for the Application """ self.restoreOverrideCursor() @@ -243,8 +243,7 @@ def main(): help='Set the Qt4 style (passed directly to Qt4).') # Set up logging log_path = AppLocation.get_directory(AppLocation.CacheDir) - if not os.path.exists(log_path): - os.makedirs(log_path) + check_directory_exists(log_path) filename = os.path.join(log_path, u'openlp.log') logfile = logging.FileHandler(filename, u'w') logfile.setFormatter(logging.Formatter( @@ -281,4 +280,4 @@ if __name__ == u'__main__': """ Instantiate and run the application. """ - main() + main() \ No newline at end of file diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ebbe31597..7ad377817 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -35,52 +35,51 @@ from PyQt4 import QtCore, QtGui log = logging.getLogger(__name__) -# TODO make external and configurable in alpha 4 via a settings dialog -html_expands = [] +base_html_expands = [] -html_expands.append({u'desc': u'Red', u'start tag': u'{r}', +base_html_expands.append({u'desc': u'Red', u'start tag': u'{r}', u'start html': u'', - u'end tag': u'{/r}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Black', u'start tag': u'{b}', + u'end tag': u'{/r}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Black', u'start tag': u'{b}', u'start html': u'', - u'end tag': u'{/b}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}', + u'end tag': u'{/b}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}', u'start html': u'', - u'end tag': u'{/bl}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}', + u'end tag': u'{/bl}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}', u'start html': u'', - u'end tag': u'{/y}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Green', u'start tag': u'{g}', + u'end tag': u'{/y}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Green', u'start tag': u'{g}', u'start html': u'', - u'end tag': u'{/g}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}', + u'end tag': u'{/g}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}', u'start html': u'', - u'end tag': u'{/pk}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Orange', u'start tag': u'{o}', + u'end tag': u'{/pk}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Orange', u'start tag': u'{o}', u'start html': u'', - u'end tag': u'{/o}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}', + u'end tag': u'{/o}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}', u'start html': u'', - u'end tag': u'{/pp}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'White', u'start tag': u'{w}', + u'end tag': u'{/pp}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'White', u'start tag': u'{w}', u'start html': u'', - u'end tag': u'{/w}', u'end html': u'', u'protected': False}) -html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}', + u'end tag': u'{/w}', u'end html': u'', u'protected': True}) +base_html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}', u'start html': u'', u'end tag': u'{/su}', u'end html': u'', u'protected': True}) -html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}', +base_html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}', u'start html': u'', u'end tag': u'{/sb}', u'end html': u'', u'protected': True}) -html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}', +base_html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}', u'start html': u'

', u'end tag': u'{/p}', u'end html': u'

', u'protected': True}) -html_expands.append({u'desc': u'Bold', u'start tag': u'{st}', +base_html_expands.append({u'desc': u'Bold', u'start tag': u'{st}', u'start html': u'', u'end tag': u'{/st}', u'end html': u'', u'protected': True}) -html_expands.append({u'desc': u'Italics', u'start tag': u'{it}', +base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}', u'start html': u'', u'end tag': u'{/it}', u'end html': u'', u'protected': True}) -html_expands.append({u'desc': u'Underline', u'start tag': u'{u}', +base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}', u'start html': u'', u'end tag': u'{/u}', u'end html': u'', u'protected': True}) @@ -102,7 +101,8 @@ def translate(context, text, comment=None, An identifying string for when the same text is used in different roles within the same context. """ - return QtCore.QCoreApplication.translate(context, text, comment, encoding, n) + return QtCore.QCoreApplication.translate( + context, text, comment, encoding, n) def get_text_file_string(text_file): """ @@ -293,7 +293,7 @@ def clean_tags(text): Remove Tags from text for display """ text = text.replace(u'
', u'\n') - for tag in html_expands: + for tag in DisplayTags.get_html_tags(): text = text.replace(tag[u'start tag'], u'') text = text.replace(tag[u'end tag'], u'') return text @@ -302,13 +302,25 @@ def expand_tags(text): """ Expand tags HTML for display """ - for tag in html_expands: + for tag in DisplayTags.get_html_tags(): text = text.replace(tag[u'start tag'], tag[u'start html']) text = text.replace(tag[u'end tag'], tag[u'end html']) return text +def check_directory_exists(dir): + """ + Check a theme directory exists and if not create it + + ``dir`` + Theme directory to make sure exists + """ + log.debug(u'check_directory_exists') + if not os.path.exists(dir): + os.makedirs(dir) + from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \ BackgroundType, HorizontalType, VerticalType +from displaytags import DisplayTags from spelltextedit import SpellTextEdit from eventreceiver import Receiver from imagemanager import ImageManager diff --git a/openlp/core/lib/displaytags.py b/openlp/core/lib/displaytags.py new file mode 100644 index 000000000..dd7276a7d --- /dev/null +++ b/openlp/core/lib/displaytags.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +""" +Provide Html Tag management and Display Tag access class +""" + +from openlp.core.lib import base_html_expands + +class DisplayTags(object): + """ + Static Class to HTML Tags to be access around the code the list is managed + by the Options Tab. + """ + html_expands = [] + + @staticmethod + def get_html_tags(): + """ + Provide access to the html_expands list. + """ + return DisplayTags.html_expands + + @staticmethod + def reset_html_tags(): + """ + Resets the html_expands list. + """ + DisplayTags.html_expands = [] + for html in base_html_expands: + DisplayTags.html_expands.append(html) + + @staticmethod + def add_html_tag(tag): + """ + Add a new tag to the list + """ + DisplayTags.html_expands.append(tag) + + @staticmethod + def remove_html_tag(id): + """ + Removes amd individual html_expands list. + """ + DisplayTags.html_expands.pop(id) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 9c4187337..24841ec33 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -48,4 +48,3 @@ class OpenLPDockWidget(QtGui.QDockWidget): self.setObjectName(name) if icon: self.setWindowIcon(icon) - self.setFloating(False) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index a9484795b..2d6bcce46 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -111,7 +111,7 @@ class MediaManagerItem(QtGui.QWidget): self.singleServiceItem = True self.pageLayout = QtGui.QVBoxLayout(self) self.pageLayout.setSpacing(0) - self.pageLayout.setContentsMargins(4, 0, 4, 0) + self.pageLayout.setMargin(0) self.requiredIcons() self.setupUi() self.retranslateUi() @@ -176,7 +176,8 @@ class MediaManagerItem(QtGui.QWidget): # break compatability), but it makes sense for the icon to # come before the tooltip (as you have to have an icon, but # not neccesarily a tooltip) - self.toolbar.addToolbarButton(title, icon, tooltip, slot, checkable) + return self.toolbar.addToolbarButton(title, icon, tooltip, slot, + checkable) def addToolbarSeparator(self): """ @@ -268,7 +269,6 @@ class MediaManagerItem(QtGui.QWidget): #Add the List widget self.listView = self.ListViewWithDnD_class(self) self.listView.uniformItemSizes = True - self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) self.listView.setSpacing(1) self.listView.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 8bc5fdb96..5a3fa41ce 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -175,6 +175,10 @@ class Plugin(QtCore.QObject): self.status = new_status QtCore.QSettings().setValue( self.settingsSection + u'/status', QtCore.QVariant(self.status)) + if new_status == PluginStatus.Active: + self.initialise() + elif new_status == PluginStatus.Inactive: + self.finalise() def isActive(self): """ @@ -314,4 +318,4 @@ class Plugin(QtCore.QObject): """ Called to define all translatable texts of the plugin """ - pass \ No newline at end of file + pass diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 738661e14..c69e1f15b 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -69,7 +69,7 @@ class SearchEdit(QtGui.QLineEdit): """ frameWidth = self.style().pixelMetric( QtGui.QStyle.PM_DefaultFrameWidth) - rightPadding = self.clearButton.sizeHint().width() + frameWidth + rightPadding = self.clearButton.width() + frameWidth if hasattr(self, u'menuButton'): leftPadding = self.menuButton.width() self.setStyleSheet( @@ -78,10 +78,10 @@ class SearchEdit(QtGui.QLineEdit): else: self.setStyleSheet(u'QLineEdit { padding-right: %spx; } ' % \ rightPadding) - msz = self.minimumSizeHint(); + msz = self.minimumSizeHint() self.setMinimumSize( max(msz.width(), - self.clearButton.sizeHint().width() + (frameWidth * 2) + 2), + self.clearButton.width() + (frameWidth * 2) + 2), max(msz.height(), self.clearButton.height() + (frameWidth * 2) + 2) ) @@ -93,13 +93,13 @@ class SearchEdit(QtGui.QLineEdit): ``event`` The event that happened. """ - sz = self.clearButton.sizeHint() + sz = self.clearButton.size() frameWidth = self.style().pixelMetric( QtGui.QStyle.PM_DefaultFrameWidth) self.clearButton.move(self.rect().right() - frameWidth - sz.width(), (self.rect().bottom() + 1 - sz.height()) / 2) if hasattr(self, u'menuButton'): - sz = self.menuButton.sizeHint() + sz = self.menuButton.size() self.menuButton.move(self.rect().left() + frameWidth + 2, (self.rect().bottom() + 1 - sz.height()) / 2) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 6586a50f2..297185127 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -55,7 +55,34 @@ class SettingsTab(QtGui.QWidget): """ Setup the tab's interface. """ - pass + self.tabLayout = QtGui.QHBoxLayout(self) + self.tabLayout.setObjectName(u'tabLayout') + self.leftColumn = QtGui.QWidget(self) + self.leftColumn.setObjectName(u'leftColumn') + self.leftLayout = QtGui.QVBoxLayout(self.leftColumn) + self.leftLayout.setMargin(0) + self.leftLayout.setObjectName(u'leftLayout') + self.tabLayout.addWidget(self.leftColumn) + self.rightColumn = QtGui.QWidget(self) + self.rightColumn.setObjectName(u'rightColumn') + self.rightLayout = QtGui.QVBoxLayout(self.rightColumn) + self.rightLayout.setMargin(0) + self.rightLayout.setObjectName(u'rightLayout') + self.tabLayout.addWidget(self.rightColumn) + + def resizeEvent(self, event=None): + """ + Resize the sides in two equal halves if the layout allows this. + """ + if event: + QtGui.QWidget.resizeEvent(self, event) + width = self.width() - self.tabLayout.spacing() - \ + self.tabLayout.contentsMargins().left() - \ + self.tabLayout.contentsMargins().right() + left_width = min(width - self.rightColumn.minimumSizeHint().width(), + width / 2) + left_width = max(left_width, self.leftColumn.minimumSizeHint().width()) + self.leftColumn.setFixedWidth(left_width) def preLoad(self): """ @@ -87,6 +114,12 @@ class SettingsTab(QtGui.QWidget): """ pass + def cancel(self): + """ + Reset any settings + """ + pass + def postSetUp(self, postUpdate=False): """ Changes which need to be made after setup of application diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index ebd4046c0..30811e08b 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -36,7 +36,7 @@ except ImportError: # http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check from PyQt4 import QtCore, QtGui -from openlp.core.lib import html_expands, translate +from openlp.core.lib import translate, DisplayTags class SpellTextEdit(QtGui.QPlainTextEdit): """ @@ -88,7 +88,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): popupMenu.insertMenu(popupMenu.actions()[0], spell_menu) tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Formatting Tags')) - for html in html_expands: + for html in DisplayTags.get_html_tags(): action = SpellAction( html[u'desc'], tagMenu) action.correct.connect(self.htmlTag) tagMenu.addAction(action) @@ -110,7 +110,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): """ Replaces the selected text with word. """ - for html in html_expands: + for html in DisplayTags.get_html_tags(): if tag == html[u'desc']: cursor = self.textCursor() if self.textCursor().hasSelection(): @@ -158,4 +158,4 @@ class SpellAction(QtGui.QAction): def __init__(self, *args): QtGui.QAction.__init__(self, *args) self.triggered.connect(lambda x: self.correct.emit( - unicode(self.text()))) \ No newline at end of file + unicode(self.text()))) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 1e4a9854e..35b62ddda 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -598,4 +598,4 @@ class ThemeXML(object): self.font_footer_shadow_size) self.add_display(self.display_horizontal_align, self.display_vertical_align, - self.display_slide_transition) \ No newline at end of file + self.display_slide_transition) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index e37dc6f22..93aed62e5 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -72,27 +72,27 @@ class OpenLPToolbar(QtGui.QToolBar): ``objectname`` The name of the object, as used in `