forked from openlp/openlp
clean ups, further implementation
This commit is contained in:
parent
0cd10c83e1
commit
86eb34ae1c
49
openlp.pyw
49
openlp.pyw
@ -167,8 +167,7 @@ class OpenLP(QtGui.QApplication):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
||||
QtCore.QObject.connect(self.desktop(),
|
||||
QtCore.SIGNAL(u'screenCountChanged(int)'),
|
||||
self.onScreenCountChanged)
|
||||
QtCore.SIGNAL(u'screenCountChanged(int)'), self.updateScreenList)
|
||||
self.setOrganizationName(u'OpenLP')
|
||||
self.setOrganizationDomain(u'openlp.org')
|
||||
self.setApplicationName(u'OpenLP')
|
||||
@ -182,17 +181,13 @@ class OpenLP(QtGui.QApplication):
|
||||
self.splash.show()
|
||||
# make sure Qt really display the splash screen
|
||||
self.processEvents()
|
||||
screens = ScreenList()
|
||||
self.screens = ScreenList()
|
||||
# Decide how many screens we have and their size
|
||||
for screen in xrange(0, self.desktop().numScreens()):
|
||||
size = self.desktop().screenGeometry(screen)
|
||||
screens.add_screen({u'number': screen,
|
||||
u'size': size,
|
||||
u'primary': (self.desktop().primaryScreen() == screen)})
|
||||
log.info(u'Screen %d found with resolution %s', screen, size)
|
||||
self.updateScreenList(True)
|
||||
# start the main app window
|
||||
self.appClipboard = self.clipboard()
|
||||
self.mainWindow = MainWindow(screens, app_version, self.appClipboard)
|
||||
self.mainWindow = MainWindow(
|
||||
self.screens, app_version, self.appClipboard)
|
||||
self.mainWindow.show()
|
||||
if show_splash:
|
||||
# now kill the splashscreen
|
||||
@ -228,17 +223,33 @@ class OpenLP(QtGui.QApplication):
|
||||
"""
|
||||
self.restoreOverrideCursor()
|
||||
|
||||
def onScreenCountChanged(self):
|
||||
def updateScreenList(self, applicationStart=False):
|
||||
"""
|
||||
Called when the user changes the monitor set up.
|
||||
Called when the list of screens has to be updated.
|
||||
|
||||
``applicationStart``
|
||||
Should be ``True`` when starting the application, otherwise
|
||||
``False``.
|
||||
"""
|
||||
data = {
|
||||
u'title': translate('OpenLP.Ui', 'Information'),
|
||||
u'message': translate('OpenLP','The monitor set up has changed. You'
|
||||
' have to restart OpenLP in order to change the live display'
|
||||
' monitor.')
|
||||
}
|
||||
Receiver.send_message(u'openlp_information_message', data)
|
||||
# Add new screens.
|
||||
for number in xrange(0, self.desktop().numScreens()):
|
||||
if not self.screens.screen_exists(number):
|
||||
size = self.desktop().screenGeometry(number)
|
||||
self.screens.add_screen({
|
||||
u'number': number,
|
||||
u'size': size,
|
||||
u'primary': (self.desktop().primaryScreen() == number)
|
||||
})
|
||||
log.info(u'Screen %d found with resolution %s', number, size)
|
||||
# Remove unplugged screens.
|
||||
for screen in self.screens.screen_list:
|
||||
if screen[u'number'] > self.desktop().numScreens():
|
||||
self.screens.remove_screen(screen)
|
||||
log.info(u'Screen %d removed' % creen[u'number'])
|
||||
if not applicationStart:
|
||||
pass
|
||||
# TODO: Refresh settings.
|
||||
# TODO: Make the new (second) monitor the live display.
|
||||
|
||||
def main():
|
||||
"""
|
||||
|
@ -300,6 +300,7 @@ class GeneralTab(SettingsTab):
|
||||
"""
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(self.settingsSection)
|
||||
self.monitorComboBox.clear()
|
||||
for screen in self.screens.screen_list:
|
||||
screen_name = u'%s %d' % (translate('OpenLP.GeneralTab', 'Screen'),
|
||||
screen[u'number'] + 1)
|
||||
|
@ -25,7 +25,7 @@
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`screen` module provides management functionality for a machines'
|
||||
displays
|
||||
displays.
|
||||
"""
|
||||
import logging
|
||||
import copy
|
||||
@ -51,25 +51,58 @@ class ScreenList(object):
|
||||
|
||||
def add_screen(self, screen):
|
||||
"""
|
||||
Add a screen to the list of known screens
|
||||
Add a screen to the list of known screens.
|
||||
|
||||
``screen``
|
||||
A dict with the screen properties::
|
||||
|
||||
{
|
||||
u'primary': True,
|
||||
u'number': 0,
|
||||
u'size': PyQt4.QtCore.QRect(0, 0, 1024, 768)
|
||||
}
|
||||
|
||||
"""
|
||||
print u'add screen: %s' % screen
|
||||
if screen[u'primary']:
|
||||
self.current = screen
|
||||
self.screen_list.append(screen)
|
||||
self.display_count += 1
|
||||
|
||||
def remove_screen(self, number):
|
||||
"""
|
||||
Remove a screen from the list of known screens.
|
||||
|
||||
``number``
|
||||
The screen number (int).
|
||||
"""
|
||||
print u'remove screen %s' % number
|
||||
for screen in self.screen_list:
|
||||
if screen[u'number'] == number:
|
||||
self.screen_list.remove(screen)
|
||||
self.display_count -= 1
|
||||
break
|
||||
|
||||
def screen_exists(self, number):
|
||||
"""
|
||||
Confirms a screen is known
|
||||
Confirms a screen is known.
|
||||
|
||||
``number``
|
||||
The screen number (int).
|
||||
"""
|
||||
for screen in self.screen_list:
|
||||
if screen[u'number'] == number:
|
||||
print u'screen %s exists' % number
|
||||
return True
|
||||
print u'screen %s does not exist' % number
|
||||
return False
|
||||
|
||||
def set_current_display(self, number):
|
||||
"""
|
||||
Set up the current screen dimensions
|
||||
Set up the current screen dimensions.
|
||||
|
||||
``number``
|
||||
The screen number (int).
|
||||
"""
|
||||
log.debug(u'set_current_display %s', number)
|
||||
if number + 1 > self.display_count:
|
||||
@ -86,8 +119,8 @@ class ScreenList(object):
|
||||
|
||||
def set_override_display(self):
|
||||
"""
|
||||
replace the current size with the override values
|
||||
user wants to have their own screen attributes
|
||||
Replace the current size with the override values, as the user wants to
|
||||
have their own screen attributes.
|
||||
"""
|
||||
log.debug(u'set_override_display')
|
||||
self.current = copy.deepcopy(self.override)
|
||||
@ -95,8 +128,8 @@ class ScreenList(object):
|
||||
|
||||
def reset_current_display(self):
|
||||
"""
|
||||
replace the current values with the correct values
|
||||
user wants to use the correct screen attributes
|
||||
Replace the current values with the correct values, as the user wants to
|
||||
use the correct screen attributes.
|
||||
"""
|
||||
log.debug(u'reset_current_display')
|
||||
self.set_current_display(self.current_display)
|
||||
|
Loading…
Reference in New Issue
Block a user