console: Set nicer font

This commit is contained in:
Florian Bruhin 2014-08-13 06:56:46 +02:00
parent 35d0fe2b52
commit 73214836da
2 changed files with 32 additions and 1 deletions

View File

@ -949,6 +949,10 @@ DATA = OrderedDict([
SettingValue(types.Font(), 'bold 12px Monospace'),
"Font used for the hints."),
('debug-console',
SettingValue(types.QtFont(), '8pt ${_monospace}'),
"Font used for the debugging console."),
('web-family-standard',
SettingValue(types.String(none_ok=True), ''),
"Font family for standard fonts."),

View File

@ -25,6 +25,7 @@ from code import InteractiveInterpreter
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
from PyQt5.QtWidgets import QLineEdit, QTextEdit, QWidget, QVBoxLayout
import qutebrowser.config.config as config
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
HistoryEndReachedError)
from qutebrowser.utils.misc import fake_io, disabled_excepthook
@ -43,6 +44,7 @@ class ConsoleLineEdit(CommandLineEdit):
if not hasattr(sys, 'ps2'):
sys.ps2 = '... '
super().__init__(parent, prompts=[sys.ps1, sys.ps2])
self.setFont(config.get('fonts', 'debug-console'))
self._more = False
self._buffer = []
self._interpreter = InteractiveInterpreter()
@ -120,6 +122,25 @@ class ConsoleLineEdit(CommandLineEdit):
else:
super().keyPressEvent(e)
def on_config_changed(self, section, option):
"""Update font when config changed."""
if section == 'fonts' and option == 'debug-console':
self.setFont(config.get('fonts', 'debug-console'))
class ConsoleTextEdit(QTextEdit):
def __init__(self, parent=None):
super().__init__(parent)
self.setAcceptRichText(False)
self.setReadOnly(True)
self.setFont(config.get('fonts', 'debug-console'))
def on_config_changed(self, section, option):
"""Update font when config changed."""
if section == 'fonts' and option == 'debug-console':
self.setFont(config.get('fonts', 'debug-console'))
class ConsoleWidget(QWidget):
@ -128,7 +149,7 @@ class ConsoleWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.lineedit = ConsoleLineEdit()
self.output = QTextEdit(acceptRichText=True, readOnly=True)
self.output = ConsoleTextEdit()
self.lineedit.write.connect(self.output.append)
self.vbox = QVBoxLayout()
self.vbox.setSpacing(0)
@ -136,3 +157,9 @@ class ConsoleWidget(QWidget):
self.vbox.addWidget(self.lineedit)
self.setLayout(self.vbox)
self.lineedit.setFocus()
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update font when config changed."""
self.lineedit.on_config_changed(section, option)
self.output.on_config_changed(section, option)