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.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
|
||||||
QtCore.QObject.connect(self.desktop(),
|
QtCore.QObject.connect(self.desktop(),
|
||||||
QtCore.SIGNAL(u'screenCountChanged(int)'),
|
QtCore.SIGNAL(u'screenCountChanged(int)'), self.updateScreenList)
|
||||||
self.onScreenCountChanged)
|
|
||||||
self.setOrganizationName(u'OpenLP')
|
self.setOrganizationName(u'OpenLP')
|
||||||
self.setOrganizationDomain(u'openlp.org')
|
self.setOrganizationDomain(u'openlp.org')
|
||||||
self.setApplicationName(u'OpenLP')
|
self.setApplicationName(u'OpenLP')
|
||||||
@ -182,17 +181,13 @@ class OpenLP(QtGui.QApplication):
|
|||||||
self.splash.show()
|
self.splash.show()
|
||||||
# make sure Qt really display the splash screen
|
# make sure Qt really display the splash screen
|
||||||
self.processEvents()
|
self.processEvents()
|
||||||
screens = ScreenList()
|
self.screens = ScreenList()
|
||||||
# Decide how many screens we have and their size
|
# Decide how many screens we have and their size
|
||||||
for screen in xrange(0, self.desktop().numScreens()):
|
self.updateScreenList(True)
|
||||||
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)
|
|
||||||
# start the main app window
|
# start the main app window
|
||||||
self.appClipboard = self.clipboard()
|
self.appClipboard = self.clipboard()
|
||||||
self.mainWindow = MainWindow(screens, app_version, self.appClipboard)
|
self.mainWindow = MainWindow(
|
||||||
|
self.screens, app_version, self.appClipboard)
|
||||||
self.mainWindow.show()
|
self.mainWindow.show()
|
||||||
if show_splash:
|
if show_splash:
|
||||||
# now kill the splashscreen
|
# now kill the splashscreen
|
||||||
@ -228,17 +223,33 @@ class OpenLP(QtGui.QApplication):
|
|||||||
"""
|
"""
|
||||||
self.restoreOverrideCursor()
|
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 = {
|
# Add new screens.
|
||||||
u'title': translate('OpenLP.Ui', 'Information'),
|
for number in xrange(0, self.desktop().numScreens()):
|
||||||
u'message': translate('OpenLP','The monitor set up has changed. You'
|
if not self.screens.screen_exists(number):
|
||||||
' have to restart OpenLP in order to change the live display'
|
size = self.desktop().screenGeometry(number)
|
||||||
' monitor.')
|
self.screens.add_screen({
|
||||||
}
|
u'number': number,
|
||||||
Receiver.send_message(u'openlp_information_message', data)
|
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():
|
def main():
|
||||||
"""
|
"""
|
||||||
|
@ -300,6 +300,7 @@ class GeneralTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
settings.beginGroup(self.settingsSection)
|
settings.beginGroup(self.settingsSection)
|
||||||
|
self.monitorComboBox.clear()
|
||||||
for screen in self.screens.screen_list:
|
for screen in self.screens.screen_list:
|
||||||
screen_name = u'%s %d' % (translate('OpenLP.GeneralTab', 'Screen'),
|
screen_name = u'%s %d' % (translate('OpenLP.GeneralTab', 'Screen'),
|
||||||
screen[u'number'] + 1)
|
screen[u'number'] + 1)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
"""
|
"""
|
||||||
The :mod:`screen` module provides management functionality for a machines'
|
The :mod:`screen` module provides management functionality for a machines'
|
||||||
displays
|
displays.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import copy
|
import copy
|
||||||
@ -51,25 +51,58 @@ class ScreenList(object):
|
|||||||
|
|
||||||
def add_screen(self, screen):
|
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']:
|
if screen[u'primary']:
|
||||||
self.current = screen
|
self.current = screen
|
||||||
self.screen_list.append(screen)
|
self.screen_list.append(screen)
|
||||||
self.display_count += 1
|
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):
|
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:
|
for screen in self.screen_list:
|
||||||
if screen[u'number'] == number:
|
if screen[u'number'] == number:
|
||||||
|
print u'screen %s exists' % number
|
||||||
return True
|
return True
|
||||||
|
print u'screen %s does not exist' % number
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def set_current_display(self, number):
|
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)
|
log.debug(u'set_current_display %s', number)
|
||||||
if number + 1 > self.display_count:
|
if number + 1 > self.display_count:
|
||||||
@ -86,8 +119,8 @@ class ScreenList(object):
|
|||||||
|
|
||||||
def set_override_display(self):
|
def set_override_display(self):
|
||||||
"""
|
"""
|
||||||
replace the current size with the override values
|
Replace the current size with the override values, as the user wants to
|
||||||
user wants to have their own screen attributes
|
have their own screen attributes.
|
||||||
"""
|
"""
|
||||||
log.debug(u'set_override_display')
|
log.debug(u'set_override_display')
|
||||||
self.current = copy.deepcopy(self.override)
|
self.current = copy.deepcopy(self.override)
|
||||||
@ -95,8 +128,8 @@ class ScreenList(object):
|
|||||||
|
|
||||||
def reset_current_display(self):
|
def reset_current_display(self):
|
||||||
"""
|
"""
|
||||||
replace the current values with the correct values
|
Replace the current values with the correct values, as the user wants to
|
||||||
user wants to use the correct screen attributes
|
use the correct screen attributes.
|
||||||
"""
|
"""
|
||||||
log.debug(u'reset_current_display')
|
log.debug(u'reset_current_display')
|
||||||
self.set_current_display(self.current_display)
|
self.set_current_display(self.current_display)
|
||||||
|
Loading…
Reference in New Issue
Block a user