Add option to queue all msgs in unfocused windows.
This commit is contained in:
parent
157c25bb13
commit
c13e09b706
@ -222,6 +222,10 @@ DATA = collections.OrderedDict([
|
|||||||
SettingValue(typ.Int(), '2000'),
|
SettingValue(typ.Int(), '2000'),
|
||||||
"Time (in ms) to show messages in the statusbar for."),
|
"Time (in ms) to show messages in the statusbar for."),
|
||||||
|
|
||||||
|
('message-unfocused',
|
||||||
|
SettingValue(typ.Bool(), 'false'),
|
||||||
|
"Whether to show messages in unfocused windows."),
|
||||||
|
|
||||||
('confirm-quit',
|
('confirm-quit',
|
||||||
SettingValue(typ.ConfirmQuit(), 'never'),
|
SettingValue(typ.ConfirmQuit(), 'never'),
|
||||||
"Whether to confirm quitting the application."),
|
"Whether to confirm quitting the application."),
|
||||||
|
@ -23,6 +23,7 @@ import datetime
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject
|
||||||
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
|
||||||
from qutebrowser.utils import usertypes, log, objreg, utils
|
from qutebrowser.utils import usertypes, log, objreg, utils
|
||||||
|
|
||||||
@ -44,20 +45,32 @@ def _wrapper(win_id, method_name, text, *args, **kwargs):
|
|||||||
text: The text do display.
|
text: The text do display.
|
||||||
*args/**kwargs: Arguments to pass to the method.
|
*args/**kwargs: Arguments to pass to the method.
|
||||||
"""
|
"""
|
||||||
|
msg = QueuedMsg(time=datetime.datetime.now(), win_id=win_id,
|
||||||
|
method_name=method_name, text=text, args=args,
|
||||||
|
kwargs=kwargs)
|
||||||
try:
|
try:
|
||||||
bridge = _get_bridge(win_id)
|
bridge = _get_bridge(win_id)
|
||||||
except objreg.RegistryUnavailableError:
|
except objreg.RegistryUnavailableError:
|
||||||
if win_id == 'current':
|
if win_id == 'current':
|
||||||
log.misc.debug("Queueing {} for window {}".format(method_name,
|
log.misc.debug("Queueing {} for current window".format(
|
||||||
win_id))
|
method_name))
|
||||||
msg = QueuedMsg(time=datetime.datetime.now(), win_id=win_id,
|
|
||||||
method_name=method_name, text=text, args=args,
|
|
||||||
kwargs=kwargs)
|
|
||||||
_QUEUED.append(msg)
|
_QUEUED.append(msg)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
from qutebrowser.config import config
|
||||||
|
win = QApplication.instance().activeWindow()
|
||||||
|
window_focused = (win is not None and
|
||||||
|
win in objreg.window_registry.values() and
|
||||||
|
win.win_id == win_id)
|
||||||
|
if (config.get('ui', 'message-unfocused') or
|
||||||
|
method_name not in ('error', 'warning', 'info') or
|
||||||
|
window_focused):
|
||||||
getattr(bridge, method_name)(text, *args, **kwargs)
|
getattr(bridge, method_name)(text, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
log.misc.debug("Queueing {} for window {}".format(method_name,
|
||||||
|
win_id))
|
||||||
|
_QUEUED.append(msg)
|
||||||
|
|
||||||
|
|
||||||
def _get_bridge(win_id):
|
def _get_bridge(win_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user