pep8 fixes
This commit is contained in:
parent
9caebdda3b
commit
6f3a2448ba
@ -1 +1 @@
|
|||||||
|
"""A vim like browser based on Qt"""
|
||||||
|
@ -13,15 +13,16 @@ from qutebrowser.widgets.mainwindow import MainWindow
|
|||||||
from qutebrowser.commands.keys import KeyParser
|
from qutebrowser.commands.keys import KeyParser
|
||||||
from qutebrowser.utils.appdirs import AppDirs
|
from qutebrowser.utils.appdirs import AppDirs
|
||||||
|
|
||||||
|
|
||||||
class QuteBrowser(QApplication):
|
class QuteBrowser(QApplication):
|
||||||
"""Main object for QuteBrowser"""
|
"""Main object for QuteBrowser"""
|
||||||
dirs = None # AppDirs - config/cache directories
|
dirs = None # AppDirs - config/cache directories
|
||||||
config = None # Config(Parser) object
|
config = None # Config(Parser) object
|
||||||
mainwindow = None
|
mainwindow = None
|
||||||
commandparser = None
|
commandparser = None
|
||||||
keyparser = None
|
keyparser = None
|
||||||
args = None # ArgumentParser
|
args = None # ArgumentParser
|
||||||
timer = None # QTimer for python hacks
|
timer = None # QTimer for python hacks
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(sys.argv)
|
super().__init__(sys.argv)
|
||||||
@ -171,7 +172,7 @@ class QuteBrowser(QApplication):
|
|||||||
try:
|
try:
|
||||||
r = eval(s)
|
r = eval(s)
|
||||||
out = repr(r)
|
out = repr(r)
|
||||||
except Exception as e: # pylint: disable=broad-except
|
except Exception as e: # pylint: disable=broad-except
|
||||||
out = ': '.join([e.__class__.__name__, str(e)])
|
out = ': '.join([e.__class__.__name__, str(e)])
|
||||||
|
|
||||||
# FIXME we probably want some nicer interface to display these about:
|
# FIXME we probably want some nicer interface to display these about:
|
||||||
|
@ -19,79 +19,95 @@ A command class can set the following properties:
|
|||||||
|
|
||||||
from qutebrowser.commands.utils import Command
|
from qutebrowser.commands.utils import Command
|
||||||
|
|
||||||
|
|
||||||
class Open(Command):
|
class Open(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
split_args = False
|
split_args = False
|
||||||
desc = 'Open a page'
|
desc = 'Open a page'
|
||||||
|
|
||||||
|
|
||||||
class TabOpen(Command):
|
class TabOpen(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
split_args = False
|
split_args = False
|
||||||
desc = 'Open a page in a new tab'
|
desc = 'Open a page in a new tab'
|
||||||
|
|
||||||
|
|
||||||
class TabClose(Command):
|
class TabClose(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Close the current tab'
|
desc = 'Close the current tab'
|
||||||
# FIXME also close [count]th tab
|
# FIXME also close [count]th tab
|
||||||
|
|
||||||
|
|
||||||
class TabNext(Command):
|
class TabNext(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Switch to the next tab'
|
desc = 'Switch to the next tab'
|
||||||
# FIXME also support [count]
|
# FIXME also support [count]
|
||||||
|
|
||||||
|
|
||||||
class TabPrev(Command):
|
class TabPrev(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Switch to the previous tab'
|
desc = 'Switch to the previous tab'
|
||||||
# FIXME also support [count]
|
# FIXME also support [count]
|
||||||
|
|
||||||
|
|
||||||
class Quit(Command):
|
class Quit(Command):
|
||||||
name = ['quit', 'q']
|
name = ['quit', 'q']
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Quit qutebrowser'
|
desc = 'Quit qutebrowser'
|
||||||
|
|
||||||
|
|
||||||
class Reload(Command):
|
class Reload(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Reload the current page'
|
desc = 'Reload the current page'
|
||||||
|
|
||||||
|
|
||||||
class Stop(Command):
|
class Stop(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Stop loading the current page'
|
desc = 'Stop loading the current page'
|
||||||
|
|
||||||
|
|
||||||
class Back(Command):
|
class Back(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Go back one page in the history'
|
desc = 'Go back one page in the history'
|
||||||
# FIXME also support [count]
|
# FIXME also support [count]
|
||||||
|
|
||||||
|
|
||||||
class Forward(Command):
|
class Forward(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Go forward one page in the history'
|
desc = 'Go forward one page in the history'
|
||||||
# FIXME also support [count]
|
# FIXME also support [count]
|
||||||
|
|
||||||
|
|
||||||
class Print(Command):
|
class Print(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Print the current page'
|
desc = 'Print the current page'
|
||||||
|
|
||||||
|
|
||||||
class Scroll(Command):
|
class Scroll(Command):
|
||||||
nargs = 2
|
nargs = 2
|
||||||
count = True
|
count = True
|
||||||
hide = True
|
hide = True
|
||||||
|
|
||||||
|
|
||||||
class Undo(Command):
|
class Undo(Command):
|
||||||
nargs = 0
|
nargs = 0
|
||||||
desc = 'Undo closing a tab'
|
desc = 'Undo closing a tab'
|
||||||
|
|
||||||
|
|
||||||
class ScrollPercX(Command):
|
class ScrollPercX(Command):
|
||||||
nargs = '?'
|
nargs = '?'
|
||||||
count = True
|
count = True
|
||||||
hide = True
|
hide = True
|
||||||
name = 'scroll_perc_x'
|
name = 'scroll_perc_x'
|
||||||
|
|
||||||
|
|
||||||
class ScrollPercY(Command):
|
class ScrollPercY(Command):
|
||||||
nargs = '?'
|
nargs = '?'
|
||||||
count = True
|
count = True
|
||||||
hide = True
|
hide = True
|
||||||
name = 'scroll_perc_y'
|
name = 'scroll_perc_y'
|
||||||
|
|
||||||
|
|
||||||
class PyEval(Command):
|
class PyEval(Command):
|
||||||
nargs = 1
|
nargs = 1
|
||||||
split_args = False
|
split_args = False
|
||||||
|
@ -6,9 +6,10 @@ from PyQt5.QtCore import QObject, pyqtSignal
|
|||||||
from qutebrowser.commands.utils import (CommandParser, ArgumentCountError,
|
from qutebrowser.commands.utils import (CommandParser, ArgumentCountError,
|
||||||
NoSuchCommandError)
|
NoSuchCommandError)
|
||||||
|
|
||||||
|
|
||||||
class KeyParser(QObject):
|
class KeyParser(QObject):
|
||||||
"""Parser for vim-like key sequences"""
|
"""Parser for vim-like key sequences"""
|
||||||
keystring = '' # The currently entered key sequence
|
keystring = '' # The currently entered key sequence
|
||||||
# Signal emitted when the statusbar should set a partial command
|
# Signal emitted when the statusbar should set a partial command
|
||||||
set_cmd_text = pyqtSignal(str)
|
set_cmd_text = pyqtSignal(str)
|
||||||
# Signal emitted when the keystring is updated
|
# Signal emitted when the keystring is updated
|
||||||
|
@ -10,20 +10,23 @@ from qutebrowser.utils.completion import CompletionModel
|
|||||||
|
|
||||||
cmd_dict = {}
|
cmd_dict = {}
|
||||||
|
|
||||||
|
|
||||||
class ArgumentCountError(TypeError):
|
class ArgumentCountError(TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NoSuchCommandError(ValueError):
|
class NoSuchCommandError(ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def register_all():
|
def register_all():
|
||||||
"""Register and initialize all commands."""
|
"""Register and initialize all commands."""
|
||||||
# We do this here to avoid a circular import, since commands.commands
|
# We do this here to avoid a circular import, since commands.commands
|
||||||
# imports Command from this module.
|
# imports Command from this module.
|
||||||
import qutebrowser.commands
|
import qutebrowser.commands
|
||||||
for (name, cls) in inspect.getmembers( # pylint: disable=unused-variable
|
for (name, cls) in inspect.getmembers( # pylint: disable=unused-variable
|
||||||
qutebrowser.commands, (lambda o: inspect.isclass(o) and
|
qutebrowser.commands, (lambda o: inspect.isclass(o) and
|
||||||
o.__module__ == 'qutebrowser.commands')):
|
o.__module__ == 'qutebrowser.commands')):
|
||||||
obj = cls()
|
obj = cls()
|
||||||
if isinstance(obj.name, str):
|
if isinstance(obj.name, str):
|
||||||
names = [obj.name]
|
names = [obj.name]
|
||||||
@ -32,12 +35,13 @@ def register_all():
|
|||||||
for n in names:
|
for n in names:
|
||||||
cmd_dict[n] = obj
|
cmd_dict[n] = obj
|
||||||
|
|
||||||
|
|
||||||
class CommandParser(QObject):
|
class CommandParser(QObject):
|
||||||
"""Parser for qutebrowser commandline commands"""
|
"""Parser for qutebrowser commandline commands"""
|
||||||
text = ''
|
text = ''
|
||||||
cmd = ''
|
cmd = ''
|
||||||
args = []
|
args = []
|
||||||
error = pyqtSignal(str) # Emitted if there's an error
|
error = pyqtSignal(str) # Emitted if there's an error
|
||||||
|
|
||||||
def _parse(self, text):
|
def _parse(self, text):
|
||||||
"""Parses a command"""
|
"""Parses a command"""
|
||||||
@ -84,6 +88,7 @@ class CommandParser(QObject):
|
|||||||
raise
|
raise
|
||||||
self._run(count=count)
|
self._run(count=count)
|
||||||
|
|
||||||
|
|
||||||
class CommandCompletionModel(CompletionModel):
|
class CommandCompletionModel(CompletionModel):
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@ -96,6 +101,7 @@ class CommandCompletionModel(CompletionModel):
|
|||||||
self._data['Commands'] = sorted(cmdlist)
|
self._data['Commands'] = sorted(cmdlist)
|
||||||
self.init_data()
|
self.init_data()
|
||||||
|
|
||||||
|
|
||||||
class Command(QObject):
|
class Command(QObject):
|
||||||
"""Base skeleton for a command. See the module help for
|
"""Base skeleton for a command. See the module help for
|
||||||
qutebrowser.commands.commands for details.
|
qutebrowser.commands.commands for details.
|
||||||
@ -113,7 +119,7 @@ class Command(QObject):
|
|||||||
split_args = True
|
split_args = True
|
||||||
signal = pyqtSignal(tuple)
|
signal = pyqtSignal(tuple)
|
||||||
hide = False
|
hide = False
|
||||||
desc = "" # FIXME add descriptions everywhere
|
desc = "" # FIXME add descriptions everywhere
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -129,8 +135,8 @@ class Command(QObject):
|
|||||||
not.
|
not.
|
||||||
"""
|
"""
|
||||||
if ((isinstance(self.nargs, int) and len(args) != self.nargs) or
|
if ((isinstance(self.nargs, int) and len(args) != self.nargs) or
|
||||||
(self.nargs == '?' and len(args) > 1) or
|
(self.nargs == '?' and len(args) > 1) or
|
||||||
(self.nargs == '+' and len(args) < 1)):
|
(self.nargs == '+' and len(args) < 1)):
|
||||||
# for nargs == '*', anything is okay
|
# for nargs == '*', anything is okay
|
||||||
raise ArgumentCountError
|
raise ArgumentCountError
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from PyQt5.QtCore import QUrl
|
from PyQt5.QtCore import QUrl
|
||||||
|
|
||||||
|
|
||||||
def qurl(url):
|
def qurl(url):
|
||||||
if isinstance(url, QUrl):
|
if isinstance(url, QUrl):
|
||||||
return url
|
return url
|
||||||
|
@ -3,6 +3,7 @@ from collections import OrderedDict
|
|||||||
from PyQt5.QtCore import (QAbstractItemModel, Qt, QModelIndex, QVariant,
|
from PyQt5.QtCore import (QAbstractItemModel, Qt, QModelIndex, QVariant,
|
||||||
QSortFilterProxyModel, pyqtSignal)
|
QSortFilterProxyModel, pyqtSignal)
|
||||||
|
|
||||||
|
|
||||||
class CompletionModel(QAbstractItemModel):
|
class CompletionModel(QAbstractItemModel):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -110,6 +111,7 @@ class CompletionModel(QAbstractItemModel):
|
|||||||
newitem = CompletionItem(item, newcat)
|
newitem = CompletionItem(item, newcat)
|
||||||
newcat.children.append(newitem)
|
newcat.children.append(newitem)
|
||||||
|
|
||||||
|
|
||||||
class CompletionItem():
|
class CompletionItem():
|
||||||
parent = None
|
parent = None
|
||||||
_data = None
|
_data = None
|
||||||
@ -146,6 +148,7 @@ class CompletionItem():
|
|||||||
return self.parent.children.index(self)
|
return self.parent.children.index(self)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class CompletionFilterModel(QSortFilterProxyModel):
|
class CompletionFilterModel(QSortFilterProxyModel):
|
||||||
_pattern = None
|
_pattern = None
|
||||||
pattern_changed = pyqtSignal(str)
|
pattern_changed = pyqtSignal(str)
|
||||||
|
@ -60,6 +60,7 @@ _MONOSPACE = ['Monospace', 'DejaVu Sans Mono', 'Consolas', 'Monaco',
|
|||||||
|
|
||||||
MONOSPACE = ', '.join(_MONOSPACE)
|
MONOSPACE = ', '.join(_MONOSPACE)
|
||||||
|
|
||||||
|
|
||||||
def init(confdir):
|
def init(confdir):
|
||||||
global config, colordict
|
global config, colordict
|
||||||
config = Config(confdir)
|
config = Config(confdir)
|
||||||
@ -68,9 +69,11 @@ def init(confdir):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
colordict = ColorDict()
|
colordict = ColorDict()
|
||||||
|
|
||||||
|
|
||||||
def get_stylesheet(template):
|
def get_stylesheet(template):
|
||||||
return template.strip().format(color=colordict, monospace=MONOSPACE)
|
return template.strip().format(color=colordict, monospace=MONOSPACE)
|
||||||
|
|
||||||
|
|
||||||
class ColorDict(dict):
|
class ColorDict(dict):
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
try:
|
try:
|
||||||
@ -90,6 +93,7 @@ class ColorDict(dict):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Config(ConfigParser):
|
class Config(ConfigParser):
|
||||||
"""Our own ConfigParser"""
|
"""Our own ConfigParser"""
|
||||||
configdir = None
|
configdir = None
|
||||||
@ -98,7 +102,7 @@ class Config(ConfigParser):
|
|||||||
def __init__(self, configdir):
|
def __init__(self, configdir):
|
||||||
"""configdir: directory to store the config in"""
|
"""configdir: directory to store the config in"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.optionxform = lambda opt: opt # be case-insensitive
|
self.optionxform = lambda opt: opt # be case-insensitive
|
||||||
self.configdir = configdir
|
self.configdir = configdir
|
||||||
if self.configdir is None:
|
if self.configdir is None:
|
||||||
self.init_config()
|
self.init_config()
|
||||||
@ -115,7 +119,7 @@ class Config(ConfigParser):
|
|||||||
self.read_dict(default_config)
|
self.read_dict(default_config)
|
||||||
return
|
return
|
||||||
cp = ConfigParser()
|
cp = ConfigParser()
|
||||||
cp.optionxform = lambda opt: opt # be case-insensitive
|
cp.optionxform = lambda opt: opt # be case-insensitive
|
||||||
cp.read_dict(default_config)
|
cp.read_dict(default_config)
|
||||||
if not os.path.exists(self.configdir):
|
if not os.path.exists(self.configdir):
|
||||||
os.makedirs(self.configdir, 0o755)
|
os.makedirs(self.configdir, 0o755)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QShortcut
|
from PyQt5.QtWidgets import QShortcut
|
||||||
from PyQt5.QtCore import QUrl, pyqtSignal, Qt, QPoint, QEvent
|
from PyQt5.QtCore import QUrl, pyqtSignal, Qt, QEvent
|
||||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog
|
from PyQt5.QtPrintSupport import QPrintPreviewDialog
|
||||||
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||||
|
|
||||||
@ -9,18 +9,19 @@ import qutebrowser.utils as utils
|
|||||||
import qutebrowser.utils.config as config
|
import qutebrowser.utils.config as config
|
||||||
from qutebrowser.widgets.tabbar import TabWidget
|
from qutebrowser.widgets.tabbar import TabWidget
|
||||||
|
|
||||||
|
|
||||||
class TabbedBrowser(TabWidget):
|
class TabbedBrowser(TabWidget):
|
||||||
"""A TabWidget with QWebViews inside"""
|
"""A TabWidget with QWebViews inside"""
|
||||||
|
|
||||||
cur_progress = pyqtSignal(int) # Progress of the current tab changed
|
cur_progress = pyqtSignal(int) # Progress of the current tab changed
|
||||||
cur_load_started = pyqtSignal() # Current tab started loading
|
cur_load_started = pyqtSignal() # Current tab started loading
|
||||||
cur_load_finished = pyqtSignal(bool) # Current tab finished loading
|
cur_load_finished = pyqtSignal(bool) # Current tab finished loading
|
||||||
cur_statusbar_message = pyqtSignal(str) # Status bar message
|
cur_statusbar_message = pyqtSignal(str) # Status bar message
|
||||||
# FIXME we need to store this in our browser object
|
# FIXME we need to store this in our browser object
|
||||||
# Current tab changed scroll position
|
# Current tab changed scroll position
|
||||||
cur_scroll_perc_changed = pyqtSignal(int, int)
|
cur_scroll_perc_changed = pyqtSignal(int, int)
|
||||||
keypress = pyqtSignal('QKeyEvent')
|
keypress = pyqtSignal('QKeyEvent')
|
||||||
_url_stack = [] # Stack of URLs of closed tabs
|
_url_stack = [] # Stack of URLs of closed tabs
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -204,12 +205,13 @@ class TabbedBrowser(TabWidget):
|
|||||||
round(100 * y / m[1]) if m[1] != 0 else 0)
|
round(100 * y / m[1]) if m[1] != 0 else 0)
|
||||||
self.cur_scroll_perc_changed.emit(*perc)
|
self.cur_scroll_perc_changed.emit(*perc)
|
||||||
|
|
||||||
|
|
||||||
class BrowserTab(QWebView):
|
class BrowserTab(QWebView):
|
||||||
"""One browser tab in TabbedBrowser"""
|
"""One browser tab in TabbedBrowser"""
|
||||||
progress = 0
|
progress = 0
|
||||||
scroll_pos_changed = pyqtSignal(int, int)
|
scroll_pos_changed = pyqtSignal(int, int)
|
||||||
_scroll_pos = (-1, -1)
|
_scroll_pos = (-1, -1)
|
||||||
open_new_tab = False # open new tab for the next action
|
open_new_tab = False # open new tab for the next action
|
||||||
open_tab = pyqtSignal('QUrl')
|
open_tab = pyqtSignal('QUrl')
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
import html
|
import html
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (QTreeView, QStyledItemDelegate, QStyle,
|
from PyQt5.QtWidgets import (QTreeView, QStyledItemDelegate, QStyle,
|
||||||
@ -12,6 +11,7 @@ import qutebrowser.utils.config as config
|
|||||||
from qutebrowser.utils.completion import CompletionFilterModel
|
from qutebrowser.utils.completion import CompletionFilterModel
|
||||||
from qutebrowser.commands.utils import CommandCompletionModel
|
from qutebrowser.commands.utils import CommandCompletionModel
|
||||||
|
|
||||||
|
|
||||||
class CompletionView(QTreeView):
|
class CompletionView(QTreeView):
|
||||||
_stylesheet = """
|
_stylesheet = """
|
||||||
QTreeView {{
|
QTreeView {{
|
||||||
@ -72,7 +72,7 @@ class CompletionView(QTreeView):
|
|||||||
def resizeEvent(self, e):
|
def resizeEvent(self, e):
|
||||||
width = e.size().width()
|
width = e.size().width()
|
||||||
for i in range(self.model.columnCount()):
|
for i in range(self.model.columnCount()):
|
||||||
self.setColumnWidth(i, width/2)
|
self.setColumnWidth(i, width / 2)
|
||||||
super().resizeEvent(e)
|
super().resizeEvent(e)
|
||||||
|
|
||||||
def setmodel(self, model):
|
def setmodel(self, model):
|
||||||
@ -166,6 +166,7 @@ class CompletionView(QTreeView):
|
|||||||
# Item is a real item, not a category header -> success
|
# Item is a real item, not a category header -> success
|
||||||
return idx
|
return idx
|
||||||
|
|
||||||
|
|
||||||
class CompletionItemDelegate(QStyledItemDelegate):
|
class CompletionItemDelegate(QStyledItemDelegate):
|
||||||
opt = None
|
opt = None
|
||||||
style = None
|
style = None
|
||||||
@ -203,7 +204,6 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
|||||||
self.opt.icon.paint(self.painter, icon_rect,
|
self.opt.icon.paint(self.painter, icon_rect,
|
||||||
self.opt.decorationAlignment, mode, state)
|
self.opt.decorationAlignment, mode, state)
|
||||||
|
|
||||||
|
|
||||||
def _draw_text(self, index):
|
def _draw_text(self, index):
|
||||||
if not self.opt.text:
|
if not self.opt.text:
|
||||||
return
|
return
|
||||||
|
@ -4,6 +4,7 @@ from qutebrowser.widgets.statusbar import StatusBar
|
|||||||
from qutebrowser.widgets.browser import TabbedBrowser
|
from qutebrowser.widgets.browser import TabbedBrowser
|
||||||
from qutebrowser.widgets.completion import CompletionView
|
from qutebrowser.widgets.completion import CompletionView
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
"""The main window of QuteBrowser"""
|
"""The main window of QuteBrowser"""
|
||||||
cwidget = None
|
cwidget = None
|
||||||
@ -35,7 +36,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.tabs.cur_progress.connect(self.status.prog.set_progress)
|
self.tabs.cur_progress.connect(self.status.prog.set_progress)
|
||||||
self.tabs.cur_load_finished.connect(self.status.prog.load_finished)
|
self.tabs.cur_load_finished.connect(self.status.prog.load_finished)
|
||||||
self.tabs.cur_load_started.connect(lambda:
|
self.tabs.cur_load_started.connect(lambda:
|
||||||
self.status.prog.set_progress(0))
|
self.status.prog.set_progress(0))
|
||||||
self.tabs.cur_scroll_perc_changed.connect(self.status.txt.set_perc)
|
self.tabs.cur_scroll_perc_changed.connect(self.status.txt.set_perc)
|
||||||
self.tabs.cur_statusbar_message.connect(self.status.txt.set_text)
|
self.tabs.cur_statusbar_message.connect(self.status.txt.set_text)
|
||||||
self.status.cmd.esc_pressed.connect(self.tabs.setFocus)
|
self.status.cmd.esc_pressed.connect(self.tabs.setFocus)
|
||||||
@ -47,4 +48,3 @@ class MainWindow(QMainWindow):
|
|||||||
#self.retranslateUi(MainWindow)
|
#self.retranslateUi(MainWindow)
|
||||||
#self.tabWidget.setCurrentIndex(0)
|
#self.tabWidget.setCurrentIndex(0)
|
||||||
#QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
#QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal
|
from PyQt5.QtCore import pyqtSignal
|
||||||
from PyQt5.QtWidgets import QHBoxLayout, QWidget
|
from PyQt5.QtWidgets import QHBoxLayout, QWidget
|
||||||
|
|
||||||
@ -8,6 +6,7 @@ from qutebrowser.widgets.statusbar.command import Command
|
|||||||
from qutebrowser.widgets.statusbar.text import Text
|
from qutebrowser.widgets.statusbar.text import Text
|
||||||
from qutebrowser.widgets.statusbar.progress import Progress
|
from qutebrowser.widgets.statusbar.progress import Progress
|
||||||
|
|
||||||
|
|
||||||
class StatusBar(QWidget):
|
class StatusBar(QWidget):
|
||||||
"""The statusbar at the bottom of the mainwindow"""
|
"""The statusbar at the bottom of the mainwindow"""
|
||||||
hbox = None
|
hbox = None
|
||||||
|
@ -4,22 +4,22 @@ from PyQt5.QtWidgets import QLineEdit, QShortcut
|
|||||||
from PyQt5.QtCore import pyqtSignal, Qt
|
from PyQt5.QtCore import pyqtSignal, Qt
|
||||||
from PyQt5.QtGui import QValidator, QKeySequence
|
from PyQt5.QtGui import QValidator, QKeySequence
|
||||||
|
|
||||||
from qutebrowser.commands.utils import CommandCompletionModel
|
|
||||||
|
|
||||||
class Command(QLineEdit):
|
class Command(QLineEdit):
|
||||||
"""The commandline part of the statusbar"""
|
"""The commandline part of the statusbar"""
|
||||||
|
# Emitted when a command is triggered by the user
|
||||||
got_cmd = pyqtSignal(str) # Emitted when a command is triggered by the user
|
got_cmd = pyqtSignal(str)
|
||||||
bar = None # The status bar object
|
bar = None # The status bar object
|
||||||
esc_pressed = pyqtSignal() # Emitted when escape is pressed
|
esc_pressed = pyqtSignal() # Emitted when escape is pressed
|
||||||
tab_pressed = pyqtSignal(bool) # Emitted when tab is pressed (arg: shift)
|
tab_pressed = pyqtSignal(bool) # Emitted when tab is pressed (arg: shift)
|
||||||
hide_completion = pyqtSignal() # Hide completion window
|
hide_completion = pyqtSignal() # Hide completion window
|
||||||
history = [] # The command history, with newer commands at the bottom
|
history = [] # The command history, with newer commands at the bottom
|
||||||
_tmphist = []
|
_tmphist = []
|
||||||
_histpos = None
|
_histpos = None
|
||||||
|
|
||||||
# FIXME won't the tab key switch to the next widget?
|
# FIXME won't the tab key switch to the next widget?
|
||||||
# See http://www.saltycrane.com/blog/2008/01/how-to-capture-tab-key-press-event-with/
|
# See
|
||||||
|
# noqa http://www.saltycrane.com/blog/2008/01/how-to-capture-tab-key-press-event-with/
|
||||||
# for a possible fix.
|
# for a possible fix.
|
||||||
|
|
||||||
def __init__(self, bar):
|
def __init__(self, bar):
|
||||||
@ -103,7 +103,7 @@ class Command(QLineEdit):
|
|||||||
|
|
||||||
def key_down_handler(self):
|
def key_down_handler(self):
|
||||||
logging.debug("history up [pre]: pos {}".format(self._histpos,
|
logging.debug("history up [pre]: pos {}".format(self._histpos,
|
||||||
self._tmphist, len(self._tmphist), self._histpos))
|
self._tmphist, len(self._tmphist), self._histpos))
|
||||||
if (self._histpos is None or
|
if (self._histpos is None or
|
||||||
self._histpos >= len(self._tmphist) - 1 or
|
self._histpos >= len(self._tmphist) - 1 or
|
||||||
not self._tmphist):
|
not self._tmphist):
|
||||||
@ -119,6 +119,7 @@ class Command(QLineEdit):
|
|||||||
def key_stab_handler(self):
|
def key_stab_handler(self):
|
||||||
self.tab_pressed.emit(True)
|
self.tab_pressed.emit(True)
|
||||||
|
|
||||||
|
|
||||||
class Validator(QValidator):
|
class Validator(QValidator):
|
||||||
"""Validator to prevent the : from getting deleted"""
|
"""Validator to prevent the : from getting deleted"""
|
||||||
def validate(self, string, pos):
|
def validate(self, string, pos):
|
||||||
@ -126,4 +127,3 @@ class Validator(QValidator):
|
|||||||
return (QValidator.Acceptable, string, pos)
|
return (QValidator.Acceptable, string, pos)
|
||||||
else:
|
else:
|
||||||
return (QValidator.Invalid, string, pos)
|
return (QValidator.Invalid, string, pos)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import qutebrowser.utils.config as config
|
|||||||
from PyQt5.QtWidgets import QProgressBar, QSizePolicy
|
from PyQt5.QtWidgets import QProgressBar, QSizePolicy
|
||||||
from PyQt5.QtCore import QSize
|
from PyQt5.QtCore import QSize
|
||||||
|
|
||||||
|
|
||||||
class Progress(QProgressBar):
|
class Progress(QProgressBar):
|
||||||
""" The progress bar part of the status bar"""
|
""" The progress bar part of the status bar"""
|
||||||
bar = None
|
bar = None
|
||||||
@ -59,4 +60,3 @@ class Progress(QProgressBar):
|
|||||||
self.hide()
|
self.hide()
|
||||||
else:
|
else:
|
||||||
self.color = config.colordict.getraw('statusbar.progress.bg.error')
|
self.color = config.colordict.getraw('statusbar.progress.bg.error')
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
from PyQt5.QtWidgets import QLabel
|
from PyQt5.QtWidgets import QLabel
|
||||||
|
|
||||||
|
|
||||||
class Text(QLabel):
|
class Text(QLabel):
|
||||||
"""The text part of the status bar, composed of several 'widgets'"""
|
"""The text part of the status bar, composed of several 'widgets'"""
|
||||||
keystring = ''
|
keystring = ''
|
||||||
@ -37,4 +38,3 @@ class Text(QLabel):
|
|||||||
"""Update the text displayed"""
|
"""Update the text displayed"""
|
||||||
self.setText(' '.join([self.keystring, self.error, self.text,
|
self.setText(' '.join([self.keystring, self.error, self.text,
|
||||||
self.scrollperc]))
|
self.scrollperc]))
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from PyQt5.QtCore import Qt
|
|||||||
|
|
||||||
import qutebrowser.utils.config as config
|
import qutebrowser.utils.config as config
|
||||||
|
|
||||||
|
|
||||||
class TabWidget(QTabWidget):
|
class TabWidget(QTabWidget):
|
||||||
"""The tabwidget used for TabbedBrowser"""
|
"""The tabwidget used for TabbedBrowser"""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user