Updated the handling of dual displays.

This commit is contained in:
Raoul Snyman 2009-05-01 13:50:09 +02:00
parent ef27be093c
commit 717e56fff7
7 changed files with 70 additions and 36 deletions

View File

@ -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()

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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)