From 717e56fff7228a00c46f331101f3bd2e1124a7be Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 1 May 2009 13:50:09 +0200 Subject: [PATCH] Updated the handling of dual displays. --- openlp.pyw | 8 ++++-- openlp/core/lib/rendermanager.py | 4 +-- openlp/core/lib/settingstab.py | 27 +++++++++++++++++- openlp/core/ui/generaltab.py | 14 ++++++---- openlp/core/ui/maindisplay.py | 47 +++++++++++++++++--------------- openlp/core/ui/mainwindow.py | 4 +-- openlp/core/ui/settingsform.py | 2 +- 7 files changed, 70 insertions(+), 36 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 388376a48..4e5e7736a 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -52,9 +52,11 @@ class OpenLP(QtGui.QApplication): self.processEvents() screens = [] # Decide how many screens we have and their size - for screen in xrange (0 , self.desktop().numScreens()): - screens.insert(screen, (screen+1, self.desktop().availableGeometry(screen+1))) - log.info(u'Screen %d found with resolution %s', screen+1, self.desktop().availableGeometry(screen+1)) + for screen in xrange(0, self.desktop().numScreens()): + screens.append({u'number': screen, + u'size': self.desktop().availableGeometry(screen), + u'primary': (self.desktop().primaryScreen() == screen)}) + log.info(u'Screen %d found with resolution %s', screen, self.desktop().availableGeometry(screen)) # start the main app window self.main_window = MainWindow(screens) self.main_window.show() diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 9781cf241..813fc961e 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -38,9 +38,9 @@ class RenderManager: self.screen_list = screen_list self.theme_manager = theme_manager self.displays = len(screen_list) - self.current_display = 1 + self.current_display = 0 self.renderer = Renderer(None) - self.calculate_default(self.screen_list[self.current_display-1][1]) + self.calculate_default(self.screen_list[self.current_display]['size']) self.frame = None def set_default_theme(self, theme): diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index fce46d40b..494ffbe55 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -33,26 +33,51 @@ class SettingsTab(QtGui.QWidget): self.tabTitle = title self.setupUi() self.retranslateUi() + self.initialise() if title == None: - self.config = PluginConfig(u"Main") + self.config = PluginConfig(u'Main') else: self.config = PluginConfig(str(title)) self.load() def setTitle(self, title): + """ + Set the title of the tab. + """ self.tabTitle = title def title(self): + """ + Get the title of the tab. + """ return self.tabTitle def setupUi(self): + """ + Setup the tab's interface. + """ pass def retranslateUi(self): + """ + Setup the interface translation strings. + """ + pass + + def initialise(self): + """ + Do any extra initialisation here. + """ pass def load(self): + """ + Load settings from disk. + """ pass def save(self): + """ + Save settings to disk. + """ pass diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 9e6bad4ac..f2c574bd5 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -29,8 +29,8 @@ class GeneralTab(SettingsTab): GeneralTab is the general settings tab in the settings dialog. """ def __init__(self, screen_list): - SettingsTab.__init__(self, translate(u'GeneralTab', u'General')) self.screen_list = screen_list + SettingsTab.__init__(self, translate(u'GeneralTab', u'General')) def setupUi(self): self.setObjectName(u'GeneralTab') @@ -55,8 +55,6 @@ class GeneralTab(SettingsTab): self.MonitorLayout.addWidget(self.MonitorLabel) self.MonitorComboBox = QtGui.QComboBox(self.MonitorGroupBox) self.MonitorComboBox.setObjectName(u'MonitorComboBox') - self.MonitorComboBox.addItem(QtCore.QString()) - self.MonitorComboBox.addItem(QtCore.QString()) self.MonitorLayout.addWidget(self.MonitorComboBox) self.GeneralLeftLayout.addWidget(self.MonitorGroupBox) self.BlankScreenGroupBox = QtGui.QGroupBox(self.GeneralLeftWidget) @@ -121,8 +119,6 @@ class GeneralTab(SettingsTab): def retranslateUi(self): self.MonitorGroupBox.setTitle(translate(u'GeneralTab', u'Monitors')) self.MonitorLabel.setText(translate(u'GeneralTab', u'Select monitor for output display:')) - self.MonitorComboBox.setItemText(0, translate(u'GeneralTab', u'Monitor 1 on X11 Windowing System')) - self.MonitorComboBox.setItemText(1, translate(u'GeneralTab', u'Monitor 2 on X11 Windowing System')) self.BlankScreenGroupBox.setTitle(translate(u'GeneralTab', u'Blank Screen')) self.WarningCheckBox.setText(translate(u'GeneralTab', u'Show warning on startup')) self.AutoOpenGroupBox.setTitle(translate(u'GeneralTab', u'Auto Open Last Service')) @@ -132,3 +128,11 @@ class GeneralTab(SettingsTab): self.UsernameLabel.setText(translate(u'GeneralTab', u'SongSelect Username:')) self.PasswordLabel.setText(translate(u'GeneralTab', u'SongSelect Password:')) + def initialise(self): + for screen in self.screen_list: + screen_name = translate(u'GeneralTab', u'Screen') + u' ' + \ + str(screen['number'] + 1) + if screen['primary']: + screen_name = screen_name + u' (' + \ + translate(u'GeneralTab', u'primary') + u')' + self.MonitorComboBox.addItem(screen_name) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index c17bd2759..d322e90af 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -24,32 +24,35 @@ from openlp.core import translate class MainDisplay(QtGui.QWidget): - def __init__(self, screens, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle(u'OpenLP Display') - self.screens = screens - self.imagesize = screens[0][1] - self.display = QtGui.QLabel(self) - #self.showMinimized() + def __init__(self, parent, screens): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle(u'OpenLP Display') + self.screens = screens + self.display = QtGui.QLabel(self) - def initialView(self): - self.display.setGeometry((self.imagesize.width()-429)/2, (self.imagesize.height()-429)/2, 429, 429) - self.display.setPixmap(QtGui.QPixmap("openlp2.png")) - self.showMaximized() - print len(self.screens) - print self.isEnabled() - print self.isVisible() - print self.geometry() - #if len(self.screens) > 0: + def setup(self, screenNumber): + """ + Sets up the screen on a particular screen. + @param (integer) screen This is the screen number. + """ + screen = self.screens[screenNumber] + if screen['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['number'] == screenNumber: + screen = scrn + break + self.setGeometry(screen['size']) + if not screen['primary']: self.showFullScreen() - self.show() + else: + self.hide() def frameView(self, frame): - self.display.setGeometry(0, 0, imagesize.width(), imagesize.height()) - self.display.setPixmap(QtGui.QPixmap(frame)) + self.display.setGeometry(0, 0, imagesize.width(), imagesize.height()) + self.display.setPixmap(QtGui.QPixmap(frame)) def kill(self): pass - - - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index a78be5040..94c0b1da4 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -37,7 +37,7 @@ class MainWindow(object): def __init__(self, screens): self.main_window = QtGui.QMainWindow() - self.main_display = MainDisplay(screens, self.main_window) + self.main_display = MainDisplay(self.main_window, screens) self.screen_list = screens self.EventManager = EventManager() self.alert_form = AlertForm() @@ -421,7 +421,7 @@ class MainWindow(object): def show(self): self.main_window.showMaximized() - self.main_display.initialView() + self.main_display.setup(0) self.main_display.show() def onHelpAboutItemClicked(self): diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 70cdb8d93..b680c8327 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -29,7 +29,7 @@ from settingsdialog import Ui_SettingsDialog log = logging.getLogger('SettingsForm') -class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): +class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def __init__(self, screen_list, parent=None): QtGui.QDialog.__init__(self, parent)