From 4414d7e4211ce1f4b653650dc77061dd92cc0c3b Mon Sep 17 00:00:00 2001 From: Garrett Date: Sun, 16 Jan 2011 14:32:39 -0800 Subject: [PATCH] Add a setting to hide the mouse cursor on the display. --- openlp/core/ui/generaltab.py | 16 ++++++++++++++++ openlp/core/ui/maindisplay.py | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 773637481..b829a67d2 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -213,6 +213,14 @@ class GeneralTab(SettingsTab): self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') self.displayLayout.addWidget(self.customHeightValueEdit, 4, 3) self.rightLayout.addWidget(self.displayGroupBox) + self.hideMouseGroupBox = QtGui.QGroupBox(self.rightColumn) + self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox') + self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox) + self.hideMouseLayout.setObjectName(u'hideMouseLayout') + self.hideMouseCheckBox = QtGui.QCheckBox(self.hideMouseGroupBox) + self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox') + self.hideMouseLayout.addWidget(self.hideMouseCheckBox) + self.rightLayout.addWidget(self.hideMouseGroupBox) self.rightLayout.addStretch() # Signals and slots QtCore.QObject.connect(self.overrideCheckBox, @@ -287,6 +295,10 @@ class GeneralTab(SettingsTab): self.customHeightLabel.setText( translate('OpenLP.GeneralTab', 'Height')) self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width')) + self.hideMouseGroupBox.setTitle(translate('OpenLP.GeneralTab', + 'Mouse Cursor')) + self.hideMouseCheckBox.setText(translate('OpenLP.GeneralTab', + 'Hide the Mouse Cursor')) def load(self): """ @@ -341,6 +353,8 @@ class GeneralTab(SettingsTab): self.customWidthValueEdit.setText( settings.value(u'width', QtCore.QVariant( self.screens.current[u'size'].width())).toString()) + self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse', + QtCore.QVariant(False)).toBool()) settings.endGroup() self.customXValueEdit.setEnabled(self.overrideCheckBox.isChecked()) self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked()) @@ -385,6 +399,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.customWidthValueEdit.text())) settings.setValue(u'override position', QtCore.QVariant(self.overrideCheckBox.isChecked())) + settings.setValue(u'hide mouse', + QtCore.QVariant(self.hideMouseCheckBox.isChecked())) settings.endGroup() self.screens.display = self.displayOnMonitorCheck.isChecked() # Monitor Number has changed. diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 273a3c4f0..2638c99e8 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -117,6 +117,8 @@ class MainDisplay(DisplayWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) + self.generalSettingsSection = u'general' + def retranslateUi(self): """ Setup the interface translation strings. @@ -205,6 +207,8 @@ class MainDisplay(DisplayWidget): Receiver.send_message(u'openlp_process_events') self.frame.evaluateJavaScript(u'show_text("%s")' % \ slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) + + self.hideMouseCursor() return self.preview() def alert(self, text): @@ -270,6 +274,7 @@ class MainDisplay(DisplayWidget): else: js = u'show_image("");' self.frame.evaluateJavaScript(js) + self.hideMouseCursor() def resetImage(self): """ @@ -359,6 +364,8 @@ class MainDisplay(DisplayWidget): self.webView.setVisible(False) self.videoWidget.setVisible(True) self.audio.setVolume(vol) + + self.hideMouseCursor() return self.preview() def isLoaded(self): @@ -474,6 +481,19 @@ class MainDisplay(DisplayWidget): self.hideMode = None # Trigger actions when display is active again Receiver.send_message(u'maindisplay_active') + + def hideMouseCursor(self): + """ + Hide the mouse cursor if enabled in settings + """ + settings = QtCore.QSettings() + if settings.value(u'%s/hide mouse' % self.generalSettingsSection, + QtCore.QVariant(False)).toBool(): + self.setCursor(QtCore.Qt.BlankCursor) + self.frame.evaluateJavaScript('document.body.style.cursor = "none"') + else: + self.setCursor(QtCore.Qt.ArrowCursor) + self.frame.evaluateJavaScript('document.body.style.cursor = "auto"') class AudioPlayer(QtCore.QObject): """