From 3c3c1f19cefaa80846288d87d556c120569a665e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 11 Sep 2009 05:54:22 +0100 Subject: [PATCH 1/7] Custom Plugin cleaup --- openlp/core/lib/mediamanageritem.py | 21 ++- openlp/plugins/custom/customplugin.py | 10 +- .../plugins/custom/forms/editcustomdialog.py | 136 ++++++++++------ openlp/plugins/custom/forms/editcustomform.py | 99 +++++++---- openlp/plugins/custom/lib/__init__.py | 1 - openlp/plugins/custom/lib/customtab.py | 33 ---- openlp/plugins/custom/lib/mediaitem.py | 154 ++++++++++-------- openlp/plugins/images/lib/mediaitem.py | 1 - openlp/plugins/presentations/lib/mediaitem.py | 2 +- resources/forms/editcustomdialog.ui | 84 +++++++--- 10 files changed, 324 insertions(+), 217 deletions(-) delete mode 100644 openlp/plugins/custom/lib/customtab.py diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8ccc51919..93f24a01f 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -173,6 +173,8 @@ class MediaManagerItem(QtGui.QWidget): """ # Add a toolbar self.addToolbar() + #Allow the plugin to define it's own header + self.addHeaderBar1() # Create buttons for the toolbar ## File Button ## if self.hasFileIcon: @@ -185,13 +187,13 @@ class MediaManagerItem(QtGui.QWidget): self.addToolbarButton( translate(self.TranslationContext, u'New '+self.PluginTextShort), translate(self.TranslationContext, u'Add a new '+self.PluginTextShort), - u':'+self.IconPath+ u'_load.png', self.onNewClick, self.PluginTextShort+u'NewItem') + u':'+self.IconPath+ u'_new.png', self.onNewClick, self.PluginTextShort+u'NewItem') ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( translate(self.TranslationContext, u'Edit '+self.PluginTextShort), translate(self.TranslationContext, u'Edit the selected '+self.PluginTextShort), - u':'+self.IconPath+ u'_load.png', self.onEditClick, self.PluginTextShort+u'EditItem') + u':'+self.IconPath+ u'_edit.png', self.onEditClick, self.PluginTextShort+u'EditItem') ## Delete Button ## self.addToolbarButton( translate(self.TranslationContext, u'Delete '+self.PluginTextShort), @@ -215,7 +217,7 @@ class MediaManagerItem(QtGui.QWidget): translate(self.TranslationContext, u'Add the selected item(s) to the service'), u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem') #Allow the plugin to define it's own header - self.addHeaderBar() + self.addHeaderBar2() #Add the List widget self.ListView = self.ListViewWithDnD_class() self.ListView.uniformItemSizes = True @@ -234,7 +236,7 @@ class MediaManagerItem(QtGui.QWidget): ':' +self.IconPath+u'_new.png', translate(self.TranslationContext, u'&Edit '+self.PluginTextShort), self.onEditClick)) - self.ListView.addAction(self.contextMenuSeparator(self.SongListWidget)) + self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction(contextMenuAction( self.ListView, ':/system/system_preview.png', translate(self.TranslationContext, u'&Preview '+self.PluginTextShort), @@ -258,7 +260,16 @@ class MediaManagerItem(QtGui.QWidget): """ pass - def addHeaderBar(self): + def addHeaderBar1(self): + """ + Slot at start of toolbar for pluin to addwidgets + """ + pass + + def addHeaderBar2(self): + """ + Slot at end of toolbar for pluin to add widgets + """ pass def onFileClick(self): diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index fd1cb43e1..352cf1c53 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -23,10 +23,18 @@ from PyQt4 import QtCore, QtGui from forms import EditCustomForm from openlp.core.lib import Plugin -from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem +from openlp.plugins.custom.lib import CustomManager, CustomMediaItem class CustomPlugin(Plugin): + """ + This plugin enables the user to create, edit and display + custom slide shows. Custom shows are divided into slides. + Each show is able to have it's own theme. + Custom shows are designed to replace the use of songs where + the songs plugin has become restrictive. Examples could be + Welcome slides, Bible Reading information, Orders of service. + """ global log log=logging.getLogger(u'CustomPlugin') diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 6b2fefa32..8eef9291b 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -1,11 +1,22 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, -# Form implementation generated from reading ui file 'editcustomdialog.ui' -# -# Created: Sat Mar 7 09:01:43 2009 -# by: PyQt4 UI code generator 4.4.4 -# -# WARNING! All changes made in this file will be lost! +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 from openlp.core.lib import translate @@ -15,7 +26,7 @@ class Ui_customEditDialog(object): customEditDialog.setObjectName(u'customEditDialog') customEditDialog.resize(590, 541) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off) customEditDialog.setWindowIcon(icon) self.gridLayout = QtGui.QGridLayout(customEditDialog) self.gridLayout.setObjectName(u'gridLayout') @@ -31,8 +42,8 @@ class Ui_customEditDialog(object): self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(u'horizontalLayout_4') self.VerseListView = QtGui.QListWidget(customEditDialog) - self.VerseListView.setObjectName(u'VerseListView') self.VerseListView.setAlternatingRowColors(True) + self.VerseListView.setObjectName(u'VerseListView') self.horizontalLayout_4.addWidget(self.VerseListView) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(u'verticalLayout') @@ -54,47 +65,49 @@ class Ui_customEditDialog(object): self.gridLayout.addLayout(self.horizontalLayout_4, 1, 0, 1, 1) self.EditWidget = QtGui.QWidget(customEditDialog) self.EditWidget.setObjectName(u'EditWidget') - self.EditLayout = QtGui.QHBoxLayout(self.EditWidget) - self.EditLayout.setSpacing(8) - self.EditLayout.setMargin(0) - self.EditLayout.setObjectName(u'EditLayout') + self.EditLayout_3 = QtGui.QHBoxLayout(self.EditWidget) + self.EditLayout_3.setSpacing(8) + self.EditLayout_3.setMargin(0) + self.EditLayout_3.setObjectName(u'EditLayout_3') self.VerseTextEdit = QtGui.QTextEdit(self.EditWidget) self.VerseTextEdit.setObjectName(u'VerseTextEdit') - self.EditLayout.addWidget(self.VerseTextEdit) - self.ButtonWidget = QtGui.QWidget(self.EditWidget) - self.ButtonWidget.setObjectName(u'ButtonWidget') - self.ButtonLayout = QtGui.QVBoxLayout(self.ButtonWidget) - self.ButtonLayout.setSpacing(8) - self.ButtonLayout.setMargin(0) - self.ButtonLayout.setObjectName(u'ButtonLayout') - self.AddButton = QtGui.QPushButton(self.ButtonWidget) + self.EditLayout_3.addWidget(self.VerseTextEdit) + self.ButtonWidge = QtGui.QWidget(self.EditWidget) + self.ButtonWidge.setObjectName(u'ButtonWidge') + self.verticalLayout_2 = QtGui.QVBoxLayout(self.ButtonWidge) + self.verticalLayout_2.setObjectName(u'verticalLayout_2') + self.AddButton = QtGui.QPushButton(self.ButtonWidge) self.AddButton.setObjectName(u'AddButton') - self.ButtonLayout.addWidget(self.AddButton) - self.EditButton = QtGui.QPushButton(self.ButtonWidget) + self.AddButton.setToolTip(translate(u'customEditDialog', u'Add new slide at bottom')) + self.verticalLayout_2.addWidget(self.AddButton) + self.EditButton = QtGui.QPushButton(self.ButtonWidge) self.EditButton.setObjectName(u'EditButton') - self.ButtonLayout.addWidget(self.EditButton) - self.SaveButton = QtGui.QPushButton(self.ButtonWidget) + self.verticalLayout_2.addWidget(self.EditButton) + self.EditAllButton = QtGui.QPushButton(self.ButtonWidge) + self.EditAllButton.setObjectName(u'EditAllButton') + self.verticalLayout_2.addWidget(self.EditAllButton) + self.SaveButton = QtGui.QPushButton(self.ButtonWidge) self.SaveButton.setObjectName(u'SaveButton') - self.ButtonLayout.addWidget(self.SaveButton) - self.DeleteButton = QtGui.QPushButton(self.ButtonWidget) + self.verticalLayout_2.addWidget(self.SaveButton) + self.DeleteButton = QtGui.QPushButton(self.ButtonWidge) self.DeleteButton.setObjectName(u'DeleteButton') - self.ButtonLayout.addWidget(self.DeleteButton) - self.ClearButton = QtGui.QPushButton(self.ButtonWidget) + self.verticalLayout_2.addWidget(self.DeleteButton) + self.ClearButton = QtGui.QPushButton(self.ButtonWidge) self.ClearButton.setObjectName(u'ClearButton') - self.ButtonLayout.addWidget(self.ClearButton) + self.verticalLayout_2.addWidget(self.ClearButton) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.ButtonLayout.addItem(spacerItem1) - self.EditLayout.addWidget(self.ButtonWidget) + self.verticalLayout_2.addItem(spacerItem1) + self.EditLayout_3.addWidget(self.ButtonWidge) self.gridLayout.addWidget(self.EditWidget, 2, 0, 1, 1) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(u'horizontalLayout') + self.horizontalLayout_3 = QtGui.QHBoxLayout() + self.horizontalLayout_3.setObjectName(u'horizontalLayout_3') self.ThemeLabel = QtGui.QLabel(customEditDialog) self.ThemeLabel.setObjectName(u'ThemeLabel') - self.horizontalLayout.addWidget(self.ThemeLabel) - self.ThemecomboBox = QtGui.QComboBox(customEditDialog) - self.ThemecomboBox.setObjectName(u'ThemecomboBox') - self.horizontalLayout.addWidget(self.ThemecomboBox) - self.gridLayout.addLayout(self.horizontalLayout, 3, 0, 1, 1) + self.horizontalLayout_3.addWidget(self.ThemeLabel) + self.ThemeComboBox = QtGui.QComboBox(customEditDialog) + self.ThemeComboBox.setObjectName(u'ThemeComboBox') + self.horizontalLayout_3.addWidget(self.ThemeComboBox) + self.gridLayout.addLayout(self.horizontalLayout_3, 3, 0, 1, 1) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(u'horizontalLayout_2') self.CreditLabel = QtGui.QLabel(customEditDialog) @@ -108,24 +121,39 @@ class Ui_customEditDialog(object): self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(u'buttonBox') self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1) + self.retranslateUi(customEditDialog) QtCore.QMetaObject.connectSlotsByName(customEditDialog) customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit) - customEditDialog.setTabOrder(self.VerseTextEdit, self.EditButton) - customEditDialog.setTabOrder(self.EditButton, self.SaveButton) - customEditDialog.setTabOrder(self.SaveButton, self.CreditEdit) - customEditDialog.setTabOrder(self.CreditEdit, self.VerseListView) - customEditDialog.setTabOrder(self.VerseListView, self.AddButton) - customEditDialog.setTabOrder(self.AddButton, self.DeleteButton) - customEditDialog.setTabOrder(self.DeleteButton, self.buttonBox) + customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton) + customEditDialog.setTabOrder(self.AddButton, self.VerseListView) + customEditDialog.setTabOrder(self.VerseListView, self.EditButton) + customEditDialog.setTabOrder(self.EditButton, self.EditAllButton) + customEditDialog.setTabOrder(self.EditAllButton, self.SaveButton) + customEditDialog.setTabOrder(self.SaveButton, self.DeleteButton) + customEditDialog.setTabOrder(self.DeleteButton, self.CreditEdit) + customEditDialog.setTabOrder(self.CreditEdit, self.UpButton) + customEditDialog.setTabOrder(self.UpButton, self.DownButton) + customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox) + customEditDialog.setTabOrder(self.ThemeComboBox, self.buttonBox) def retranslateUi(self, customEditDialog): - customEditDialog.setWindowTitle(translate(u'customEditDialog', u'Edit Custom Slides')) - self.TitleLabel.setText(translate(u'customEditDialog', u'Title:')) - self.AddButton.setText(translate(u'customEditDialog', u'Add')) - self.EditButton.setText(translate(u'customEditDialog', u'Edit')) - self.SaveButton.setText(translate(u'customEditDialog', u'Save')) - self.DeleteButton.setText(translate(u'customEditDialog', u'Delete')) - self.ClearButton.setText(translate(u'customEditDialog', u'Clear')) - self.ThemeLabel.setText(translate(u'customEditDialog', u'Theme:')) - self.CreditLabel.setText(translate(u'customEditDialog', u'Credits:')) + self.UpButton.setToolTip(translate(u'customEditDialog', u'Move slide Up 1')) + self.DownButton.setToolTip(translate(u'customEditDialog', u'Move slide down 1')) + customEditDialog.setWindowTitle(translate(u'customEditDialog', 'Edit Custom Slides')) + self.TitleLabel.setText(translate(u'customEditDialog', 'Title:')) + self.AddButton.setText(translate(u'customEditDialog', 'Add New')) + self.AddButton.setToolTip(translate(u'customEditDialog', u'Add new slide at bottom')) + self.EditButton.setText(translate(u'customEditDialog', 'Edit')) + self.EditButton.setToolTip(translate(u'customEditDialog', u'Edit selected slide')) + self.EditAllButton.setText(translate(u'customEditDialog', 'Edit All')) + self.EditAllButton.setToolTip(translate(u'customEditDialog', u'Edit all slides')) + self.SaveButton.setText(translate(u'customEditDialog', 'Save')) + self.SaveButton.setToolTip(translate(u'customEditDialog', u'Replace edited slide')) + self.DeleteButton.setText(translate(u'customEditDialog', 'Delete')) + self.DeleteButton.setToolTip(translate(u'customEditDialog', u'Delete selected slide')) + self.ClearButton.setText(translate(u'customEditDialog', 'Clear')) + self.ClearButton.setToolTip(translate(u'customEditDialog', u'Clear edit area')) + self.ThemeLabel.setText(translate(u'customEditDialog', 'Theme:')) + self.ThemeComboBox.setToolTip(translate(u'customEditDialog', u'Set Theme for Slides')) + self.CreditLabel.setText(translate(u'customEditDialog', 'Credits:')) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a223a9429..260e08424 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -35,20 +35,33 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): #self.parent = parent self.setupUi(self) # Connecting signals and slots - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), self.rejected) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), self.accept) - QtCore.QObject.connect(self.AddButton, QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed) - QtCore.QObject.connect(self.EditButton, QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) - QtCore.QObject.connect(self.SaveButton, QtCore.SIGNAL(u'pressed()'), self.onSaveButtonPressed) - QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed) - QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL(u'pressed()'), self.onClearButtonPressed) - QtCore.QObject.connect(self.UpButton, QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) - QtCore.QObject.connect(self.DownButton, QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'rejected()'), self.rejected) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'accepted()'), self.accept) + QtCore.QObject.connect(self.AddButton, + QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed) + QtCore.QObject.connect(self.EditButton, + QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed) + QtCore.QObject.connect(self.EditAllButton, + QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed) + QtCore.QObject.connect(self.SaveButton, + QtCore.SIGNAL(u'pressed()'), self.onSaveButtonPressed) + QtCore.QObject.connect(self.DeleteButton, + QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed) + QtCore.QObject.connect(self.ClearButton, + QtCore.SIGNAL(u'pressed()'), self.onClearButtonPressed) + QtCore.QObject.connect(self.UpButton, + QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) + QtCore.QObject.connect(self.DownButton, + QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) QtCore.QObject.connect(self.VerseListView, - QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected) + QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), + self.onVerseListViewSelected) QtCore.QObject.connect(self.VerseListView, - QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed) + QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), + self.onVerseListViewPressed) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_themes'), self.loadThemes) # Create other objects and forms @@ -56,23 +69,25 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.initialise() def initialise(self): - self.valid = True + self.editAll = False self.DeleteButton.setEnabled(False) self.EditButton.setEnabled(False) + self.EditAllButton.setEnabled(True) self.SaveButton.setEnabled(False) + self.ClearButton.setEnabled(False) self.TitleEdit.setText(u'') self.CreditEdit.setText(u'') self.VerseTextEdit.clear() self.VerseListView.clear() #make sure we have a new item self.customSlide = CustomSlide() - self.ThemecomboBox.addItem(u'') + self.ThemeComboBox.addItem(u'') def loadThemes(self, themelist): - self.ThemecomboBox.clear() - self.ThemecomboBox.addItem(u'') + self.ThemeComboBox.clear() + self.ThemeComboBox.addItem(u'') for themename in themelist: - self.ThemecomboBox.addItem(themename) + self.ThemeComboBox.addItem(themename) def loadCustom(self, id): self.customSlide = CustomSlide() @@ -87,12 +102,12 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): for verse in verseList: self.VerseListView.addItem(verse[1]) theme = unicode(self.customSlide.theme_name) - id = self.ThemecomboBox.findText(theme, QtCore.Qt.MatchExactly) + id = self.ThemeComboBox.findText(theme, QtCore.Qt.MatchExactly) if id == -1: id = 0 # Not Found - self.ThemecomboBox.setCurrentIndex(id) + self.ThemeComboBox.setCurrentIndex(id) else: - self.ThemecomboBox.setCurrentIndex(0) + self.ThemeComboBox.setCurrentIndex(0) def accept(self): valid , message = self._validate() @@ -111,7 +126,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.customSlide.title = unicode(self.TitleEdit.displayText()) self.customSlide.text = unicode(sxml.extract_xml()) self.customSlide.credits = unicode(self.CreditEdit.displayText()) - self.customSlide.theme_name = unicode(self.ThemecomboBox.currentText()) + self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText()) self.custommanager.save_slide(self.customSlide) self.close() @@ -135,6 +150,10 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): def onClearButtonPressed(self): self.VerseTextEdit.clear() + self.editAll = False + self.AddButton.setEnabled(True) + self.EditAllButton.setEnabled(True) + self.SaveButton.setEnabled(False) def onVerseListViewPressed(self, item): self.DeleteButton.setEnabled(True) @@ -151,30 +170,52 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): def onEditButtonPressed(self): self.editText(self.VerseListView.currentItem().text()) + def onEditAllButtonPressed(self): + self.editAll = True + self.AddButton.setEnabled(False) + if self.VerseListView.count() > 0: + verse_list = u'' + for row in range(0, self.VerseListView.count()): + item = self.VerseListView.item(row) + verse_list += item.text() + verse_list += u'\n---\n' + self.editText(verse_list) + def editText(self, text): self.beforeText = text self.VerseTextEdit.setPlainText(text) self.DeleteButton.setEnabled(False) self.EditButton.setEnabled(False) + self.EditAllButton.setEnabled(False) self.SaveButton.setEnabled(True) + self.ClearButton.setEnabled(True) def onSaveButtonPressed(self): - self.VerseListView.currentItem().setText(self.VerseTextEdit.toPlainText()) - #number of lines has change - if len(self.beforeText.split(u'\n')) != len(self.VerseTextEdit.toPlainText().split(u'\n')): - tempList = {} - for row in range(0, self.VerseListView.count()): - tempList[row] = self.VerseListView.item(row).text() + if self.editAll: self.VerseListView.clear() - for row in range (0, len(tempList)): - self.VerseListView.addItem(tempList[row]) - self.VerseListView.repaint() + for row in unicode(self.VerseTextEdit.toPlainText()).split(u'---'): + self.VerseListView.addItem(row) + else: + self.VerseListView.currentItem().setText(self.VerseTextEdit.toPlainText()) + #number of lines has change + if len(self.beforeText.split(u'\n')) != len(self.VerseTextEdit.toPlainText().split(u'\n')): + tempList = {} + for row in range(0, self.VerseListView.count()): + tempList[row] = self.VerseListView.item(row).text() + self.VerseListView.clear() + for row in range (0, len(tempList)): + self.VerseListView.addItem(tempList[row]) + self.VerseListView.repaint() + self.AddButton.setEnabled(True) self.SaveButton.setEnabled(False) self.EditButton.setEnabled(False) + self.EditAllButton.setEnabled(True) + self.VerseTextEdit.clear() def onDeleteButtonPressed(self): self.VerseListView.takeItem(self.VerseListView.currentRow()) self.EditButton.setEnabled(False) + self.EditAllButton.setEnabled(True) def _validate(self): valid = True diff --git a/openlp/plugins/custom/lib/__init__.py b/openlp/plugins/custom/lib/__init__.py index afecb5dd1..92c85de87 100644 --- a/openlp/plugins/custom/lib/__init__.py +++ b/openlp/plugins/custom/lib/__init__.py @@ -18,5 +18,4 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ from manager import CustomManager -from customtab import CustomTab from mediaitem import CustomMediaItem diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py deleted file mode 100644 index 2140cd1e2..000000000 --- a/openlp/plugins/custom/lib/customtab.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -""" -OpenLP - Open Source Lyrics Projection -Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley, - -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 - -from openlp.core.lib import SettingsTab, translate - -class CustomTab(SettingsTab): - """ - SongsTab is the songs settings tab in the settings dialog. - """ - def __init__(self): - SettingsTab.__init__(self, translate(u'CustomTab', u'Custom'), u'Custom') - - def setupUi(self): - self.setObjectName(u'CustomTab') diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index d264d52d4..3ce6433c7 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -21,7 +21,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD +from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, \ + translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD class CustomListView(BaseListWithDnD): def __init__(self, parent=None): @@ -40,77 +41,86 @@ class CustomMediaItem(MediaManagerItem): self.TranslationContext = u'CustomPlugin' self.PluginTextShort = u'Custom' self.ConfigSection = u'custom' + self.IconPath = u'custom/custom' + self.hasFileIcon = False + self.hasNewIcon = True + self.hasEditIcon = True + # this next is a class, not an instance of a class - it will + # be instanced by the base MediaManagerItem + self.ListViewWithDnD_class = CustomListView + self.ServiceItemIconName = u':/custom/custom_image.png' + self.servicePath = None MediaManagerItem.__init__(self, parent, icon, title) self.parent = parent - def setupUi(self): - # Add a toolbar - self.addToolbar() - # Create buttons for the toolbar - ## New Custom Button ## - self.addToolbarButton( - translate(u'CustomMediaItem',u'New Custom Item'), - translate(u'CustomMediaItem',u'Add a new Custom Item'), - u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem') - ## Edit Custom Button ## - self.addToolbarButton( - translate(u'CustomMediaItem',u'Edit Custom Item'), - translate(u'CustomMediaItem',u'Edit the selected Custom Item'), - u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem') - ## Delete Custom Button ## - self.addToolbarButton( - translate(u'CustomMediaItem',u'Delete Custom Item'), - translate(u'CustomMediaItem',u'Delete the selected Custom Item'), - u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem') - ## Separator Line ## - self.addToolbarSeparator() - ## Preview Custom Button ## - self.addToolbarButton( - translate(u'CustomMediaItem',u'Preview Custom Item'), - translate(u'CustomMediaItem',u'Preview the selected Custom Item'), - u':/system/system_preview.png', self.onPreviewClick, u'CustomPreviewItem') - ## Live Custom Button ## - self.addToolbarButton( - translate(u'CustomMediaItem',u'Go Live'), - translate(u'CustomMediaItem', u'Send the selected Custom live'), - u':/system/system_live.png', self.onLiveClick, u'CustomLiveItem') - ## Add Custom Button ## - self.addToolbarButton( - translate(u'CustomMediaItem',u'Add Custom To Service'), - translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'), - u':/system/system_add.png', self.onAddClick, u'CustomAddItem') - # Add the CustomListView widget - self.CustomWidget = QtGui.QWidget(self) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth()) - self.CustomWidget.setSizePolicy(sizePolicy) - self.CustomWidget.setObjectName(u'CustomWidget') - # Add the Custom widget to the page layout - self.PageLayout.addWidget(self.CustomWidget) - self.ListView = CustomListView() - self.ListView.setAlternatingRowColors(True) - self.ListView.setDragEnabled(True) - self.PageLayout.addWidget(self.ListView) - # Signals - QtCore.QObject.connect(self.ListView, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick) - #define and add the context menu - self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.ListView.addAction(contextMenuAction(self.ListView, - ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'), - self.onCustomEditClick)) - self.ListView.addAction(contextMenuSeparator(self.ListView)) - self.ListView.addAction(contextMenuAction( - self.ListView, ':/system/system_preview.png', - translate(u'CustomMediaItem',u'&Preview Custom'), self.onPreviewClick)) - self.ListView.addAction(contextMenuAction( - self.ListView, ':/system/system_live.png', - translate(u'CustomMediaItem',u'&Show Live'), self.onLiveClick)) - self.ListView.addAction(contextMenuAction( - self.ListView, ':/system/system_add.png', - translate(u'CustomMediaItem',u'&Add to Service'), self.onAddClick)) +# def addHeaderBar(self): +# # Add a toolbar +# self.addToolbar() +# # Create buttons for the toolbar +# ## New Custom Button ## +# self.addToolbarButton( +# translate(u'CustomMediaItem',u'New Custom Item'), +# translate(u'CustomMediaItem',u'Add a new Custom Item'), +# u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem') +# ## Edit Custom Button ## +# self.addToolbarButton( +# translate(u'CustomMediaItem',u'Edit Custom Item'), +# translate(u'CustomMediaItem',u'Edit the selected Custom Item'), +# u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem') +# ## Delete Custom Button ## +# self.addToolbarButton( +# translate(u'CustomMediaItem',u'Delete Custom Item'), +# translate(u'CustomMediaItem',u'Delete the selected Custom Item'), +# u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem') +# ## Separator Line ## +# self.addToolbarSeparator() +# ## Preview Custom Button ## +# self.addToolbarButton( +# translate(u'CustomMediaItem',u'Preview Custom Item'), +# translate(u'CustomMediaItem',u'Preview the selected Custom Item'), +# u':/system/system_preview.png', self.onPreviewClick, u'CustomPreviewItem') +# ## Live Custom Button ## +# self.addToolbarButton( +# translate(u'CustomMediaItem',u'Go Live'), +# translate(u'CustomMediaItem', u'Send the selected Custom live'), +# u':/system/system_live.png', self.onLiveClick, u'CustomLiveItem') +# ## Add Custom Button ## +# self.addToolbarButton( +# translate(u'CustomMediaItem',u'Add Custom To Service'), +# translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'), +# u':/system/system_add.png', self.onAddClick, u'CustomAddItem') +# # Add the CustomListView widget +# self.CustomWidget = QtGui.QWidget(self) +# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) +# sizePolicy.setHorizontalStretch(0) +# sizePolicy.setVerticalStretch(0) +# sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth()) +# self.CustomWidget.setSizePolicy(sizePolicy) +# self.CustomWidget.setObjectName(u'CustomWidget') +# # Add the Custom widget to the page layout +# self.PageLayout.addWidget(self.CustomWidget) +# self.ListView = CustomListView() +# self.ListView.setAlternatingRowColors(True) +# self.ListView.setDragEnabled(True) +# self.PageLayout.addWidget(self.ListView) +# # Signals +# QtCore.QObject.connect(self.ListView, +# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick) +# #define and add the context menu +# self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) +# self.ListView.addAction(contextMenuAction(self.ListView, +# ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'), +# self.onCustomEditClick)) +# self.ListView.addAction(contextMenuSeparator(self.ListView)) +# self.ListView.addAction(contextMenuAction( +# self.ListView, ':/system/system_preview.png', +# translate(u'CustomMediaItem',u'&Preview Custom'), self.onPreviewClick)) +# self.ListView.addAction(contextMenuAction( +# self.ListView, ':/system/system_live.png', +# translate(u'CustomMediaItem',u'&Show Live'), self.onLiveClick)) +# self.ListView.addAction(contextMenuAction( +# self.ListView, ':/system/system_add.png', +# translate(u'CustomMediaItem',u'&Add to Service'), self.onAddClick)) def initialise(self): self.loadCustomListView(self.parent.custommanager.get_all_slides()) @@ -122,12 +132,12 @@ class CustomMediaItem(MediaManagerItem): custom_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id)) self.ListView.addItem(custom_name) - def onCustomNewClick(self): + def onNewClick(self): self.parent.edit_custom_form.loadCustom(0) self.parent.edit_custom_form.exec_() self.initialise() - def onCustomEditClick(self): + def onEditClick(self): item = self.ListView.currentItem() if item is not None: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] @@ -135,7 +145,7 @@ class CustomMediaItem(MediaManagerItem): self.parent.edit_custom_form.exec_() self.initialise() - def onCustomDeleteClick(self): + def onDeleteClick(self): item = self.ListView.currentItem() if item is not None: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 467ab20e2..c725e27a4 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -48,7 +48,6 @@ class ImageMediaItem(MediaManagerItem): self.hasEditIcon = False self.OnNewPrompt = u'Select Image(s)' self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)' - self.slidecontroller = u'image' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = ImageListView diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 96b64b6cb..35f37f704 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -57,7 +57,7 @@ class PresentationMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, icon, title) self.message_listener = MessageListener(controllers) - def addHeaderBar(self): + def addHeaderBar2(self): self.PresentationWidget = QtGui.QWidget(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) diff --git a/resources/forms/editcustomdialog.ui b/resources/forms/editcustomdialog.ui index 3fce3f588..98bc1abb0 100644 --- a/resources/forms/editcustomdialog.ui +++ b/resources/forms/editcustomdialog.ui @@ -14,7 +14,7 @@ Edit Custom Slides - + :/icon/openlp.org-icon-32.bmp:/icon/openlp.org-icon-32.bmp @@ -35,12 +35,19 @@ - + + + true + + + + + @@ -65,6 +72,9 @@ + + + @@ -88,33 +98,46 @@ 0 - + - - - 8 - - - 0 - + - + + + + - Add + Add New - + + + + Edit - + + + + + + Edit All + + + + + + + + Save @@ -122,11 +145,24 @@ + + + Delete + + + + + + + Clear + + + @@ -156,7 +192,11 @@ - + + + + + @@ -185,13 +225,17 @@ TitleEdit - VerseTextEdit_3 - EditButton_3 - SaveButton_3 - CreditEdit + VerseTextEdit + AddButton VerseListView - AddButton_3 + EditButton + EditAllButton + SaveButton DeleteButton + CreditEdit + UpButton + DownButton + ThemeComboBox buttonBox From 1ca02a35360e27384e34c2679b801e16bc1bda6f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 11 Sep 2009 05:56:52 +0100 Subject: [PATCH 2/7] Custom Plugin cleaup 2 --- openlp/plugins/custom/lib/mediaitem.py | 69 -------------------------- 1 file changed, 69 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 3ce6433c7..85486cac8 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -53,75 +53,6 @@ class CustomMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, icon, title) self.parent = parent -# def addHeaderBar(self): -# # Add a toolbar -# self.addToolbar() -# # Create buttons for the toolbar -# ## New Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'New Custom Item'), -# translate(u'CustomMediaItem',u'Add a new Custom Item'), -# u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem') -# ## Edit Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Edit Custom Item'), -# translate(u'CustomMediaItem',u'Edit the selected Custom Item'), -# u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem') -# ## Delete Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Delete Custom Item'), -# translate(u'CustomMediaItem',u'Delete the selected Custom Item'), -# u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem') -# ## Separator Line ## -# self.addToolbarSeparator() -# ## Preview Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Preview Custom Item'), -# translate(u'CustomMediaItem',u'Preview the selected Custom Item'), -# u':/system/system_preview.png', self.onPreviewClick, u'CustomPreviewItem') -# ## Live Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Go Live'), -# translate(u'CustomMediaItem', u'Send the selected Custom live'), -# u':/system/system_live.png', self.onLiveClick, u'CustomLiveItem') -# ## Add Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Add Custom To Service'), -# translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'), -# u':/system/system_add.png', self.onAddClick, u'CustomAddItem') -# # Add the CustomListView widget -# self.CustomWidget = QtGui.QWidget(self) -# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) -# sizePolicy.setHorizontalStretch(0) -# sizePolicy.setVerticalStretch(0) -# sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth()) -# self.CustomWidget.setSizePolicy(sizePolicy) -# self.CustomWidget.setObjectName(u'CustomWidget') -# # Add the Custom widget to the page layout -# self.PageLayout.addWidget(self.CustomWidget) -# self.ListView = CustomListView() -# self.ListView.setAlternatingRowColors(True) -# self.ListView.setDragEnabled(True) -# self.PageLayout.addWidget(self.ListView) -# # Signals -# QtCore.QObject.connect(self.ListView, -# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick) -# #define and add the context menu -# self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) -# self.ListView.addAction(contextMenuAction(self.ListView, -# ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'), -# self.onCustomEditClick)) -# self.ListView.addAction(contextMenuSeparator(self.ListView)) -# self.ListView.addAction(contextMenuAction( -# self.ListView, ':/system/system_preview.png', -# translate(u'CustomMediaItem',u'&Preview Custom'), self.onPreviewClick)) -# self.ListView.addAction(contextMenuAction( -# self.ListView, ':/system/system_live.png', -# translate(u'CustomMediaItem',u'&Show Live'), self.onLiveClick)) -# self.ListView.addAction(contextMenuAction( -# self.ListView, ':/system/system_add.png', -# translate(u'CustomMediaItem',u'&Add to Service'), self.onAddClick)) - def initialise(self): self.loadCustomListView(self.parent.custommanager.get_all_slides()) From 07452df24a10802f3e3089653314461893670e41 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 11 Sep 2009 20:29:57 +0100 Subject: [PATCH 3/7] fixes to custom and save state of screen --- openlp/core/lib/mediamanageritem.py | 12 +++++----- openlp/core/lib/settingsmanager.py | 24 ++++++++++++++----- openlp/core/ui/mainwindow.py | 22 +++++++++++++---- openlp/core/ui/slidecontroller.py | 3 --- .../presentations/lib/impresscontroller.py | 3 ++- openlp/plugins/presentations/lib/mediaitem.py | 2 +- .../presentations/presentationplugin.py | 1 - 7 files changed, 45 insertions(+), 22 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 93f24a01f..65149d05c 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -174,7 +174,7 @@ class MediaManagerItem(QtGui.QWidget): # Add a toolbar self.addToolbar() #Allow the plugin to define it's own header - self.addHeaderBar1() + self.addStartHeaderBar() # Create buttons for the toolbar ## File Button ## if self.hasFileIcon: @@ -217,7 +217,7 @@ class MediaManagerItem(QtGui.QWidget): translate(self.TranslationContext, u'Add the selected item(s) to the service'), u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem') #Allow the plugin to define it's own header - self.addHeaderBar2() + self.addEndHeaderBar() #Add the List widget self.ListView = self.ListViewWithDnD_class() self.ListView.uniformItemSizes = True @@ -260,15 +260,15 @@ class MediaManagerItem(QtGui.QWidget): """ pass - def addHeaderBar1(self): + def addStartHeaderBar(self): """ - Slot at start of toolbar for pluin to addwidgets + Slot at start of toolbar for plugin to addwidgets """ pass - def addHeaderBar2(self): + def addEndHeaderBar(self): """ - Slot at end of toolbar for pluin to add widgets + Slot at end of toolbar for plugin to add widgets """ pass diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 26146d7fd..bebe6a322 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -34,13 +34,22 @@ class SettingsManager(object): self.width = self.screen[u'size'].width() self.height = self.screen[u'size'].height() self.mainwindow_height = self.height * 0.8 - self.mainwindow_docbars = self.width / 5 - if self.mainwindow_docbars > 300: - self.mainwindow_docbars > 300 - self.mainwindow_slidecontroller = self.width / 6 - self.slidecontroller = ((self.width - (self.mainwindow_docbars * 3 ) / 2 ) / 2 ) -100 + mainwindow_docbars = self.width / 5 + self.mainwindow_left = 0 + self.mainwindow_right = 0 + if mainwindow_docbars > 300: + self.mainwindow_left = 300 + self.mainwindow_right = 300 + + self.mainwindow_left = int( ConfigHelper.get_config( + u'user interface', u'mediamanager left', self.mainwindow_left)) + self.mainwindow_right = int( ConfigHelper.get_config( + u'user interface', u'mediamanager right', self.mainwindow_right)) + print self.mainwindow_left, self.mainwindow_right + + self.slidecontroller = (self.width - (self.mainwindow_left + self.mainwindow_right) - 100 ) / 2 self.slidecontroller_image = self.slidecontroller - 50 - print self.width, self.mainwindow_docbars, self.slidecontroller, self.slidecontroller_image + print self.width, mainwindow_docbars, self.slidecontroller, self.slidecontroller_image self.showMediaManager = str_to_bool( ConfigHelper.get_config( u'user interface', u'display mediamanager', True)) @@ -67,3 +76,6 @@ class SettingsManager(object): ConfigHelper.set_config(u'user interface', u'display previewpanel', isVisible) + def setDockbarLeft(self, value): + ConfigHelper.set_config(u'user interface', u'mediamanager left', value) + diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6f3a3a384..9b890f3fd 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -31,6 +31,15 @@ from openlp.core.lib import translate, Plugin, MediaManagerItem, \ from openlp.core.utils import ConfigHelper +class mediaDock(QtGui.QDockWidget): + def __init__(self, parent=None, name=None): + QtGui.QDockWidget.__init__(self, parent) + self.parent = parent + + def resizeEvent(self, resizeEvent): + if resizeEvent.size().width() != resizeEvent.oldSize().width(): + self.parent.settingsmanager.setDockbarLeft(resizeEvent.size().width()) + class Ui_MainWindow(object): def setupUi(self, MainWindow): """ @@ -102,15 +111,20 @@ class Ui_MainWindow(object): self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel') self.StatusBar.addPermanentWidget(self.DefaultThemeLabel) # Create the MediaManager - self.MediaManagerDock = QtGui.QDockWidget(MainWindow) + self.MediaManagerDock = mediaDock(MainWindow) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(u':/system/system_mediamanager.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.MediaManagerDock.setWindowIcon(icon) self.MediaManagerDock.setFloating(False) self.MediaManagerDock.setObjectName(u'MediaManagerDock') - self.MediaManagerDock.setMinimumWidth( - self.settingsmanager.mainwindow_docbars) + self.MediaManagerDock.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, + QtGui.QSizePolicy.Maximum)) + geometry = self.MediaManagerDock.geometry() + geometry.setWidth(self.settingsmanager.mainwindow_left) + self.MediaManagerDock.setGeometry(geometry) + self.MediaManagerDock.setMinimumWidth(10) + self.MediaManagerContents = QtGui.QWidget() self.MediaManagerContents.setObjectName(u'MediaManagerContents') self.MediaManagerLayout = QtGui.QHBoxLayout(self.MediaManagerContents) @@ -134,7 +148,7 @@ class Ui_MainWindow(object): QtGui.QDockWidget.AllDockWidgetFeatures) self.ServiceManagerDock.setObjectName(u'ServiceManagerDock') self.ServiceManagerDock.setMinimumWidth( - self.settingsmanager.mainwindow_docbars) + self.settingsmanager.mainwindow_right) self.ServiceManagerContents = ServiceManager(self) self.ServiceManagerDock.setWidget(self.ServiceManagerContents) MainWindow.addDockWidget( diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d94eb4465..a8119e3c6 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -374,6 +374,3 @@ class SlideController(QtGui.QWidget): def timerEvent(self, event): if event.timerId() == self.timer_id: self.onSlideSelectedNext() - - - diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 6124333eb..854e1ff7e 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -57,7 +57,8 @@ class ImpressController(object): when required. """ log.debug(u'start Openoffice') - cmd = u'openoffice.org -nologo -norestore -minimized -headless ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' + # -headless + cmd = u'openoffice.org -nologo -norestore -minimized -invisible ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' self.process = QtCore.QProcess() self.process.startDetached(cmd) self.process.waitForStarted() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 35f37f704..956d8feb8 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -57,7 +57,7 @@ class PresentationMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, icon, title) self.message_listener = MessageListener(controllers) - def addHeaderBar2(self): + def addEndHeaderBar(self): self.PresentationWidget = QtGui.QWidget(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 154231be1..6d66cc003 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -104,5 +104,4 @@ class PresentationPlugin(Plugin): log.debug(u'Finalise') #Ask each controller to tidy up for controller in self.controllers: - print controller self.controllers[controller].kill() From 43b374a994b4aafe0d9fa50c4982fa83d22f713d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 11 Sep 2009 20:51:06 +0100 Subject: [PATCH 4/7] Impress issues --- openlp/core/lib/settingsmanager.py | 3 ++- openlp/core/ui/mainwindow.py | 15 +++++++++------ openlp/core/ui/slidecontroller.py | 18 +++++++++--------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index bebe6a322..55fcaf6d2 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -77,5 +77,6 @@ class SettingsManager(object): isVisible) def setDockbarLeft(self, value): - ConfigHelper.set_config(u'user interface', u'mediamanager left', value) + #ConfigHelper.set_config(u'user interface', u'mediamanager left', value) + pass diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 9b890f3fd..d511a751a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -118,12 +118,15 @@ class Ui_MainWindow(object): self.MediaManagerDock.setWindowIcon(icon) self.MediaManagerDock.setFloating(False) self.MediaManagerDock.setObjectName(u'MediaManagerDock') - self.MediaManagerDock.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, - QtGui.QSizePolicy.Maximum)) - geometry = self.MediaManagerDock.geometry() - geometry.setWidth(self.settingsmanager.mainwindow_left) - self.MediaManagerDock.setGeometry(geometry) - self.MediaManagerDock.setMinimumWidth(10) + self.MediaManagerDock.setMinimumWidth( + self.settingsmanager.mainwindow_left) + +# self.MediaManagerDock.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, +# QtGui.QSizePolicy.Maximum)) +# geometry = self.MediaManagerDock.geometry() +# geometry.setWidth(self.settingsmanager.mainwindow_left) +# self.MediaManagerDock.setGeometry(geometry) +# self.MediaManagerDock.setMinimumWidth(10) self.MediaManagerContents = QtGui.QWidget() self.MediaManagerContents.setObjectName(u'MediaManagerContents') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a8119e3c6..1addd14b0 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -70,7 +70,7 @@ class SlideController(QtGui.QWidget): self.parent = parent self.image_list = [u'Start Loop', u'Stop Loop', u'Loop Separator', u'Image SpinBox'] self.timer_id = 0 - self.item = None + self.commandItem = None self.Panel = QtGui.QWidget(parent.ControlSplitter) self.Splitter = QtGui.QSplitter(self.Panel) self.Splitter.setOrientation(QtCore.Qt.Vertical) @@ -233,9 +233,9 @@ class SlideController(QtGui.QWidget): """ log.debug(u'addServiceItem') #If old item was a command tell it to stop - if self.item is not None and self.item.service_item_type == ServiceType.Command: + if self.commandItem is not None and self.commandItem.service_item_type == ServiceType.Command: Receiver().send_message(u'%s_stop'% self.item.name.lower()) - self.item = item + self.commandItem = item item.render() self.enableToolBar(item) if item.service_item_type == ServiceType.Command: @@ -252,9 +252,9 @@ class SlideController(QtGui.QWidget): """ log.debug(u'addServiceItem') #If old item was a command tell it to stop - if self.item is not None and self.item.service_item_type == ServiceType.Command: + if self.commandItem is not None and self.commandItem.service_item_type == ServiceType.Command: Receiver().send_message(u'%s_stop'% self.item.name.lower()) - self.item = item + self.commandItem = item self.enableToolBar(item) if item.service_item_type == ServiceType.Command: Receiver().send_message(u'%s_start'%item.name.lower(), \ @@ -329,8 +329,8 @@ class SlideController(QtGui.QWidget): """ Go to the next slide. """ - if self.item.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_next'% self.item.name.lower()) + if self.commandItem.service_item_type == ServiceType.Command: + Receiver().send_message(u'%s_next'% self.commandItem.name.lower()) else: row = self.PreviewListWidget.currentRow() + 1 if row == self.PreviewListWidget.rowCount(): @@ -342,8 +342,8 @@ class SlideController(QtGui.QWidget): """ Go to the previous slide. """ - if self.item.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_previous'% self.item.name.lower()) + if self.commandItem.service_item_type == ServiceType.Command: + Receiver().send_message(u'%s_previous'% self.commandItem.name.lower()) else: row = self.PreviewListWidget.currentRow() - 1 if row == -1: From ca919b74c37bf0e2f74fa8e2d822465640b99b28 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Sep 2009 07:25:07 +0100 Subject: [PATCH 5/7] Correct settings --- openlp/plugins/presentations/presentationplugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 5947634db..8228d5b3e 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -72,7 +72,7 @@ class PresentationPlugin(Plugin): """ log.debug('check_pre_conditions') #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Impress', 0)) == 2: + if int(self.config.get_config(u'Impress', 0)) == QtCore.Qt.Checked: try: #Check to see if we have uno installed import uno @@ -81,7 +81,7 @@ class PresentationPlugin(Plugin): except: log.error(u'Reason : %s', sys.exc_info()) #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint', 0)) == 2: + if int(self.config.get_config(u'Powerpoint', 0)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch @@ -90,7 +90,7 @@ class PresentationPlugin(Plugin): except: log.error(u'Reason : %s', sys.exc_info()) #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint Viewer', 0)) == 2: + if int(self.config.get_config(u'Powerpoint Viewer', 0)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch From 1ef543253c8af803a7655c790356e081ed8937c5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Sep 2009 08:39:48 +0100 Subject: [PATCH 6/7] Fix up Presentations so Impress works! --- openlp/core/lib/renderer.py | 2 +- openlp/core/lib/serviceitem.py | 10 +- openlp/core/ui/amendthemeform.py | 1430 ++++++++--------- openlp/plugins/bibles/lib/biblestab.py | 4 +- openlp/plugins/presentations/lib/__init__.py | 2 +- .../presentations/lib/powerpointcontroller.py | 6 +- .../presentations/presentationplugin.py | 17 +- openlp/plugins/remotes/remoteplugin.py | 2 +- 8 files changed, 740 insertions(+), 733 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 24e8a5b8f..ba4adbd53 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -519,7 +519,7 @@ class Renderer(object): self.footerFont = QtGui.QFont(self._theme.font_footer_name, int(self._theme.font_footer_proportion), # size int(footer_weight), # weight - self._theme.font_footer_italics)# italic + self._theme.font_footer_italics) # italic self.footerFont.setPixelSize(int(self._theme.font_footer_proportion)) main_weight = 50 if self._theme.font_main_weight == u'Bold': diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 9648ba2ba..d0b81e3e7 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -88,13 +88,13 @@ class ServiceItem(object): The render method is what renders the frames for the screen. """ log.debug(u'Render called') - if self.theme == None: - self.RenderManager.set_override_theme(None) - else: - self.RenderManager.set_override_theme(self.theme) - log.debug(u'Formatting slides') self.frames = [] if self.service_item_type == ServiceType.Text: + log.debug(u'Formatting slides') + if self.theme == None: + self.RenderManager.set_override_theme(None) + else: + self.RenderManager.set_override_theme(self.theme) for slide in self.service_frames: formated = self.RenderManager.format_slide(slide[u'raw_slide']) for format in formated: diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 04e4417af..9b6b8d979 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -1,715 +1,715 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2009 Raoul Snyman # -# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # -# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # -# --------------------------------------------------------------------------- # -# 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 -import os, os.path - -from PyQt4 import QtCore, QtGui -from openlp.core.lib import ThemeXML, Renderer, file_to_xml, str_to_bool, \ - translate - -from amendthemedialog import Ui_AmendThemeDialog - -log = logging.getLogger(u'AmendThemeForm') - -class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): - - def __init__(self, thememanager, parent=None): - QtGui.QDialog.__init__(self, parent) - self.thememanager = thememanager - self.path = None - self.theme = ThemeXML() - self.setupUi(self) - #define signals - #Buttons - QtCore.QObject.connect(self.Color1PushButton , - QtCore.SIGNAL(u'pressed()'), self.onColor1PushButtonClicked) - QtCore.QObject.connect(self.Color2PushButton , - QtCore.SIGNAL(u'pressed()'), self.onColor2PushButtonClicked) - QtCore.QObject.connect(self.FontMainColorPushButton, - QtCore.SIGNAL(u'pressed()'), self.onFontMainColorPushButtonClicked) - QtCore.QObject.connect(self.FontFooterColorPushButton, - QtCore.SIGNAL(u'pressed()'), - self.onFontFooterColorPushButtonClicked) - QtCore.QObject.connect(self.OutlineColorPushButton, - QtCore.SIGNAL(u'pressed()'), self.onOutlineColorPushButtonClicked) - QtCore.QObject.connect(self.ShadowColorPushButton, - QtCore.SIGNAL(u'pressed()'), self.onShadowColorPushButtonClicked) - QtCore.QObject.connect(self.ImageToolButton, - QtCore.SIGNAL(u'pressed()'), self.onImageToolButtonClicked) - #Combo boxes - QtCore.QObject.connect(self.BackgroundComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected) - QtCore.QObject.connect(self.BackgroundTypeComboBox, - QtCore.SIGNAL(u'activated(int)'), - self.onBackgroundTypeComboBoxSelected) - QtCore.QObject.connect(self.GradientComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onGradientComboBoxSelected) - QtCore.QObject.connect(self.FontMainComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onFontMainComboBoxSelected) - QtCore.QObject.connect(self.FontMainWeightComboBox, - QtCore.SIGNAL(u'activated(int)'), - self.onFontMainWeightComboBoxSelected) - QtCore.QObject.connect(self.FontFooterComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onFontFooterComboBoxSelected) - QtCore.QObject.connect(self.FontFooterWeightComboBox, - QtCore.SIGNAL(u'activated(int)'), - self.onFontFooterWeightComboBoxSelected) - QtCore.QObject.connect(self.HorizontalComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onHorizontalComboBoxSelected) - QtCore.QObject.connect(self.VerticalComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onVerticalComboBoxSelected) - #Spin boxes - QtCore.QObject.connect(self.FontMainSizeSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontMainSizeSpinBoxChanged) - QtCore.QObject.connect(self.FontFooterSizeSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontFooterSizeSpinBoxChanged) - QtCore.QObject.connect(self.FontMainDefaultCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onFontMainDefaultCheckBoxChanged) - QtCore.QObject.connect(self.FontMainXSpinBox, - QtCore.SIGNAL(u'editingFinished()'), self.onFontMainXSpinBoxChanged) - QtCore.QObject.connect(self.FontMainYSpinBox, - QtCore.SIGNAL(u'editingFinished()'), self.onFontMainYSpinBoxChanged) - QtCore.QObject.connect(self.FontMainWidthSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontMainWidthSpinBoxChanged) - QtCore.QObject.connect(self.FontMainHeightSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontMainHeightSpinBoxChanged) - QtCore.QObject.connect(self.FontFooterDefaultCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onFontFooterDefaultCheckBoxChanged) - QtCore.QObject.connect(self.FontFooterXSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontFooterXSpinBoxChanged) - QtCore.QObject.connect(self.FontFooterYSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontFooterYSpinBoxChanged) - QtCore.QObject.connect(self.FontFooterWidthSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontFooterWidthSpinBoxChanged) - QtCore.QObject.connect(self.FontFooterHeightSpinBox, - QtCore.SIGNAL(u'editingFinished()'), - self.onFontFooterHeightSpinBoxChanged) - QtCore.QObject.connect(self.OutlineCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged) - QtCore.QObject.connect(self.ShadowCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged) - - def accept(self): - new_theme = ThemeXML() - theme_name = unicode(self.ThemeNameEdit.displayText()) - new_theme.new_document(theme_name) - save_from = None - save_to = None - if self.theme.background_mode == u'transparent': - new_theme.add_background_transparent() - else: - if self.theme.background_type == u'solid': - new_theme.add_background_solid( \ - unicode(self.theme.background_color)) - elif self.theme.background_type == u'gradient': - new_theme.add_background_gradient( \ - unicode(self.theme.background_startColor), - unicode(self.theme.background_endColor), - self.theme.background_direction) - else: - (path, filename) = \ - os.path.split(unicode(self.theme.background_filename)) - new_theme.add_background_image(filename) - save_to= os.path.join(self.path, theme_name, filename ) - save_from = self.theme.background_filename - - new_theme.add_font(unicode(self.theme.font_main_name), - unicode(self.theme.font_main_color), - unicode(self.theme.font_main_proportion), - unicode(self.theme.font_main_override), u'main', - unicode(self.theme.font_main_weight), - unicode(self.theme.font_main_italics), - unicode(self.theme.font_main_x), - unicode(self.theme.font_main_y), - unicode(self.theme.font_main_width), - unicode(self.theme.font_main_height)) - new_theme.add_font(unicode(self.theme.font_footer_name), - unicode(self.theme.font_footer_color), - unicode(self.theme.font_footer_proportion), - unicode(self.theme.font_footer_override), u'footer', - unicode(self.theme.font_footer_weight), - unicode(self.theme.font_footer_italics), - unicode(self.theme.font_footer_x), - unicode(self.theme.font_footer_y), - unicode(self.theme.font_footer_width), - unicode(self.theme.font_footer_height) ) - new_theme.add_display(unicode(self.theme.display_shadow), - unicode(self.theme.display_shadow_color), - unicode(self.theme.display_outline), - unicode(self.theme.display_outline_color), - unicode(self.theme.display_horizontalAlign), - unicode(self.theme.display_verticalAlign), - unicode(self.theme.display_wrapStyle)) - theme = new_theme.extract_xml() - pretty_theme = new_theme.extract_formatted_xml() - if self.thememanager.saveTheme(theme_name, theme, pretty_theme, - save_from, save_to) is not False: - return QtGui.QDialog.accept(self) - - def loadTheme(self, theme): - log.debug(u'LoadTheme %s', theme) - if theme == None: - self.theme.parse(self.baseTheme()) - else: - xml_file = os.path.join(self.path, theme, theme + u'.xml') - xml = file_to_xml(xml_file) - self.theme.parse(xml) - self.theme.extend_image_filename(self.path) - self.cleanTheme(self.theme) - self.allowPreview = False - self.paintUi(self.theme) - self.allowPreview = True - self.previewTheme(self.theme) - - def cleanTheme(self, theme): - self.theme.background_color = theme.background_color.strip() - self.theme.background_direction = theme.background_direction.strip() - self.theme.background_endColor = theme.background_endColor.strip() - if theme.background_filename: - self.theme.background_filename = theme.background_filename.strip() - #self.theme.background_mode - self.theme.background_startColor = theme.background_startColor.strip() - #self.theme.background_type - self.theme.display_display = theme.display_display.strip() - self.theme.display_horizontalAlign = \ - theme.display_horizontalAlign.strip() - self.theme.display_outline = str_to_bool(theme.display_outline) - #self.theme.display_outline_color - self.theme.display_shadow = str_to_bool(theme.display_shadow) - #self.theme.display_shadow_color - self.theme.display_verticalAlign = \ - theme.display_verticalAlign.strip() - self.theme.display_wrapStyle = theme.display_wrapStyle.strip() - self.theme.font_footer_color = theme.font_footer_color.strip() - self.theme.font_footer_height = theme.font_footer_height.strip() - self.theme.font_footer_italics = str_to_bool(theme.font_footer_italics) - self.theme.font_footer_name = theme.font_footer_name.strip() - #self.theme.font_footer_override - self.theme.font_footer_proportion = \ - theme.font_footer_proportion.strip() - self.theme.font_footer_weight = theme.font_footer_weight.strip() - self.theme.font_footer_width = theme.font_footer_width.strip() - self.theme.font_footer_x = theme.font_footer_x.strip() - self.theme.font_footer_y = theme.font_footer_y.strip() - self.theme.font_main_color = theme.font_main_color.strip() - self.theme.font_main_height = theme.font_main_height.strip() - self.theme.font_main_italics = str_to_bool(theme.font_main_italics) - self.theme.font_main_name = theme.font_main_name.strip() - #self.theme.font_main_override - self.theme.font_main_proportion = theme.font_main_proportion.strip() - self.theme.font_main_weight = theme.font_main_weight.strip() - self.theme.font_main_x = theme.font_main_x.strip() - self.theme.font_main_y = theme.font_main_y.strip() - #self.theme.theme_mode - self.theme.theme_name = theme.theme_name.strip() - #self.theme.theme_version - - def onImageToolButtonClicked(self): - filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file') - if filename != "": - self.ImageLineEdit.setText(filename) - self.theme.background_filename = filename - self.previewTheme(self.theme) - # - #Main Font Tab - # - def onFontMainComboBoxSelected(self): - self.theme.font_main_name = self.FontMainComboBox.currentFont().family() - self.previewTheme(self.theme) - - def onFontMainWeightComboBoxSelected(self, value): - if value ==0: - self.theme.font_main_weight = u'Normal' - self.theme.font_main_italics = False - elif value == 1: - self.theme.font_main_weight = u'Bold' - self.theme.font_main_italics = False - elif value == 2: - self.theme.font_main_weight = u'Normal' - self.theme.font_main_italics = True - else: - self.theme.font_main_weight = u'Bold' - self.theme.font_main_italics = True - self.previewTheme(self.theme) - - def onFontMainColorPushButtonClicked(self): - self.theme.font_main_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.font_main_color), self).name() - - self.FontMainColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.font_main_color)) - self.previewTheme(self.theme) - - def onFontMainSizeSpinBoxChanged(self): - if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): - self.theme.font_main_proportion = self.FontMainSizeSpinBox.value() - self.previewTheme(self.theme) - - def onFontMainDefaultCheckBoxChanged(self, value): - if value == 2: # checked - self.theme.font_main_override = False - else: - self.theme.font_main_override = True - - if int(self.theme.font_main_x) == 0 and \ - int(self.theme.font_main_y) == 0 and \ - int(self.theme.font_main_width) == 0 and \ - int(self.theme.font_main_height) == 0: - self.theme.font_main_x = u'10' - self.theme.font_main_y = u'10' - self.theme.font_main_width = u'1024' - self.theme.font_main_height = u'730' - self.FontMainXSpinBox.setValue(int(self.theme.font_main_x)) - self.FontMainYSpinBox.setValue(int(self.theme.font_main_y)) - self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) - self.FontMainHeightSpinBox.setValue(int( \ - self.theme.font_main_height)) - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onFontMainXSpinBoxChanged(self): - if self.theme.font_main_x != self.FontMainXSpinBox.value(): - self.theme.font_main_x = self.FontMainXSpinBox.value() - self.previewTheme(self.theme) - - def onFontMainYSpinBoxChanged(self): - if self.theme.font_main_y != self.FontMainYSpinBox.value(): - self.theme.font_main_y = self.FontMainYSpinBox.value() - self.previewTheme(self.theme) - - def onFontMainWidthSpinBoxChanged(self): - if self.theme.font_main_width != self.FontMainWidthSpinBox.value(): - self.theme.font_main_width = self.FontMainWidthSpinBox.value() - self.previewTheme(self.theme) - - def onFontMainHeightSpinBoxChanged(self): - if self.theme.font_main_height != self.FontMainHeightSpinBox.value(): - self.theme.font_main_height = self.FontMainHeightSpinBox.value() - self.previewTheme(self.theme) - # - #Footer Font Tab - # - def onFontFooterComboBoxSelected(self): - self.theme.font_footer_name = \ - self.FontFooterComboBox.currentFont().family() - self.previewTheme(self.theme) - - def onFontFooterWeightComboBoxSelected(self, value): - if value == 0: - self.theme.font_footer_weight = u'Normal' - self.theme.font_footer_italics = False - elif value == 1: - self.theme.font_footer_weight = u'Bold' - self.theme.font_footer_italics = False - elif value == 2: - self.theme.font_footer_weight = u'Normal' - self.theme.font_footer_italics = True - else: - self.theme.font_footer_weight = u'Bold' - self.theme.font_footer_italics = True - self.previewTheme(self.theme) - - def onFontFooterColorPushButtonClicked(self): - self.theme.font_footer_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.font_footer_color), self).name() - - self.FontFooterColorPushButton.setStyleSheet( - 'background-color: %s' % unicode(self.theme.font_footer_color)) - self.previewTheme(self.theme) - - def onFontFooterSizeSpinBoxChanged(self): - if self.theme.font_footer_proportion != \ - self.FontFooterSizeSpinBox.value(): - self.theme.font_footer_proportion = \ - self.FontFooterSizeSpinBox.value() - self.previewTheme(self.theme) - - def onFontFooterDefaultCheckBoxChanged(self, value): - if value == 2: # checked - self.theme.font_footer_override = False - else: - self.theme.font_footer_override = True - - if int(self.theme.font_footer_x) == 0 and \ - int(self.theme.font_footer_y) == 0 and \ - int(self.theme.font_footer_width) == 0 and \ - int(self.theme.font_footer_height) == 0: - self.theme.font_footer_x = u'10' - self.theme.font_footer_y = u'730' - self.theme.font_footer_width = u'1024' - self.theme.font_footer_height = u'38' - - self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x)) - self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y)) - self.FontFooterWidthSpinBox.setValue(int( \ - self.theme.font_footer_width)) - self.FontFooterHeightSpinBox.setValue(int( \ - self.theme.font_footer_height)) - - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onFontFooterXSpinBoxChanged(self): - if self.theme.font_footer_x != self.FontFooterXSpinBox.value(): - self.theme.font_footer_x = self.FontFooterXSpinBox.value() - self.previewTheme(self.theme) - - def onFontFooterYSpinBoxChanged(self): - if self.theme.font_footer_y != self.FontFooterYSpinBox.value(): - self.theme.font_footer_y = self.FontFooterYSpinBox.value() - self.previewTheme(self.theme) - - def onFontFooterWidthSpinBoxChanged(self): - if self.theme.font_footer_width != self.FontFooterWidthSpinBox.value(): - self.theme.font_footer_width = self.FontFooterWidthSpinBox.value() - self.previewTheme(self.theme) - - def onFontFooterHeightSpinBoxChanged(self): - if self.theme.font_footer_height != \ - self.FontFooterHeightSpinBox.value(): - self.theme.font_footer_height = self.FontFooterHeightSpinBox.value() - self.previewTheme(self.theme) - # - #Background Tab - # - def onGradientComboBoxSelected(self, currentIndex): - self.setBackground(self.BackgroundTypeComboBox.currentIndex(), - currentIndex) - - def onBackgroundComboBoxSelected(self, currentIndex): - if currentIndex == 0: # Opaque - self.theme.background_mode = u'opaque' - else: - self.theme.background_mode = u'transparent' - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onBackgroundTypeComboBoxSelected(self, currentIndex): - self.setBackground(currentIndex, self.GradientComboBox.currentIndex()) - - def setBackground(self, background, gradient): - if background == 0: # Solid - self.theme.background_type = u'solid' - if self.theme.background_color is None : - self.theme.background_color = u'#000000' - elif background == 1: # Gradient - self.theme.background_type = u'gradient' - if gradient == 0: # Horizontal - self.theme.background_direction = u'horizontal' - elif gradient == 1: # vertical - self.theme.background_direction = u'vertical' - else: - self.theme.background_direction = u'circular' - if self.theme.background_startColor is None : - self.theme.background_startColor = u'#000000' - if self.theme.background_endColor is None : - self.theme.background_endColor = u'#ff0000' - else: - self.theme.background_type = u'image' - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onColor1PushButtonClicked(self): - if self.theme.background_type == u'solid': - self.theme.background_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_color), self).name() - self.Color1PushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.background_color)) - else: - self.theme.background_startColor = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_startColor), self).name() - self.Color1PushButton.setStyleSheet( - u'background-color: %s' % \ - unicode(self.theme.background_startColor)) - - self.previewTheme(self.theme) - - def onColor2PushButtonClicked(self): - self.theme.background_endColor = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_endColor), self).name() - self.Color2PushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.background_endColor)) - - self.previewTheme(self.theme) - # - #Other Tab - # - def onOutlineCheckBoxChanged(self, value): - if value == 2: # checked - self.theme.display_outline = True - else: - self.theme.display_outline = False - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onOutlineColorPushButtonClicked(self): - self.theme.display_outline_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.display_outline_color), self).name() - self.OutlineColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.display_outline_color)) - self.previewTheme(self.theme) - - def onShadowCheckBoxChanged(self, value): - if value == 2: # checked - self.theme.display_shadow = True - else: - self.theme.display_shadow = False - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onShadowColorPushButtonClicked(self): - self.theme.display_shadow_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.display_shadow_color), self).name() - self.ShadowColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(self.theme.display_shadow_color)) - self.previewTheme(self.theme) - - def onHorizontalComboBoxSelected(self, currentIndex): - self.theme.display_horizontalAlign = currentIndex - self.stateChanging(self.theme) - self.previewTheme(self.theme) - - def onVerticalComboBoxSelected(self, currentIndex): - self.theme.display_verticalAlign = currentIndex - self.stateChanging(self.theme) - self.previewTheme(self.theme) - # - #Local Methods - # - def baseTheme(self): - log.debug(u'base theme created') - newtheme = ThemeXML() - newtheme.new_document(u'New Theme') - newtheme.add_background_solid(unicode(u'#000000')) - newtheme.add_font(unicode(QtGui.QFont().family()), unicode(u'#FFFFFF'), - unicode(30), u'False') - newtheme.add_font(unicode(QtGui.QFont().family()), unicode(u'#FFFFFF'), - unicode(12), u'False', u'footer') - newtheme.add_display(u'False', unicode(u'#FFFFFF'), u'False', - unicode(u'#FFFFFF'), - unicode(0), unicode(0), unicode(0)) - - return newtheme.extract_xml() - - def paintUi(self, theme): - self.stateChanging(theme) - self.ThemeNameEdit.setText(self.theme.theme_name) - if self.theme.background_mode == u'opaque': - self.BackgroundComboBox.setCurrentIndex(0) - else: - self.BackgroundComboBox.setCurrentIndex(1) - - if theme.background_type == u'solid': - self.BackgroundTypeComboBox.setCurrentIndex(0) - elif theme.background_type == u'gradient': - self.BackgroundTypeComboBox.setCurrentIndex(1) - else: - self.BackgroundTypeComboBox.setCurrentIndex(2) - - if self.theme.background_direction == u'horizontal': - self.GradientComboBox.setCurrentIndex(0) - elif self.theme.background_direction == u'vertical': - self.GradientComboBox.setCurrentIndex(1) - else: - self.GradientComboBox.setCurrentIndex(2) - - self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion)) - if not self.theme.font_main_italics and \ - self.theme.font_main_weight == u'Normal': - self.FontMainWeightComboBox.setCurrentIndex(0) - elif not self.theme.font_main_italics and \ - self.theme.font_main_weight == u'Bold': - self.FontMainWeightComboBox.setCurrentIndex(1) - elif self.theme.font_main_italics and \ - self.theme.font_main_weight == u'Normal': - self.FontMainWeightComboBox.setCurrentIndex(2) - else: - self.FontMainWeightComboBox.setCurrentIndex(3) - - self.FontMainXSpinBox.setValue(int(self.theme.font_main_x)) - self.FontMainYSpinBox.setValue(int(self.theme.font_main_y)) - self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) - self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height)) - self.FontFooterSizeSpinBox.setValue( - int(self.theme.font_footer_proportion)) - if not self.theme.font_footer_italics and \ - self.theme.font_footer_weight == u'Normal': - self.FontFooterWeightComboBox.setCurrentIndex(0) - elif not self.theme.font_footer_italics and \ - self.theme.font_footer_weight == u'Bold': - self.FontFooterWeightComboBox.setCurrentIndex(1) - elif self.theme.font_footer_italics and \ - self.theme.font_footer_weight == u'Normal': - self.FontFooterWeightComboBox.setCurrentIndex(2) - else: - self.FontFooterWeightComboBox.setCurrentIndex(3) - self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x)) - self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y)) - self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width)) - self.FontFooterHeightSpinBox.setValue( - int(self.theme.font_footer_height)) - self.FontMainColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(theme.font_main_color)) - self.FontFooterColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(theme.font_footer_color)) - - if self.theme.font_main_override == False: - self.FontMainDefaultCheckBox.setChecked(True) - else: - self.FontMainDefaultCheckBox.setChecked(False) - - if self.theme.font_footer_override == False: - self.FontFooterDefaultCheckBox.setChecked(True) - else: - self.FontFooterDefaultCheckBox.setChecked(False) - - self.OutlineColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(theme.display_outline_color)) - self.ShadowColorPushButton.setStyleSheet( - u'background-color: %s' % unicode(theme.display_shadow_color)) - - if self.theme.display_outline: - self.OutlineCheckBox.setChecked(True) - self.OutlineColorPushButton.setEnabled(True) - else: - self.OutlineCheckBox.setChecked(False) - self.OutlineColorPushButton.setEnabled(False) - - if self.theme.display_shadow: - self.ShadowCheckBox.setChecked(True) - self.ShadowColorPushButton.setEnabled(True) - else: - self.ShadowCheckBox.setChecked(False) - self.ShadowColorPushButton.setEnabled(False) - - self.HorizontalComboBox.setCurrentIndex( - int(self.theme.display_horizontalAlign)) - self.VerticalComboBox.setCurrentIndex( - int(self.theme.display_verticalAlign)) - - def stateChanging(self, theme): - if theme.background_mode == u'transparent': - self.Color1Label.setVisible(False) - self.Color1PushButton.setVisible(False) - self.Color2Label.setVisible(False) - self.Color2PushButton.setVisible(False) - self.ImageLabel.setVisible(False) - self.ImageLineEdit.setVisible(False) - self.ImageFilenameWidget.setVisible(False) - self.GradientLabel.setVisible(False) - self.GradientComboBox.setVisible(False) - self.BackgroundTypeComboBox.setVisible(False) - self.BackgroundTypeLabel.setVisible(False) - else: - self.BackgroundTypeComboBox.setVisible(True) - self.BackgroundTypeLabel.setVisible(True) - if theme.background_type == u'solid': - self.Color1PushButton.setStyleSheet( - u'background-color: %s' % unicode(theme.background_color)) - self.Color1Label.setText(translate(u'ThemeManager', - u'Background Color:')) - self.Color1Label.setVisible(True) - self.Color1PushButton.setVisible(True) - self.Color2Label.setVisible(False) - self.Color2PushButton.setVisible(False) - self.ImageLabel.setVisible(False) - self.ImageLineEdit.setVisible(False) - self.ImageFilenameWidget.setVisible(False) - self.GradientLabel.setVisible(False) - self.GradientComboBox.setVisible(False) - elif theme.background_type == u'gradient': - self.Color1PushButton.setStyleSheet(u'background-color: %s' \ - % unicode(theme.background_startColor)) - self.Color2PushButton.setStyleSheet(u'background-color: %s' \ - % unicode(theme.background_endColor)) - self.Color1Label.setText(translate(u'ThemeManager', - u'First Color:')) - self.Color2Label.setText(translate(u'ThemeManager', - u'Second Color:')) - self.Color1Label.setVisible(True) - self.Color1PushButton.setVisible(True) - self.Color2Label.setVisible(True) - self.Color2PushButton.setVisible(True) - self.ImageLabel.setVisible(False) - self.ImageLineEdit.setVisible(False) - self.ImageFilenameWidget.setVisible(False) - self.GradientLabel.setVisible(True) - self.GradientComboBox.setVisible(True) - else: # must be image - self.Color1Label.setVisible(False) - self.Color1PushButton.setVisible(False) - self.Color2Label.setVisible(False) - self.Color2PushButton.setVisible(False) - self.ImageLabel.setVisible(True) - self.ImageLineEdit.setVisible(True) - self.ImageFilenameWidget.setVisible(True) - self.GradientLabel.setVisible(False) - self.GradientComboBox.setVisible(False) - - if theme.font_main_override == False: - self.FontMainXSpinBox.setEnabled(False) - self.FontMainYSpinBox.setEnabled(False) - self.FontMainWidthSpinBox.setEnabled(False) - self.FontMainHeightSpinBox.setEnabled(False) - else: - self.FontMainXSpinBox.setEnabled(True) - self.FontMainYSpinBox.setEnabled(True) - self.FontMainWidthSpinBox.setEnabled(True) - self.FontMainHeightSpinBox.setEnabled(True) - - if theme.font_footer_override == False: - self.FontFooterXSpinBox.setEnabled(False) - self.FontFooterYSpinBox.setEnabled(False) - self.FontFooterWidthSpinBox.setEnabled(False) - self.FontFooterHeightSpinBox.setEnabled(False) - else: - self.FontFooterXSpinBox.setEnabled(True) - self.FontFooterYSpinBox.setEnabled(True) - self.FontFooterWidthSpinBox.setEnabled(True) - self.FontFooterHeightSpinBox.setEnabled(True) - - if self.theme.display_outline: - self.OutlineColorPushButton.setEnabled(True) - else: - self.OutlineColorPushButton.setEnabled(False) - - if self.theme.display_shadow: - self.ShadowColorPushButton.setEnabled(True) - else: - self.ShadowColorPushButton.setEnabled(False) - - def previewTheme(self, theme): - if self.allowPreview: - frame = self.thememanager.generateImage(theme) - self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 +import os, os.path + +from PyQt4 import QtCore, QtGui +from openlp.core.lib import ThemeXML, Renderer, file_to_xml, str_to_bool, \ + translate + +from amendthemedialog import Ui_AmendThemeDialog + +log = logging.getLogger(u'AmendThemeForm') + +class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): + + def __init__(self, thememanager, parent=None): + QtGui.QDialog.__init__(self, parent) + self.thememanager = thememanager + self.path = None + self.theme = ThemeXML() + self.setupUi(self) + #define signals + #Buttons + QtCore.QObject.connect(self.Color1PushButton , + QtCore.SIGNAL(u'pressed()'), self.onColor1PushButtonClicked) + QtCore.QObject.connect(self.Color2PushButton , + QtCore.SIGNAL(u'pressed()'), self.onColor2PushButtonClicked) + QtCore.QObject.connect(self.FontMainColorPushButton, + QtCore.SIGNAL(u'pressed()'), self.onFontMainColorPushButtonClicked) + QtCore.QObject.connect(self.FontFooterColorPushButton, + QtCore.SIGNAL(u'pressed()'), + self.onFontFooterColorPushButtonClicked) + QtCore.QObject.connect(self.OutlineColorPushButton, + QtCore.SIGNAL(u'pressed()'), self.onOutlineColorPushButtonClicked) + QtCore.QObject.connect(self.ShadowColorPushButton, + QtCore.SIGNAL(u'pressed()'), self.onShadowColorPushButtonClicked) + QtCore.QObject.connect(self.ImageToolButton, + QtCore.SIGNAL(u'pressed()'), self.onImageToolButtonClicked) + #Combo boxes + QtCore.QObject.connect(self.BackgroundComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected) + QtCore.QObject.connect(self.BackgroundTypeComboBox, + QtCore.SIGNAL(u'activated(int)'), + self.onBackgroundTypeComboBoxSelected) + QtCore.QObject.connect(self.GradientComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onGradientComboBoxSelected) + QtCore.QObject.connect(self.FontMainComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onFontMainComboBoxSelected) + QtCore.QObject.connect(self.FontMainWeightComboBox, + QtCore.SIGNAL(u'activated(int)'), + self.onFontMainWeightComboBoxSelected) + QtCore.QObject.connect(self.FontFooterComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onFontFooterComboBoxSelected) + QtCore.QObject.connect(self.FontFooterWeightComboBox, + QtCore.SIGNAL(u'activated(int)'), + self.onFontFooterWeightComboBoxSelected) + QtCore.QObject.connect(self.HorizontalComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onHorizontalComboBoxSelected) + QtCore.QObject.connect(self.VerticalComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onVerticalComboBoxSelected) + #Spin boxes + QtCore.QObject.connect(self.FontMainSizeSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontMainSizeSpinBoxChanged) + QtCore.QObject.connect(self.FontFooterSizeSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontFooterSizeSpinBoxChanged) + QtCore.QObject.connect(self.FontMainDefaultCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onFontMainDefaultCheckBoxChanged) + QtCore.QObject.connect(self.FontMainXSpinBox, + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainXSpinBoxChanged) + QtCore.QObject.connect(self.FontMainYSpinBox, + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainYSpinBoxChanged) + QtCore.QObject.connect(self.FontMainWidthSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontMainWidthSpinBoxChanged) + QtCore.QObject.connect(self.FontMainHeightSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontMainHeightSpinBoxChanged) + QtCore.QObject.connect(self.FontFooterDefaultCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onFontFooterDefaultCheckBoxChanged) + QtCore.QObject.connect(self.FontFooterXSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontFooterXSpinBoxChanged) + QtCore.QObject.connect(self.FontFooterYSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontFooterYSpinBoxChanged) + QtCore.QObject.connect(self.FontFooterWidthSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontFooterWidthSpinBoxChanged) + QtCore.QObject.connect(self.FontFooterHeightSpinBox, + QtCore.SIGNAL(u'editingFinished()'), + self.onFontFooterHeightSpinBoxChanged) + QtCore.QObject.connect(self.OutlineCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged) + QtCore.QObject.connect(self.ShadowCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged) + + def accept(self): + new_theme = ThemeXML() + theme_name = unicode(self.ThemeNameEdit.displayText()) + new_theme.new_document(theme_name) + save_from = None + save_to = None + if self.theme.background_mode == u'transparent': + new_theme.add_background_transparent() + else: + if self.theme.background_type == u'solid': + new_theme.add_background_solid( \ + unicode(self.theme.background_color)) + elif self.theme.background_type == u'gradient': + new_theme.add_background_gradient( \ + unicode(self.theme.background_startColor), + unicode(self.theme.background_endColor), + self.theme.background_direction) + else: + (path, filename) = \ + os.path.split(unicode(self.theme.background_filename)) + new_theme.add_background_image(filename) + save_to= os.path.join(self.path, theme_name, filename ) + save_from = self.theme.background_filename + + new_theme.add_font(unicode(self.theme.font_main_name), + unicode(self.theme.font_main_color), + unicode(self.theme.font_main_proportion), + unicode(self.theme.font_main_override), u'main', + unicode(self.theme.font_main_weight), + unicode(self.theme.font_main_italics), + unicode(self.theme.font_main_x), + unicode(self.theme.font_main_y), + unicode(self.theme.font_main_width), + unicode(self.theme.font_main_height)) + new_theme.add_font(unicode(self.theme.font_footer_name), + unicode(self.theme.font_footer_color), + unicode(self.theme.font_footer_proportion), + unicode(self.theme.font_footer_override), u'footer', + unicode(self.theme.font_footer_weight), + unicode(self.theme.font_footer_italics), + unicode(self.theme.font_footer_x), + unicode(self.theme.font_footer_y), + unicode(self.theme.font_footer_width), + unicode(self.theme.font_footer_height) ) + new_theme.add_display(unicode(self.theme.display_shadow), + unicode(self.theme.display_shadow_color), + unicode(self.theme.display_outline), + unicode(self.theme.display_outline_color), + unicode(self.theme.display_horizontalAlign), + unicode(self.theme.display_verticalAlign), + unicode(self.theme.display_wrapStyle)) + theme = new_theme.extract_xml() + pretty_theme = new_theme.extract_formatted_xml() + if self.thememanager.saveTheme(theme_name, theme, pretty_theme, + save_from, save_to) is not False: + return QtGui.QDialog.accept(self) + + def loadTheme(self, theme): + log.debug(u'LoadTheme %s', theme) + if theme == None: + self.theme.parse(self.baseTheme()) + else: + xml_file = os.path.join(self.path, theme, theme + u'.xml') + xml = file_to_xml(xml_file) + self.theme.parse(xml) + self.theme.extend_image_filename(self.path) + self.cleanTheme(self.theme) + self.allowPreview = False + self.paintUi(self.theme) + self.allowPreview = True + self.previewTheme(self.theme) + + def cleanTheme(self, theme): + self.theme.background_color = theme.background_color.strip() + self.theme.background_direction = theme.background_direction.strip() + self.theme.background_endColor = theme.background_endColor.strip() + if theme.background_filename: + self.theme.background_filename = theme.background_filename.strip() + #self.theme.background_mode + self.theme.background_startColor = theme.background_startColor.strip() + #self.theme.background_type + self.theme.display_display = theme.display_display.strip() + self.theme.display_horizontalAlign = \ + theme.display_horizontalAlign.strip() + self.theme.display_outline = str_to_bool(theme.display_outline) + #self.theme.display_outline_color + self.theme.display_shadow = str_to_bool(theme.display_shadow) + #self.theme.display_shadow_color + self.theme.display_verticalAlign = \ + theme.display_verticalAlign.strip() + self.theme.display_wrapStyle = theme.display_wrapStyle.strip() + self.theme.font_footer_color = theme.font_footer_color.strip() + self.theme.font_footer_height = theme.font_footer_height.strip() + self.theme.font_footer_italics = str_to_bool(theme.font_footer_italics) + self.theme.font_footer_name = theme.font_footer_name.strip() + #self.theme.font_footer_override + self.theme.font_footer_proportion = \ + theme.font_footer_proportion.strip() + self.theme.font_footer_weight = theme.font_footer_weight.strip() + self.theme.font_footer_width = theme.font_footer_width.strip() + self.theme.font_footer_x = theme.font_footer_x.strip() + self.theme.font_footer_y = theme.font_footer_y.strip() + self.theme.font_main_color = theme.font_main_color.strip() + self.theme.font_main_height = theme.font_main_height.strip() + self.theme.font_main_italics = str_to_bool(theme.font_main_italics) + self.theme.font_main_name = theme.font_main_name.strip() + #self.theme.font_main_override + self.theme.font_main_proportion = theme.font_main_proportion.strip() + self.theme.font_main_weight = theme.font_main_weight.strip() + self.theme.font_main_x = theme.font_main_x.strip() + self.theme.font_main_y = theme.font_main_y.strip() + #self.theme.theme_mode + self.theme.theme_name = theme.theme_name.strip() + #self.theme.theme_version + + def onImageToolButtonClicked(self): + filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file') + if filename != "": + self.ImageLineEdit.setText(filename) + self.theme.background_filename = filename + self.previewTheme(self.theme) + # + #Main Font Tab + # + def onFontMainComboBoxSelected(self): + self.theme.font_main_name = self.FontMainComboBox.currentFont().family() + self.previewTheme(self.theme) + + def onFontMainWeightComboBoxSelected(self, value): + if value ==0: + self.theme.font_main_weight = u'Normal' + self.theme.font_main_italics = False + elif value == 1: + self.theme.font_main_weight = u'Bold' + self.theme.font_main_italics = False + elif value == 2: + self.theme.font_main_weight = u'Normal' + self.theme.font_main_italics = True + else: + self.theme.font_main_weight = u'Bold' + self.theme.font_main_italics = True + self.previewTheme(self.theme) + + def onFontMainColorPushButtonClicked(self): + self.theme.font_main_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.font_main_color), self).name() + + self.FontMainColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.font_main_color)) + self.previewTheme(self.theme) + + def onFontMainSizeSpinBoxChanged(self): + if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): + self.theme.font_main_proportion = self.FontMainSizeSpinBox.value() + self.previewTheme(self.theme) + + def onFontMainDefaultCheckBoxChanged(self, value): + if value == QtCore.Qt.Checked: # checked + self.theme.font_main_override = False + else: + self.theme.font_main_override = True + + if int(self.theme.font_main_x) == 0 and \ + int(self.theme.font_main_y) == 0 and \ + int(self.theme.font_main_width) == 0 and \ + int(self.theme.font_main_height) == 0: + self.theme.font_main_x = u'10' + self.theme.font_main_y = u'10' + self.theme.font_main_width = u'1024' + self.theme.font_main_height = u'730' + self.FontMainXSpinBox.setValue(int(self.theme.font_main_x)) + self.FontMainYSpinBox.setValue(int(self.theme.font_main_y)) + self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) + self.FontMainHeightSpinBox.setValue(int( \ + self.theme.font_main_height)) + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onFontMainXSpinBoxChanged(self): + if self.theme.font_main_x != self.FontMainXSpinBox.value(): + self.theme.font_main_x = self.FontMainXSpinBox.value() + self.previewTheme(self.theme) + + def onFontMainYSpinBoxChanged(self): + if self.theme.font_main_y != self.FontMainYSpinBox.value(): + self.theme.font_main_y = self.FontMainYSpinBox.value() + self.previewTheme(self.theme) + + def onFontMainWidthSpinBoxChanged(self): + if self.theme.font_main_width != self.FontMainWidthSpinBox.value(): + self.theme.font_main_width = self.FontMainWidthSpinBox.value() + self.previewTheme(self.theme) + + def onFontMainHeightSpinBoxChanged(self): + if self.theme.font_main_height != self.FontMainHeightSpinBox.value(): + self.theme.font_main_height = self.FontMainHeightSpinBox.value() + self.previewTheme(self.theme) + # + #Footer Font Tab + # + def onFontFooterComboBoxSelected(self): + self.theme.font_footer_name = \ + self.FontFooterComboBox.currentFont().family() + self.previewTheme(self.theme) + + def onFontFooterWeightComboBoxSelected(self, value): + if value == 0: + self.theme.font_footer_weight = u'Normal' + self.theme.font_footer_italics = False + elif value == 1: + self.theme.font_footer_weight = u'Bold' + self.theme.font_footer_italics = False + elif value == 2: + self.theme.font_footer_weight = u'Normal' + self.theme.font_footer_italics = True + else: + self.theme.font_footer_weight = u'Bold' + self.theme.font_footer_italics = True + self.previewTheme(self.theme) + + def onFontFooterColorPushButtonClicked(self): + self.theme.font_footer_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.font_footer_color), self).name() + + self.FontFooterColorPushButton.setStyleSheet( + 'background-color: %s' % unicode(self.theme.font_footer_color)) + self.previewTheme(self.theme) + + def onFontFooterSizeSpinBoxChanged(self): + if self.theme.font_footer_proportion != \ + self.FontFooterSizeSpinBox.value(): + self.theme.font_footer_proportion = \ + self.FontFooterSizeSpinBox.value() + self.previewTheme(self.theme) + + def onFontFooterDefaultCheckBoxChanged(self, value): + if value == QtCore.Qt.Checked: # checked + self.theme.font_footer_override = False + else: + self.theme.font_footer_override = True + + if int(self.theme.font_footer_x) == 0 and \ + int(self.theme.font_footer_y) == 0 and \ + int(self.theme.font_footer_width) == 0 and \ + int(self.theme.font_footer_height) == 0: + self.theme.font_footer_x = u'10' + self.theme.font_footer_y = u'730' + self.theme.font_footer_width = u'1024' + self.theme.font_footer_height = u'38' + + self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x)) + self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y)) + self.FontFooterWidthSpinBox.setValue(int( \ + self.theme.font_footer_width)) + self.FontFooterHeightSpinBox.setValue(int( \ + self.theme.font_footer_height)) + + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onFontFooterXSpinBoxChanged(self): + if self.theme.font_footer_x != self.FontFooterXSpinBox.value(): + self.theme.font_footer_x = self.FontFooterXSpinBox.value() + self.previewTheme(self.theme) + + def onFontFooterYSpinBoxChanged(self): + if self.theme.font_footer_y != self.FontFooterYSpinBox.value(): + self.theme.font_footer_y = self.FontFooterYSpinBox.value() + self.previewTheme(self.theme) + + def onFontFooterWidthSpinBoxChanged(self): + if self.theme.font_footer_width != self.FontFooterWidthSpinBox.value(): + self.theme.font_footer_width = self.FontFooterWidthSpinBox.value() + self.previewTheme(self.theme) + + def onFontFooterHeightSpinBoxChanged(self): + if self.theme.font_footer_height != \ + self.FontFooterHeightSpinBox.value(): + self.theme.font_footer_height = self.FontFooterHeightSpinBox.value() + self.previewTheme(self.theme) + # + #Background Tab + # + def onGradientComboBoxSelected(self, currentIndex): + self.setBackground(self.BackgroundTypeComboBox.currentIndex(), + currentIndex) + + def onBackgroundComboBoxSelected(self, currentIndex): + if currentIndex == 0: # Opaque + self.theme.background_mode = u'opaque' + else: + self.theme.background_mode = u'transparent' + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onBackgroundTypeComboBoxSelected(self, currentIndex): + self.setBackground(currentIndex, self.GradientComboBox.currentIndex()) + + def setBackground(self, background, gradient): + if background == 0: # Solid + self.theme.background_type = u'solid' + if self.theme.background_color is None : + self.theme.background_color = u'#000000' + elif background == 1: # Gradient + self.theme.background_type = u'gradient' + if gradient == 0: # Horizontal + self.theme.background_direction = u'horizontal' + elif gradient == 1: # vertical + self.theme.background_direction = u'vertical' + else: + self.theme.background_direction = u'circular' + if self.theme.background_startColor is None : + self.theme.background_startColor = u'#000000' + if self.theme.background_endColor is None : + self.theme.background_endColor = u'#ff0000' + else: + self.theme.background_type = u'image' + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onColor1PushButtonClicked(self): + if self.theme.background_type == u'solid': + self.theme.background_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_color), self).name() + self.Color1PushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.background_color)) + else: + self.theme.background_startColor = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_startColor), self).name() + self.Color1PushButton.setStyleSheet( + u'background-color: %s' % \ + unicode(self.theme.background_startColor)) + + self.previewTheme(self.theme) + + def onColor2PushButtonClicked(self): + self.theme.background_endColor = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.background_endColor), self).name() + self.Color2PushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.background_endColor)) + + self.previewTheme(self.theme) + # + #Other Tab + # + def onOutlineCheckBoxChanged(self, value): + if value == QtCore.Qt.Checked: # checked + self.theme.display_outline = True + else: + self.theme.display_outline = False + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onOutlineColorPushButtonClicked(self): + self.theme.display_outline_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.display_outline_color), self).name() + self.OutlineColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.display_outline_color)) + self.previewTheme(self.theme) + + def onShadowCheckBoxChanged(self, value): + if value == QtCore.Qt.Checked: # checked + self.theme.display_shadow = True + else: + self.theme.display_shadow = False + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onShadowColorPushButtonClicked(self): + self.theme.display_shadow_color = QtGui.QColorDialog.getColor( + QtGui.QColor(self.theme.display_shadow_color), self).name() + self.ShadowColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(self.theme.display_shadow_color)) + self.previewTheme(self.theme) + + def onHorizontalComboBoxSelected(self, currentIndex): + self.theme.display_horizontalAlign = currentIndex + self.stateChanging(self.theme) + self.previewTheme(self.theme) + + def onVerticalComboBoxSelected(self, currentIndex): + self.theme.display_verticalAlign = currentIndex + self.stateChanging(self.theme) + self.previewTheme(self.theme) + # + #Local Methods + # + def baseTheme(self): + log.debug(u'base theme created') + newtheme = ThemeXML() + newtheme.new_document(u'New Theme') + newtheme.add_background_solid(unicode(u'#000000')) + newtheme.add_font(unicode(QtGui.QFont().family()), unicode(u'#FFFFFF'), + unicode(30), u'False') + newtheme.add_font(unicode(QtGui.QFont().family()), unicode(u'#FFFFFF'), + unicode(12), u'False', u'footer') + newtheme.add_display(u'False', unicode(u'#FFFFFF'), u'False', + unicode(u'#FFFFFF'), + unicode(0), unicode(0), unicode(0)) + + return newtheme.extract_xml() + + def paintUi(self, theme): + self.stateChanging(theme) + self.ThemeNameEdit.setText(self.theme.theme_name) + if self.theme.background_mode == u'opaque': + self.BackgroundComboBox.setCurrentIndex(0) + else: + self.BackgroundComboBox.setCurrentIndex(1) + + if theme.background_type == u'solid': + self.BackgroundTypeComboBox.setCurrentIndex(0) + elif theme.background_type == u'gradient': + self.BackgroundTypeComboBox.setCurrentIndex(1) + else: + self.BackgroundTypeComboBox.setCurrentIndex(2) + + if self.theme.background_direction == u'horizontal': + self.GradientComboBox.setCurrentIndex(0) + elif self.theme.background_direction == u'vertical': + self.GradientComboBox.setCurrentIndex(1) + else: + self.GradientComboBox.setCurrentIndex(2) + + self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion)) + if not self.theme.font_main_italics and \ + self.theme.font_main_weight == u'Normal': + self.FontMainWeightComboBox.setCurrentIndex(0) + elif not self.theme.font_main_italics and \ + self.theme.font_main_weight == u'Bold': + self.FontMainWeightComboBox.setCurrentIndex(1) + elif self.theme.font_main_italics and \ + self.theme.font_main_weight == u'Normal': + self.FontMainWeightComboBox.setCurrentIndex(2) + else: + self.FontMainWeightComboBox.setCurrentIndex(3) + + self.FontMainXSpinBox.setValue(int(self.theme.font_main_x)) + self.FontMainYSpinBox.setValue(int(self.theme.font_main_y)) + self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width)) + self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height)) + self.FontFooterSizeSpinBox.setValue( + int(self.theme.font_footer_proportion)) + if not self.theme.font_footer_italics and \ + self.theme.font_footer_weight == u'Normal': + self.FontFooterWeightComboBox.setCurrentIndex(0) + elif not self.theme.font_footer_italics and \ + self.theme.font_footer_weight == u'Bold': + self.FontFooterWeightComboBox.setCurrentIndex(1) + elif self.theme.font_footer_italics and \ + self.theme.font_footer_weight == u'Normal': + self.FontFooterWeightComboBox.setCurrentIndex(2) + else: + self.FontFooterWeightComboBox.setCurrentIndex(3) + self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x)) + self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y)) + self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width)) + self.FontFooterHeightSpinBox.setValue( + int(self.theme.font_footer_height)) + self.FontMainColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(theme.font_main_color)) + self.FontFooterColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(theme.font_footer_color)) + + if self.theme.font_main_override == False: + self.FontMainDefaultCheckBox.setChecked(True) + else: + self.FontMainDefaultCheckBox.setChecked(False) + + if self.theme.font_footer_override == False: + self.FontFooterDefaultCheckBox.setChecked(True) + else: + self.FontFooterDefaultCheckBox.setChecked(False) + + self.OutlineColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(theme.display_outline_color)) + self.ShadowColorPushButton.setStyleSheet( + u'background-color: %s' % unicode(theme.display_shadow_color)) + + if self.theme.display_outline: + self.OutlineCheckBox.setChecked(True) + self.OutlineColorPushButton.setEnabled(True) + else: + self.OutlineCheckBox.setChecked(False) + self.OutlineColorPushButton.setEnabled(False) + + if self.theme.display_shadow: + self.ShadowCheckBox.setChecked(True) + self.ShadowColorPushButton.setEnabled(True) + else: + self.ShadowCheckBox.setChecked(False) + self.ShadowColorPushButton.setEnabled(False) + + self.HorizontalComboBox.setCurrentIndex( + int(self.theme.display_horizontalAlign)) + self.VerticalComboBox.setCurrentIndex( + int(self.theme.display_verticalAlign)) + + def stateChanging(self, theme): + if theme.background_mode == u'transparent': + self.Color1Label.setVisible(False) + self.Color1PushButton.setVisible(False) + self.Color2Label.setVisible(False) + self.Color2PushButton.setVisible(False) + self.ImageLabel.setVisible(False) + self.ImageLineEdit.setVisible(False) + self.ImageFilenameWidget.setVisible(False) + self.GradientLabel.setVisible(False) + self.GradientComboBox.setVisible(False) + self.BackgroundTypeComboBox.setVisible(False) + self.BackgroundTypeLabel.setVisible(False) + else: + self.BackgroundTypeComboBox.setVisible(True) + self.BackgroundTypeLabel.setVisible(True) + if theme.background_type == u'solid': + self.Color1PushButton.setStyleSheet( + u'background-color: %s' % unicode(theme.background_color)) + self.Color1Label.setText(translate(u'ThemeManager', + u'Background Color:')) + self.Color1Label.setVisible(True) + self.Color1PushButton.setVisible(True) + self.Color2Label.setVisible(False) + self.Color2PushButton.setVisible(False) + self.ImageLabel.setVisible(False) + self.ImageLineEdit.setVisible(False) + self.ImageFilenameWidget.setVisible(False) + self.GradientLabel.setVisible(False) + self.GradientComboBox.setVisible(False) + elif theme.background_type == u'gradient': + self.Color1PushButton.setStyleSheet(u'background-color: %s' \ + % unicode(theme.background_startColor)) + self.Color2PushButton.setStyleSheet(u'background-color: %s' \ + % unicode(theme.background_endColor)) + self.Color1Label.setText(translate(u'ThemeManager', + u'First Color:')) + self.Color2Label.setText(translate(u'ThemeManager', + u'Second Color:')) + self.Color1Label.setVisible(True) + self.Color1PushButton.setVisible(True) + self.Color2Label.setVisible(True) + self.Color2PushButton.setVisible(True) + self.ImageLabel.setVisible(False) + self.ImageLineEdit.setVisible(False) + self.ImageFilenameWidget.setVisible(False) + self.GradientLabel.setVisible(True) + self.GradientComboBox.setVisible(True) + else: # must be image + self.Color1Label.setVisible(False) + self.Color1PushButton.setVisible(False) + self.Color2Label.setVisible(False) + self.Color2PushButton.setVisible(False) + self.ImageLabel.setVisible(True) + self.ImageLineEdit.setVisible(True) + self.ImageFilenameWidget.setVisible(True) + self.GradientLabel.setVisible(False) + self.GradientComboBox.setVisible(False) + + if theme.font_main_override == False: + self.FontMainXSpinBox.setEnabled(False) + self.FontMainYSpinBox.setEnabled(False) + self.FontMainWidthSpinBox.setEnabled(False) + self.FontMainHeightSpinBox.setEnabled(False) + else: + self.FontMainXSpinBox.setEnabled(True) + self.FontMainYSpinBox.setEnabled(True) + self.FontMainWidthSpinBox.setEnabled(True) + self.FontMainHeightSpinBox.setEnabled(True) + + if theme.font_footer_override == False: + self.FontFooterXSpinBox.setEnabled(False) + self.FontFooterYSpinBox.setEnabled(False) + self.FontFooterWidthSpinBox.setEnabled(False) + self.FontFooterHeightSpinBox.setEnabled(False) + else: + self.FontFooterXSpinBox.setEnabled(True) + self.FontFooterYSpinBox.setEnabled(True) + self.FontFooterWidthSpinBox.setEnabled(True) + self.FontFooterHeightSpinBox.setEnabled(True) + + if self.theme.display_outline: + self.OutlineColorPushButton.setEnabled(True) + else: + self.OutlineColorPushButton.setEnabled(False) + + if self.theme.display_shadow: + self.ShadowColorPushButton.setEnabled(True) + else: + self.ShadowColorPushButton.setEnabled(False) + + def previewTheme(self, theme): + if self.allowPreview: + frame = self.thememanager.generateImage(theme) + self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 3a5f1ad37..39d85ea8b 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -184,14 +184,14 @@ class BiblesTab(SettingsTab): check_state = self.NewChaptersCheckBox.checkState() self.show_new_chapters = False # we have a set value convert to True/False - if check_state == 2: + if check_state == QtCore.Qt.Checked: self.show_new_chapters = True def onBibleSearchCheckBoxChanged(self): check_state = self.BibleSearchCheckBox.checkState() self.bible_search = False # we have a set value convert to True/False - if check_state == 2: + if check_state == QtCore.Qt.Checked: self.bible_search = True def load(self): diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index b2bbadaa5..2ee88aaba 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -23,7 +23,7 @@ ############################################################################### from impresscontroller import ImpressController -from powerpointcontroller import PowerpointController +#from powerpointcontroller import PowerpointController from messagelistener import MessageListener from mediaitem import PresentationMediaItem from presentationtab import PresentationTab diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index e31c1ce4e..b239e350c 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -21,8 +21,10 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - -from win32com.client import Dispatch +try: + from win32com.client import Dispatch +except: + pass # PPT API documentation: # http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 8228d5b3e..7f2d07c11 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -30,7 +30,12 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, MediaManagerItem from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, \ - ImpressController, PowerpointController + ImpressController +try: + from openlp.plugins.presentations.lib import PowerpointController +except: + pass + class PresentationPlugin(Plugin): @@ -72,7 +77,7 @@ class PresentationPlugin(Plugin): """ log.debug('check_pre_conditions') #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Impress', 0)) == QtCore.Qt.Checked: + if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we have uno installed import uno @@ -80,8 +85,8 @@ class PresentationPlugin(Plugin): self.registerControllers(u'Impress', openoffice) except: log.error(u'Reason : %s', sys.exc_info()) - #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint', 0)) == QtCore.Qt.Checked: + #Lets see if Powerpoint is required (Default is Not wanted) + if int(self.config.get_config(u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch @@ -89,8 +94,8 @@ class PresentationPlugin(Plugin): self.registerControllers(u'Powerpoint', powerpoint) except: log.error(u'Reason : %s', sys.exc_info()) - #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint Viewer', 0)) == QtCore.Qt.Checked: + #Lets see if Powerpoint Viewer is required (Default is Not wanted) + if int(self.config.get_config(u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 6852e08d2..4205b994d 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -42,7 +42,7 @@ class RemotesPlugin(Plugin): """ log.debug('check_pre_conditions') #Lets see if Remote is required - if int(self.config.get_config(u'startup', 0)) == 2: + if int(self.config.get_config(u'startup', 0)) == QtCore.Qt.Checked: return True else: return False From f4599bf94786c74bc3050026dbcfce653004946d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Sep 2009 20:31:31 +0100 Subject: [PATCH 7/7] Fixed reset presentation bug --- openlp/core/ui/slidecontroller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index db0130374..7676231ca 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -239,7 +239,7 @@ class SlideController(QtGui.QWidget): log.debug(u'addServiceItem') #If old item was a command tell it to stop if self.commandItem is not None and self.commandItem.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_stop'% self.item.name.lower()) + Receiver().send_message(u'%s_stop'% self.commandItem.name.lower()) self.commandItem = item item.render() self.enableToolBar(item) @@ -258,7 +258,7 @@ class SlideController(QtGui.QWidget): log.debug(u'addServiceItem') #If old item was a command tell it to stop if self.commandItem is not None and self.commandItem.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_stop'% self.item.name.lower()) + Receiver().send_message(u'%s_stop'% self.commandItem.name.lower()) self.commandItem = item self.enableToolBar(item) if item.service_item_type == ServiceType.Command: