Start to add ability to set display screen size for a session

This commit is contained in:
Tim Bentley 2010-04-24 19:42:01 +01:00
parent a29ea3f861
commit d7e060c503
10 changed files with 630 additions and 28 deletions

View File

@ -183,8 +183,6 @@ class Ui_AmendThemeDialog(object):
self.MainFontLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainWrapLineAdjustmentLabel)
self.FontMainLineAdjustmentSpinBox = QtGui.QSpinBox(self.FontMainGroupBox)
self.FontMainLineAdjustmentSpinBox.setObjectName("FontMainLineAdjustmentSpinBox")
self.FontMainLineAdjustmentSpinBox.setMaximum(30)
self.FontMainLineAdjustmentSpinBox.setMinimum(-30)
self.MainFontLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.FontMainLineAdjustmentSpinBox)
self.FontMainWrapIndentationLabel = QtGui.QLabel(self.FontMainGroupBox)
self.FontMainWrapIndentationLabel.setObjectName("FontMainWrapIndentationLabel")

View File

@ -137,6 +137,10 @@ class MainDisplay(DisplayWidget):
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_hide_theme'), self.hideThemeDisplay)
# QtCore.QObject.connect(Receiver.get_receiver(),
# QtCore.SIGNAL(u'maindisplay_show_theme'), self.showThemeDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay)
@ -208,6 +212,14 @@ class MainDisplay(DisplayWidget):
self.display_text.setPixmap(self.transparent)
self.moveToTop()
def hideThemeDisplay(self):
log.debug(u'hideDisplay')
a=c
self.display_image.setPixmap(self.transparent)
self.display_alert.setPixmap(self.transparent)
self.display_text.setPixmap(self.transparent)
self.moveToTop()
def moveToTop(self):
log.debug(u'moveToTop')
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint \
@ -365,7 +377,7 @@ class VideoDisplay(Phonon.VideoWidget):
def onMediaQueue(self, message):
log.debug(u'VideoDisplay Queue new media message %s' % message)
file = os.path.join(message[0].get_frame_path(),
file = os.path.join(message[0].get_frame_path(),
message[0].get_frame_title())
source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file))
self.onMediaPlay()

View File

@ -64,7 +64,23 @@ class ScreenList(object):
self.current_display = 0
else:
self.current = self.screen_list[number]
self.override = self.current
self.preview = self.current
self.current_display = number
if self.display_count == 1:
self.preview = self.screen_list[0]
def set_override_display(self):
"""
replace the current size with the override values
user wants to have their own screen attributes
"""
self.current = self.override
self.preview = self.current
def reset_current(self):
"""
replace the current values with the correct values
user wants to use the correct screen attributes
"""
self.set_current_display(self.current_display)

View File

@ -234,6 +234,16 @@ class SlideController(QtGui.QWidget):
self.Mediabar.addToolbarButton(
u'Media Stop', u':/slides/media_playback_stop.png',
self.trUtf8('Start playing media'), self.onMediaStop)
if self.isLive:
self.blankButton = self.Mediabar.addToolbarButton(
u'Blank Screen', u':/slides/slide_blank.png',
self.trUtf8('Blank Screen'), self.onBlankDisplay, True)
self.themeButton = self.Mediabar.addToolbarButton(
u'Display Theme', u':/slides/slide_theme.png',
self.trUtf8('Theme Screen'), self.onThemeDisplay, True)
self.hideButton = self.Mediabar.addToolbarButton(
u'Hide screen', u':/slides/slide_desktop.png',
self.trUtf8('Hide Screen'), self.onHideDisplay, True)
if not self.isLive:
self.seekSlider = Phonon.SeekSlider()
self.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
@ -259,7 +269,7 @@ class SlideController(QtGui.QWidget):
self.PreviewFrame = QtGui.QFrame(self.Splitter)
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225))
self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy(
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Label))
self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
self.PreviewFrame.setFrameShadow(QtGui.QFrame.Sunken)
@ -316,26 +326,26 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.type_prefix),
self.onStopLoop)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_first' % self.type_prefix),
QtCore.SIGNAL(u'slidecontroller_%s_first' % self.type_prefix),
self.onSlideSelectedFirst)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_next' % self.type_prefix),
QtCore.SIGNAL(u'slidecontroller_%s_next' % self.type_prefix),
self.onSlideSelectedNext)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.type_prefix),
QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.type_prefix),
self.onSlideSelectedPrevious)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_next_noloop' % self.type_prefix),
QtCore.SIGNAL(u'slidecontroller_%s_next_noloop' % self.type_prefix),
self.onSlideSelectedNextNoloop)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_previous_noloop' %
QtCore.SIGNAL(u'slidecontroller_%s_previous_noloop' %
self.type_prefix),
self.onSlideSelectedPreviousNoloop)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_last' % self.type_prefix),
QtCore.SIGNAL(u'slidecontroller_%s_last' % self.type_prefix),
self.onSlideSelectedLast)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix),
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.type_prefix),
self.onSlideChange)
QtCore.QObject.connect(self.Splitter,
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
@ -481,7 +491,7 @@ class SlideController(QtGui.QWidget):
blanked = self.blankButton.isChecked()
else:
blanked = False
Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
[serviceItem, self.isLive, blanked, slideno])
self.slideList = {}
width = self.parent.ControlSplitter.sizes()[self.split]
@ -554,9 +564,9 @@ class SlideController(QtGui.QWidget):
self.enableToolBar(serviceItem)
self.onSlideSelected()
self.PreviewListWidget.setFocus()
Receiver.send_message(u'%s_%s_started' %
(self.serviceItem.name.lower(),
'live' if self.isLive else 'preview'),
Receiver.send_message(u'%s_%s_started' %
(self.serviceItem.name.lower(),
'live' if self.isLive else 'preview'),
[serviceItem])
log.log(15, u'Display Rendering took %4s' % (time.time() - before))
@ -567,7 +577,7 @@ class SlideController(QtGui.QWidget):
"""
if not self.serviceItem:
return
Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(),
Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
if self.serviceItem.is_command():
self.updatePreview()
@ -593,7 +603,10 @@ class SlideController(QtGui.QWidget):
log.debug(u'onThemeDisplay %d' % force)
if force:
self.themeButton.setChecked(True)
self.blankScreen(HideMode.Theme, self.themeButton.isChecked())
if self.themeButton.isChecked():
Receiver.send_message(u'maindisplay_show_theme')
else:
Receiver.send_message(u'maindisplay_hide_theme')
def onHideDisplay(self, force=False):
"""
@ -603,9 +616,9 @@ class SlideController(QtGui.QWidget):
if force:
self.hideButton.setChecked(True)
if self.hideButton.isChecked():
self.parent.mainDisplay.hideDisplay()
Receiver.send_message(u'maindisplay_hide')
else:
self.parent.mainDisplay.showDisplay()
Receiver.send_message(u'maindisplay_show')
def blankScreen(self, blankType, blanked=False):
"""
@ -613,15 +626,15 @@ class SlideController(QtGui.QWidget):
"""
if self.serviceItem is not None:
if blanked:
Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(),
Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
else:
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
self.parent.mainDisplay.blankDisplay(blankType, blanked)
self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked)
else:
self.parent.mainDisplay.blankDisplay(blankType, blanked)
self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked)
def onSlideSelected(self):
"""
@ -685,7 +698,7 @@ class SlideController(QtGui.QWidget):
"""
if not self.serviceItem:
return
Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(),
Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
if self.serviceItem.is_command():
self.updatePreview()
@ -709,7 +722,7 @@ class SlideController(QtGui.QWidget):
"""
if not self.serviceItem:
return
Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(),
Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
if self.serviceItem.is_command():
self.updatePreview()
@ -729,7 +742,7 @@ class SlideController(QtGui.QWidget):
"""
if not self.serviceItem:
return
Receiver.send_message(u'%s_last' % self.serviceItem.name.lower(),
Receiver.send_message(u'%s_last' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
if self.serviceItem.is_command():
self.updatePreview()
@ -775,7 +788,7 @@ class SlideController(QtGui.QWidget):
def onMediaStart(self, item):
if self.isLive:
Receiver.send_message(u'videodisplay_start',
Receiver.send_message(u'videodisplay_start',
[item, self.blankButton.isChecked()])
else:
self.mediaObject.stop()

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################

View File

@ -0,0 +1,117 @@
from openlp.plugins.alerts.forms import AlertsTab, AlertForm# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from datetime import datetime
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon
from openlp.plugins.display.forms import DisplayForm
log = logging.getLogger(__name__)
class DisplayPlugin(Plugin):
log.info(u'Display Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'Display', u'1.9.1', plugin_helpers)
self.weight = -2
self.icon = build_icon(u':/media/media_image.png')
def add_tools_menu_item(self, tools_menu):
"""
Give the Display plugin the opportunity to add items to the
**Tools** menu.
``tools_menu``
The actual **Tools** menu item, so that your actions can
use it as their parent.
"""
log.info(u'add tools menu')
self.toolsMenu = tools_menu
self.DisplayMenu = QtGui.QMenu(tools_menu)
self.DisplayMenu.setObjectName(u'DisplayMenu')
self.DisplayMenu.setTitle(tools_menu.trUtf8('&Override Display'))
#Display Delete
self.DisplayOverride = QtGui.QAction(tools_menu)
self.DisplayOverride.setText(
tools_menu.trUtf8('&Change Display Attributes'))
self.DisplayOverride.setStatusTip(
tools_menu.trUtf8('Amend the display attributes'))
self.DisplayOverride.setObjectName(u'DisplayOverride')
#Display activation
DisplayIcon = build_icon(u':/tools/tools_alert.png')
self.DisplayStatus = QtGui.QAction(tools_menu)
self.DisplayStatus.setIcon(DisplayIcon)
self.DisplayStatus.setCheckable(True)
self.DisplayStatus.setChecked(False)
self.DisplayStatus.setText(tools_menu.trUtf8('Use Display Override'))
self.DisplayStatus.setStatusTip(
tools_menu.trUtf8('Change start/stop using Display Override'))
self.DisplayStatus.setShortcut(u'FX')
self.DisplayStatus.setObjectName(u'DisplayStatus')
#Add Menus together
self.toolsMenu.addAction(self.DisplayMenu.menuAction())
self.DisplayMenu.addAction(self.DisplayStatus)
self.DisplayMenu.addSeparator()
self.DisplayMenu.addAction(self.DisplayOverride)
# Signals and slots
QtCore.QObject.connect(self.DisplayStatus,
QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.DisplayStatus.setChecked)
QtCore.QObject.connect(self.DisplayStatus,
QtCore.SIGNAL(u'triggered(bool)'),
self.toggleDisplayState)
QtCore.QObject.connect(self.DisplayOverride,
QtCore.SIGNAL(u'triggered()'), self.onDisplayOverride)
self.DisplayMenu.menuAction().setVisible(False)
def initialise(self):
log.info(u'Display Initialising')
Plugin.initialise(self)
self.DisplayStatus.setChecked(False)
self.screens = self.maindisplay.screens
self.displayform = DisplayForm(self, self.screens)
self.DisplayMenu.menuAction().setVisible(True)
def finalise(self):
log.info(u'Plugin Finalise')
self.DisplayMenu.menuAction().setVisible(False)
def toggleDisplayState(self):
Receiver.send_message(u'config_screen_changed')
def onDisplayOverride(self):
self.displayform.initialise()
self.displayform.exec_()
if self.DisplayStatus.isChecked():
Receiver.send_message(u'config_screen_changed')
def about(self):
about_text = self.trUtf8('<b>Display Plugin</b><br>This plugin '
'allows the dimensions of the live display to be changed.\n'
'These changes are not stored.')
return about_text

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from displayform import DisplayForm

View File

@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'displaydialog.ui'
#
# Created: Sat Apr 24 17:20:48 2010
# by: PyQt4 UI code generator 4.7.2
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_DisplaysDialog(object):
def setupUi(self, DisplaysDialog):
DisplaysDialog.setObjectName("DisplaysDialog")
DisplaysDialog.resize(327, 224)
self.OkpushButton = QtGui.QPushButton(DisplaysDialog)
self.OkpushButton.setGeometry(QtCore.QRect(210, 200, 97, 24))
self.OkpushButton.setObjectName("OkpushButton")
self.widget = QtGui.QWidget(DisplaysDialog)
self.widget.setGeometry(QtCore.QRect(10, 0, 301, 191))
self.widget.setObjectName("widget")
self.verticalLayout = QtGui.QVBoxLayout(self.widget)
self.verticalLayout.setObjectName("verticalLayout")
self.CurrentGroupBox = QtGui.QGroupBox(self.widget)
self.CurrentGroupBox.setObjectName("CurrentGroupBox")
self.layoutWidget = QtGui.QWidget(self.CurrentGroupBox)
self.layoutWidget.setGeometry(QtCore.QRect(20, 30, 261, 17))
self.layoutWidget.setObjectName("layoutWidget")
self.horizontalLayout = QtGui.QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.Xpos = QtGui.QLabel(self.layoutWidget)
self.Xpos.setAlignment(QtCore.Qt.AlignCenter)
self.Xpos.setObjectName("Xpos")
self.horizontalLayout.addWidget(self.Xpos)
self.Ypos = QtGui.QLabel(self.layoutWidget)
self.Ypos.setAlignment(QtCore.Qt.AlignCenter)
self.Ypos.setObjectName("Ypos")
self.horizontalLayout.addWidget(self.Ypos)
self.Height = QtGui.QLabel(self.layoutWidget)
self.Height.setAlignment(QtCore.Qt.AlignCenter)
self.Height.setObjectName("Height")
self.horizontalLayout.addWidget(self.Height)
self.Width = QtGui.QLabel(self.layoutWidget)
self.Width.setAlignment(QtCore.Qt.AlignCenter)
self.Width.setObjectName("Width")
self.horizontalLayout.addWidget(self.Width)
self.verticalLayout.addWidget(self.CurrentGroupBox)
self.CurrentGroupBox_2 = QtGui.QGroupBox(self.widget)
self.CurrentGroupBox_2.setObjectName("CurrentGroupBox_2")
self.layoutWidget1 = QtGui.QWidget(self.CurrentGroupBox_2)
self.layoutWidget1.setGeometry(QtCore.QRect(20, 30, 261, 27))
self.layoutWidget1.setObjectName("layoutWidget1")
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.layoutWidget1)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.XposEdit = QtGui.QLineEdit(self.layoutWidget1)
self.XposEdit.setObjectName("XposEdit")
self.horizontalLayout_2.addWidget(self.XposEdit)
self.YposEdit = QtGui.QLineEdit(self.layoutWidget1)
self.YposEdit.setObjectName("YposEdit")
self.horizontalLayout_2.addWidget(self.YposEdit)
self.HeightEdit = QtGui.QLineEdit(self.layoutWidget1)
self.HeightEdit.setObjectName("HeightEdit")
self.horizontalLayout_2.addWidget(self.HeightEdit)
self.WidthEdit = QtGui.QLineEdit(self.layoutWidget1)
self.WidthEdit.setObjectName("WidthEdit")
self.horizontalLayout_2.addWidget(self.WidthEdit)
self.verticalLayout.addWidget(self.CurrentGroupBox_2)
self.retranslateUi(DisplaysDialog)
QtCore.QObject.connect(self.OkpushButton, QtCore.SIGNAL("pressed()"), DisplaysDialog.close)
QtCore.QMetaObject.connectSlotsByName(DisplaysDialog)
def retranslateUi(self, DisplaysDialog):
DisplaysDialog.setWindowTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Display Settings", None, QtGui.QApplication.UnicodeUTF8))
self.OkpushButton.setText(QtGui.QApplication.translate("DisplaysDialog", "Ok", None, QtGui.QApplication.UnicodeUTF8))
self.CurrentGroupBox.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Default Settings", None, QtGui.QApplication.UnicodeUTF8))
self.Xpos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8))
self.Ypos.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8))
self.Height.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8))
self.Width.setText(QtGui.QApplication.translate("DisplaysDialog", "0", None, QtGui.QApplication.UnicodeUTF8))
self.CurrentGroupBox_2.setTitle(QtGui.QApplication.translate("DisplaysDialog", "Amend Settings", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -0,0 +1,163 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from PyQt4 import QtGui, QtCore
from openlp.plugins.alerts.lib.models import AlertItem
from displaydialog import Ui_DisplaysDialog
class DisplayForm(QtGui.QDialog, Ui_DisplaysDialog):
"""
Class documentation goes here.
"""
def __init__(self, parent, screens):
"""
Constructor
"""
self.parent = parent
self.screens = screens
self.item_id = None
QtGui.QDialog.__init__(self, None)
self.setupUi(self)
# QtCore.QObject.connect(self.DisplayButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onDisplayClicked)
# QtCore.QObject.connect(self.DisplayCloseButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onDisplayCloseClicked)
# QtCore.QObject.connect(self.AlertTextEdit,
# QtCore.SIGNAL(u'textChanged(const QString&)'),
# self.onTextChanged)
# QtCore.QObject.connect(self.NewButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onNewClick)
# QtCore.QObject.connect(self.DeleteButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onDeleteClick)
# QtCore.QObject.connect(self.SaveButton,
# QtCore.SIGNAL(u'clicked()'),
# self.onSaveClick)
# QtCore.QObject.connect(self.AlertListWidget,
# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
# self.onDoubleClick)
# QtCore.QObject.connect(self.AlertListWidget,
# QtCore.SIGNAL(u'clicked(QModelIndex)'),
# self.onSingleClick)
def initialise(self):
self.Xpos.setText(unicode(self.screens.current[u'size'].x()))
self.Ypos.setText(unicode(self.screens.current[u'size'].y()))
self.Height.setText(unicode(self.screens.current[u'size'].height()))
self.Width.setText(unicode(self.screens.current[u'size'].width()))
self.XposEdit.setText(unicode(self.screens.override[u'size'].x()))
self.YposEdit.setText(unicode(self.screens.override[u'size'].y()))
self.HeightEdit.setText(unicode(self.screens.override[u'size'].height()))
self.WidthEdit.setText(unicode(self.screens.override[u'size'].width()))
def close(self):
self.screens.override[u'size'] = QtCore.QRect(int(self.XposEdit.text()),\
int(self.YposEdit.text()), int(self.WidthEdit.text()),\
int(self.HeightEdit.text()))
return QtGui.QDialog.close(self)
def onDisplayClicked(self):
if self.triggerAlert(unicode(self.AlertTextEdit.text())):
self.loadList()
def onDisplayCloseClicked(self):
if self.triggerAlert(unicode(self.AlertTextEdit.text())):
self.close()
def onDeleteClick(self):
item = self.AlertListWidget.currentItem()
if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.manager.delete_alert(item_id)
row = self.AlertListWidget.row(item)
self.AlertListWidget.takeItem(row)
self.AlertTextEdit.setText(u'')
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False)
def onNewClick(self):
if len(self.AlertTextEdit.text()) == 0:
QtGui.QMessageBox.information(self,
self.trUtf8('Item selected to Add'),
self.trUtf8('Missing data'))
else:
alert = AlertItem()
alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert)
self.AlertTextEdit.setText(u'')
self.loadList()
def onSaveClick(self):
if self.item_id:
alert = self.manager.get_alert(self.item_id)
alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert)
self.item_id = None
self.loadList()
else:
self.onNewClick()
def onTextChanged(self):
#Data has changed by editing it so potential storage required
self.SaveButton.setEnabled(True)
def onDoubleClick(self):
"""
List item has been double clicked to display it
"""
items = self.AlertListWidget.selectedIndexes()
for item in items:
bitem = self.AlertListWidget.item(item.row())
self.triggerAlert(bitem.text())
self.AlertTextEdit.setText(bitem.text())
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
def onSingleClick(self):
"""
List item has been single clicked to add it to
the edit field so it can be changed.
"""
items = self.AlertListWidget.selectedIndexes()
for item in items:
bitem = self.AlertListWidget.item(item.row())
self.AlertTextEdit.setText(bitem.text())
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
def triggerAlert(self, text):
if text:
text = text.replace(u'<>', unicode(self.ParameterEdit.text()))
self.parent.alertsmanager.displayAlert(text)
return True
return False

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DisplaysDialog</class>
<widget class="QWidget" name="DisplaysDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>224</height>
</rect>
</property>
<property name="windowTitle">
<string>Amend Display Settings</string>
</property>
<widget class="QPushButton" name="OkpushButton">
<property name="geometry">
<rect>
<x>210</x>
<y>200</y>
<width>97</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Ok</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>301</width>
<height>191</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="CurrentGroupBox">
<property name="title">
<string>Default Settings</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>261</width>
<height>17</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="Xpos">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="Ypos">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="Height">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="Width">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="CurrentGroupBox_2">
<property name="title">
<string>Amend Settings</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>261</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="XposEdit"/>
</item>
<item>
<widget class="QLineEdit" name="YposEdit"/>
</item>
<item>
<widget class="QLineEdit" name="HeightEdit"/>
</item>
<item>
<widget class="QLineEdit" name="WidthEdit"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>OkpushButton</sender>
<signal>pressed()</signal>
<receiver>DisplaysDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>258</x>
<y>211</y>
</hint>
<hint type="destinationlabel">
<x>163</x>
<y>111</y>
</hint>
</hints>
</connection>
</connections>
</ui>