forked from openlp/openlp
cleanup the screen size code
This commit is contained in:
parent
60d7416e69
commit
3c8c20f2d4
@ -109,6 +109,12 @@ class EventReceiver(QtCore.QObject):
|
||||
``presentation types``
|
||||
Informs all components of the presentation types supported.
|
||||
|
||||
``blank_check``
|
||||
Check to see if th eblank display message is required
|
||||
|
||||
``version_check``
|
||||
Version has changed so pop up window.
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
|
@ -29,7 +29,6 @@ from PyQt4 import QtCore
|
||||
|
||||
from renderer import Renderer
|
||||
from openlp.core.lib import ThemeLevel
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class RenderManager(object):
|
||||
@ -49,7 +48,7 @@ class RenderManager(object):
|
||||
"""
|
||||
log.info(u'RenderManager Loaded')
|
||||
|
||||
def __init__(self, theme_manager, screens, screen_number=0):
|
||||
def __init__(self, theme_manager, screens):
|
||||
"""
|
||||
Initialise the render manager.
|
||||
"""
|
||||
@ -57,7 +56,6 @@ class RenderManager(object):
|
||||
self.screens = screens
|
||||
self.theme_manager = theme_manager
|
||||
self.renderer = Renderer()
|
||||
self.screens.set_current_display(screen_number)
|
||||
self.calculate_default(self.screens.current[u'size'])
|
||||
self.theme = u''
|
||||
self.service_theme = u''
|
||||
@ -65,12 +63,9 @@ class RenderManager(object):
|
||||
self.override_background = None
|
||||
self.themedata = None
|
||||
|
||||
def update_display(self, screen_number):
|
||||
def update_display(self):
|
||||
"""
|
||||
Updates the render manager's information about the current screen.
|
||||
|
||||
``screen_number``
|
||||
The updated index of the output/display screen.
|
||||
"""
|
||||
log.debug(u'Update Display')
|
||||
self.calculate_default(self.screens.current[u'size'])
|
||||
|
@ -54,6 +54,7 @@ class SettingsTab(QtGui.QWidget):
|
||||
self.config = PluginConfig(title)
|
||||
else:
|
||||
self.config = PluginConfig(section)
|
||||
self.preLoad()
|
||||
self.load()
|
||||
|
||||
def setupUi(self):
|
||||
@ -62,6 +63,12 @@ class SettingsTab(QtGui.QWidget):
|
||||
"""
|
||||
pass
|
||||
|
||||
def preLoad(self):
|
||||
"""
|
||||
Setup the tab's interface.
|
||||
"""
|
||||
pass
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
Setup the interface translation strings.
|
||||
|
@ -25,16 +25,29 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, str_to_bool
|
||||
from openlp.core.lib import SettingsTab, str_to_bool, Receiver
|
||||
|
||||
class GeneralTab(SettingsTab):
|
||||
"""
|
||||
GeneralTab is the general settings tab in the settings dialog.
|
||||
"""
|
||||
def __init__(self, screen_list):
|
||||
self.screen_list = screen_list
|
||||
def __init__(self, screens):
|
||||
self.screens = screens
|
||||
SettingsTab.__init__(self, u'General')
|
||||
|
||||
def preLoad(self):
|
||||
"""
|
||||
Set up the display screen and set correct screen
|
||||
values.
|
||||
If not set before default to last screen.
|
||||
"""
|
||||
self.MonitorNumber = int(self.config.get_config(u'monitor',
|
||||
self.screens.monitor_number))
|
||||
self.screens.set_current_display(self.MonitorNumber)
|
||||
self.screens.monitor_number = self.MonitorNumber
|
||||
self.MonitorDisplay = str_to_bool(self.config.get_config(u'monitor display', u'True'))
|
||||
self.screens.display = self.MonitorDisplay
|
||||
|
||||
def setupUi(self):
|
||||
self.setObjectName(u'GeneralTab')
|
||||
self.tabTitleVisible = self.trUtf8('General')
|
||||
@ -60,6 +73,10 @@ class GeneralTab(SettingsTab):
|
||||
self.MonitorComboBox = QtGui.QComboBox(self.MonitorGroupBox)
|
||||
self.MonitorComboBox.setObjectName(u'MonitorComboBox')
|
||||
self.MonitorLayout.addWidget(self.MonitorComboBox)
|
||||
self.MonitorLayout.addWidget(self.MonitorComboBox)
|
||||
self.MonitorDisplayCheck = QtGui.QCheckBox(self.MonitorGroupBox)
|
||||
self.MonitorDisplayCheck.setObjectName(u'MonitorComboBox')
|
||||
self.MonitorLayout.addWidget(self.MonitorDisplayCheck)
|
||||
self.GeneralLeftLayout.addWidget(self.MonitorGroupBox)
|
||||
self.StartupGroupBox = QtGui.QGroupBox(self.GeneralLeftWidget)
|
||||
self.StartupGroupBox.setObjectName(u'StartupGroupBox')
|
||||
@ -133,6 +150,8 @@ class GeneralTab(SettingsTab):
|
||||
self.GeneralLayout.addWidget(self.GeneralRightWidget)
|
||||
QtCore.QObject.connect(self.MonitorComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged)
|
||||
QtCore.QObject.connect(self.MonitorDisplayCheck,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onMonitorDisplayCheckChanged)
|
||||
QtCore.QObject.connect(self.WarningCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged)
|
||||
QtCore.QObject.connect(self.AutoOpenCheckBox,
|
||||
@ -153,6 +172,7 @@ class GeneralTab(SettingsTab):
|
||||
def retranslateUi(self):
|
||||
self.MonitorGroupBox.setTitle(self.trUtf8('Monitors'))
|
||||
self.MonitorLabel.setText(self.trUtf8('Select monitor for output display:'))
|
||||
self.MonitorDisplayCheck.setText(self.trUtf8('Do not display if single screen'))
|
||||
self.StartupGroupBox.setTitle(self.trUtf8('Application Startup'))
|
||||
self.WarningCheckBox.setText(self.trUtf8('Show blank screen warning'))
|
||||
self.AutoOpenCheckBox.setText(self.trUtf8('Automatically open the last service'))
|
||||
@ -168,6 +188,9 @@ class GeneralTab(SettingsTab):
|
||||
def onMonitorComboBoxChanged(self):
|
||||
self.MonitorNumber = self.MonitorComboBox.currentIndex()
|
||||
|
||||
def onMonitorDisplayCheckChanged(self, value):
|
||||
self.MonitorDisplay = (value == QtCore.Qt.Checked)
|
||||
|
||||
def onAutoOpenCheckBoxChanged(self, value):
|
||||
self.AutoOpen = (value == QtCore.Qt.Checked)
|
||||
|
||||
@ -193,13 +216,12 @@ class GeneralTab(SettingsTab):
|
||||
self.Password = self.PasswordEdit.displayText()
|
||||
|
||||
def load(self):
|
||||
for screen in self.screen_list.screen_list:
|
||||
for screen in self.screens.screen_list:
|
||||
screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1)
|
||||
if screen[u'primary']:
|
||||
screen_name = u'%s (%s)' % (screen_name, self.trUtf8('primary'))
|
||||
self.MonitorComboBox.addItem(screen_name)
|
||||
# Get the configs
|
||||
self.MonitorNumber = int(self.config.get_config(u'monitor', u'0'))
|
||||
self.Warning = str_to_bool(self.config.get_config(u'blank warning', u'False'))
|
||||
self.AutoOpen = str_to_bool(self.config.get_config(u'auto open', u'False'))
|
||||
self.ShowSplash = str_to_bool(self.config.get_config(u'show splash', u'True'))
|
||||
@ -211,6 +233,7 @@ class GeneralTab(SettingsTab):
|
||||
self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService)
|
||||
# Set a few things up
|
||||
self.MonitorComboBox.setCurrentIndex(self.MonitorNumber)
|
||||
self.MonitorDisplayCheck.setChecked(self.MonitorDisplay)
|
||||
self.WarningCheckBox.setChecked(self.Warning)
|
||||
self.AutoOpenCheckBox.setChecked(self.AutoOpen)
|
||||
self.ShowSplashCheckBox.setChecked(self.ShowSplash)
|
||||
@ -221,6 +244,7 @@ class GeneralTab(SettingsTab):
|
||||
|
||||
def save(self):
|
||||
self.config.set_config(u'monitor', self.MonitorNumber)
|
||||
self.config.set_config(u'monitor display', self.MonitorDisplay)
|
||||
self.config.set_config(u'blank warning', self.Warning)
|
||||
self.config.set_config(u'auto open', self.AutoOpen)
|
||||
self.config.set_config(u'show splash', self.ShowSplash)
|
||||
@ -229,3 +253,9 @@ class GeneralTab(SettingsTab):
|
||||
self.config.set_config(u'ccli number', self.CCLINumber)
|
||||
self.config.set_config(u'songselect username', self.Username)
|
||||
self.config.set_config(u'songselect password', self.Password)
|
||||
self.screens.display = self.MonitorDisplay
|
||||
#Monitor Number has changed.
|
||||
if self.screens.monitor_number != self.MonitorNumber:
|
||||
self.screens.monitor_number = self.MonitorNumber
|
||||
self.screens.set_current_display(self.MonitorNumber)
|
||||
Receiver.send_message(u'screen_changed')
|
||||
|
@ -130,13 +130,15 @@ class MainDisplay(DisplayWidget):
|
||||
QtCore.SIGNAL(u'media_pause'), self.onMediaPause)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'media_stop'), self.onMediaStop)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_config'), self.setup)
|
||||
|
||||
def setup(self, screenNumber):
|
||||
def setup(self):
|
||||
"""
|
||||
Sets up the screen on a particular screen.
|
||||
@param (integer) screen This is the screen number.
|
||||
"""
|
||||
log.debug(u'Setup %s for %s ' %(self.screens, screenNumber))
|
||||
log.debug(u'Setup %s for %s ' %(self.screens,
|
||||
self.screens.monitor_number))
|
||||
self.setVisible(False)
|
||||
self.screen = self.screens.current
|
||||
#Sort out screen locations and sizes
|
||||
@ -183,7 +185,6 @@ class MainDisplay(DisplayWidget):
|
||||
else:
|
||||
self.setVisible(False)
|
||||
self.primary = True
|
||||
Receiver.send_message(u'screen_changed')
|
||||
|
||||
def resetDisplay(self):
|
||||
Receiver.send_message(u'stop_display_loop')
|
||||
@ -247,7 +248,7 @@ class MainDisplay(DisplayWidget):
|
||||
else:
|
||||
self.display_text.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||
self.display_frame = frame
|
||||
if not self.isVisible():
|
||||
if not self.isVisible() and not self.screens.display:
|
||||
self.setVisible(True)
|
||||
self.showFullScreen()
|
||||
else:
|
||||
@ -320,4 +321,4 @@ class MainDisplay(DisplayWidget):
|
||||
self.video.setVisible(False)
|
||||
self.display_text.show()
|
||||
self.display_image.show()
|
||||
self.blankDisplay(False, False)
|
||||
self.blankDisplay(False, False)
|
||||
|
@ -496,6 +496,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtCore.SIGNAL(u'version_check'), self.versionCheck)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'blank_check'), self.blankCheck)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'screen_changed'), self.screenChanged)
|
||||
QtCore.QObject.connect(self.FileNewItem,
|
||||
QtCore.SIGNAL(u'triggered()'),
|
||||
self.ServiceManagerContents.onNewService)
|
||||
@ -512,7 +514,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
#RenderManager needs to call ThemeManager and
|
||||
#ThemeManager needs to call RenderManager
|
||||
self.RenderManager = RenderManager(self.ThemeManagerContents,
|
||||
self.screens, self.getMonitorNumber())
|
||||
self.screens)
|
||||
#Define the media Dock Manager
|
||||
self.mediaDockManager = MediaDockManager(self.MediaToolBox)
|
||||
log.info(u'Load Plugins')
|
||||
@ -563,24 +565,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
|
||||
QtGui.QMessageBox.Ok)
|
||||
|
||||
def getMonitorNumber(self):
|
||||
"""
|
||||
Set up the default behaviour of the monitor configuration in
|
||||
here. Currently it is set to default to monitor 0 if the saved
|
||||
monitor number does not exist.
|
||||
"""
|
||||
screen_number = int(self.generalConfig.get_config(u'monitor', 0))
|
||||
if not self.screens.screen_exists(screen_number):
|
||||
screen_number = 0
|
||||
return screen_number
|
||||
|
||||
def show(self):
|
||||
"""
|
||||
Show the main form, as well as the display form
|
||||
"""
|
||||
self.showMaximized()
|
||||
screen_number = self.getMonitorNumber()
|
||||
self.mainDisplay.setup(screen_number)
|
||||
#screen_number = self.getMonitorNumber()
|
||||
self.mainDisplay.setup()
|
||||
if self.mainDisplay.isVisible():
|
||||
self.mainDisplay.setFocus()
|
||||
self.activateWindow()
|
||||
@ -598,7 +589,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtGui.QMessageBox.Ok)
|
||||
|
||||
def versionThread(self):
|
||||
#app_version = self.applicationVersion[u'full']
|
||||
vT = VersionThread(self, self.applicationVersion, self.generalConfig)
|
||||
vT.start()
|
||||
|
||||
@ -621,13 +611,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
Show the Settings dialog
|
||||
"""
|
||||
self.settingsForm.exec_()
|
||||
updated_display = self.getMonitorNumber()
|
||||
if updated_display != self.screens.current_display:
|
||||
self.screens.set_current_display(updated_display)
|
||||
self.RenderManager.update_display(updated_display)
|
||||
self.mainDisplay.setup(updated_display)
|
||||
#Trigger after changes have been made
|
||||
Receiver.send_message(u'config_updated')
|
||||
|
||||
def screenChanged(self):
|
||||
self.RenderManager.update_display()
|
||||
self.mainDisplay.setup()
|
||||
self.activateWindow()
|
||||
|
||||
def closeEvent(self, event):
|
||||
|
@ -37,14 +37,17 @@ class ScreenList(object):
|
||||
self.preview = None
|
||||
self.current = None
|
||||
self.screen_list = []
|
||||
self.count = 0
|
||||
self.display_count = 0
|
||||
#actual display number
|
||||
self.current_display = 0
|
||||
#save config display number
|
||||
self.monitor_number = 0
|
||||
|
||||
def add_screen(self, screen):
|
||||
if screen[u'primary']:
|
||||
self.current = screen
|
||||
self.screen_list.append(screen)
|
||||
self.count += 1
|
||||
self.display_count += 1
|
||||
|
||||
def screen_exists(self, number):
|
||||
for screen in self.screen_list:
|
||||
@ -53,21 +56,15 @@ class ScreenList(object):
|
||||
return False
|
||||
|
||||
def set_current_display(self, number):
|
||||
if number + 1 > self.count:
|
||||
"""
|
||||
Set up the current screen dimensions
|
||||
"""
|
||||
if number + 1 > self.display_count:
|
||||
self.current = self.screen_list[0]
|
||||
self.current_display = 0
|
||||
else:
|
||||
self.current = self.screen_list[number]
|
||||
self.preview = self.current
|
||||
self.current_display = number
|
||||
if self.count == 1:
|
||||
if self.display_count == 1:
|
||||
self.preview = self.screen_list[0]
|
||||
|
||||
# if self.screen[u'number'] != screenNumber:
|
||||
# # We will most probably never actually hit this bit, but just in
|
||||
# # case the index in the list doesn't match the screen number, we
|
||||
# # search for it.
|
||||
# for scrn in self.screens:
|
||||
# if scrn[u'number'] == screenNumber:
|
||||
# self.screen = scrn
|
||||
# break
|
||||
|
@ -34,11 +34,11 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
|
||||
def __init__(self, screen_list, mainWindow, parent=None):
|
||||
def __init__(self, screens, mainWindow, parent=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
# General tab
|
||||
self.GeneralTab = GeneralTab(screen_list)
|
||||
self.GeneralTab = GeneralTab(screens)
|
||||
self.addTab(u'General', self.GeneralTab)
|
||||
# Themes tab
|
||||
self.ThemesTab = ThemesTab(mainWindow)
|
||||
|
Loading…
Reference in New Issue
Block a user