Add a ui -> hide-mouse-cursor option.
This commit is contained in:
parent
7160a89cb9
commit
f77ba5744b
@ -43,6 +43,7 @@
|
|||||||
|<<ui-remove-finished-downloads,remove-finished-downloads>>|Whether to remove finished downloads automatically.
|
|<<ui-remove-finished-downloads,remove-finished-downloads>>|Whether to remove finished downloads automatically.
|
||||||
|<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown.
|
|<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown.
|
||||||
|<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined:
|
|<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined:
|
||||||
|
|<<ui-hide-mouse-cursor,hide-mouse-cursor>>|Whether to hide the mouse cursor.
|
||||||
|==============
|
|==============
|
||||||
|
|
||||||
.Quick reference for section ``network''
|
.Quick reference for section ``network''
|
||||||
@ -564,6 +565,17 @@ The format to use for the window title. The following placeholders are defined:
|
|||||||
|
|
||||||
Default: +pass:[{perc}{title}{title_sep}qutebrowser]+
|
Default: +pass:[{perc}{title}{title_sep}qutebrowser]+
|
||||||
|
|
||||||
|
[[ui-hide-mouse-cursor]]
|
||||||
|
=== hide-mouse-cursor
|
||||||
|
Whether to hide the mouse cursor.
|
||||||
|
|
||||||
|
Valid values:
|
||||||
|
|
||||||
|
* +true+
|
||||||
|
* +false+
|
||||||
|
|
||||||
|
Default: +pass:[false]+
|
||||||
|
|
||||||
== network
|
== network
|
||||||
Settings related to the network.
|
Settings related to the network.
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import faulthandler
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox
|
||||||
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon
|
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor
|
||||||
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl,
|
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl,
|
||||||
QObject, Qt, QSocketNotifier)
|
QObject, Qt, QSocketNotifier)
|
||||||
try:
|
try:
|
||||||
@ -210,6 +210,19 @@ class Application(QApplication):
|
|||||||
objreg.register('cache', diskcache)
|
objreg.register('cache', diskcache)
|
||||||
log.init.debug("Initializing completions...")
|
log.init.debug("Initializing completions...")
|
||||||
completionmodels.init()
|
completionmodels.init()
|
||||||
|
log.init.debug("Misc initialization...")
|
||||||
|
self.maybe_hide_mouse_cursor()
|
||||||
|
objreg.get('config').changed.connect(self.maybe_hide_mouse_cursor)
|
||||||
|
|
||||||
|
@config.change_filter('ui', 'hide-mouse-cursor')
|
||||||
|
def maybe_hide_mouse_cursor(self):
|
||||||
|
"""Hide the mouse cursor if it isn't yet and it's configured."""
|
||||||
|
if config.get('ui', 'hide-mouse-cursor'):
|
||||||
|
if self.overrideCursor() is not None:
|
||||||
|
return
|
||||||
|
self.setOverrideCursor(QCursor(Qt.BlankCursor))
|
||||||
|
else:
|
||||||
|
self.restoreOverrideCursor()
|
||||||
|
|
||||||
def _init_icon(self):
|
def _init_icon(self):
|
||||||
"""Initialize the icon of qutebrowser."""
|
"""Initialize the icon of qutebrowser."""
|
||||||
@ -940,8 +953,10 @@ class Application(QApplication):
|
|||||||
objreg.delete('last-focused-main-window')
|
objreg.delete('last-focused-main-window')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
self.restoreOverrideCursor()
|
||||||
else:
|
else:
|
||||||
objreg.register('last-focused-main-window', window, update=True)
|
objreg.register('last-focused-main-window', window, update=True)
|
||||||
|
self.maybe_hide_mouse_cursor()
|
||||||
|
|
||||||
@pyqtSlot(QUrl)
|
@pyqtSlot(QUrl)
|
||||||
def open_desktopservices_url(self, url):
|
def open_desktopservices_url(self, url):
|
||||||
|
@ -297,6 +297,10 @@ def data(readonly=False):
|
|||||||
"otherwise.\n"
|
"otherwise.\n"
|
||||||
"* `{id}`: The internal window ID of this window."),
|
"* `{id}`: The internal window ID of this window."),
|
||||||
|
|
||||||
|
('hide-mouse-cursor',
|
||||||
|
SettingValue(typ.Bool(), 'false'),
|
||||||
|
"Whether to hide the mouse cursor."),
|
||||||
|
|
||||||
readonly=readonly
|
readonly=readonly
|
||||||
)),
|
)),
|
||||||
|
|
||||||
|
@ -131,9 +131,20 @@ class EventFilter(QObject):
|
|||||||
def eventFilter(self, obj, event):
|
def eventFilter(self, obj, event):
|
||||||
"""Forward events to the correct modeman."""
|
"""Forward events to the correct modeman."""
|
||||||
try:
|
try:
|
||||||
|
qapp = QApplication.instance()
|
||||||
if not self._activated:
|
if not self._activated:
|
||||||
return False
|
return False
|
||||||
if event.type() not in [QEvent.KeyPress, QEvent.KeyRelease]:
|
if event.type() in [QEvent.MouseButtonDblClick,
|
||||||
|
QEvent.MouseButtonPress,
|
||||||
|
QEvent.MouseButtonRelease,
|
||||||
|
QEvent.MouseMove]:
|
||||||
|
if qapp.overrideCursor() is None:
|
||||||
|
# Mouse cursor shown -> don't filter event
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# Mouse cursor hidden -> filter event
|
||||||
|
return True
|
||||||
|
elif event.type() not in [QEvent.KeyPress, QEvent.KeyRelease]:
|
||||||
# We're not interested in non-key-events so we pass them
|
# We're not interested in non-key-events so we pass them
|
||||||
# through.
|
# through.
|
||||||
return False
|
return False
|
||||||
@ -141,8 +152,7 @@ class EventFilter(QObject):
|
|||||||
# We already handled this same event at some point earlier, so
|
# We already handled this same event at some point earlier, so
|
||||||
# we're not interested in it anymore.
|
# we're not interested in it anymore.
|
||||||
return False
|
return False
|
||||||
if (QApplication.instance().activeWindow() not in
|
if qapp.activeWindow() not in objreg.window_registry.values():
|
||||||
objreg.window_registry.values()):
|
|
||||||
# Some other window (print dialog, etc.) is focused so we pass
|
# Some other window (print dialog, etc.) is focused so we pass
|
||||||
# the event through.
|
# the event through.
|
||||||
return False
|
return False
|
||||||
|
@ -128,6 +128,10 @@ class MainWindow(QWidget):
|
|||||||
# we defer this until everything else is initialized.
|
# we defer this until everything else is initialized.
|
||||||
QTimer.singleShot(0, self._connect_resize_completion)
|
QTimer.singleShot(0, self._connect_resize_completion)
|
||||||
objreg.get('config').changed.connect(self.on_config_changed)
|
objreg.get('config').changed.connect(self.on_config_changed)
|
||||||
|
|
||||||
|
if config.get('ui', 'hide-mouse-cursor'):
|
||||||
|
self.setCursor(Qt.BlankCursor)
|
||||||
|
|
||||||
#self.retranslateUi(MainWindow)
|
#self.retranslateUi(MainWindow)
|
||||||
#self.tabWidget.setCurrentIndex(0)
|
#self.tabWidget.setCurrentIndex(0)
|
||||||
#QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
#QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
Loading…
Reference in New Issue
Block a user