python package cleanup
This commit is contained in:
parent
921464ef5e
commit
39ed73c3cf
@ -38,7 +38,7 @@ import qutebrowser.commands.utils as cmdutils
|
||||
import qutebrowser.utils.config as config
|
||||
import qutebrowser.utils.about as about
|
||||
from qutebrowser.widgets.mainwindow import MainWindow
|
||||
from qutebrowser.widgets import CrashDialog
|
||||
from qutebrowser.widgets.crash import CrashDialog
|
||||
from qutebrowser.commands.keys import KeyParser
|
||||
from qutebrowser.utils.appdirs import AppDirs
|
||||
|
||||
|
@ -1,19 +1,3 @@
|
||||
"""All command classes.
|
||||
|
||||
These are automatically propagated from commands.utils
|
||||
via inspect.
|
||||
|
||||
A command class can set the following properties:
|
||||
|
||||
nargs -- Number of arguments. Either a number, '?' (0 or 1), '+' (1 or
|
||||
more), or '*' (any). Default: 0
|
||||
name -- The name of the command, or a list of aliases.
|
||||
split_args -- If arguments should be split or not. Default: True
|
||||
count -- If the command supports a count. Default: False
|
||||
hide -- If the command should be hidden in tab completion. Default: False
|
||||
|
||||
"""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
@ -31,242 +15,4 @@ A command class can set the following properties:
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from qutebrowser.commands.template import Command
|
||||
|
||||
|
||||
class Open(Command):
|
||||
|
||||
"""Open a page in the current or [count]th tab.
|
||||
|
||||
arg: The URL to open.
|
||||
|
||||
"""
|
||||
|
||||
nargs = 1
|
||||
split_args = False
|
||||
count = True
|
||||
|
||||
|
||||
class OpenCur(Command):
|
||||
|
||||
"""Fill the statusbar with :open and the current url."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
|
||||
|
||||
class TabOpen(Command):
|
||||
|
||||
"""Open a page in a new tab.
|
||||
|
||||
arg: The URL to open.
|
||||
|
||||
"""
|
||||
|
||||
nargs = 1
|
||||
split_args = False
|
||||
|
||||
|
||||
class TabOpenCur(Command):
|
||||
|
||||
"""Fill the statusbar with :tabopen and the current url."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
|
||||
|
||||
class TabClose(Command):
|
||||
|
||||
"""Close the current tab, or tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class TabNext(Command):
|
||||
|
||||
"""Switch to the next tab, or skip [count] tabs."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class TabPrev(Command):
|
||||
|
||||
"""Switch to the previous tab, or skip [count] tabs."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Quit(Command):
|
||||
|
||||
"""Quit qutebrowser."""
|
||||
|
||||
name = ['quit', 'q']
|
||||
nargs = 0
|
||||
|
||||
|
||||
class Reload(Command):
|
||||
|
||||
"""Reload the current page, or the page in tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Stop(Command):
|
||||
|
||||
"""Stop loading the current page, or the page in tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Back(Command):
|
||||
|
||||
"""Go back one/[count] page(s) in the history."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Forward(Command):
|
||||
|
||||
"""Go forward one/[count] page(s) in the history."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Print(Command):
|
||||
|
||||
"""Print the current page, or the page in tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Scroll(Command):
|
||||
|
||||
"""Scroll in x/y direction by a number of pixels.
|
||||
|
||||
arg 1: delta x
|
||||
arg 2: delta y
|
||||
count: multiplicator
|
||||
|
||||
"""
|
||||
|
||||
nargs = 2
|
||||
count = True
|
||||
hide = True
|
||||
|
||||
|
||||
class Undo(Command):
|
||||
|
||||
"""Undo closing a tab."""
|
||||
|
||||
nargs = 0
|
||||
|
||||
|
||||
class ScrollPercX(Command):
|
||||
|
||||
"""Scroll N percent horizontally.
|
||||
|
||||
optional arg: How many percent to scroll.
|
||||
count: How many percent to scroll.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
count = True
|
||||
hide = True
|
||||
name = 'scroll_perc_x'
|
||||
|
||||
|
||||
class ScrollPercY(Command):
|
||||
|
||||
"""Scroll N percent vertically.
|
||||
|
||||
optional arg: How many percent to scroll.
|
||||
count: How many percent to scroll.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
count = True
|
||||
hide = True
|
||||
name = 'scroll_perc_y'
|
||||
|
||||
|
||||
class PyEval(Command):
|
||||
|
||||
"""Evaluate python code.
|
||||
|
||||
arg: The python code to evaluate.
|
||||
|
||||
"""
|
||||
|
||||
nargs = 1
|
||||
split_args = False
|
||||
|
||||
|
||||
class NextSearch(Command):
|
||||
|
||||
"""Jump to the next or [count]th next search term."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
count = True
|
||||
|
||||
|
||||
class Yank(Command):
|
||||
|
||||
"""Yank the URL of the current tab to the clipboard.
|
||||
|
||||
optional arg: If 'sel', yank to the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class YankTitle(Command):
|
||||
|
||||
"""Yank the title of the current tab to the clipboard.
|
||||
|
||||
optional arg: If 'sel', yank to the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class Paste(Command):
|
||||
|
||||
"""Open an URL from the clipboard.
|
||||
|
||||
optional arg: If 'sel', paste from the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class TabPaste(Command):
|
||||
|
||||
"""Open an URL from the clipboard in a new tab.
|
||||
|
||||
optional arg: If 'sel', paste from the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class Crash(Command):
|
||||
|
||||
"""Simply raise an exception for debugging."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
"""Utilities and classes regarding to commands."""
|
||||
|
272
qutebrowser/commands/commands.py
Normal file
272
qutebrowser/commands/commands.py
Normal file
@ -0,0 +1,272 @@
|
||||
"""All command classes.
|
||||
|
||||
These are automatically propagated from commands.utils
|
||||
via inspect.
|
||||
|
||||
A command class can set the following properties:
|
||||
|
||||
nargs -- Number of arguments. Either a number, '?' (0 or 1), '+' (1 or
|
||||
more), or '*' (any). Default: 0
|
||||
name -- The name of the command, or a list of aliases.
|
||||
split_args -- If arguments should be split or not. Default: True
|
||||
count -- If the command supports a count. Default: False
|
||||
hide -- If the command should be hidden in tab completion. Default: False
|
||||
|
||||
"""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from qutebrowser.commands.template import Command
|
||||
|
||||
|
||||
class Open(Command):
|
||||
|
||||
"""Open a page in the current or [count]th tab.
|
||||
|
||||
arg: The URL to open.
|
||||
|
||||
"""
|
||||
|
||||
nargs = 1
|
||||
split_args = False
|
||||
count = True
|
||||
|
||||
|
||||
class OpenCur(Command):
|
||||
|
||||
"""Fill the statusbar with :open and the current url."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
|
||||
|
||||
class TabOpen(Command):
|
||||
|
||||
"""Open a page in a new tab.
|
||||
|
||||
arg: The URL to open.
|
||||
|
||||
"""
|
||||
|
||||
nargs = 1
|
||||
split_args = False
|
||||
|
||||
|
||||
class TabOpenCur(Command):
|
||||
|
||||
"""Fill the statusbar with :tabopen and the current url."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
|
||||
|
||||
class TabClose(Command):
|
||||
|
||||
"""Close the current tab, or tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class TabNext(Command):
|
||||
|
||||
"""Switch to the next tab, or skip [count] tabs."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class TabPrev(Command):
|
||||
|
||||
"""Switch to the previous tab, or skip [count] tabs."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Quit(Command):
|
||||
|
||||
"""Quit qutebrowser."""
|
||||
|
||||
name = ['quit', 'q']
|
||||
nargs = 0
|
||||
|
||||
|
||||
class Reload(Command):
|
||||
|
||||
"""Reload the current page, or the page in tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Stop(Command):
|
||||
|
||||
"""Stop loading the current page, or the page in tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Back(Command):
|
||||
|
||||
"""Go back one/[count] page(s) in the history."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Forward(Command):
|
||||
|
||||
"""Go forward one/[count] page(s) in the history."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Print(Command):
|
||||
|
||||
"""Print the current page, or the page in tab [count]."""
|
||||
|
||||
nargs = 0
|
||||
count = True
|
||||
|
||||
|
||||
class Scroll(Command):
|
||||
|
||||
"""Scroll in x/y direction by a number of pixels.
|
||||
|
||||
arg 1: delta x
|
||||
arg 2: delta y
|
||||
count: multiplicator
|
||||
|
||||
"""
|
||||
|
||||
nargs = 2
|
||||
count = True
|
||||
hide = True
|
||||
|
||||
|
||||
class Undo(Command):
|
||||
|
||||
"""Undo closing a tab."""
|
||||
|
||||
nargs = 0
|
||||
|
||||
|
||||
class ScrollPercX(Command):
|
||||
|
||||
"""Scroll N percent horizontally.
|
||||
|
||||
optional arg: How many percent to scroll.
|
||||
count: How many percent to scroll.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
count = True
|
||||
hide = True
|
||||
name = 'scroll_perc_x'
|
||||
|
||||
|
||||
class ScrollPercY(Command):
|
||||
|
||||
"""Scroll N percent vertically.
|
||||
|
||||
optional arg: How many percent to scroll.
|
||||
count: How many percent to scroll.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
count = True
|
||||
hide = True
|
||||
name = 'scroll_perc_y'
|
||||
|
||||
|
||||
class PyEval(Command):
|
||||
|
||||
"""Evaluate python code.
|
||||
|
||||
arg: The python code to evaluate.
|
||||
|
||||
"""
|
||||
|
||||
nargs = 1
|
||||
split_args = False
|
||||
|
||||
|
||||
class NextSearch(Command):
|
||||
|
||||
"""Jump to the next or [count]th next search term."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
||||
count = True
|
||||
|
||||
|
||||
class Yank(Command):
|
||||
|
||||
"""Yank the URL of the current tab to the clipboard.
|
||||
|
||||
optional arg: If 'sel', yank to the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class YankTitle(Command):
|
||||
|
||||
"""Yank the title of the current tab to the clipboard.
|
||||
|
||||
optional arg: If 'sel', yank to the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class Paste(Command):
|
||||
|
||||
"""Open an URL from the clipboard.
|
||||
|
||||
optional arg: If 'sel', paste from the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class TabPaste(Command):
|
||||
|
||||
"""Open an URL from the clipboard in a new tab.
|
||||
|
||||
optional arg: If 'sel', paste from the primary selection.
|
||||
|
||||
"""
|
||||
|
||||
nargs = '?'
|
||||
|
||||
|
||||
class Crash(Command):
|
||||
|
||||
"""Simply raise an exception for debugging."""
|
||||
|
||||
nargs = 0
|
||||
hide = True
|
@ -23,7 +23,7 @@ import shlex
|
||||
from PyQt5.QtCore import QObject, pyqtSignal
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
|
||||
import qutebrowser.commands
|
||||
import qutebrowser.commands.commands
|
||||
import qutebrowser.utils.config as config
|
||||
from qutebrowser.commands.exceptions import (ArgumentCountError,
|
||||
NoSuchCommandError)
|
||||
@ -36,8 +36,9 @@ cmd_dict = {}
|
||||
def register_all():
|
||||
"""Register and initialize all commands."""
|
||||
for (name, cls) in inspect.getmembers( # pylint: disable=unused-variable
|
||||
qutebrowser.commands, (lambda o: inspect.isclass(o) and
|
||||
o.__module__ == 'qutebrowser.commands')):
|
||||
qutebrowser.commands.commands,
|
||||
(lambda o: inspect.isclass(o) and o.__module__ ==
|
||||
'qutebrowser.commands.commands')):
|
||||
obj = cls()
|
||||
if isinstance(obj.name, str):
|
||||
names = [obj.name]
|
||||
|
@ -1,5 +1,3 @@
|
||||
"""Misc utility functions."""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
@ -17,58 +15,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, qVersion
|
||||
from PyQt5.QtWebKit import qWebKitVersion
|
||||
|
||||
import qutebrowser
|
||||
|
||||
|
||||
def version():
|
||||
"""Return a string with various version informations."""
|
||||
if sys.platform == 'linux':
|
||||
osver = ', '.join((platform.dist()))
|
||||
elif sys.platform == 'win32':
|
||||
osver = ', '.join((platform.win32_ver()))
|
||||
elif sys.platform == 'darwin':
|
||||
osver = ', '.join((platform.mac_ver()))
|
||||
else:
|
||||
osver = '?'
|
||||
|
||||
gitver = _git_str()
|
||||
|
||||
lines = [
|
||||
'qutebrowser v{}\n\n'.format(qutebrowser.__version__),
|
||||
'Python {}\n'.format(platform.python_version()),
|
||||
'Qt {}, runtime {}\n'.format(QT_VERSION_STR, qVersion()),
|
||||
'PyQt {}\n'.format(PYQT_VERSION_STR),
|
||||
'Webkit {}\n\n'.format(qWebKitVersion()),
|
||||
'Platform: {}, {}\n'.format(platform.platform(),
|
||||
platform.architecture()[0]),
|
||||
'OS Version: {}\n'.format(osver),
|
||||
]
|
||||
|
||||
if gitver is not None:
|
||||
lines.append('\nGit commit: {}'.format(gitver))
|
||||
|
||||
return ''.join(lines)
|
||||
|
||||
|
||||
def _git_str():
|
||||
"""Try to find out git version and return a string if possible.
|
||||
|
||||
Return None if there was an error or we're not in a git repo.
|
||||
|
||||
"""
|
||||
# FIXME this runs in PWD, not the qutebrowser dir?!
|
||||
if not os.path.isdir(".git"):
|
||||
return None
|
||||
try:
|
||||
return subprocess.check_output(['git', 'describe', '--tags', '--dirty',
|
||||
'--always']).decode('UTF-8').strip()
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
return None
|
||||
"""Misc utility functions."""
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from qutebrowser.utils import version
|
||||
from qutebrowser.utils.version import version
|
||||
from qutebrowser.utils.url import is_about_url
|
||||
|
||||
|
||||
|
74
qutebrowser/utils/version.py
Normal file
74
qutebrowser/utils/version.py
Normal file
@ -0,0 +1,74 @@
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Utilities to show various version informations."""
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, qVersion
|
||||
from PyQt5.QtWebKit import qWebKitVersion
|
||||
|
||||
import qutebrowser
|
||||
|
||||
|
||||
def version():
|
||||
"""Return a string with various version informations."""
|
||||
if sys.platform == 'linux':
|
||||
osver = ', '.join((platform.dist()))
|
||||
elif sys.platform == 'win32':
|
||||
osver = ', '.join((platform.win32_ver()))
|
||||
elif sys.platform == 'darwin':
|
||||
osver = ', '.join((platform.mac_ver()))
|
||||
else:
|
||||
osver = '?'
|
||||
|
||||
gitver = _git_str()
|
||||
|
||||
lines = [
|
||||
'qutebrowser v{}\n\n'.format(qutebrowser.__version__),
|
||||
'Python {}\n'.format(platform.python_version()),
|
||||
'Qt {}, runtime {}\n'.format(QT_VERSION_STR, qVersion()),
|
||||
'PyQt {}\n'.format(PYQT_VERSION_STR),
|
||||
'Webkit {}\n\n'.format(qWebKitVersion()),
|
||||
'Platform: {}, {}\n'.format(platform.platform(),
|
||||
platform.architecture()[0]),
|
||||
'OS Version: {}\n'.format(osver),
|
||||
]
|
||||
|
||||
if gitver is not None:
|
||||
lines.append('\nGit commit: {}'.format(gitver))
|
||||
|
||||
return ''.join(lines)
|
||||
|
||||
|
||||
def _git_str():
|
||||
"""Try to find out git version and return a string if possible.
|
||||
|
||||
Return None if there was an error or we're not in a git repo.
|
||||
|
||||
"""
|
||||
# FIXME this runs in PWD, not the qutebrowser dir?!
|
||||
if not os.path.isdir(".git"):
|
||||
return None
|
||||
try:
|
||||
return subprocess.check_output(['git', 'describe', '--tags', '--dirty',
|
||||
'--always']).decode('UTF-8').strip()
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
return None
|
@ -1,5 +1,3 @@
|
||||
"""The Qt widgets needed by qutebrowser."""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
@ -17,68 +15,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QVBoxLayout,
|
||||
QHBoxLayout, QPushButton)
|
||||
|
||||
import qutebrowser.utils as utils
|
||||
|
||||
|
||||
class CrashDialog(QDialog):
|
||||
|
||||
"""Dialog which gets shown after there was a crash."""
|
||||
|
||||
def __init__(self, pages, cmdhist, exc):
|
||||
super().__init__()
|
||||
self.setFixedSize(500, 350)
|
||||
self.setWindowTitle('Whoops!')
|
||||
self.setModal(True)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
lbl = QLabel(self)
|
||||
text = ('Argh! qutebrowser crashed unexpectedly.<br/>'
|
||||
'Please review the info below to remove sensitive data and '
|
||||
'then submit it to <a href="mailto:crash@qutebrowser.org">'
|
||||
'crash@qutebrowser.org</a>.<br/><br/>')
|
||||
if pages:
|
||||
text += ('You can click "Restore tabs" to attempt to reopen your '
|
||||
'open tabs.')
|
||||
lbl.setText(text)
|
||||
lbl.setWordWrap(True)
|
||||
vbox.addWidget(lbl)
|
||||
|
||||
txt = QTextEdit(self)
|
||||
txt.setReadOnly(True)
|
||||
outputs = [
|
||||
('Version info', utils.version()),
|
||||
('Exception', ''.join(traceback.format_exception(*exc))),
|
||||
('Open Pages', '\n'.join(pages)),
|
||||
('Command history', '\n'.join(cmdhist)),
|
||||
('Commandline args', ' '.join(sys.argv[1:])),
|
||||
('Config', utils.config.config.dump_userconfig()),
|
||||
]
|
||||
chunks = []
|
||||
for (header, body) in outputs:
|
||||
h = '==== {} ===='.format(header)
|
||||
chunks.append('\n'.join([h, body]))
|
||||
|
||||
txt.setText('\n\n'.join(chunks))
|
||||
vbox.addWidget(txt)
|
||||
self.setLayout(vbox)
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
btn_quit = QPushButton(self)
|
||||
btn_quit.setText('Quit')
|
||||
btn_quit.clicked.connect(self.reject)
|
||||
hbox.addWidget(btn_quit)
|
||||
if pages:
|
||||
btn_restore = QPushButton(self)
|
||||
btn_restore.setText('Restore tabs')
|
||||
btn_restore.clicked.connect(self.accept)
|
||||
btn_restore.setDefault(True)
|
||||
hbox.addWidget(btn_restore)
|
||||
|
||||
vbox.addLayout(hbox)
|
||||
self.show()
|
||||
"""The Qt widgets needed by qutebrowser."""
|
||||
|
85
qutebrowser/widgets/crash.py
Normal file
85
qutebrowser/widgets/crash.py
Normal file
@ -0,0 +1,85 @@
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""The dialog which gets shown when qutebrowser crashes."""
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QVBoxLayout,
|
||||
QHBoxLayout, QPushButton)
|
||||
|
||||
import qutebrowser.utils.config as config
|
||||
from qutebrowser.utils.version import version
|
||||
|
||||
|
||||
class CrashDialog(QDialog):
|
||||
|
||||
"""Dialog which gets shown after there was a crash."""
|
||||
|
||||
def __init__(self, pages, cmdhist, exc):
|
||||
super().__init__()
|
||||
self.setFixedSize(500, 350)
|
||||
self.setWindowTitle('Whoops!')
|
||||
self.setModal(True)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
lbl = QLabel(self)
|
||||
text = ('Argh! qutebrowser crashed unexpectedly.<br/>'
|
||||
'Please review the info below to remove sensitive data and '
|
||||
'then submit it to <a href="mailto:crash@qutebrowser.org">'
|
||||
'crash@qutebrowser.org</a>.<br/><br/>')
|
||||
if pages:
|
||||
text += ('You can click "Restore tabs" to attempt to reopen your '
|
||||
'open tabs.')
|
||||
lbl.setText(text)
|
||||
lbl.setWordWrap(True)
|
||||
vbox.addWidget(lbl)
|
||||
|
||||
txt = QTextEdit(self)
|
||||
txt.setReadOnly(True)
|
||||
outputs = [
|
||||
('Version info', version()),
|
||||
('Exception', ''.join(traceback.format_exception(*exc))),
|
||||
('Open Pages', '\n'.join(pages)),
|
||||
('Command history', '\n'.join(cmdhist)),
|
||||
('Commandline args', ' '.join(sys.argv[1:])),
|
||||
('Config', config.config.dump_userconfig()),
|
||||
]
|
||||
chunks = []
|
||||
for (header, body) in outputs:
|
||||
h = '==== {} ===='.format(header)
|
||||
chunks.append('\n'.join([h, body]))
|
||||
|
||||
txt.setText('\n\n'.join(chunks))
|
||||
vbox.addWidget(txt)
|
||||
self.setLayout(vbox)
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
btn_quit = QPushButton(self)
|
||||
btn_quit.setText('Quit')
|
||||
btn_quit.clicked.connect(self.reject)
|
||||
hbox.addWidget(btn_quit)
|
||||
if pages:
|
||||
btn_restore = QPushButton(self)
|
||||
btn_restore.setText('Restore tabs')
|
||||
btn_restore.clicked.connect(self.accept)
|
||||
btn_restore.setDefault(True)
|
||||
hbox.addWidget(btn_restore)
|
||||
|
||||
vbox.addLayout(hbox)
|
||||
self.show()
|
@ -1,5 +1,3 @@
|
||||
"""The commandline part of the statusbar."""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
@ -17,15 +15,102 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Widgets needed in the qutebrowser statusbar."""
|
||||
|
||||
import logging
|
||||
|
||||
from PyQt5.QtWidgets import QLineEdit, QShortcut, QSizePolicy
|
||||
from PyQt5.QtCore import pyqtSignal, Qt
|
||||
from PyQt5.QtWidgets import (QLineEdit, QShortcut, QHBoxLayout, QWidget,
|
||||
QSizePolicy, QProgressBar, QLabel)
|
||||
from PyQt5.QtGui import QValidator, QKeySequence
|
||||
|
||||
import qutebrowser.utils.config as config
|
||||
import qutebrowser.commands.keys as keys
|
||||
|
||||
|
||||
class StatusBar(QWidget):
|
||||
|
||||
"""The statusbar at the bottom of the mainwindow."""
|
||||
|
||||
hbox = None
|
||||
cmd = None
|
||||
txt = None
|
||||
prog = None
|
||||
resized = pyqtSignal('QRect')
|
||||
moved = pyqtSignal('QPoint')
|
||||
fgcolor = None
|
||||
bgcolor = None
|
||||
_stylesheet = """
|
||||
* {{
|
||||
{color[statusbar.bg.__cur__]}
|
||||
{color[statusbar.fg.__cur__]}
|
||||
{font[statusbar]}
|
||||
}}
|
||||
"""
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""Update the stylesheet if relevant attributes have been changed."""
|
||||
super().__setattr__(name, value)
|
||||
if name == 'fgcolor' and value is not None:
|
||||
config.colordict['statusbar.fg.__cur__'] = value
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
elif name == 'bgcolor' and value is not None:
|
||||
config.colordict['statusbar.bg.__cur__'] = value
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
|
||||
# TODO: the statusbar should be a bit smaller
|
||||
def __init__(self, mainwindow):
|
||||
super().__init__(mainwindow)
|
||||
self.fgcolor = config.colordict.getraw('statusbar.fg')
|
||||
self.bgcolor = config.colordict.getraw('statusbar.bg')
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||
|
||||
self.hbox = QHBoxLayout(self)
|
||||
self.hbox.setContentsMargins(0, 0, 0, 0)
|
||||
self.hbox.setSpacing(0)
|
||||
|
||||
self.cmd = Command(self)
|
||||
self.hbox.addWidget(self.cmd)
|
||||
|
||||
self.txt = Text(self)
|
||||
self.hbox.addWidget(self.txt)
|
||||
|
||||
self.prog = Progress(self)
|
||||
self.hbox.addWidget(self.prog)
|
||||
|
||||
def disp_error(self, text):
|
||||
"""Displaysan error in the statusbar."""
|
||||
self.bgcolor = config.colordict.getraw('statusbar.bg.error')
|
||||
self.fgcolor = config.colordict.getraw('statusbar.fg.error')
|
||||
self.txt.error = text
|
||||
|
||||
def clear_error(self):
|
||||
"""Clear a displayed error from the status bar."""
|
||||
self.bgcolor = config.colordict.getraw('statusbar.bg')
|
||||
self.fgcolor = config.colordict.getraw('statusbar.fg')
|
||||
self.txt.error = ''
|
||||
|
||||
def resizeEvent(self, e):
|
||||
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
||||
|
||||
e -- The QResizeEvent.
|
||||
|
||||
"""
|
||||
super().resizeEvent(e)
|
||||
self.resized.emit(self.geometry())
|
||||
|
||||
def moveEvent(self, e):
|
||||
"""Extend moveEvent of QWidget to emit a moved signal afterwards.
|
||||
|
||||
e -- The QMoveEvent.
|
||||
|
||||
"""
|
||||
super().moveEvent(e)
|
||||
self.moved.emit(e.pos())
|
||||
|
||||
|
||||
class Command(QLineEdit):
|
||||
|
||||
"""The commandline part of the statusbar."""
|
||||
@ -52,7 +137,7 @@ class Command(QLineEdit):
|
||||
# FIXME
|
||||
self.statusbar = statusbar
|
||||
self.setStyleSheet("border: 0px; padding-left: 1px;")
|
||||
self.setValidator(Validator())
|
||||
self.setValidator(CommandValidator())
|
||||
self.returnPressed.connect(self.process_cmdline)
|
||||
self.textEdited.connect(self._histbrowse_stop)
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored)
|
||||
@ -157,7 +242,7 @@ class Command(QLineEdit):
|
||||
self.set_cmd(self._tmphist[self._histpos])
|
||||
|
||||
|
||||
class Validator(QValidator):
|
||||
class CommandValidator(QValidator):
|
||||
|
||||
"""Validator to prevent the : from getting deleted."""
|
||||
|
||||
@ -174,3 +259,110 @@ class Validator(QValidator):
|
||||
return (QValidator.Acceptable, string, pos)
|
||||
else:
|
||||
return (QValidator.Invalid, string, pos)
|
||||
|
||||
|
||||
class Progress(QProgressBar):
|
||||
|
||||
"""The progress bar part of the status bar."""
|
||||
|
||||
statusbar = None
|
||||
color = None
|
||||
_stylesheet = """
|
||||
QProgressBar {{
|
||||
border-radius: 0px;
|
||||
border: 2px solid transparent;
|
||||
margin-left: 1px;
|
||||
}}
|
||||
|
||||
QProgressBar::chunk {{
|
||||
{color[statusbar.progress.bg.__cur__]}
|
||||
}}
|
||||
"""
|
||||
|
||||
def __init__(self, statusbar):
|
||||
self.statusbar = statusbar
|
||||
super().__init__(statusbar)
|
||||
|
||||
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Ignored)
|
||||
self.setTextVisible(False)
|
||||
self.color = config.colordict.getraw('statusbar.progress.bg')
|
||||
self.hide()
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""Update the stylesheet if relevant attributes have been changed."""
|
||||
super().__setattr__(name, value)
|
||||
if name == 'color' and value is not None:
|
||||
config.colordict['statusbar.progress.bg.__cur__'] = value
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
|
||||
def set_progress(self, prog):
|
||||
"""Set the progress of the bar and show/hide it if necessary."""
|
||||
# TODO display failed loading in some meaningful way?
|
||||
if prog == 100:
|
||||
self.setValue(prog)
|
||||
else:
|
||||
color = config.colordict.getraw('status.progress.bg')
|
||||
if self.color != color:
|
||||
self.color = color
|
||||
self.setValue(prog)
|
||||
self.show()
|
||||
|
||||
def load_finished(self, ok):
|
||||
"""Hide the progress bar or color it red, depending on ok.
|
||||
|
||||
Slot for the loadFinished signal of a QWebView.
|
||||
|
||||
"""
|
||||
if ok:
|
||||
self.color = config.colordict.getraw('status.progress.bg')
|
||||
self.hide()
|
||||
else:
|
||||
self.color = config.colordict.getraw('statusbar.progress.bg.error')
|
||||
|
||||
|
||||
class Text(QLabel):
|
||||
|
||||
"""The text part of the status bar.
|
||||
|
||||
Contains several parts (keystring, error, text, scrollperc) which are later
|
||||
joined and displayed.
|
||||
|
||||
"""
|
||||
|
||||
keystring = ''
|
||||
error = ''
|
||||
text = ''
|
||||
scrollperc = ''
|
||||
|
||||
def __init__(self, bar):
|
||||
super().__init__(bar)
|
||||
self.setStyleSheet("padding-right: 1px;")
|
||||
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
super().__setattr__(name, value)
|
||||
self.update()
|
||||
|
||||
def set_keystring(self, s):
|
||||
"""Setter to be used as a Qt slot."""
|
||||
self.keystring = s
|
||||
|
||||
def set_perc(self, x, y):
|
||||
"""Setter to be used as a Qt slot."""
|
||||
# pylint: disable=unused-argument
|
||||
if y == 0:
|
||||
self.scrollperc = '[top]'
|
||||
elif y == 100:
|
||||
self.scrollperc = '[bot]'
|
||||
else:
|
||||
self.scrollperc = '[{}%]'.format(y)
|
||||
|
||||
def set_text(self, text):
|
||||
"""Setter to be used as a Qt slot."""
|
||||
logging.debug('Setting text to "{}"'.format(text))
|
||||
self.text = text
|
||||
|
||||
def update(self):
|
||||
"""Update the text displayed."""
|
||||
self.setText(' '.join([self.keystring, self.error, self.text,
|
||||
self.scrollperc]))
|
@ -1,109 +0,0 @@
|
||||
"""Several widgets in the statusbar."""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QHBoxLayout, QWidget, QSizePolicy
|
||||
|
||||
import qutebrowser.utils.config as config
|
||||
from qutebrowser.widgets.statusbar.command import Command
|
||||
from qutebrowser.widgets.statusbar.text import Text
|
||||
from qutebrowser.widgets.statusbar.progress import Progress
|
||||
|
||||
|
||||
class StatusBar(QWidget):
|
||||
|
||||
"""The statusbar at the bottom of the mainwindow."""
|
||||
|
||||
hbox = None
|
||||
cmd = None
|
||||
txt = None
|
||||
prog = None
|
||||
resized = pyqtSignal('QRect')
|
||||
moved = pyqtSignal('QPoint')
|
||||
fgcolor = None
|
||||
bgcolor = None
|
||||
_stylesheet = """
|
||||
* {{
|
||||
{color[statusbar.bg.__cur__]}
|
||||
{color[statusbar.fg.__cur__]}
|
||||
{font[statusbar]}
|
||||
}}
|
||||
"""
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""Update the stylesheet if relevant attributes have been changed."""
|
||||
super().__setattr__(name, value)
|
||||
if name == 'fgcolor' and value is not None:
|
||||
config.colordict['statusbar.fg.__cur__'] = value
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
elif name == 'bgcolor' and value is not None:
|
||||
config.colordict['statusbar.bg.__cur__'] = value
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
|
||||
# TODO: the statusbar should be a bit smaller
|
||||
def __init__(self, mainwindow):
|
||||
super().__init__(mainwindow)
|
||||
self.fgcolor = config.colordict.getraw('statusbar.fg')
|
||||
self.bgcolor = config.colordict.getraw('statusbar.bg')
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||
|
||||
self.hbox = QHBoxLayout(self)
|
||||
self.hbox.setContentsMargins(0, 0, 0, 0)
|
||||
self.hbox.setSpacing(0)
|
||||
|
||||
self.cmd = Command(self)
|
||||
self.hbox.addWidget(self.cmd)
|
||||
|
||||
self.txt = Text(self)
|
||||
self.hbox.addWidget(self.txt)
|
||||
|
||||
self.prog = Progress(self)
|
||||
self.hbox.addWidget(self.prog)
|
||||
|
||||
def disp_error(self, text):
|
||||
"""Displaysan error in the statusbar."""
|
||||
self.bgcolor = config.colordict.getraw('statusbar.bg.error')
|
||||
self.fgcolor = config.colordict.getraw('statusbar.fg.error')
|
||||
self.txt.error = text
|
||||
|
||||
def clear_error(self):
|
||||
"""Clear a displayed error from the status bar."""
|
||||
self.bgcolor = config.colordict.getraw('statusbar.bg')
|
||||
self.fgcolor = config.colordict.getraw('statusbar.fg')
|
||||
self.txt.error = ''
|
||||
|
||||
def resizeEvent(self, e):
|
||||
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.
|
||||
|
||||
e -- The QResizeEvent.
|
||||
|
||||
"""
|
||||
super().resizeEvent(e)
|
||||
self.resized.emit(self.geometry())
|
||||
|
||||
def moveEvent(self, e):
|
||||
"""Extend moveEvent of QWidget to emit a moved signal afterwards.
|
||||
|
||||
e -- The QMoveEvent.
|
||||
|
||||
"""
|
||||
super().moveEvent(e)
|
||||
self.moved.emit(e.pos())
|
@ -1,81 +0,0 @@
|
||||
"""Widget to show the percentage of the page load in the statusbar."""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import qutebrowser.utils.config as config
|
||||
|
||||
from PyQt5.QtWidgets import QProgressBar, QSizePolicy
|
||||
|
||||
|
||||
class Progress(QProgressBar):
|
||||
|
||||
"""The progress bar part of the status bar."""
|
||||
|
||||
statusbar = None
|
||||
color = None
|
||||
_stylesheet = """
|
||||
QProgressBar {{
|
||||
border-radius: 0px;
|
||||
border: 2px solid transparent;
|
||||
margin-left: 1px;
|
||||
}}
|
||||
|
||||
QProgressBar::chunk {{
|
||||
{color[statusbar.progress.bg.__cur__]}
|
||||
}}
|
||||
"""
|
||||
|
||||
def __init__(self, statusbar):
|
||||
self.statusbar = statusbar
|
||||
super().__init__(statusbar)
|
||||
|
||||
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Ignored)
|
||||
self.setTextVisible(False)
|
||||
self.color = config.colordict.getraw('statusbar.progress.bg')
|
||||
self.hide()
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""Update the stylesheet if relevant attributes have been changed."""
|
||||
super().__setattr__(name, value)
|
||||
if name == 'color' and value is not None:
|
||||
config.colordict['statusbar.progress.bg.__cur__'] = value
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
|
||||
def set_progress(self, prog):
|
||||
"""Set the progress of the bar and show/hide it if necessary."""
|
||||
# TODO display failed loading in some meaningful way?
|
||||
if prog == 100:
|
||||
self.setValue(prog)
|
||||
else:
|
||||
color = config.colordict.getraw('status.progress.bg')
|
||||
if self.color != color:
|
||||
self.color = color
|
||||
self.setValue(prog)
|
||||
self.show()
|
||||
|
||||
def load_finished(self, ok):
|
||||
"""Hide the progress bar or color it red, depending on ok.
|
||||
|
||||
Slot for the loadFinished signal of a QWebView.
|
||||
|
||||
"""
|
||||
if ok:
|
||||
self.color = config.colordict.getraw('status.progress.bg')
|
||||
self.hide()
|
||||
else:
|
||||
self.color = config.colordict.getraw('statusbar.progress.bg.error')
|
@ -1,69 +0,0 @@
|
||||
"""The text part of the statusbar."""
|
||||
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
from PyQt5.QtWidgets import QLabel, QSizePolicy
|
||||
|
||||
|
||||
class Text(QLabel):
|
||||
|
||||
"""The text part of the status bar.
|
||||
|
||||
Contains several parts (keystring, error, text, scrollperc) which are later
|
||||
joined and displayed.
|
||||
|
||||
"""
|
||||
|
||||
keystring = ''
|
||||
error = ''
|
||||
text = ''
|
||||
scrollperc = ''
|
||||
|
||||
def __init__(self, bar):
|
||||
super().__init__(bar)
|
||||
self.setStyleSheet("padding-right: 1px;")
|
||||
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
super().__setattr__(name, value)
|
||||
self.update()
|
||||
|
||||
def set_keystring(self, s):
|
||||
"""Setter to be used as a Qt slot."""
|
||||
self.keystring = s
|
||||
|
||||
def set_perc(self, x, y):
|
||||
"""Setter to be used as a Qt slot."""
|
||||
# pylint: disable=unused-argument
|
||||
if y == 0:
|
||||
self.scrollperc = '[top]'
|
||||
elif y == 100:
|
||||
self.scrollperc = '[bot]'
|
||||
else:
|
||||
self.scrollperc = '[{}%]'.format(y)
|
||||
|
||||
def set_text(self, text):
|
||||
"""Setter to be used as a Qt slot."""
|
||||
logging.debug('Setting text to "{}"'.format(text))
|
||||
self.text = text
|
||||
|
||||
def update(self):
|
||||
"""Update the text displayed."""
|
||||
self.setText(' '.join([self.keystring, self.error, self.text,
|
||||
self.scrollperc]))
|
Loading…
Reference in New Issue
Block a user