Last of the dialogs

This commit is contained in:
Raoul Snyman 2013-02-01 23:34:23 +02:00
parent 4bd77075f3
commit c891edc40c
19 changed files with 325 additions and 78 deletions

View File

@ -26,14 +26,23 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The UI widgets for the service item edit dialog
"""
from PyQt4 import QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box, create_button
class Ui_ServiceItemEditDialog(object):
"""
The UI widgets for the service item edit dialog
"""
def setupUi(self, serviceItemEditDialog):
"""
Set up the UI
"""
serviceItemEditDialog.setObjectName(u'serviceItemEditDialog')
self.dialog_layout = QtGui.QGridLayout(serviceItemEditDialog)
self.dialog_layout.setContentsMargins(8, 8, 8, 8)
@ -61,4 +70,7 @@ class Ui_ServiceItemEditDialog(object):
self.retranslateUi(serviceItemEditDialog)
def retranslateUi(self, serviceItemEditDialog):
"""
Translate the UI on the fly
"""
serviceItemEditDialog.setWindowTitle(translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item'))

View File

@ -26,12 +26,15 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The service item edit dialog
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Registry
from serviceitemeditdialog import Ui_ServiceItemEditDialog
class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
"""
This is the form that is used to edit the verses of the song.
@ -47,6 +50,9 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
self.on_current_row_changed)
def set_service_item(self, item):
"""
Set the service item to be edited.
"""
self.item = item
self.item_list = []
if self.item.is_image():
@ -57,6 +63,9 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
self.list_widget.setCurrentItem(self.list_widget.currentItem())
def get_service_item(self):
"""
Get the modified service item.
"""
if self.data:
self.item._raw_frames = []
if self.item.is_image():

View File

@ -26,6 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The service manager sets up, loads, saves and manages services.
"""
import cgi
import cPickle
import logging
@ -48,11 +51,15 @@ from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, split_filename, format_time
from openlp.core.utils.actions import ActionList, CategoryOrder
class ServiceManagerList(QtGui.QTreeWidget):
"""
Set up key bindings and mouse behaviour for the service list
"""
def __init__(self, serviceManager, parent=None):
"""
Constructor
"""
QtGui.QTreeWidget.__init__(self, parent)
self.serviceManager = serviceManager
@ -93,16 +100,22 @@ class ServiceManagerList(QtGui.QTreeWidget):
mime_data.setText(u'ServiceManager')
drag.start(QtCore.Qt.CopyAction)
class ServiceManagerDialog(object):
"""
The UI for the service manager.
"""
def setup_ui(self,widget):
def setup_ui(self, widget):
"""
Set up the UI for the service manager
"""
# Create the top toolbar
self.toolbar = OpenLPToolbar(self)
self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png',
tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked)
self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png',
tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), triggers=self.on_load_service_clicked)
tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'),
triggers=self.on_load_service_clicked)
self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png',
tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method)
self.toolbar.addSeparator()
@ -185,7 +198,8 @@ class ServiceManagerDialog(object):
self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live',
text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png',
tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'),
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, triggers=self.make_live)
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service,
triggers=self.make_live)
self.layout.addWidget(self.order_toolbar)
# Connect up our signals and slots
QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'),
@ -697,7 +711,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
try:
ucsfile = zip_info.filename.decode(u'utf-8')
except UnicodeDecodeError:
log.exception(u'file_name "%s" is not valid UTF-8' % zip_info.file_name.decode(u'utf-8', u'replace'))
log.exception(u'file_name "%s" is not valid UTF-8', zip_info.file_name.decode(u'utf-8', u'replace'))
critical_error_message_box(message=translate('OpenLP.ServiceManager',
'File is not a valid service.\n The content encoding is not UTF-8.'))
continue
@ -809,7 +823,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
delay_suffix = u' %s s' % unicode(service_item[u'service_item'].timed_slide_interval)
else:
delay_suffix = u' ...'
self.timed_slide_interval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix)
self.timed_slide_interval.setText(
translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix)
# TODO for future: make group explains itself more visually
else:
self.auto_play_slides_group.menuAction().setVisible(False)
@ -818,7 +833,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
if service_item[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive):
self.auto_start_action.setVisible(True)
self.auto_start_action.setIcon(self.inactive)
self.auto_start_action.setText(translate('OpenLP.ServiceManager','&Auto Start - inactive'))
self.auto_start_action.setText(translate('OpenLP.ServiceManager', '&Auto Start - inactive'))
if service_item[u'service_item'].will_auto_start:
self.auto_start_action.setText(translate('OpenLP.ServiceManager', '&Auto Start - active'))
self.auto_start_action.setIcon(self.active)
@ -876,7 +891,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.main_window.generalSettingsSection + u'/loop delay')
self.set_modified()
def toggle_auto_play_slides_loop(self):
"""
Toggle Auto play slide loop.
@ -892,7 +906,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.main_window.generalSettingsSection + u'/loop delay')
self.set_modified()
def on_timed_slide_interval(self):
"""
Shows input dialog for enter interval in seconds for delay

View File

@ -26,12 +26,15 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm` class.
"""
from PyQt4 import QtGui
from openlp.core.lib import translate, SpellTextEdit, Registry
from openlp.core.lib.ui import create_button_box
class ServiceNoteForm(QtGui.QDialog):
"""
This is the form that is used to edit the verses of the song.
@ -45,10 +48,16 @@ class ServiceNoteForm(QtGui.QDialog):
self.retranslateUi()
def exec_(self):
"""
Execute the form and return the result.
"""
self.text_edit.setFocus()
return QtGui.QDialog.exec_(self)
def setupUi(self):
"""
Set up the UI of the dialog
"""
self.setObjectName(u'serviceNoteEdit')
self.dialog_layout = QtGui.QVBoxLayout(self)
self.dialog_layout.setContentsMargins(8, 8, 8, 8)
@ -61,6 +70,9 @@ class ServiceNoteForm(QtGui.QDialog):
self.dialog_layout.addWidget(self.button_box)
def retranslateUi(self):
"""
Translate the UI on the fly
"""
self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
def _get_main_window(self):

View File

@ -26,14 +26,23 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The UI widgets of the settings dialog.
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, build_icon
from openlp.core.lib.ui import create_button_box
class Ui_SettingsDialog(object):
"""
The UI widgets of the settings dialog.
"""
def setupUi(self, settingsDialog):
"""
Set up the UI
"""
settingsDialog.setObjectName(u'settingsDialog')
settingsDialog.resize(800, 500)
settingsDialog.setWindowIcon(build_icon(u':/system/system_settings.png'))
@ -55,4 +64,7 @@ class Ui_SettingsDialog(object):
QtCore.QObject.connect(self.settingListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.tabChanged)
def retranslateUi(self, settingsDialog):
"""
Translate the UI on the fly
"""
settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm', 'Configure OpenLP'))

View File

@ -40,6 +40,7 @@ from settingsdialog import Ui_SettingsDialog
log = logging.getLogger(__name__)
class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
"""
Provide the form to manipulate the settings for OpenLP
@ -61,6 +62,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
self.playerTab = PlayerTab(self, self.main_window)
def exec_(self):
"""
Execute the form
"""
# load all the settings
self.settingListWidget.clear()
while self.stackedLayout.count():

View File

@ -26,17 +26,23 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The list of shortcuts within a dialog.
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, build_icon
from openlp.core.lib.ui import create_button_box
class CaptureShortcutButton(QtGui.QPushButton):
"""
A class to encapsulate a ``QPushButton``.
"""
def __init__(self, *args):
"""
Constructor
"""
QtGui.QPushButton.__init__(self, *args)
self.setCheckable(True)
@ -51,7 +57,13 @@ class CaptureShortcutButton(QtGui.QPushButton):
class Ui_ShortcutListDialog(object):
"""
The UI widgets for the shortcut dialog.
"""
def setupUi(self, shortcutListDialog):
"""
Set up the UI
"""
shortcutListDialog.setObjectName(u'shortcutListDialog')
shortcutListDialog.resize(500, 438)
self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog)
@ -113,6 +125,9 @@ class Ui_ShortcutListDialog(object):
self.retranslateUi(shortcutListDialog)
def retranslateUi(self, shortcutListDialog):
"""
Translate the UI on the fly
"""
shortcutListDialog.setWindowTitle(translate('OpenLP.ShortcutListDialog', 'Configure Shortcuts'))
self.descriptionLabel.setText(
translate('OpenLP.ShortcutListDialog', 'Select an action and click one of the buttons below to start '

View File

@ -26,7 +26,8 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`~openlp.core.ui.shortcutlistform` module contains the form class"""
import logging
import re
@ -48,6 +49,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
"""
def __init__(self, parent=None):
"""
Constructor
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.changedActions = {}
@ -72,6 +76,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.onCustomRadioButtonClicked)
def keyPressEvent(self, event):
"""
Respond to certain key presses
"""
if event.key() == QtCore.Qt.Key_Space:
self.keyReleaseEvent(event)
elif self.primaryPushButton.isChecked() or self.alternatePushButton.isChecked():
@ -81,6 +88,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
self.close()
def keyReleaseEvent(self, event):
"""
Respond to certain key presses
"""
if not self.primaryPushButton.isChecked() and not self.alternatePushButton.isChecked():
return
key = event.key()
@ -106,6 +116,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
False, text=key_sequence.toString())
def exec_(self):
"""
Execute the dialog
"""
self.changedActions = {}
self.reloadShortcutList()
self._adjustButton(self.primaryPushButton, False, False, u'')
@ -422,7 +435,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
is_valid = False
if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
is_valid = False
if not is_valid:
Receiver.send_message(u'openlp_warning_message', {

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`slidecontroller` module contains argubly the most important part of OpenLP - the slide controller
"""
import os
import logging
import copy
@ -257,7 +259,7 @@ class SlideController(DisplayController):
self.audioMenu.addAction(self.nextTrackItem)
self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks'))
self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar)
self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setStyleSheet(
u'background-color: palette(background); '
u'border-top-color: palette(shadow); '
@ -288,7 +290,7 @@ class SlideController(DisplayController):
self.slideLayout.setObjectName(u'SlideLayout')
self.previewDisplay = Display(self, self.isLive, self)
self.previewDisplay.setGeometry(QtCore.QRect(0, 0, 300, 300))
self.previewDisplay.screen = {u'size':self.previewDisplay.geometry()}
self.previewDisplay.screen = {u'size': self.previewDisplay.geometry()}
self.previewDisplay.setup()
self.slideLayout.insertWidget(0, self.previewDisplay)
self.previewDisplay.hide()
@ -432,6 +434,9 @@ class SlideController(DisplayController):
self.current_shortcut = u''
def setLiveHotkeys(self, parent=None):
"""
Set the live hotkeys
"""
self.previousService = create_action(parent, u'previousService',
text=translate('OpenLP.SlideController', 'Previous Service'),
shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
@ -442,10 +447,13 @@ class SlideController(DisplayController):
triggers=self.serviceNext)
self.escapeItem = create_action(parent, 'escapeItem',
text=translate('OpenLP.SlideController', 'Escape Item'),
shortcuts=[QtCore.Qt.Key_Escape],context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
shortcuts=[QtCore.Qt.Key_Escape], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.liveEscape)
def liveEscape(self):
"""
If you press ESC on the live screen it should close the display temporarily.
"""
self.display.setVisible(False)
self.media_controller.media_stop(self)
@ -520,11 +528,14 @@ class SlideController(DisplayController):
serviceItem = ServiceItem()
self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive,
plugins=self.plugin_manager.plugins))
self.media_controller.setup_display(self.previewDisplay,True)
self.media_controller.setup_display(self.previewDisplay, True)
if self.serviceItem:
self.refreshServiceItem()
def __addActionsToWidget(self, widget):
"""
Add actions to the widget specified by `widget`
"""
widget.addActions([
self.previousItem, self.nextItem,
self.previousService, self.nextService,
@ -564,6 +575,9 @@ class SlideController(DisplayController):
self.previewListWidget.setRowHeight(framenumber, width / self.ratio)
def onSongBarHandler(self):
"""
Some song handler
"""
request = self.sender().text()
slide_no = self.slideList[request]
self.__updatePreviewSelection(slide_no)
@ -690,7 +704,7 @@ class SlideController(DisplayController):
self.playSlidesLoop.setChecked(item.auto_play_slides_loop)
self.delaySpinBox.setValue(int(item.timed_slide_interval))
self.onPlaySlidesLoop()
elif self.isLive and item.auto_play_slides_once and item.timed_slide_interval > 0:
elif self.isLive and item.auto_play_slides_once and item.timed_slide_interval > 0:
self.playSlidesOnce.setChecked(item.auto_play_slides_once)
self.delaySpinBox.setValue(int(item.timed_slide_interval))
self.onPlaySlidesOnce()
@ -1088,6 +1102,9 @@ class SlideController(DisplayController):
self.slideSelected()
def __checkUpdateSelectedSlide(self, row):
"""
Check if this slide has been updated
"""
if row + 1 < self.previewListWidget.rowCount():
self.previewListWidget.scrollToItem(self.previewListWidget.item(row + 1, 0))
self.previewListWidget.selectRow(row)
@ -1160,9 +1177,15 @@ class SlideController(DisplayController):
self.onToggleLoop()
def setAudioItemsVisibility(self, visible):
"""
Set the visibility of the audio stuff
"""
self.toolbar.setWidgetVisible(self.audioList, visible)
def onAudioPauseClicked(self, checked):
"""
Pause the audio player
"""
if not self.audioPauseItem.isVisible():
return
if checked:
@ -1268,15 +1291,24 @@ class SlideController(DisplayController):
return None
def onNextTrackClicked(self):
"""
Go to the next track when next is clicked
"""
self.display.audioPlayer.next()
def onAudioTimeRemaining(self, time):
"""
Update how much time is remaining
"""
seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000
minutes = seconds // 60
seconds %= 60
self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds))
def onTrackTriggered(self):
"""
Start playing a track
"""
action = self.sender()
self.display.audioPlayer.goTo(action.data())

View File

@ -26,17 +26,30 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The splash screen
"""
from openlp.core.lib import Receiver
from PyQt4 import QtCore, QtGui
class SplashScreen(QtGui.QSplashScreen):
"""
The splash screen
"""
def __init__(self):
"""
Constructor
"""
QtGui.QSplashScreen.__init__(self)
self.setupUi()
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'close_splash'), self.close)
def setupUi(self):
"""
Set up the UI
"""
self.setObjectName(u'splashScreen')
self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
splash_image = QtGui.QPixmap(u':/graphics/openlp-splash-screen.png')

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The UI widgets for the time dialog
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, UiStrings
@ -34,7 +36,13 @@ from openlp.core.lib.ui import create_button_box
class Ui_StartTimeDialog(object):
"""
The UI widgets for the time dialog
"""
def setupUi(self, StartTimeDialog):
"""
Set up the UI
"""
StartTimeDialog.setObjectName(u'StartTimeDialog')
StartTimeDialog.resize(350, 10)
self.dialogLayout = QtGui.QGridLayout(StartTimeDialog)
@ -108,6 +116,9 @@ class Ui_StartTimeDialog(object):
self.setMaximumHeight(self.sizeHint().height())
def retranslateUi(self, StartTimeDialog):
"""
Update the translations on the fly
"""
self.setWindowTitle(translate('OpenLP.StartTimeForm', 'Item Start and Finish Time'))
self.hourSpinBox.setSuffix(UiStrings().Hours)
self.minuteSpinBox.setSuffix(UiStrings().Minutes)

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The actual start time form.
"""
from PyQt4 import QtGui
from starttimedialog import Ui_StartTimeDialog
@ -34,11 +36,15 @@ from starttimedialog import Ui_StartTimeDialog
from openlp.core.lib import translate, UiStrings, Registry
from openlp.core.lib.ui import critical_error_message_box
class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
"""
The exception dialog
The start time dialog
"""
def __init__(self):
"""
Constructor
"""
QtGui.QDialog.__init__(self, self.main_window)
self.setupUi(self)
@ -60,6 +66,9 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
return QtGui.QDialog.exec_(self)
def accept(self):
"""
When the dialog succeeds, this is run
"""
start = self.hourSpinBox.value() * 3600 + \
self.minuteSpinBox.value() * 60 + \
self.secondSpinBox.value()
@ -79,6 +88,9 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog):
return QtGui.QDialog.accept(self)
def _time_split(self, seconds):
"""
Split time up into hours minutes and seconds from secongs
"""
hours = seconds / 3600
seconds -= 3600 * hours
minutes = seconds / 60

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The Theme wizard
"""
import logging
import os
@ -41,6 +43,7 @@ from themewizard import Ui_ThemeWizard
log = logging.getLogger(__name__)
class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
"""
This is the Theme Import Wizard, which allows easy creation and editing of
@ -72,14 +75,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.onGradientStartButtonClicked)
QtCore.QObject.connect(self.gradientEndButton, QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked)
QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked)
QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked)
QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked)
QtCore.QObject.connect(self.outlineColorButton, QtCore.SIGNAL(u'clicked()'), self.onOutlineColorButtonClicked)
QtCore.QObject.connect(self.shadowColorButton, QtCore.SIGNAL(u'clicked()'), self.onShadowColorButtonClicked)
QtCore.QObject.connect(self.outlineCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onOutlineCheckCheckBoxStateChanged)
QtCore.QObject.connect(self.shadowCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onShadowCheckCheckBoxStateChanged)
QtCore.QObject.connect(self.footerColorButton,QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked)
QtCore.QObject.connect(self.footerColorButton, QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked)
QtCore.QObject.connect(self, QtCore.SIGNAL(u'customButtonClicked(int)'), self.onCustom1ButtonClicked)
QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'stateChanged(int)'),
self.onMainPositionCheckBoxStateChanged)
@ -178,6 +181,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
pixmapHeight + 2 * frameWidth)
def validateCurrentPage(self):
"""
Validate the current page
"""
background_image = BackgroundType.to_string(BackgroundType.Image)
if self.page(self.currentId()) == self.backgroundPage and \
self.theme.background_type == background_image and not self.imageFileEdit.text():
@ -444,18 +450,30 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.setBackgroundPageValues()
def onMainColorButtonClicked(self):
"""
Set the main colour value
"""
self.theme.font_main_color = self._colorButton(self.theme.font_main_color)
self.setMainAreaPageValues()
def onOutlineColorButtonClicked(self):
"""
Set the outline colour value
"""
self.theme.font_main_outline_color = self._colorButton(self.theme.font_main_outline_color)
self.setMainAreaPageValues()
def onShadowColorButtonClicked(self):
"""
Set the shadow colour value
"""
self.theme.font_main_shadow_color = self._colorButton(self.theme.font_main_shadow_color)
self.setMainAreaPageValues()
def onFooterColorButtonClicked(self):
"""
Set the footer colour value
"""
self.theme.font_footer_color = self._colorButton(self.theme.font_footer_color)
self.setFooterAreaPageValues()

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The layout of the theme
"""
from PyQt4 import QtGui
from openlp.core.lib import translate
@ -34,7 +36,13 @@ from openlp.core.lib.ui import create_button_box
class Ui_ThemeLayoutDialog(object):
"""
The layout of the theme
"""
def setupUi(self, themeLayoutDialog):
"""
Set up the UI
"""
themeLayoutDialog.setObjectName(u'themeLayoutDialogDialog')
#themeLayoutDialog.resize(300, 200)
self.previewLayout = QtGui.QVBoxLayout(themeLayoutDialog)
@ -63,7 +71,9 @@ class Ui_ThemeLayoutDialog(object):
self.retranslateUi(themeLayoutDialog)
def retranslateUi(self, themeLayoutDialog):
"""
Translate the UI on the fly
"""
themeLayoutDialog.setWindowTitle(translate('OpenLP.StartTimeForm', 'Theme Layout'))
self.mainColourLabel.setText(translate('OpenLP.StartTimeForm', 'The blue box shows the main area.'))
self.footerColourLabel.setText(translate('OpenLP.StartTimeForm', 'The red box shows the footer.'))

View File

@ -26,16 +26,22 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The form layout
"""
from PyQt4 import QtGui, QtCore
from themelayoutdialog import Ui_ThemeLayoutDialog
class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog):
"""
The exception dialog
"""
def __init__(self, parent):
"""
Constructor
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
@ -44,11 +50,7 @@ class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog):
Run the Dialog with correct heading.
"""
pixmap = image.scaledToHeight(400, QtCore.Qt.SmoothTransformation)
self.themeDisplayLabel.setPixmap(image)
self.themeDisplayLabel.setPixmap(pixmap)
displayAspectRatio = float(image.width()) / image.height()
self.themeDisplayLabel.setFixedSize(400, 400 / displayAspectRatio )
self.themeDisplayLabel.setFixedSize(400, 400 / displayAspectRatio)
return QtGui.QDialog.exec_(self)
def accept(self):
return QtGui.QDialog.accept(self)

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The Theme Manager manages adding, deleteing and modifying of themes.
"""
import os
import zipfile
import shutil
@ -47,11 +49,15 @@ from openlp.core.utils import AppLocation, delete_file, locale_compare, get_file
log = logging.getLogger(__name__)
class ThemeManager(QtGui.QWidget):
"""
Manages the orders of Theme.
"""
def __init__(self, parent=None):
"""
Constructor
"""
QtGui.QWidget.__init__(self, parent)
Registry().register(u'theme_manager', self)
self.settingsSection = u'themes'
@ -149,10 +155,10 @@ class ThemeManager(QtGui.QWidget):
"""
Receiver.send_message(u'cursor_busy')
files = SettingsManager.get_files(self.settingsSection, u'.otz')
for file in files:
file = os.path.join(self.path, file)
self.unzipTheme(file, self.path)
delete_file(file)
for theme_file in files:
theme_file = os.path.join(self.path, theme_file)
self.unzipTheme(theme_file, self.path)
delete_file(theme_file)
Receiver.send_message(u'cursor_normal')
def configUpdated(self):
@ -197,7 +203,7 @@ class ThemeManager(QtGui.QWidget):
tab
"""
log.debug(u'changeGlobalFromTab %s', theme_name)
for count in range (0, self.themeListWidget.count()):
for count in range(0, self.themeListWidget.count()):
# reset the old name
item = self.themeListWidget.item(count)
old_name = item.text()
@ -218,7 +224,7 @@ class ThemeManager(QtGui.QWidget):
"""
log.debug(u'changeGlobalFromScreen %s', index)
selected_row = self.themeListWidget.currentRow()
for count in range (0, self.themeListWidget.count()):
for count in range(0, self.themeListWidget.count()):
item = self.themeListWidget.item(count)
old_name = item.text()
# reset the old name
@ -365,16 +371,16 @@ class ThemeManager(QtGui.QWidget):
if path:
Settings().setValue(self.settingsSection + u'/last directory export', path)
theme_path = os.path.join(path, theme + u'.otz')
# FIXME: Do not overwrite build-in.
zip = None
theme_zip = None
try:
zip = zipfile.ZipFile(theme_path, u'w')
theme_zip = zipfile.ZipFile(theme_path, u'w')
source = os.path.join(self.path, theme)
for files in os.walk(source):
for name in files[2]:
zip.write(
theme_zip.write(
os.path.join(source, name).encode(u'utf-8'),
os.path.join(theme, name).encode(u'utf-8'))
os.path.join(theme, name).encode(u'utf-8')
)
QtGui.QMessageBox.information(self,
translate('OpenLP.ThemeManager', 'Theme Exported'),
translate('OpenLP.ThemeManager', 'Your theme has been successfully exported.'))
@ -384,8 +390,8 @@ class ThemeManager(QtGui.QWidget):
translate('OpenLP.ThemeManager', 'Theme Export Failed'),
translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.'))
finally:
if zip:
zip.close()
if theme_zip:
theme_zip.close()
Receiver.send_message(u'cursor_normal')
def onImportTheme(self):
@ -483,6 +489,9 @@ class ThemeManager(QtGui.QWidget):
return self._createThemeFromXml(xml, self.path)
def overWriteMessageBox(self, theme_name):
"""
Display a warning box to the user that a theme already exists
"""
ret = QtGui.QMessageBox.question(self,
translate('OpenLP.ThemeManager', 'Theme Already Exists'),
translate('OpenLP.ThemeManager',
@ -491,7 +500,7 @@ class ThemeManager(QtGui.QWidget):
QtGui.QMessageBox.No)
return ret == QtGui.QMessageBox.Yes
def unzipTheme(self, file_name, dir):
def unzipTheme(self, file_name, directory):
"""
Unzip the theme, remove the preview file if stored
Generate a new preview file. Check the XML theme version and upgrade if
@ -499,32 +508,31 @@ class ThemeManager(QtGui.QWidget):
"""
log.debug(u'Unzipping theme %s', file_name)
file_name = unicode(file_name)
zip = None
theme_zip = None
out_file = None
file_xml = None
abort_import = True
try:
zip = zipfile.ZipFile(file_name)
xml_file = filter(lambda name:
os.path.splitext(name)[1].lower() == u'.xml', zip.namelist())
theme_zip = zipfile.ZipFile(file_name)
xml_file = filter(lambda name: os.path.splitext(name)[1].lower() == u'.xml', theme_zip.namelist())
if len(xml_file) != 1:
log.exception(u'Theme contains "%s" XML files' % len(xml_file))
raise Exception(u'validation')
xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot()
xml_tree = ElementTree(element=XML(theme_zip.read(xml_file[0]))).getroot()
v1_background = xml_tree.find(u'BackgroundType')
if v1_background is not None:
theme_name, file_xml, out_file, abort_import = self.unzipVersion122(
dir, zip, xml_file[0], xml_tree, v1_background, out_file)
directory, theme_zip, xml_file[0], xml_tree, v1_background, out_file)
else:
theme_name = xml_tree.find(u'name').text.strip()
theme_folder = os.path.join(dir, theme_name)
theme_folder = os.path.join(directory, theme_name)
theme_exists = os.path.exists(theme_folder)
if theme_exists and not self.overWriteMessageBox(theme_name):
abort_import = True
return
else:
abort_import = False
for name in zip.namelist():
for name in theme_zip.namelist():
try:
uname = unicode(name, u'utf-8')
except UnicodeDecodeError:
@ -536,15 +544,15 @@ class ThemeManager(QtGui.QWidget):
if split_name[-1] == u'' or len(split_name) == 1:
# is directory or preview file
continue
full_name = os.path.join(dir, uname)
full_name = os.path.join(directory, uname)
check_directory_exists(os.path.dirname(full_name))
if os.path.splitext(uname)[1].lower() == u'.xml':
file_xml = unicode(zip.read(name), u'utf-8')
file_xml = unicode(theme_zip.read(name), u'utf-8')
out_file = open(full_name, u'w')
out_file.write(file_xml.encode(u'utf-8'))
else:
out_file = open(full_name, u'wb')
out_file.write(zip.read(name))
out_file.write(theme_zip.read(name))
out_file.close()
except (IOError, zipfile.BadZipfile):
log.exception(u'Importing theme from zip failed %s' % file_name)
@ -557,24 +565,24 @@ class ThemeManager(QtGui.QWidget):
raise
finally:
# Close the files, to be able to continue creating the theme.
if zip:
zip.close()
if theme_zip:
theme_zip.close()
if out_file:
out_file.close()
if not abort_import:
# As all files are closed, we can create the Theme.
if file_xml:
theme = self._createThemeFromXml(file_xml, self.path)
self.generateAndSaveImage(dir, theme_name, theme)
self.generateAndSaveImage(directory, theme_name, theme)
# Only show the error message, when IOError was not raised (in
# this case the error message has already been shown).
elif zip is not None:
elif theme_zip is not None:
critical_error_message_box(
translate('OpenLP.ThemeManager', 'Validation Error'),
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
log.exception(u'Theme file does not contain XML data %s' % file_name)
def unzipVersion122(self, dir, zip, xml_file, xml_tree, background,
def unzipVersion122(self, directory, theme_zip, xml_file, xml_tree, background,
out_file):
"""
Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling
@ -582,13 +590,13 @@ class ThemeManager(QtGui.QWidget):
"""
theme_name = xml_tree.find(u'Name').text.strip()
theme_name = self.badV1NameChars.sub(u'', theme_name)
theme_folder = os.path.join(dir, theme_name)
theme_folder = os.path.join(directory, theme_name)
theme_exists = os.path.exists(theme_folder)
if theme_exists and not self.overWriteMessageBox(theme_name):
return '', '', '', True
themedir = os.path.join(dir, theme_name)
themedir = os.path.join(directory, theme_name)
check_directory_exists(themedir)
file_xml = unicode(zip.read(xml_file), u'utf-8')
file_xml = unicode(theme_zip.read(xml_file), u'utf-8')
file_xml = self._migrateVersion122(file_xml)
out_file = open(os.path.join(themedir, theme_name + u'.xml'), u'w')
out_file.write(file_xml.encode(u'utf-8'))
@ -598,10 +606,10 @@ class ThemeManager(QtGui.QWidget):
# image file has same extension and is in subfolder
image_file = filter(lambda name: os.path.splitext(name)[1].lower()
== os.path.splitext(image_name)[1].lower() and name.find(r'/'),
zip.namelist())
theme_zip.namelist())
if len(image_file) >= 1:
out_file = open(os.path.join(themedir, image_name), u'wb')
out_file.write(zip.read(image_file[0]))
out_file.write(theme_zip.read(image_file[0]))
out_file.close()
else:
log.exception(u'Theme file does not contain image file "%s"' % image_name.decode(u'utf-8', u'replace'))
@ -664,8 +672,11 @@ class ThemeManager(QtGui.QWidget):
log.exception(u'Failed to save theme image')
self.generateAndSaveImage(self.path, name, theme)
def generateAndSaveImage(self, dir, name, theme):
log.debug(u'generateAndSaveImage %s %s', dir, name)
def generateAndSaveImage(self, directory, name, theme):
"""
Generate and save a preview image
"""
log.debug(u'generateAndSaveImage %s %s', directory, name)
frame = self.generateImage(theme)
sample_path_name = os.path.join(self.path, name + u'.png')
if os.path.exists(sample_path_name):

View File

@ -26,7 +26,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The Themes configuration tab
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings
@ -39,12 +41,18 @@ class ThemesTab(SettingsTab):
ThemesTab is the theme settings tab in the settings dialog.
"""
def __init__(self, parent, mainwindow):
"""
Constructor
"""
self.mainwindow = mainwindow
generalTranslated = translate('OpenLP.ThemesTab', 'Themes')
SettingsTab.__init__(self, parent, u'Themes', generalTranslated)
self.iconPath = u':/themes/theme_new.png'
def setupUi(self):
"""
Set up the UI
"""
self.setObjectName(u'ThemesTab')
SettingsTab.setupUi(self)
self.GlobalGroupBox = QtGui.QGroupBox(self.leftColumn)
@ -100,6 +108,9 @@ class ThemesTab(SettingsTab):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
def retranslateUi(self):
"""
Translate the UI on the fly
"""
self.tabTitleVisible = UiStrings().Themes
self.GlobalGroupBox.setTitle(translate('OpenLP.ThemesTab', 'Global Theme'))
self.LevelGroupBox.setTitle(translate('OpenLP.ThemesTab', 'Theme Level'))
@ -117,6 +128,9 @@ class ThemesTab(SettingsTab):
'any themes associated with either the service or the songs.'))
def load(self):
"""
Load the theme settings into the tab
"""
settings = Settings()
settings.beginGroup(self.settingsSection)
self.theme_level = settings.value(u'theme level')
@ -130,6 +144,9 @@ class ThemesTab(SettingsTab):
self.SongLevelRadioButton.setChecked(True)
def save(self):
"""
Save the settings
"""
settings = Settings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'theme level', self.theme_level)
@ -140,18 +157,33 @@ class ThemesTab(SettingsTab):
Receiver.send_message(u'theme_update_global', self.global_theme)
def postSetUp(self):
"""
After setting things up...
"""
Receiver.send_message(u'theme_update_global', self.global_theme)
def onSongLevelButtonClicked(self):
"""
Set the theme level
"""
self.theme_level = ThemeLevel.Song
def onServiceLevelButtonClicked(self):
"""
Set the theme level
"""
self.theme_level = ThemeLevel.Service
def onGlobalLevelButtonClicked(self):
"""
Set the theme level
"""
self.theme_level = ThemeLevel.Global
def onDefaultComboBoxChanged(self, value):
"""
Set the global default theme
"""
self.global_theme = self.DefaultComboBox.currentText()
self.mainwindow.renderer.set_global_theme(self.global_theme)
self.__previewGlobalTheme()

View File

@ -26,15 +26,24 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The Create/Edit theme wizard
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, build_icon, UiStrings
from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType
from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets
class Ui_ThemeWizard(object):
"""
The Create/Edit theme wizard
"""
def setupUi(self, themeWizard):
"""
Set up the UI
"""
themeWizard.setObjectName(u'OpenLP.ThemeWizard')
themeWizard.setModal(True)
themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
@ -372,7 +381,7 @@ class Ui_ThemeWizard(object):
QtCore.SLOT(u'setDisabled(bool)'))
QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.mainHeightSpinBox,
QtCore.SLOT(u'setDisabled(bool)'))
QtCore.QObject.connect(self.footerPositionCheckBox,QtCore.SIGNAL(u'toggled(bool)'), self.footerXSpinBox,
QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerXSpinBox,
QtCore.SLOT(u'setDisabled(bool)'))
QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerYSpinBox,
QtCore.SLOT(u'setDisabled(bool)'))
@ -382,8 +391,11 @@ class Ui_ThemeWizard(object):
QtCore.SLOT(u'setDisabled(bool)'))
def retranslateUi(self, themeWizard):
"""
Translate the UI on the fly
"""
themeWizard.setWindowTitle(translate('OpenLP.ThemeWizard', 'Theme Wizard'))
self.titleLabel.setText(u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
self.titleLabel.setText(u'<span style="font-size:14pt; font-weight:600;">%s</span>' %
translate('OpenLP.ThemeWizard', 'Welcome to the Theme Wizard'))
self.informationLabel.setText(
translate('OpenLP.ThemeWizard', 'This wizard will help you to '

View File

@ -39,6 +39,7 @@ from openlp.core.lib.ui import add_welcome_page
log = logging.getLogger(__name__)
class WizardStrings(object):
"""
Provide standard strings for wizards to use.
@ -80,6 +81,9 @@ class OpenLPWizard(QtGui.QWizard):
and feel.
"""
def __init__(self, parent, plugin, name, image):
"""
Constructor
"""
QtGui.QWizard.__init__(self, parent)
self.plugin = plugin
self.setObjectName(name)