This commit is contained in:
Raoul Snyman 2010-12-28 23:23:11 +02:00
commit a2eae992bf
4 changed files with 108 additions and 111 deletions

View File

@ -37,13 +37,15 @@ class OpenLPDockWidget(QtGui.QDockWidget):
"""
Custom DockWidget class to handle events
"""
def __init__(self, parent=None, name=None):
def __init__(self, parent=None, name=None, icon=None):
"""
Initialise the DockWidget
"""
log.debug(u'Initialise the %s widget' % name)
QtGui.QDockWidget.__init__(self, parent)
self.parent = parent
if name:
self.setObjectName(name)
if icon:
self.setWindowIcon(icon)
self.setFloating(False)
log.debug(u'Init done')

View File

@ -55,7 +55,7 @@ class SettingsManager(object):
self.mainwindow_left = mainwindow_docbars
self.mainwindow_right = mainwindow_docbars
self.slidecontroller = (self.width - (
self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
self.mainwindow_left + self.mainwindow_right) - 100) / 2
self.slidecontroller_image = self.slidecontroller - 50
@staticmethod

View File

@ -76,7 +76,7 @@ class Ui_MainWindow(object):
MainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
MainWindow.setWindowIcon(MainIcon)
self.setDockNestingEnabled(True)
# Set up the main container, which contains all the other form widgets
# Set up the main container, which contains all the other form widgets.
self.MainContent = QtGui.QWidget(MainWindow)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
@ -141,13 +141,12 @@ class Ui_MainWindow(object):
self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel')
self.StatusBar.addPermanentWidget(self.DefaultThemeLabel)
# Create the MediaManager
self.MediaManagerDock = OpenLPDockWidget(MainWindow)
self.MediaManagerDock.setWindowIcon(
self.MediaManagerDock = OpenLPDockWidget(
MainWindow, u'MediaManagerDock',
build_icon(u':/system/system_mediamanager.png'))
self.MediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE)
self.MediaManagerDock.setMinimumWidth(
self.settingsmanager.mainwindow_left)
self.MediaManagerDock.setObjectName(u'MediaManagerDock')
self.MediaManagerContents = QtGui.QWidget(MainWindow)
self.MediaManagerContents.setObjectName(u'MediaManagerContents')
self.MediaManagerLayout = QtGui.QHBoxLayout(self.MediaManagerContents)
@ -161,10 +160,9 @@ class Ui_MainWindow(object):
MainWindow.addDockWidget(
QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)
# Create the service manager
self.ServiceManagerDock = OpenLPDockWidget(MainWindow)
self.ServiceManagerDock.setWindowIcon(
self.ServiceManagerDock = OpenLPDockWidget(
MainWindow, u'ServiceManagerDock',
build_icon(u':/system/system_servicemanager.png'))
self.ServiceManagerDock.setObjectName(u'ServiceManagerDock')
self.ServiceManagerDock.setMinimumWidth(
self.settingsmanager.mainwindow_right)
self.ServiceManagerContents = ServiceManager(self)
@ -172,10 +170,9 @@ class Ui_MainWindow(object):
MainWindow.addDockWidget(
QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock)
# Create the theme manager
self.ThemeManagerDock = OpenLPDockWidget(MainWindow)
self.ThemeManagerDock.setWindowIcon(
self.ThemeManagerDock = OpenLPDockWidget(
MainWindow, u'ThemeManagerDock',
build_icon(u':/system/system_thememanager.png'))
self.ThemeManagerDock.setObjectName(u'ThemeManagerDock')
self.ThemeManagerDock.setMinimumWidth(
self.settingsmanager.mainwindow_right)
self.ThemeManagerContents = ThemeManager(self)
@ -272,7 +269,7 @@ class Ui_MainWindow(object):
self.SettingsPluginListItem.setObjectName(u'SettingsPluginListItem')
MainWindow.actionList.add_action(self.SettingsPluginListItem,
u'Settings')
#i18n Language Items
# i18n Language Items
self.AutoLanguageItem = QtGui.QAction(MainWindow)
self.AutoLanguageItem.setObjectName(u'AutoLanguageItem')
self.AutoLanguageItem.setCheckable(True)
@ -331,7 +328,7 @@ class Ui_MainWindow(object):
None, self.ViewMediaManagerItem, self.ViewServiceManagerItem,
self.ViewThemeManagerItem, None, self.ViewPreviewPanel,
self.ViewLivePanel))
#i18n add Language Actions
# i18n add Language Actions
add_actions(self.SettingsLanguageMenu, (self.AutoLanguageItem, None))
add_actions(self.SettingsLanguageMenu, self.LanguageGroup.actions())
add_actions(self.SettingsMenu, (self.SettingsPluginListItem,
@ -354,17 +351,8 @@ class Ui_MainWindow(object):
QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu)
QtCore.QObject.connect(self.FileExitItem,
QtCore.SIGNAL(u'triggered()'), MainWindow.close)
QtCore.QObject.connect(self.ControlSplitter,
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def trackSplitter(self, tab, pos):
"""
Splitter between the Preview and Live Controllers.
"""
self.liveController.widthChanged()
self.previewController.widthChanged()
def retranslateUi(self, MainWindow):
"""
Set up the translation system
@ -998,8 +986,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
The service filename to add
"""
# The maxRecentFiles value does not have an interface and so never gets
# actually stored in the settings therefore the default value of 20
# will always be used.
# actually stored in the settings therefore the default value of 20 will
# always be used.
maxRecentFiles = QtCore.QSettings().value(u'advanced/max recent files',
QtCore.QVariant(20)).toInt()[0]
if filename:
@ -1009,4 +997,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.recentFiles.insert(0, QtCore.QString(filename))
while self.recentFiles.count() > maxRecentFiles:
# Don't care what API says takeLast works, removeLast doesn't!
self.recentFiles.takeLast()
self.recentFiles.takeLast()

View File

@ -73,6 +73,7 @@ class SlideList(QtGui.QTableWidget):
else:
event.ignore()
class SlideController(QtGui.QWidget):
"""
SlideController is the slide controller widget. This widget is what the
@ -183,41 +184,23 @@ class SlideController(QtGui.QWidget):
translate('OpenLP.SlideController',
'Blank Screen'), self.HideMenu)
self.BlankScreen.setCheckable(True)
QtCore.QObject.connect(self.BlankScreen,
QtCore.SIGNAL("triggered(bool)"), self.onBlankDisplay)
self.ThemeScreen = QtGui.QAction(QtGui.QIcon(
u':/slides/slide_theme.png'),
translate('OpenLP.SlideController',
'Blank to Theme'), self.HideMenu)
self.ThemeScreen.setCheckable(True)
QtCore.QObject.connect(self.ThemeScreen,
QtCore.SIGNAL("triggered(bool)"), self.onThemeDisplay)
if self.screens.display_count > 1:
self.DesktopScreen = QtGui.QAction(QtGui.QIcon(
u':/slides/slide_desktop.png'),
translate('OpenLP.SlideController',
'Show Desktop'), self.HideMenu)
self.DesktopScreen.setCheckable(True)
QtCore.QObject.connect(self.DesktopScreen,
QtCore.SIGNAL("triggered(bool)"), self.onHideDisplay)
self.HideMenu.setDefaultAction(self.BlankScreen)
self.HideMenu.menu().addAction(self.BlankScreen)
self.HideMenu.menu().addAction(self.ThemeScreen)
if self.screens.display_count > 1:
self.DesktopScreen = QtGui.QAction(QtGui.QIcon(
u':/slides/slide_desktop.png'),
translate('OpenLP.SlideController',
'Show Desktop'), self.HideMenu)
self.HideMenu.menu().addAction(self.DesktopScreen)
if not self.isLive:
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(
u'Go Live', u':/general/general_live.png',
translate('OpenLP.SlideController', 'Move to live'),
self.onGoLive)
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(
u'Edit Song', u':/general/general_edit.png',
translate('OpenLP.SlideController',
'Edit and reload song preview'),
self.onEditSong)
if isLive:
self.DesktopScreen.setCheckable(True)
QtCore.QObject.connect(self.DesktopScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onHideDisplay)
self.Toolbar.addToolbarSeparator(u'Loop Separator')
self.Toolbar.addToolbarButton(
u'Start Loop', u':/media/media_time.png',
@ -230,12 +213,23 @@ class SlideController(QtGui.QWidget):
self.DelaySpinBox = QtGui.QSpinBox()
self.DelaySpinBox.setMinimum(1)
self.DelaySpinBox.setMaximum(180)
self.Toolbar.addToolbarWidget(
u'Image SpinBox', self.DelaySpinBox)
self.Toolbar.addToolbarWidget(u'Image SpinBox', self.DelaySpinBox)
self.DelaySpinBox.setSuffix(translate('OpenLP.SlideController',
's'))
self.DelaySpinBox.setToolTip(translate('OpenLP.SlideController',
'Delay between slides in seconds'))
else:
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(
u'Go Live', u':/general/general_live.png',
translate('OpenLP.SlideController', 'Move to live'),
self.onGoLive)
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(
u'Edit Song', u':/general/general_edit.png',
translate('OpenLP.SlideController',
'Edit and reload song preview'),
self.onEditSong)
self.ControllerLayout.addWidget(self.Toolbar)
# Build a Media ToolBar
self.Mediabar = OpenLPToolbar(self)
@ -251,42 +245,39 @@ class SlideController(QtGui.QWidget):
u'Media Stop', u':/slides/media_playback_stop.png',
translate('OpenLP.SlideController', 'Start playing media'),
self.onMediaStop)
if not self.isLive:
self.seekSlider = Phonon.SeekSlider()
self.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.seekSlider.setObjectName(u'seekSlider')
self.Mediabar.addToolbarWidget(
u'Seek Slider', self.seekSlider)
self.volumeSlider = Phonon.VolumeSlider()
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.volumeSlider.setObjectName(u'volumeSlider')
self.Mediabar.addToolbarWidget(u'Audio Volume', self.volumeSlider)
else:
self.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
self.volumeSlider.setTickInterval(1)
self.volumeSlider.setTickPosition(QtGui.QSlider.TicksAbove)
self.volumeSlider.setMinimum(0)
self.volumeSlider.setMaximum(10)
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.volumeSlider.setObjectName(u'volumeSlider')
self.Mediabar.addToolbarWidget(u'Audio Volume', self.volumeSlider)
self.ControllerLayout.addWidget(self.Mediabar)
# Build the Song Toolbar
if isLive:
if self.isLive:
# Build the Song Toolbar
self.SongMenu = QtGui.QToolButton(self.Toolbar)
self.SongMenu.setText(translate('OpenLP.SlideController',
'Go To'))
self.SongMenu.setPopupMode(QtGui.QToolButton.InstantPopup)
self.Toolbar.addToolbarWidget(u'Song Menu', self.SongMenu)
self.SongMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go To'),
self.Toolbar))
translate('OpenLP.SlideController', 'Go To'), self.Toolbar))
self.Toolbar.makeWidgetsInvisible([u'Song Menu'])
# Build the volumeSlider.
self.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
self.volumeSlider.setTickInterval(1)
self.volumeSlider.setTickPosition(QtGui.QSlider.TicksAbove)
self.volumeSlider.setMinimum(0)
self.volumeSlider.setMaximum(10)
else:
# Build the seekSlider.
self.seekSlider = Phonon.SeekSlider()
self.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.seekSlider.setObjectName(u'seekSlider')
self.Mediabar.addToolbarWidget(u'Seek Slider', self.seekSlider)
self.volumeSlider = Phonon.VolumeSlider()
self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
self.volumeSlider.setObjectName(u'volumeSlider')
self.Mediabar.addToolbarWidget(u'Audio Volume', self.volumeSlider)
self.ControllerLayout.addWidget(self.Mediabar)
# Screen preview area
self.PreviewFrame = QtGui.QFrame(self.Splitter)
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225))
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio))
self.PreviewFrame.setMinimumHeight(100)
self.PreviewFrame.setSizePolicy(QtGui.QSizePolicy(
QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored,
QtGui.QSizePolicy.Label))
self.PreviewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
self.PreviewFrame.setFrameShadow(QtGui.QFrame.Sunken)
@ -306,7 +297,6 @@ class SlideController(QtGui.QWidget):
Phonon.createPath(self.mediaObject, self.audio)
if not self.isLive:
self.video.setGeometry(QtCore.QRect(0, 0, 300, 225))
self.video.setVisible(False)
self.SlideLayout.insertWidget(0, self.video)
# Actual preview screen
self.SlidePreview = QtGui.QLabel(self)
@ -330,18 +320,24 @@ class SlideController(QtGui.QWidget):
# Signals
QtCore.QObject.connect(self.PreviewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
if not self.isLive:
QtCore.QObject.connect(self.PreviewListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onGoLiveClick)
if isLive:
if self.isLive:
QtCore.QObject.connect(self.BlankScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onBlankDisplay)
QtCore.QObject.connect(self.ThemeScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onThemeDisplay)
QtCore.QObject.connect(self.volumeSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_live_spin_delay'),
self.receiveSpinDelay)
if isLive:
self.Toolbar.makeWidgetsInvisible(self.loopList)
self.Toolbar.actions[u'Stop Loop'].setVisible(False)
else:
QtCore.QObject.connect(self.PreviewListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onGoLiveClick)
self.Toolbar.makeWidgetsInvisible(self.songEditList)
self.Mediabar.setVisible(False)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -381,54 +377,65 @@ class SlideController(QtGui.QWidget):
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.typePrefix),
self.onTextRequest)
QtCore.QObject.connect(self.parent.ControlSplitter,
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.previewSizeChanged)
QtCore.QObject.connect(self.Splitter,
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.trackSplitter)
QtCore.SIGNAL(u'splitterMoved(int, int)'), self.previewSizeChanged)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.refreshServiceItem)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
if self.isLive:
QtCore.QObject.connect(self.volumeSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview)
def paintEvent(self, event):
"""
When the Slidecontroller is painted, we need to make sure, that the
SlidePreview's size is updated.
"""
# We need to make this circuit, because we have to consider the other
# slidecontroller as well.
self.parent.previewController.previewSizeChanged()
self.parent.liveController.previewSizeChanged()
def screenSizeChanged(self):
"""
Settings dialog has changed the screen size of adjust output and
screen previews
screen previews.
"""
log.debug(u'screenSizeChanged live = %s' % self.isLive)
# rebuild display as screen size changed
self.display = MainDisplay(self, self.screens, self.isLive)
self.display.imageManager = self.parent.renderManager.image_manager
self.display.alertTab = self.alertTab
self.display.setup()
# The SlidePreview's ratio.
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.display.setup()
self.SlidePreview.setFixedSize(
QtCore.QSize(self.settingsmanager.slidecontroller_image,
self.settingsmanager.slidecontroller_image / self.ratio))
self.previewSizeChanged()
def widthChanged(self):
def previewSizeChanged(self):
"""
Handle changes of width from the splitter between the live and preview
controller. Event only issues when changes have finished
Takes care of the SlidePreview's size. Is called when one of the the
splitters is moved or when the screen size is changed.
"""
log.debug(u'widthChanged live = %s' % self.isLive)
log.debug(u'previewSizeChanged live = %s' % self.isLive)
if self.ratio < float(self.PreviewFrame.width()) / float(
self.PreviewFrame.height()):
# We have to take the height as limit.
max_height = self.PreviewFrame.height() - self.grid.margin() * 2
self.SlidePreview.setFixedSize(QtCore.QSize(max_height * self.ratio,
max_height))
else:
# We have to take the width as limit.
max_width = self.PreviewFrame.width() - self.grid.margin() * 2
self.SlidePreview.setFixedSize(QtCore.QSize(max_width,
max_width / self.ratio))
width = self.parent.ControlSplitter.sizes()[self.split]
height = width * self.parent.renderManager.screen_ratio
self.PreviewListWidget.setColumnWidth(0, width)
# Sort out image heights (Songs, bibles excluded)
if self.serviceItem and not self.serviceItem.is_text():
for framenumber in range(len(self.serviceItem.get_frames())):
self.PreviewListWidget.setRowHeight(framenumber, height)
def trackSplitter(self, tab, pos):
"""
Splitter between the slide list and the preview panel
"""
pass
self.PreviewListWidget.setRowHeight(
framenumber, width / self.ratio)
def onSongBarHandler(self):
request = unicode(self.sender().text())
@ -1033,4 +1040,4 @@ class SlideController(QtGui.QWidget):
self.mediaObject.clearQueue()
self.video.hide()
self.SlidePreview.clear()
self.SlidePreview.show()
self.SlidePreview.show()