Start implementing config storage
This commit is contained in:
parent
da7a95d6ec
commit
7ed257467b
@ -5,7 +5,9 @@ from PyQt5.QtWidgets import QWidget, QApplication
|
|||||||
from PyQt5.QtCore import QUrl
|
from PyQt5.QtCore import QUrl
|
||||||
from qutebrowser.widgets.mainwindow import MainWindow
|
from qutebrowser.widgets.mainwindow import MainWindow
|
||||||
from qutebrowser.commands.keys import KeyParser
|
from qutebrowser.commands.keys import KeyParser
|
||||||
|
from qutebrowser.utils.config import Config
|
||||||
import qutebrowser.commands.utils as cmdutils
|
import qutebrowser.commands.utils as cmdutils
|
||||||
|
from qutebrowser.utils.appdirs import AppDirs
|
||||||
|
|
||||||
class QuteBrowser(QApplication):
|
class QuteBrowser(QApplication):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -13,6 +15,9 @@ class QuteBrowser(QApplication):
|
|||||||
args = self.parseopts()
|
args = self.parseopts()
|
||||||
self.initlog()
|
self.initlog()
|
||||||
|
|
||||||
|
self.dirs = AppDirs('qutebrowser')
|
||||||
|
self.config = Config(self.dirs.user_data_dir)
|
||||||
|
|
||||||
self.mainwindow = MainWindow()
|
self.mainwindow = MainWindow()
|
||||||
self.commandparser = cmdutils.CommandParser()
|
self.commandparser = cmdutils.CommandParser()
|
||||||
self.keyparser = KeyParser(self.mainwindow)
|
self.keyparser = KeyParser(self.mainwindow)
|
||||||
@ -54,7 +59,7 @@ class QuteBrowser(QApplication):
|
|||||||
cmds = cmdutils.cmd_dict
|
cmds = cmdutils.cmd_dict
|
||||||
for cmd in cmds.values():
|
for cmd in cmds.values():
|
||||||
cmd.signal.connect(self.cmd_handler)
|
cmd.signal.connect(self.cmd_handler)
|
||||||
self.keyparser.from_cmd_dict(cmdutils.cmd_dict)
|
self.keyparser.from_config_sect(self.config['keybind'])
|
||||||
|
|
||||||
def cmd_handler(self, tpl):
|
def cmd_handler(self, tpl):
|
||||||
(count, argv) = tpl
|
(count, argv) = tpl
|
||||||
@ -64,7 +69,7 @@ class QuteBrowser(QApplication):
|
|||||||
handlers = {
|
handlers = {
|
||||||
'open': self.mainwindow.tabs.openurl,
|
'open': self.mainwindow.tabs.openurl,
|
||||||
'tabopen': self.mainwindow.tabs.tabopen,
|
'tabopen': self.mainwindow.tabs.tabopen,
|
||||||
'quit': QApplication.closeAllWindows, # FIXME
|
'quit': self.exit,
|
||||||
'tabclose': self.mainwindow.tabs.close_act,
|
'tabclose': self.mainwindow.tabs.close_act,
|
||||||
'tabprev': self.mainwindow.tabs.switch_prev,
|
'tabprev': self.mainwindow.tabs.switch_prev,
|
||||||
'tabnext': self.mainwindow.tabs.switch_next,
|
'tabnext': self.mainwindow.tabs.switch_next,
|
||||||
@ -103,3 +108,7 @@ class QuteBrowser(QApplication):
|
|||||||
tab.setUrl(QUrl('about:pyeval'))
|
tab.setUrl(QUrl('about:pyeval'))
|
||||||
tab.setContent(out.encode('UTF-8'), 'text/plain')
|
tab.setContent(out.encode('UTF-8'), 'text/plain')
|
||||||
|
|
||||||
|
def exit(self, status=0):
|
||||||
|
self.config.save()
|
||||||
|
QApplication.closeAllWindows()
|
||||||
|
# FIXME do this right
|
||||||
|
@ -3,78 +3,63 @@ from qutebrowser.commands.utils import Command
|
|||||||
|
|
||||||
class Open(Command):
|
class Open(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
key = 'o'
|
|
||||||
split_args = False
|
split_args = False
|
||||||
|
|
||||||
class TabOpen(Command):
|
class TabOpen(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
key = 'O'
|
|
||||||
split_args = False
|
split_args = False
|
||||||
|
|
||||||
class TabClose(Command):
|
class TabClose(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'd'
|
|
||||||
|
|
||||||
class TabNext(Command):
|
class TabNext(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'J'
|
|
||||||
|
|
||||||
class TabPrev(Command):
|
class TabPrev(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'K'
|
|
||||||
|
|
||||||
class Quit(Command):
|
class Quit(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
|
|
||||||
class Reload(Command):
|
class Reload(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'r'
|
|
||||||
|
|
||||||
class Stop(Command):
|
class Stop(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
|
|
||||||
class Back(Command):
|
class Back(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'H'
|
|
||||||
|
|
||||||
class Forward(Command):
|
class Forward(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'L'
|
|
||||||
|
|
||||||
class Print(Command):
|
class Print(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
|
|
||||||
class ScrollLeft(Command):
|
class ScrollLeft(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'h'
|
|
||||||
count = True
|
count = True
|
||||||
|
|
||||||
class ScrollDown(Command):
|
class ScrollDown(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'j'
|
|
||||||
count = True
|
count = True
|
||||||
|
|
||||||
class ScrollUp(Command):
|
class ScrollUp(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'k'
|
|
||||||
count = True
|
count = True
|
||||||
|
|
||||||
class ScrollRight(Command):
|
class ScrollRight(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'l'
|
|
||||||
count = True
|
count = True
|
||||||
|
|
||||||
class Undo(Command):
|
class Undo(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'u'
|
|
||||||
|
|
||||||
class ScrollStart(Command):
|
class ScrollStart(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'gg'
|
|
||||||
|
|
||||||
class ScrollEnd(Command):
|
class ScrollEnd(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
key = 'G'
|
|
||||||
|
|
||||||
class PyEval(Command):
|
class PyEval(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from PyQt5.QtCore import QObject, Qt, pyqtSignal
|
from PyQt5.QtCore import QObject, Qt, pyqtSignal
|
||||||
from PyQt5.QtWidgets import QShortcut
|
from PyQt5.QtWidgets import QShortcut
|
||||||
from PyQt5.QtGui import QKeySequence
|
from PyQt5.QtGui import QKeySequence
|
||||||
|
import qutebrowser.commands.utils as cmdutils
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -10,11 +11,10 @@ class KeyParser(QObject):
|
|||||||
keystring_updated = pyqtSignal(str)
|
keystring_updated = pyqtSignal(str)
|
||||||
key_to_cmd = {}
|
key_to_cmd = {}
|
||||||
|
|
||||||
def from_cmd_dict(self, d):
|
def from_config_sect(self, sect):
|
||||||
for cmd in d.values():
|
for (key, cmd) in sect.items():
|
||||||
if cmd.key is not None:
|
logging.debug('registered: {} -> {}'.format(key, cmd))
|
||||||
logging.debug('registered: {} -> {}'.format(cmd.name, cmd.key))
|
self.key_to_cmd[key] = cmdutils.cmd_dict[cmd]
|
||||||
self.key_to_cmd[cmd.key] = cmd
|
|
||||||
|
|
||||||
def handle(self, e):
|
def handle(self, e):
|
||||||
self._handle(e)
|
self._handle(e)
|
||||||
|
@ -50,7 +50,6 @@ class CommandParser(QObject):
|
|||||||
class Command(QObject):
|
class Command(QObject):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
name = None
|
name = None
|
||||||
key = None
|
|
||||||
signal = None
|
signal = None
|
||||||
count = False
|
count = False
|
||||||
bind = True
|
bind = True
|
||||||
|
Loading…
Reference in New Issue
Block a user