Object names cleanup
This commit is contained in:
parent
04be586bca
commit
2b60cdb64c
@ -105,7 +105,7 @@ class Application(QApplication):
|
|||||||
self._handle_segfault()
|
self._handle_segfault()
|
||||||
log.init.debug("Initializing modes...")
|
log.init.debug("Initializing modes...")
|
||||||
self._init_modes()
|
self._init_modes()
|
||||||
modeman_obj = self.registry['modeman']
|
mode_manager = self.registry['mode-manager']
|
||||||
log.init.debug("Initializing websettings...")
|
log.init.debug("Initializing websettings...")
|
||||||
websettings.init()
|
websettings.init()
|
||||||
log.init.debug("Initializing quickmarks...")
|
log.init.debug("Initializing quickmarks...")
|
||||||
@ -117,27 +117,27 @@ class Application(QApplication):
|
|||||||
log.init.debug("Initializing utility commands...")
|
log.init.debug("Initializing utility commands...")
|
||||||
utilcmds.init()
|
utilcmds.init()
|
||||||
log.init.debug("Initializing cookies...")
|
log.init.debug("Initializing cookies...")
|
||||||
cookiejar = cookies.CookieJar(self)
|
cookie_jar = cookies.CookieJar(self)
|
||||||
self.registry['cookiejar'] = cookiejar
|
self.registry['cookie-jar'] = cookie_jar
|
||||||
log.init.debug("Initializing cache...")
|
log.init.debug("Initializing cache...")
|
||||||
diskcache = cache.DiskCache(self)
|
diskcache = cache.DiskCache(self)
|
||||||
self.registry['cache'] = diskcache
|
self.registry['cache'] = diskcache
|
||||||
log.init.debug("Initializing commands...")
|
log.init.debug("Initializing commands...")
|
||||||
self._commandrunner = runners.CommandRunner()
|
self._commandrunner = runners.CommandRunner()
|
||||||
log.init.debug("Initializing search...")
|
log.init.debug("Initializing search...")
|
||||||
searchrunner = runners.SearchRunner(self)
|
search_runner = runners.SearchRunner(self)
|
||||||
self.registry['searchrunner'] = searchrunner
|
self.registry['search-runner'] = search_runner
|
||||||
log.init.debug("Initializing downloads...")
|
log.init.debug("Initializing downloads...")
|
||||||
downloadmanager = downloads.DownloadManager(self)
|
download_manager = downloads.DownloadManager(self)
|
||||||
self.registry['downloadmanager'] = downloadmanager
|
self.registry['download-manager'] = download_manager
|
||||||
log.init.debug("Initializing main window...")
|
log.init.debug("Initializing main window...")
|
||||||
mainwin = mainwindow.MainWindow()
|
main_window = mainwindow.MainWindow()
|
||||||
self.registry['mainwindow'] = mainwin
|
self.registry['main-window'] = main_window
|
||||||
log.init.debug("Initializing debug console...")
|
log.init.debug("Initializing debug console...")
|
||||||
debug_console = console.ConsoleWidget()
|
debug_console = console.ConsoleWidget()
|
||||||
self.registry['debug-console'] = debug_console
|
self.registry['debug-console'] = debug_console
|
||||||
log.init.debug("Initializing eventfilter...")
|
log.init.debug("Initializing eventfilter...")
|
||||||
self.installEventFilter(modeman_obj)
|
self.installEventFilter(mode_manager)
|
||||||
self.setQuitOnLastWindowClosed(False)
|
self.setQuitOnLastWindowClosed(False)
|
||||||
|
|
||||||
log.init.debug("Connecting signals...")
|
log.init.debug("Connecting signals...")
|
||||||
@ -146,7 +146,7 @@ class Application(QApplication):
|
|||||||
|
|
||||||
log.init.debug("Showing mainwindow...")
|
log.init.debug("Showing mainwindow...")
|
||||||
if not args.nowindow:
|
if not args.nowindow:
|
||||||
mainwin.show()
|
main_window.show()
|
||||||
log.init.debug("Applying python hacks...")
|
log.init.debug("Applying python hacks...")
|
||||||
self._python_hacks()
|
self._python_hacks()
|
||||||
QTimer.singleShot(0, self._process_init_args)
|
QTimer.singleShot(0, self._process_init_args)
|
||||||
@ -189,7 +189,7 @@ class Application(QApplication):
|
|||||||
else:
|
else:
|
||||||
self.registry['config'] = config_obj
|
self.registry['config'] = config_obj
|
||||||
try:
|
try:
|
||||||
keyconfig = keyconfparser.KeyConfigParser(confdir, 'keys.conf')
|
key_config = keyconfparser.KeyConfigParser(confdir, 'keys.conf')
|
||||||
except keyconfparser.KeyConfigError as e:
|
except keyconfparser.KeyConfigError as e:
|
||||||
log.init.exception(e)
|
log.init.exception(e)
|
||||||
errstr = "Error while reading key config:\n"
|
errstr = "Error while reading key config:\n"
|
||||||
@ -202,12 +202,12 @@ class Application(QApplication):
|
|||||||
# We didn't really initialize much so far, so we just quit hard.
|
# We didn't really initialize much so far, so we just quit hard.
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
self.registry['keyconfig'] = keyconfig
|
self.registry['key-config'] = key_config
|
||||||
stateconfig = iniparsers.ReadWriteConfigParser(confdir, 'state')
|
state_config = iniparsers.ReadWriteConfigParser(confdir, 'state')
|
||||||
self.registry['stateconfig'] = stateconfig
|
self.registry['state-config'] = state_config
|
||||||
cmd_history = lineparser.LineConfigParser(
|
command_history = lineparser.LineConfigParser(
|
||||||
confdir, 'cmd_history', ('completion', 'history-length'))
|
confdir, 'cmd_history', ('completion', 'history-length'))
|
||||||
self.registry['cmd_history'] = cmd_history
|
self.registry['command-history'] = command_history
|
||||||
|
|
||||||
def _init_modes(self):
|
def _init_modes(self):
|
||||||
"""Inizialize the mode manager and the keyparsers."""
|
"""Inizialize the mode manager and the keyparsers."""
|
||||||
@ -227,27 +227,27 @@ class Application(QApplication):
|
|||||||
utypes.KeyMode.yesno:
|
utypes.KeyMode.yesno:
|
||||||
modeparsers.PromptKeyParser(self),
|
modeparsers.PromptKeyParser(self),
|
||||||
}
|
}
|
||||||
modeman_obj = modeman.ModeManager(self)
|
mode_manager = modeman.ModeManager(self)
|
||||||
self.registry['modeman'] = modeman_obj
|
self.registry['mode-manager'] = mode_manager
|
||||||
modeman_obj.register(utypes.KeyMode.normal,
|
mode_manager.register(utypes.KeyMode.normal,
|
||||||
self._keyparsers[utypes.KeyMode.normal].handle)
|
self._keyparsers[utypes.KeyMode.normal].handle)
|
||||||
modeman_obj.register(utypes.KeyMode.hint,
|
mode_manager.register(utypes.KeyMode.hint,
|
||||||
self._keyparsers[utypes.KeyMode.hint].handle)
|
self._keyparsers[utypes.KeyMode.hint].handle)
|
||||||
modeman_obj.register(utypes.KeyMode.insert,
|
mode_manager.register(utypes.KeyMode.insert,
|
||||||
self._keyparsers[utypes.KeyMode.insert].handle,
|
self._keyparsers[utypes.KeyMode.insert].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
modeman_obj.register(
|
mode_manager.register(
|
||||||
utypes.KeyMode.passthrough,
|
utypes.KeyMode.passthrough,
|
||||||
self._keyparsers[utypes.KeyMode.passthrough].handle,
|
self._keyparsers[utypes.KeyMode.passthrough].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
modeman_obj.register(utypes.KeyMode.command,
|
mode_manager.register(utypes.KeyMode.command,
|
||||||
self._keyparsers[utypes.KeyMode.command].handle,
|
self._keyparsers[utypes.KeyMode.command].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
modeman_obj.register(utypes.KeyMode.prompt,
|
mode_manager.register(utypes.KeyMode.prompt,
|
||||||
self._keyparsers[utypes.KeyMode.prompt].handle,
|
self._keyparsers[utypes.KeyMode.prompt].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
modeman_obj.register(utypes.KeyMode.yesno,
|
mode_manager.register(utypes.KeyMode.yesno,
|
||||||
self._keyparsers[utypes.KeyMode.yesno].handle)
|
self._keyparsers[utypes.KeyMode.yesno].handle)
|
||||||
|
|
||||||
def _init_misc(self):
|
def _init_misc(self):
|
||||||
"""Initialize misc things."""
|
"""Initialize misc things."""
|
||||||
@ -262,10 +262,10 @@ class Application(QApplication):
|
|||||||
self.setOrganizationName("qutebrowser")
|
self.setOrganizationName("qutebrowser")
|
||||||
self.setApplicationName("qutebrowser")
|
self.setApplicationName("qutebrowser")
|
||||||
self.setApplicationVersion(qutebrowser.__version__)
|
self.setApplicationVersion(qutebrowser.__version__)
|
||||||
messagebridge = message.MessageBridge(self)
|
message_bridge = message.MessageBridge(self)
|
||||||
self.registry['messagebridge'] = messagebridge
|
self.registry['message-bridge'] = message_bridge
|
||||||
rl_bridge = readline.ReadlineBridge()
|
readline_bridge = readline.ReadlineBridge()
|
||||||
self.registry['rl_bridge'] = rl_bridge
|
self.registry['readline-bridge'] = readline_bridge
|
||||||
|
|
||||||
def _handle_segfault(self):
|
def _handle_segfault(self):
|
||||||
"""Handle a segfault from a previous run."""
|
"""Handle a segfault from a previous run."""
|
||||||
@ -328,7 +328,7 @@ class Application(QApplication):
|
|||||||
# we make sure the GUI is refreshed here, so the start seems faster.
|
# we make sure the GUI is refreshed here, so the start seems faster.
|
||||||
self.processEvents(QEventLoop.ExcludeUserInputEvents |
|
self.processEvents(QEventLoop.ExcludeUserInputEvents |
|
||||||
QEventLoop.ExcludeSocketNotifiers)
|
QEventLoop.ExcludeSocketNotifiers)
|
||||||
tabbedbrowser = self.registry['tabbedbrowser']
|
tabbed_browser = self.registry['tabbed-browser']
|
||||||
for cmd in self._args.command:
|
for cmd in self._args.command:
|
||||||
if cmd.startswith(':'):
|
if cmd.startswith(':'):
|
||||||
log.init.debug("Startup cmd {}".format(cmd))
|
log.init.debug("Startup cmd {}".format(cmd))
|
||||||
@ -341,9 +341,9 @@ class Application(QApplication):
|
|||||||
message.error("Error in startup argument '{}': {}".format(
|
message.error("Error in startup argument '{}': {}".format(
|
||||||
cmd, e))
|
cmd, e))
|
||||||
else:
|
else:
|
||||||
tabbedbrowser.tabopen(url)
|
tabbed_browser.tabopen(url)
|
||||||
|
|
||||||
if tabbedbrowser.count() == 0:
|
if tabbed_browser.count() == 0:
|
||||||
log.init.debug("Opening startpage")
|
log.init.debug("Opening startpage")
|
||||||
for urlstr in config.get('general', 'startpage'):
|
for urlstr in config.get('general', 'startpage'):
|
||||||
try:
|
try:
|
||||||
@ -351,7 +351,7 @@ class Application(QApplication):
|
|||||||
except urlutils.FuzzyUrlError as e:
|
except urlutils.FuzzyUrlError as e:
|
||||||
message.error("Error when opening startpage: {}".format(e))
|
message.error("Error when opening startpage: {}".format(e))
|
||||||
else:
|
else:
|
||||||
tabbedbrowser.tabopen(url)
|
tabbed_browser.tabopen(url)
|
||||||
|
|
||||||
def _python_hacks(self):
|
def _python_hacks(self):
|
||||||
"""Get around some PyQt-oddities by evil hacks.
|
"""Get around some PyQt-oddities by evil hacks.
|
||||||
@ -365,44 +365,44 @@ class Application(QApplication):
|
|||||||
timer = utypes.Timer(self, 'python_hacks')
|
timer = utypes.Timer(self, 'python_hacks')
|
||||||
timer.start(500)
|
timer.start(500)
|
||||||
timer.timeout.connect(lambda: None)
|
timer.timeout.connect(lambda: None)
|
||||||
self.registry['python_hack_timer'] = timer
|
self.registry['python-hack-timer'] = timer
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
"""Connect all signals to their slots."""
|
"""Connect all signals to their slots."""
|
||||||
# pylint: disable=too-many-statements
|
# pylint: disable=too-many-statements
|
||||||
# syntactic sugar
|
# syntactic sugar
|
||||||
kp = self._keyparsers
|
kp = self._keyparsers
|
||||||
mainwin = self.registry['mainwindow']
|
main_window = self.registry['main-window']
|
||||||
status = mainwin.status
|
status = main_window.status
|
||||||
completion = self.registry['completion']
|
completion = self.registry['completion']
|
||||||
tabs = self.registry['tabbedbrowser']
|
tabs = self.registry['tabbed-browser']
|
||||||
cmd = self.registry['status-cmd']
|
cmd = self.registry['status-command']
|
||||||
completer = self.registry['completer']
|
completer = self.registry['completer']
|
||||||
searchrunner = self.registry['searchrunner']
|
search_runner = self.registry['search-runner']
|
||||||
messagebridge = self.registry['messagebridge']
|
message_bridge = self.registry['message-bridge']
|
||||||
modeman = self.registry['modeman']
|
mode_manager = self.registry['mode-manager']
|
||||||
prompter = self.registry['prompter']
|
prompter = self.registry['prompter']
|
||||||
cmd_history = self.registry['cmd_history']
|
command_history = self.registry['command-history']
|
||||||
downloadmanager = self.registry['downloadmanager']
|
download_manager = self.registry['download-manager']
|
||||||
config_obj = self.registry['config']
|
config_obj = self.registry['config']
|
||||||
keyconfig = self.registry['keyconfig']
|
key_config = self.registry['key-config']
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
self.lastWindowClosed.connect(self.shutdown)
|
self.lastWindowClosed.connect(self.shutdown)
|
||||||
tabs.quit.connect(self.shutdown)
|
tabs.quit.connect(self.shutdown)
|
||||||
|
|
||||||
# status bar
|
# status bar
|
||||||
modeman.entered.connect(status.on_mode_entered)
|
mode_manager.entered.connect(status.on_mode_entered)
|
||||||
modeman.left.connect(status.on_mode_left)
|
mode_manager.left.connect(status.on_mode_left)
|
||||||
modeman.left.connect(cmd.on_mode_left)
|
mode_manager.left.connect(cmd.on_mode_left)
|
||||||
modeman.left.connect(prompter.on_mode_left)
|
mode_manager.left.connect(prompter.on_mode_left)
|
||||||
|
|
||||||
# commands
|
# commands
|
||||||
cmd.got_cmd.connect(self._commandrunner.run_safely)
|
cmd.got_cmd.connect(self._commandrunner.run_safely)
|
||||||
cmd.got_search.connect(searchrunner.search)
|
cmd.got_search.connect(search_runner.search)
|
||||||
cmd.got_search_rev.connect(searchrunner.search_rev)
|
cmd.got_search_rev.connect(search_runner.search_rev)
|
||||||
cmd.returnPressed.connect(tabs.setFocus)
|
cmd.returnPressed.connect(tabs.setFocus)
|
||||||
searchrunner.do_search.connect(tabs.search)
|
search_runner.do_search.connect(tabs.search)
|
||||||
kp[utypes.KeyMode.normal].keystring_updated.connect(
|
kp[utypes.KeyMode.normal].keystring_updated.connect(
|
||||||
status.keystring.setText)
|
status.keystring.setText)
|
||||||
tabs.got_cmd.connect(self._commandrunner.run_safely)
|
tabs.got_cmd.connect(self._commandrunner.run_safely)
|
||||||
@ -415,21 +415,21 @@ class Application(QApplication):
|
|||||||
kp[utypes.KeyMode.hint].on_hint_strings_updated)
|
kp[utypes.KeyMode.hint].on_hint_strings_updated)
|
||||||
|
|
||||||
# messages
|
# messages
|
||||||
messagebridge.s_error.connect(status.disp_error)
|
message_bridge.s_error.connect(status.disp_error)
|
||||||
messagebridge.s_info.connect(status.disp_temp_text)
|
message_bridge.s_info.connect(status.disp_temp_text)
|
||||||
messagebridge.s_set_text.connect(status.set_text)
|
message_bridge.s_set_text.connect(status.set_text)
|
||||||
messagebridge.s_maybe_reset_text.connect(status.txt.maybe_reset_text)
|
message_bridge.s_maybe_reset_text.connect(status.txt.maybe_reset_text)
|
||||||
messagebridge.s_set_cmd_text.connect(cmd.set_cmd_text)
|
message_bridge.s_set_cmd_text.connect(cmd.set_cmd_text)
|
||||||
messagebridge.s_question.connect(prompter.ask_question,
|
message_bridge.s_question.connect(prompter.ask_question,
|
||||||
Qt.DirectConnection)
|
Qt.DirectConnection)
|
||||||
|
|
||||||
# config
|
# config
|
||||||
config_obj.style_changed.connect(style.get_stylesheet.cache_clear)
|
config_obj.style_changed.connect(style.get_stylesheet.cache_clear)
|
||||||
for obj in (tabs, completion, mainwin, cmd_history,
|
for obj in (tabs, completion, main_window, command_history,
|
||||||
websettings, modeman, status, status.txt):
|
websettings, mode_manager, status, status.txt):
|
||||||
config_obj.changed.connect(obj.on_config_changed)
|
config_obj.changed.connect(obj.on_config_changed)
|
||||||
for obj in kp.values():
|
for obj in kp.values():
|
||||||
keyconfig.changed.connect(obj.on_keyconfig_changed)
|
key_config.changed.connect(obj.on_keyconfig_changed)
|
||||||
|
|
||||||
# statusbar
|
# statusbar
|
||||||
# FIXME some of these probably only should be triggered on mainframe
|
# FIXME some of these probably only should be triggered on mainframe
|
||||||
@ -452,7 +452,7 @@ class Application(QApplication):
|
|||||||
tabs.cur_load_status_changed.connect(status.url.on_load_status_changed)
|
tabs.cur_load_status_changed.connect(status.url.on_load_status_changed)
|
||||||
|
|
||||||
# command input / completion
|
# command input / completion
|
||||||
modeman.left.connect(tabs.on_mode_left)
|
mode_manager.left.connect(tabs.on_mode_left)
|
||||||
cmd.clear_completion_selection.connect(
|
cmd.clear_completion_selection.connect(
|
||||||
completion.on_clear_completion_selection)
|
completion.on_clear_completion_selection)
|
||||||
cmd.hide_completion.connect(completion.hide)
|
cmd.hide_completion.connect(completion.hide)
|
||||||
@ -460,8 +460,8 @@ class Application(QApplication):
|
|||||||
completer.change_completed_part.connect(cmd.on_change_completed_part)
|
completer.change_completed_part.connect(cmd.on_change_completed_part)
|
||||||
|
|
||||||
# downloads
|
# downloads
|
||||||
tabs.start_download.connect(downloadmanager.fetch)
|
tabs.start_download.connect(download_manager.fetch)
|
||||||
tabs.download_get.connect(downloadmanager.get)
|
tabs.download_get.connect(download_manager.get)
|
||||||
|
|
||||||
def _get_widgets(self):
|
def _get_widgets(self):
|
||||||
"""Get a string list of all widgets."""
|
"""Get a string list of all widgets."""
|
||||||
@ -516,11 +516,11 @@ class Application(QApplication):
|
|||||||
A list of open pages, or an empty list.
|
A list of open pages, or an empty list.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
tabbedbrowser = self.registry['tabbedbrowser']
|
tabbed_browser = self.registry['tabbed-browser']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return []
|
return []
|
||||||
pages = []
|
pages = []
|
||||||
for tab in tabbedbrowser.widgets():
|
for tab in tabbed_browser.widgets():
|
||||||
try:
|
try:
|
||||||
url = tab.cur_url.toString(
|
url = tab.cur_url.toString(
|
||||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||||
@ -532,14 +532,14 @@ class Application(QApplication):
|
|||||||
|
|
||||||
def _save_geometry(self):
|
def _save_geometry(self):
|
||||||
"""Save the window geometry to the state config."""
|
"""Save the window geometry to the state config."""
|
||||||
stateconfig = self.registry['stateconfig']
|
state_config = self.registry['state-config']
|
||||||
data = bytes(self.registry['mainwindow'].saveGeometry())
|
data = bytes(self.registry['main-window'].saveGeometry())
|
||||||
geom = base64.b64encode(data).decode('ASCII')
|
geom = base64.b64encode(data).decode('ASCII')
|
||||||
try:
|
try:
|
||||||
stateconfig.add_section('geometry')
|
state_config.add_section('geometry')
|
||||||
except configparser.DuplicateSectionError:
|
except configparser.DuplicateSectionError:
|
||||||
pass
|
pass
|
||||||
stateconfig['geometry']['mainwindow'] = geom
|
state_config['geometry']['mainwindow'] = geom
|
||||||
|
|
||||||
def _destroy_crashlogfile(self):
|
def _destroy_crashlogfile(self):
|
||||||
"""Clean up the crash log file and delete it."""
|
"""Clean up the crash log file and delete it."""
|
||||||
@ -588,7 +588,7 @@ class Application(QApplication):
|
|||||||
pages = []
|
pages = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
history = self.registry['status-cmd'].history[-5:]
|
history = self.registry['status-command'].history[-5:]
|
||||||
except Exception:
|
except Exception:
|
||||||
log.destroy.exception("Error while getting history: {}")
|
log.destroy.exception("Error while getting history: {}")
|
||||||
history = []
|
history = []
|
||||||
@ -623,7 +623,7 @@ class Application(QApplication):
|
|||||||
# exceptions occur.
|
# exceptions occur.
|
||||||
if pages is None:
|
if pages is None:
|
||||||
pages = []
|
pages = []
|
||||||
for tab in utils.get_object('tabbedbrowser').widgets():
|
for tab in utils.get_object('tabbed-browser').widgets():
|
||||||
urlstr = tab.cur_url.toString(
|
urlstr = tab.cur_url.toString(
|
||||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||||
if urlstr:
|
if urlstr:
|
||||||
@ -670,14 +670,14 @@ class Application(QApplication):
|
|||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
out = traceback.format_exc()
|
out = traceback.format_exc()
|
||||||
qutescheme.pyeval_output = out
|
qutescheme.pyeval_output = out
|
||||||
self.registry['tabbedbrowser'].openurl(
|
self.registry['tabbed-browser'].openurl(
|
||||||
QUrl('qute:pyeval'), newtab=True)
|
QUrl('qute:pyeval'), newtab=True)
|
||||||
|
|
||||||
@cmdutils.register(instance='app')
|
@cmdutils.register(instance='app')
|
||||||
def report(self):
|
def report(self):
|
||||||
"""Report a bug in qutebrowser."""
|
"""Report a bug in qutebrowser."""
|
||||||
pages = self._recover_pages()
|
pages = self._recover_pages()
|
||||||
history = self.registry['status-cmd'].history[-5:]
|
history = self.registry['status-command'].history[-5:]
|
||||||
objects = self.get_all_objects()
|
objects = self.get_all_objects()
|
||||||
self._crashdlg = crash.ReportDialog(pages, history, objects)
|
self._crashdlg = crash.ReportDialog(pages, history, objects)
|
||||||
self._crashdlg.show()
|
self._crashdlg.show()
|
||||||
@ -753,13 +753,13 @@ class Application(QApplication):
|
|||||||
# Remove eventfilter
|
# Remove eventfilter
|
||||||
try:
|
try:
|
||||||
log.destroy.debug("Removing eventfilter...")
|
log.destroy.debug("Removing eventfilter...")
|
||||||
self.removeEventFilter(self.registry['modeman'])
|
self.removeEventFilter(self.registry['mode-manager'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# Close all tabs
|
# Close all tabs
|
||||||
try:
|
try:
|
||||||
log.destroy.debug("Closing tabs...")
|
log.destroy.debug("Closing tabs...")
|
||||||
self.registry['tabbedbrowser'].shutdown()
|
self.registry['tabbed-browser'].shutdown()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# Save everything
|
# Save everything
|
||||||
@ -773,31 +773,31 @@ class Application(QApplication):
|
|||||||
if config.get('general', 'auto-save-config'):
|
if config.get('general', 'auto-save-config'):
|
||||||
to_save.append(("config", config_obj.save))
|
to_save.append(("config", config_obj.save))
|
||||||
try:
|
try:
|
||||||
keyconfig = self.registry['keyconfig']
|
key_config = self.registry['key-config']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
to_save.append(("keyconfig", keyconfig.save))
|
to_save.append(("keyconfig", key_config.save))
|
||||||
to_save += [("window geometry", self._save_geometry),
|
to_save += [("window geometry", self._save_geometry),
|
||||||
("quickmarks", quickmarks.save)]
|
("quickmarks", quickmarks.save)]
|
||||||
try:
|
try:
|
||||||
cmd_history = self.registry['cmd_history']
|
command_history = self.registry['command-history']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
to_save.append(("command history", cmd_history.save))
|
to_save.append(("command history", command_history.save))
|
||||||
try:
|
try:
|
||||||
stateconfig = self.registry['stateconfig']
|
state_config = self.registry['state-config']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
to_save.append(("window geometry", stateconfig.save))
|
to_save.append(("window geometry", state_config.save))
|
||||||
try:
|
try:
|
||||||
cookiejar = self.registry['cookiejar']
|
cookie_jar = self.registry['cookie-jar']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
to_save.append(("cookies", cookiejar.save))
|
to_save.append(("cookies", cookie_jar.save))
|
||||||
for what, handler in to_save:
|
for what, handler in to_save:
|
||||||
log.destroy.debug("Saving {} (handler: {})".format(
|
log.destroy.debug("Saving {} (handler: {})".format(
|
||||||
what, handler.__qualname__))
|
what, handler.__qualname__))
|
||||||
|
@ -363,7 +363,7 @@ class DownloadManager(QObject):
|
|||||||
reply = page.networkAccessManager().get(req)
|
reply = page.networkAccessManager().get(req)
|
||||||
self.fetch(reply)
|
self.fetch(reply)
|
||||||
|
|
||||||
@cmdutils.register(instance='downloadmanager')
|
@cmdutils.register(instance='download-manager')
|
||||||
def cancel_download(self, count=1):
|
def cancel_download(self, count=1):
|
||||||
"""Cancel the first/[count]th download.
|
"""Cancel the first/[count]th download.
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ class DownloadManager(QObject):
|
|||||||
q.destroyed.connect(functools.partial(self.questions.remove, q))
|
q.destroyed.connect(functools.partial(self.questions.remove, q))
|
||||||
self.questions.append(q)
|
self.questions.append(q)
|
||||||
download.cancelled.connect(q.abort)
|
download.cancelled.connect(q.abort)
|
||||||
utils.get_object('messagebridge').ask(q, blocking=False)
|
utils.get_object('message-bridge').ask(q, blocking=False)
|
||||||
|
|
||||||
@pyqtSlot(DownloadItem)
|
@pyqtSlot(DownloadItem)
|
||||||
def on_finished(self, download):
|
def on_finished(self, download):
|
||||||
|
@ -149,8 +149,8 @@ class HintManager(QObject):
|
|||||||
"""
|
"""
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._context = None
|
self._context = None
|
||||||
utils.get_object('modeman').left.connect(self.on_mode_left)
|
utils.get_object('mode-manager').left.connect(self.on_mode_left)
|
||||||
utils.get_object('modeman').entered.connect(self.on_mode_entered)
|
utils.get_object('mode-manager').entered.connect(self.on_mode_entered)
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
"""Clean up after hinting."""
|
"""Clean up after hinting."""
|
||||||
@ -160,7 +160,7 @@ class HintManager(QObject):
|
|||||||
except webelem.IsNullError:
|
except webelem.IsNullError:
|
||||||
pass
|
pass
|
||||||
text = self.HINT_TEXTS[self._context.target]
|
text = self.HINT_TEXTS[self._context.target]
|
||||||
utils.get_object('messagebridge').maybe_reset_text(text)
|
utils.get_object('message-bridge').maybe_reset_text(text)
|
||||||
self._context = None
|
self._context = None
|
||||||
|
|
||||||
def _hint_strings(self, elems):
|
def _hint_strings(self, elems):
|
||||||
@ -541,7 +541,7 @@ class HintManager(QObject):
|
|||||||
self._context.frames = webelem.get_child_frames(mainframe)
|
self._context.frames = webelem.get_child_frames(mainframe)
|
||||||
self._context.args = args
|
self._context.args = args
|
||||||
self._init_elements(mainframe, group)
|
self._init_elements(mainframe, group)
|
||||||
utils.get_object('messagebridge').set_text(self.HINT_TEXTS[target])
|
utils.get_object('message-bridge').set_text(self.HINT_TEXTS[target])
|
||||||
self._connect_frame_signals()
|
self._connect_frame_signals()
|
||||||
try:
|
try:
|
||||||
modeman.enter(usertypes.KeyMode.hint, 'HintManager.start')
|
modeman.enter(usertypes.KeyMode.hint, 'HintManager.start')
|
||||||
|
@ -54,7 +54,7 @@ class HelpAction(argparse.Action):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(self, parser, _namespace, _values, _option_string=None):
|
def __call__(self, parser, _namespace, _values, _option_string=None):
|
||||||
utils.get_object('tabbedbrowser').tabopen(
|
utils.get_object('tabbed-browser').tabopen(
|
||||||
QUrl('qute://help/commands.html#{}'.format(parser.name)))
|
QUrl('qute://help/commands.html#{}'.format(parser.name)))
|
||||||
parser.exit()
|
parser.exit()
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class Command:
|
|||||||
Raise:
|
Raise:
|
||||||
PrerequisitesError if the command can't be called currently.
|
PrerequisitesError if the command can't be called currently.
|
||||||
"""
|
"""
|
||||||
curmode = utils.get_object('modeman').mode()
|
curmode = utils.get_object('mode-manager').mode()
|
||||||
if self.modes is not None and curmode not in self.modes:
|
if self.modes is not None and curmode not in self.modes:
|
||||||
mode_names = '/'.join(mode.name for mode in self.modes)
|
mode_names = '/'.join(mode.name for mode in self.modes)
|
||||||
raise cmdexc.PrerequisitesError(
|
raise cmdexc.PrerequisitesError(
|
||||||
|
@ -32,7 +32,7 @@ def replace_variables(arglist):
|
|||||||
args = []
|
args = []
|
||||||
for arg in arglist:
|
for arg in arglist:
|
||||||
if arg == '{url}':
|
if arg == '{url}':
|
||||||
url = utils.get_object('tabbedbrowser').current_url().toString(
|
url = utils.get_object('tabbed-browser').current_url().toString(
|
||||||
QUrl.FullyEncoded | QUrl.RemovePassword)
|
QUrl.FullyEncoded | QUrl.RemovePassword)
|
||||||
args.append(url)
|
args.append(url)
|
||||||
else:
|
else:
|
||||||
@ -114,7 +114,7 @@ class SearchRunner(QObject):
|
|||||||
"""
|
"""
|
||||||
self._search(text, rev=True)
|
self._search(text, rev=True)
|
||||||
|
|
||||||
@cmdutils.register(instance='searchrunner', hide=True)
|
@cmdutils.register(instance='search-runner', hide=True)
|
||||||
def search_next(self, count=1):
|
def search_next(self, count=1):
|
||||||
"""Continue the search to the ([count]th) next term.
|
"""Continue the search to the ([count]th) next term.
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class SearchRunner(QObject):
|
|||||||
for _ in range(count):
|
for _ in range(count):
|
||||||
self.do_search.emit(self._text, self._flags)
|
self.do_search.emit(self._text, self._flags)
|
||||||
|
|
||||||
@cmdutils.register(instance='searchrunner', hide=True)
|
@cmdutils.register(instance='search-runner', hide=True)
|
||||||
def search_prev(self, count=1):
|
def search_prev(self, count=1):
|
||||||
"""Continue the search to the ([count]th) previous term.
|
"""Continue the search to the ([count]th) previous term.
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class KeyConfigParser(QObject):
|
|||||||
with open(self._configfile, 'w', encoding='utf-8') as f:
|
with open(self._configfile, 'w', encoding='utf-8') as f:
|
||||||
f.write(str(self))
|
f.write(str(self))
|
||||||
|
|
||||||
@cmdutils.register(instance='keyconfig')
|
@cmdutils.register(instance='key-config')
|
||||||
def bind(self, key, *command, mode=None):
|
def bind(self, key, *command, mode=None):
|
||||||
"""Bind a key to a command.
|
"""Bind a key to a command.
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class KeyConfigParser(QObject):
|
|||||||
for m in mode.split(','):
|
for m in mode.split(','):
|
||||||
self.changed.emit(m)
|
self.changed.emit(m)
|
||||||
|
|
||||||
@cmdutils.register(instance='keyconfig')
|
@cmdutils.register(instance='key-config')
|
||||||
def unbind(self, key, mode=None):
|
def unbind(self, key, mode=None):
|
||||||
"""Unbind a keychain.
|
"""Unbind a keychain.
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class BaseKeyParser(QObject):
|
|||||||
self._modename = modename
|
self._modename = modename
|
||||||
self.bindings = {}
|
self.bindings = {}
|
||||||
self.special_bindings = {}
|
self.special_bindings = {}
|
||||||
keyconfparser = utils.get_object('keyconfig')
|
keyconfparser = utils.get_object('key-config')
|
||||||
for (key, cmd) in keyconfparser.get_bindings_for(modename).items():
|
for (key, cmd) in keyconfparser.get_bindings_for(modename).items():
|
||||||
if not cmd:
|
if not cmd:
|
||||||
continue
|
continue
|
||||||
|
@ -39,18 +39,18 @@ class ModeLockedError(Exception):
|
|||||||
|
|
||||||
def enter(mode, reason=None):
|
def enter(mode, reason=None):
|
||||||
"""Enter the mode 'mode'."""
|
"""Enter the mode 'mode'."""
|
||||||
utils.get_object('modeman').enter(mode, reason)
|
utils.get_object('mode-manager').enter(mode, reason)
|
||||||
|
|
||||||
|
|
||||||
def leave(mode, reason=None):
|
def leave(mode, reason=None):
|
||||||
"""Leave the mode 'mode'."""
|
"""Leave the mode 'mode'."""
|
||||||
utils.get_object('modeman').leave(mode, reason)
|
utils.get_object('mode-manager').leave(mode, reason)
|
||||||
|
|
||||||
|
|
||||||
def maybe_enter(mode, reason=None):
|
def maybe_enter(mode, reason=None):
|
||||||
"""Convenience method to enter 'mode' without exceptions."""
|
"""Convenience method to enter 'mode' without exceptions."""
|
||||||
try:
|
try:
|
||||||
utils.get_object('modeman').enter(mode, reason)
|
utils.get_object('mode-manager').enter(mode, reason)
|
||||||
except ModeLockedError:
|
except ModeLockedError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ def maybe_enter(mode, reason=None):
|
|||||||
def maybe_leave(mode, reason=None):
|
def maybe_leave(mode, reason=None):
|
||||||
"""Convenience method to leave 'mode' without exceptions."""
|
"""Convenience method to leave 'mode' without exceptions."""
|
||||||
try:
|
try:
|
||||||
utils.get_object('modeman').leave(mode, reason)
|
utils.get_object('mode-manager').leave(mode, reason)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
# This is rather likely to happen, so we only log to debug log.
|
# This is rather likely to happen, so we only log to debug log.
|
||||||
log.modes.debug(e)
|
log.modes.debug(e)
|
||||||
@ -212,7 +212,7 @@ class ModeManager(QObject):
|
|||||||
log.modes.debug("New mode stack: {}".format(self._mode_stack))
|
log.modes.debug("New mode stack: {}".format(self._mode_stack))
|
||||||
self.entered.emit(mode)
|
self.entered.emit(mode)
|
||||||
|
|
||||||
@cmdutils.register(instance='modeman', hide=True)
|
@cmdutils.register(instance='mode-manager', hide=True)
|
||||||
def enter_mode(self, mode):
|
def enter_mode(self, mode):
|
||||||
"""Enter a key mode.
|
"""Enter a key mode.
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ class ModeManager(QObject):
|
|||||||
self._mode_stack))
|
self._mode_stack))
|
||||||
self.left.emit(mode)
|
self.left.emit(mode)
|
||||||
|
|
||||||
@cmdutils.register(instance='modeman', name='leave-mode',
|
@cmdutils.register(instance='mode-manager', name='leave-mode',
|
||||||
not_modes=[usertypes.KeyMode.normal], hide=True)
|
not_modes=[usertypes.KeyMode.normal], hide=True)
|
||||||
def leave_current_mode(self):
|
def leave_current_mode(self):
|
||||||
"""Leave the mode we're currently in."""
|
"""Leave the mode we're currently in."""
|
||||||
@ -283,7 +283,7 @@ class ModeManager(QObject):
|
|||||||
# we're not interested in it anymore.
|
# we're not interested in it anymore.
|
||||||
return False
|
return False
|
||||||
if (QApplication.instance().activeWindow() is not
|
if (QApplication.instance().activeWindow() is not
|
||||||
utils.get_object('mainwindow')):
|
utils.get_object('main-window')):
|
||||||
# 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
|
||||||
|
@ -39,14 +39,14 @@ class DownloadModel(QAbstractListModel):
|
|||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
downloadmanager = utils.get_object('downloadmanager')
|
download_manager = utils.get_object('download-manager')
|
||||||
downloadmanager.download_about_to_be_added.connect(
|
download_manager.download_about_to_be_added.connect(
|
||||||
lambda idx: self.beginInsertRows(QModelIndex(), idx, idx))
|
lambda idx: self.beginInsertRows(QModelIndex(), idx, idx))
|
||||||
downloadmanager.download_added.connect(self.endInsertRows)
|
download_manager.download_added.connect(self.endInsertRows)
|
||||||
downloadmanager.download_about_to_be_finished.connect(
|
download_manager.download_about_to_be_finished.connect(
|
||||||
lambda idx: self.beginRemoveRows(QModelIndex(), idx, idx))
|
lambda idx: self.beginRemoveRows(QModelIndex(), idx, idx))
|
||||||
downloadmanager.download_finished.connect(self.endRemoveRows)
|
download_manager.download_finished.connect(self.endRemoveRows)
|
||||||
downloadmanager.data_changed.connect(self.on_data_changed)
|
download_manager.data_changed.connect(self.on_data_changed)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{}>'.format(self.__class__.__name__)
|
return '<{}>'.format(self.__class__.__name__)
|
||||||
@ -81,7 +81,7 @@ class DownloadModel(QAbstractListModel):
|
|||||||
if index.parent().isValid() or index.column() != 0:
|
if index.parent().isValid() or index.column() != 0:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
item = utils.get_object('downloadmanager').downloads[index.row()]
|
item = utils.get_object('download-manager').downloads[index.row()]
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
data = str(item)
|
data = str(item)
|
||||||
elif role == Qt.ForegroundRole:
|
elif role == Qt.ForegroundRole:
|
||||||
@ -105,4 +105,4 @@ class DownloadModel(QAbstractListModel):
|
|||||||
if parent.isValid():
|
if parent.isValid():
|
||||||
# We don't have children
|
# We don't have children
|
||||||
return 0
|
return 0
|
||||||
return len(utils.get_object('downloadmanager').downloads)
|
return len(utils.get_object('download-manager').downloads)
|
||||||
|
@ -55,9 +55,9 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
# We have a shared cookie jar and cache - we restore their parents so
|
# We have a shared cookie jar and cache - we restore their parents so
|
||||||
# we don't take ownership of them.
|
# we don't take ownership of them.
|
||||||
app = QCoreApplication.instance()
|
app = QCoreApplication.instance()
|
||||||
cookiejar = utils.get_object('cookiejar')
|
cookie_jar = utils.get_object('cookie-jar')
|
||||||
self.setCookieJar(cookiejar)
|
self.setCookieJar(cookie_jar)
|
||||||
cookiejar.setParent(app)
|
cookie_jar.setParent(app)
|
||||||
cache = utils.get_object('cache')
|
cache = utils.get_object('cache')
|
||||||
self.setCache(cache)
|
self.setCache(cache)
|
||||||
cache.setParent(app)
|
cache.setParent(app)
|
||||||
|
@ -30,7 +30,7 @@ def error(message, immediately=False):
|
|||||||
Args:
|
Args:
|
||||||
See MessageBridge.error.
|
See MessageBridge.error.
|
||||||
"""
|
"""
|
||||||
utils.get_object('messagebridge').error(message, immediately)
|
utils.get_object('message-bridge').error(message, immediately)
|
||||||
|
|
||||||
|
|
||||||
def info(message, immediately=True):
|
def info(message, immediately=True):
|
||||||
@ -39,12 +39,12 @@ def info(message, immediately=True):
|
|||||||
Args:
|
Args:
|
||||||
See MessageBridge.info.
|
See MessageBridge.info.
|
||||||
"""
|
"""
|
||||||
utils.get_object('messagebridge').info(message, immediately)
|
utils.get_object('message-bridge').info(message, immediately)
|
||||||
|
|
||||||
|
|
||||||
def set_cmd_text(txt):
|
def set_cmd_text(txt):
|
||||||
"""Convienience function to Set the statusbar command line to a text."""
|
"""Convienience function to Set the statusbar command line to a text."""
|
||||||
utils.get_object('messagebridge').set_cmd_text(txt)
|
utils.get_object('message-bridge').set_cmd_text(txt)
|
||||||
|
|
||||||
|
|
||||||
def ask(message, mode, default=None):
|
def ask(message, mode, default=None):
|
||||||
@ -62,7 +62,7 @@ def ask(message, mode, default=None):
|
|||||||
q.text = message
|
q.text = message
|
||||||
q.mode = mode
|
q.mode = mode
|
||||||
q.default = default
|
q.default = default
|
||||||
utils.get_object('messagebridge').ask(q, blocking=True)
|
utils.get_object('message-bridge').ask(q, blocking=True)
|
||||||
q.deleteLater()
|
q.deleteLater()
|
||||||
return q.answer
|
return q.answer
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ def alert(message):
|
|||||||
q = usertypes.Question()
|
q = usertypes.Question()
|
||||||
q.text = message
|
q.text = message
|
||||||
q.mode = usertypes.PromptMode.alert
|
q.mode = usertypes.PromptMode.alert
|
||||||
utils.get_object('messagebridge').ask(q, blocking=True)
|
utils.get_object('message-bridge').ask(q, blocking=True)
|
||||||
q.deleteLater()
|
q.deleteLater()
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ def ask_async(message, mode, handler, default=None):
|
|||||||
"""
|
"""
|
||||||
if not isinstance(mode, usertypes.PromptMode):
|
if not isinstance(mode, usertypes.PromptMode):
|
||||||
raise TypeError("Mode {} is no PromptMode member!".format(mode))
|
raise TypeError("Mode {} is no PromptMode member!".format(mode))
|
||||||
bridge = utils.get_object('messagebridge')
|
bridge = utils.get_object('message-bridge')
|
||||||
q = usertypes.Question(bridge)
|
q = usertypes.Question(bridge)
|
||||||
q.text = message
|
q.text = message
|
||||||
q.mode = mode
|
q.mode = mode
|
||||||
@ -106,7 +106,7 @@ def confirm_async(message, yes_action, no_action=None, default=None):
|
|||||||
no_action: Callable to be called when the user answered no.
|
no_action: Callable to be called when the user answered no.
|
||||||
default: True/False to set a default value, or None.
|
default: True/False to set a default value, or None.
|
||||||
"""
|
"""
|
||||||
bridge = utils.get_object('messagebridge')
|
bridge = utils.get_object('message-bridge')
|
||||||
q = usertypes.Question(bridge)
|
q = usertypes.Question(bridge)
|
||||||
q.text = message
|
q.text = message
|
||||||
q.mode = usertypes.PromptMode.yesno
|
q.mode = usertypes.PromptMode.yesno
|
||||||
|
@ -44,7 +44,7 @@ class ReadlineBridge:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_backward_char(self):
|
def rl_backward_char(self):
|
||||||
"""Move back a character.
|
"""Move back a character.
|
||||||
@ -56,7 +56,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.cursorBackward(False)
|
widget.cursorBackward(False)
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_forward_char(self):
|
def rl_forward_char(self):
|
||||||
"""Move forward a character.
|
"""Move forward a character.
|
||||||
@ -68,7 +68,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.cursorForward(False)
|
widget.cursorForward(False)
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_backward_word(self):
|
def rl_backward_word(self):
|
||||||
"""Move back to the start of the current or previous word.
|
"""Move back to the start of the current or previous word.
|
||||||
@ -80,7 +80,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.cursorWordBackward(False)
|
widget.cursorWordBackward(False)
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_forward_word(self):
|
def rl_forward_word(self):
|
||||||
"""Move forward to the end of the next word.
|
"""Move forward to the end of the next word.
|
||||||
@ -92,7 +92,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.cursorWordForward(False)
|
widget.cursorWordForward(False)
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_beginning_of_line(self):
|
def rl_beginning_of_line(self):
|
||||||
"""Move to the start of the line.
|
"""Move to the start of the line.
|
||||||
@ -104,7 +104,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.home(False)
|
widget.home(False)
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_end_of_line(self):
|
def rl_end_of_line(self):
|
||||||
"""Move to the end of the line.
|
"""Move to the end of the line.
|
||||||
@ -116,7 +116,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.end(False)
|
widget.end(False)
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_unix_line_discard(self):
|
def rl_unix_line_discard(self):
|
||||||
"""Remove chars backward from the cursor to the beginning of the line.
|
"""Remove chars backward from the cursor to the beginning of the line.
|
||||||
@ -130,7 +130,7 @@ class ReadlineBridge:
|
|||||||
self.deleted[widget] = widget.selectedText()
|
self.deleted[widget] = widget.selectedText()
|
||||||
widget.del_()
|
widget.del_()
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_kill_line(self):
|
def rl_kill_line(self):
|
||||||
"""Remove chars from the cursor to the end of the line.
|
"""Remove chars from the cursor to the end of the line.
|
||||||
@ -144,7 +144,7 @@ class ReadlineBridge:
|
|||||||
self.deleted[widget] = widget.selectedText()
|
self.deleted[widget] = widget.selectedText()
|
||||||
widget.del_()
|
widget.del_()
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_unix_word_rubout(self):
|
def rl_unix_word_rubout(self):
|
||||||
"""Remove chars from the cursor to the beginning of the word.
|
"""Remove chars from the cursor to the beginning of the word.
|
||||||
@ -158,7 +158,7 @@ class ReadlineBridge:
|
|||||||
self.deleted[widget] = widget.selectedText()
|
self.deleted[widget] = widget.selectedText()
|
||||||
widget.del_()
|
widget.del_()
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_kill_word(self):
|
def rl_kill_word(self):
|
||||||
"""Remove chars from the cursor to the end of the current word.
|
"""Remove chars from the cursor to the end of the current word.
|
||||||
@ -172,7 +172,7 @@ class ReadlineBridge:
|
|||||||
self.deleted[widget] = widget.selectedText()
|
self.deleted[widget] = widget.selectedText()
|
||||||
widget.del_()
|
widget.del_()
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_yank(self):
|
def rl_yank(self):
|
||||||
"""Paste the most recently deleted text.
|
"""Paste the most recently deleted text.
|
||||||
@ -184,7 +184,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.insert(self.deleted[widget])
|
widget.insert(self.deleted[widget])
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_delete_char(self):
|
def rl_delete_char(self):
|
||||||
"""Delete the character after the cursor.
|
"""Delete the character after the cursor.
|
||||||
@ -196,7 +196,7 @@ class ReadlineBridge:
|
|||||||
return
|
return
|
||||||
widget.del_()
|
widget.del_()
|
||||||
|
|
||||||
@cmdutils.register(instance='rl_bridge', hide=True,
|
@cmdutils.register(instance='readline-bridge', hide=True,
|
||||||
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
modes=[typ.KeyMode.command, typ.KeyMode.prompt])
|
||||||
def rl_backward_delete_char(self):
|
def rl_backward_delete_char(self):
|
||||||
"""Delete the character before the cursor.
|
"""Delete the character before the cursor.
|
||||||
|
@ -390,10 +390,6 @@ class ObjectRegistry(collections.UserDict):
|
|||||||
"""A registry of long-living objects in qutebrowser.
|
"""A registry of long-living objects in qutebrowser.
|
||||||
|
|
||||||
Inspired by the eric IDE code (E5Gui/E5Application.py).
|
Inspired by the eric IDE code (E5Gui/E5Application.py).
|
||||||
|
|
||||||
Objects registered globally:
|
|
||||||
cookiejar: CookieJar instance.
|
|
||||||
cache: DiskCache instance.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __setitem__(self, name, obj):
|
def __setitem__(self, name, obj):
|
||||||
|
@ -42,7 +42,7 @@ class MainWindow(QWidget):
|
|||||||
Attributes:
|
Attributes:
|
||||||
status: The StatusBar widget.
|
status: The StatusBar widget.
|
||||||
downloadview: The DownloadView widget.
|
downloadview: The DownloadView widget.
|
||||||
_tabbedbrowser: The TabbedBrowser widget.
|
_tabbed_browser: The TabbedBrowser widget.
|
||||||
_vbox: The main QVBoxLayout.
|
_vbox: The main QVBoxLayout.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ class MainWindow(QWidget):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.setWindowTitle('qutebrowser')
|
self.setWindowTitle('qutebrowser')
|
||||||
stateconf = utils.get_object('stateconfig')
|
state_config = utils.get_object('state-config')
|
||||||
try:
|
try:
|
||||||
data = stateconf['geometry']['mainwindow']
|
data = state_config['geometry']['mainwindow']
|
||||||
log.init.debug("Restoring mainwindow from {}".format(data))
|
log.init.debug("Restoring mainwindow from {}".format(data))
|
||||||
geom = base64.b64decode(data, validate=True)
|
geom = base64.b64decode(data, validate=True)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -81,10 +81,10 @@ class MainWindow(QWidget):
|
|||||||
self._vbox.addWidget(self.downloadview)
|
self._vbox.addWidget(self.downloadview)
|
||||||
self.downloadview.show()
|
self.downloadview.show()
|
||||||
|
|
||||||
self._tabbedbrowser = tabbedbrowser.TabbedBrowser()
|
self._tabbed_browser = tabbedbrowser.TabbedBrowser()
|
||||||
self._tabbedbrowser.title_changed.connect(self.setWindowTitle)
|
self._tabbed_browser.title_changed.connect(self.setWindowTitle)
|
||||||
utils.register_object('tabbedbrowser', self._tabbedbrowser)
|
utils.register_object('tabbed-browser', self._tabbed_browser)
|
||||||
self._vbox.addWidget(self._tabbedbrowser)
|
self._vbox.addWidget(self._tabbed_browser)
|
||||||
|
|
||||||
self._completion = completion.CompletionView(self)
|
self._completion = completion.CompletionView(self)
|
||||||
utils.register_object('completion', self._completion)
|
utils.register_object('completion', self._completion)
|
||||||
@ -145,7 +145,7 @@ class MainWindow(QWidget):
|
|||||||
if rect.isValid():
|
if rect.isValid():
|
||||||
self._completion.setGeometry(rect)
|
self._completion.setGeometry(rect)
|
||||||
|
|
||||||
@cmdutils.register(instance='mainwindow', name=['quit', 'q'])
|
@cmdutils.register(instance='main-window', name=['quit', 'q'])
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Quit qutebrowser.
|
"""Quit qutebrowser.
|
||||||
|
|
||||||
@ -164,12 +164,12 @@ class MainWindow(QWidget):
|
|||||||
super().resizeEvent(e)
|
super().resizeEvent(e)
|
||||||
self.resize_completion()
|
self.resize_completion()
|
||||||
self.downloadview.updateGeometry()
|
self.downloadview.updateGeometry()
|
||||||
self._tabbedbrowser.tabBar().refresh()
|
self._tabbed_browser.tabBar().refresh()
|
||||||
|
|
||||||
def closeEvent(self, e):
|
def closeEvent(self, e):
|
||||||
"""Override closeEvent to display a confirmation if needed."""
|
"""Override closeEvent to display a confirmation if needed."""
|
||||||
confirm_quit = config.get('ui', 'confirm-quit')
|
confirm_quit = config.get('ui', 'confirm-quit')
|
||||||
count = self._tabbedbrowser.count()
|
count = self._tabbed_browser.count()
|
||||||
if confirm_quit == 'never':
|
if confirm_quit == 'never':
|
||||||
e.accept()
|
e.accept()
|
||||||
elif confirm_quit == 'multiple-tabs' and count <= 1:
|
elif confirm_quit == 'multiple-tabs' and count <= 1:
|
||||||
|
@ -133,7 +133,7 @@ class StatusBar(QWidget):
|
|||||||
self._stack.setContentsMargins(0, 0, 0, 0)
|
self._stack.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
||||||
self._cmd = command.Command()
|
self._cmd = command.Command()
|
||||||
utils.register_object('status-cmd', self._cmd)
|
utils.register_object('status-command', self._cmd)
|
||||||
self._stack.addWidget(self._cmd)
|
self._stack.addWidget(self._cmd)
|
||||||
|
|
||||||
self.txt = textwidget.Text()
|
self.txt = textwidget.Text()
|
||||||
@ -377,7 +377,7 @@ class StatusBar(QWidget):
|
|||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def on_mode_entered(self, mode):
|
def on_mode_entered(self, mode):
|
||||||
"""Mark certain modes in the commandline."""
|
"""Mark certain modes in the commandline."""
|
||||||
if mode in utils.get_object('modeman').passthrough:
|
if mode in utils.get_object('mode-manager').passthrough:
|
||||||
text = "-- {} MODE --".format(mode.name.upper())
|
text = "-- {} MODE --".format(mode.name.upper())
|
||||||
self.txt.set_text(self.txt.Text.normal, text)
|
self.txt.set_text(self.txt.Text.normal, text)
|
||||||
if mode == usertypes.KeyMode.insert:
|
if mode == usertypes.KeyMode.insert:
|
||||||
@ -386,7 +386,7 @@ class StatusBar(QWidget):
|
|||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Clear marked mode."""
|
"""Clear marked mode."""
|
||||||
if mode in utils.get_object('modeman').passthrough:
|
if mode in utils.get_object('mode-manager').passthrough:
|
||||||
self.txt.set_text(self.txt.Text.normal, '')
|
self.txt.set_text(self.txt.Text.normal, '')
|
||||||
if mode == usertypes.KeyMode.insert:
|
if mode == usertypes.KeyMode.insert:
|
||||||
self._set_insert_active(False)
|
self._set_insert_active(False)
|
||||||
|
@ -74,7 +74,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
misc.CommandLineEdit.__init__(self, parent)
|
misc.CommandLineEdit.__init__(self, parent)
|
||||||
misc.MinimalLineEditMixin.__init__(self)
|
misc.MinimalLineEditMixin.__init__(self)
|
||||||
self.cursor_part = 0
|
self.cursor_part = 0
|
||||||
self.history.history = utils.get_object('cmd_history').data
|
self.history.history = utils.get_object('command-history').data
|
||||||
self._empty_item_idx = None
|
self._empty_item_idx = None
|
||||||
self.textEdited.connect(self.on_text_edited)
|
self.textEdited.connect(self.on_text_edited)
|
||||||
self.cursorPositionChanged.connect(self._update_cursor_part)
|
self.cursorPositionChanged.connect(self._update_cursor_part)
|
||||||
@ -160,7 +160,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
self.setFocus()
|
self.setFocus()
|
||||||
self.show_cmd.emit()
|
self.show_cmd.emit()
|
||||||
|
|
||||||
@cmdutils.register(instance='status-cmd', name='set-cmd-text')
|
@cmdutils.register(instance='status-command', name='set-cmd-text')
|
||||||
def set_cmd_text_command(self, text):
|
def set_cmd_text_command(self, text):
|
||||||
"""Preset the statusbar to some text.
|
"""Preset the statusbar to some text.
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
Args:
|
Args:
|
||||||
text: The commandline to set.
|
text: The commandline to set.
|
||||||
"""
|
"""
|
||||||
url = utils.get_object('tabbedbrowser').current_url().toString(
|
url = utils.get_object('tabbed-browser').current_url().toString(
|
||||||
QUrl.FullyEncoded | QUrl.RemovePassword)
|
QUrl.FullyEncoded | QUrl.RemovePassword)
|
||||||
# FIXME we currently replace the URL in any place in the arguments,
|
# FIXME we currently replace the URL in any place in the arguments,
|
||||||
# rather than just replacing it if it is a dedicated argument. We could
|
# rather than just replacing it if it is a dedicated argument. We could
|
||||||
@ -215,7 +215,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
self.setFocus()
|
self.setFocus()
|
||||||
self.show_cmd.emit()
|
self.show_cmd.emit()
|
||||||
|
|
||||||
@cmdutils.register(instance='status-cmd', hide=True,
|
@cmdutils.register(instance='status-command', hide=True,
|
||||||
modes=[usertypes.KeyMode.command])
|
modes=[usertypes.KeyMode.command])
|
||||||
def command_history_prev(self):
|
def command_history_prev(self):
|
||||||
"""Go back in the commandline history."""
|
"""Go back in the commandline history."""
|
||||||
@ -230,7 +230,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
if item:
|
if item:
|
||||||
self.set_cmd_text(item)
|
self.set_cmd_text(item)
|
||||||
|
|
||||||
@cmdutils.register(instance='status-cmd', hide=True,
|
@cmdutils.register(instance='status-command', hide=True,
|
||||||
modes=[usertypes.KeyMode.command])
|
modes=[usertypes.KeyMode.command])
|
||||||
def command_history_next(self):
|
def command_history_next(self):
|
||||||
"""Go forward in the commandline history."""
|
"""Go forward in the commandline history."""
|
||||||
@ -243,7 +243,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
if item:
|
if item:
|
||||||
self.set_cmd_text(item)
|
self.set_cmd_text(item)
|
||||||
|
|
||||||
@cmdutils.register(instance='status-cmd', hide=True,
|
@cmdutils.register(instance='status-command', hide=True,
|
||||||
modes=[usertypes.KeyMode.command])
|
modes=[usertypes.KeyMode.command])
|
||||||
def command_accept(self):
|
def command_accept(self):
|
||||||
"""Execute the command currently in the commandline.
|
"""Execute the command currently in the commandline.
|
||||||
|
@ -280,14 +280,14 @@ class Prompter:
|
|||||||
self.question = question
|
self.question = question
|
||||||
mode = self._display_question()
|
mode = self._display_question()
|
||||||
question.aborted.connect(lambda: modeman.maybe_leave(mode, 'aborted'))
|
question.aborted.connect(lambda: modeman.maybe_leave(mode, 'aborted'))
|
||||||
modeman_obj = utils.get_object('modeman')
|
mode_manager = utils.get_object('mode-manager')
|
||||||
try:
|
try:
|
||||||
modeman.enter(mode, 'question asked')
|
modeman.enter(mode, 'question asked')
|
||||||
except modeman.ModeLockedError:
|
except modeman.ModeLockedError:
|
||||||
if modeman_obj.mode() != usertypes.KeyMode.prompt:
|
if mode_manager.mode() != usertypes.KeyMode.prompt:
|
||||||
question.abort()
|
question.abort()
|
||||||
return None
|
return None
|
||||||
modeman_obj.locked = True
|
mode_manager.locked = True
|
||||||
if blocking:
|
if blocking:
|
||||||
loop = qtutils.EventLoop()
|
loop = qtutils.EventLoop()
|
||||||
self._loops.append(loop)
|
self._loops.append(loop)
|
||||||
|
@ -209,7 +209,7 @@ class TabBar(QTabBar):
|
|||||||
confwidth = str(config.get('tabs', 'width'))
|
confwidth = str(config.get('tabs', 'width'))
|
||||||
if confwidth.endswith('%'):
|
if confwidth.endswith('%'):
|
||||||
perc = int(confwidth.rstrip('%'))
|
perc = int(confwidth.rstrip('%'))
|
||||||
width = utils.get_object('mainwindow').width() * perc / 100
|
width = utils.get_object('main-window').width() * perc / 100
|
||||||
else:
|
else:
|
||||||
width = int(confwidth)
|
width = int(confwidth)
|
||||||
size = QSize(max(minimum_size.width(), width), height)
|
size = QSize(max(minimum_size.width(), width), height)
|
||||||
|
@ -358,8 +358,8 @@ class WebView(QWebView):
|
|||||||
self._set_load_status(LoadStatus.error)
|
self._set_load_status(LoadStatus.error)
|
||||||
if not config.get('input', 'auto-insert-mode'):
|
if not config.get('input', 'auto-insert-mode'):
|
||||||
return
|
return
|
||||||
if (utils.get_object('modeman').mode() == usertypes.KeyMode.insert or
|
cur_mode = utils.get_object('mode-manager').mode()
|
||||||
not ok):
|
if curmode == usertypes.KeyMode.insert or not ok:
|
||||||
return
|
return
|
||||||
frame = self.page().currentFrame()
|
frame = self.page().currentFrame()
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user