Fix issues with maindisplay at startup and when on a single monitor

bzr-revno: 1857
This commit is contained in:
Jonathan Corwin 2011-12-27 09:43:20 +00:00
commit 6897daf2c9
4 changed files with 30 additions and 2 deletions

View File

@ -421,6 +421,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
if self.displayComboBox.currentIndex() != -1:
QtCore.QSettings().setValue(u'General/monitor',
QtCore.QVariant(self.displayComboBox.currentIndex()))
self.screens.set_current_display(
self.displayComboBox.currentIndex())
# Set Global Theme
if self.themeComboBox.currentIndex() != -1:
QtCore.QSettings().setValue(u'themes/global theme',

View File

@ -416,6 +416,11 @@ class MainDisplay(Display):
Store the images so they can be replaced when required
"""
log.debug(u'hideDisplay mode = %d', mode)
if self.screens.display_count == 1:
# Only make visible if setting enabled
if not QtCore.QSettings().value(u'general/display on monitor',
QtCore.QVariant(True)).toBool():
return
if mode == HideMode.Screen:
self.frame.evaluateJavaScript(u'show_blank("desktop");')
self.setVisible(False)
@ -436,6 +441,11 @@ class MainDisplay(Display):
Make the stored images None to release memory.
"""
log.debug(u'showDisplay')
if self.screens.display_count == 1:
# Only make visible if setting enabled
if not QtCore.QSettings().value(u'general/display on monitor',
QtCore.QVariant(True)).toBool():
return
self.frame.evaluateJavaScript('show_blank("show");')
if self.isHidden():
self.setVisible(True)

View File

@ -222,6 +222,21 @@ class ScreenList(object):
log.debug(u'reset_current_display')
self.set_current_display(self.current[u'number'])
def which_screen(self, window):
"""
Return the screen number that the centre of the passed window is in.
``window``
A QWidget we are finding the location of.
"""
x = window.x() + (window.width() / 2)
y = window.y() + (window.height() / 2)
for screen in self.screen_list:
size = screen[u'size']
if x >= size.x() and x <= (size.x() + size.width()) \
and y >= size.y() and y <= (size.y() + size.height()):
return screen[u'number']
def _load_screen_settings(self):
"""
Loads the screen size and the monitor number from the settings.

View File

@ -956,7 +956,8 @@ class SlideController(Controller):
display_type = QtCore.QSettings().value(
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'')).toString()
if not self.display.primary:
if self.screens.which_screen(self.window()) != \
self.screens.which_screen(self.display):
# Order done to handle initial conversion
if display_type == u'themed':
self.onThemeDisplay(True)
@ -967,7 +968,7 @@ class SlideController(Controller):
else:
Receiver.send_message(u'live_display_show')
else:
Receiver.send_message(u'live_display_hide', HideMode.Screen)
self.liveEscape()
def onSlideBlank(self):
"""