diff --git a/qutebrowser/widgets/misc.py b/qutebrowser/widgets/misc.py new file mode 100644 index 000000000..6ab2f07f8 --- /dev/null +++ b/qutebrowser/widgets/misc.py @@ -0,0 +1,35 @@ +# Copyright 2014 Florian Bruhin (The Compiler) +# +# 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 . + +"""Misc. widgets used at different places.""" + +from PyQt5.QtWidgets import QLineEdit + + +class MinimalLineEdit(QLineEdit): + + """A LineEdit with a minimal look (without borders/background).""" + + def __init__(self, parent=None): + super().__init__(parent) + self.setStyleSheet(""" + QLineEdit { + border: 0px; + padding-left: 1px; + background-color: transparent; + } + """) diff --git a/qutebrowser/widgets/statusbar/_command.py b/qutebrowser/widgets/statusbar/_command.py index 48ddfa440..0cbfc5354 100644 --- a/qutebrowser/widgets/statusbar/_command.py +++ b/qutebrowser/widgets/statusbar/_command.py @@ -20,24 +20,24 @@ import logging from PyQt5.QtCore import pyqtSignal, pyqtSlot -from PyQt5.QtWidgets import QLineEdit, QSizePolicy +from PyQt5.QtWidgets import QSizePolicy from PyQt5.QtGui import QValidator import qutebrowser.keyinput.modeman as modeman import qutebrowser.commands.utils as cmdutils +from qutebrowser.widgets.misc import MinimalLineEdit from qutebrowser.commands.managers import split_cmdline from qutebrowser.keyinput.modeparsers import STARTCHARS from qutebrowser.models.cmdhistory import (History, HistoryEmptyError, HistoryEndReachedError) -class Command(QLineEdit): +class Command(MinimalLineEdit): """The commandline part of the statusbar. Attributes: history: The command history object. - _statusbar: The statusbar (parent) QWidget. _validator: The current command validator. Signals: @@ -66,16 +66,8 @@ class Command(QLineEdit): # See http://www.saltycrane.com/blog/2008/01/how-to-capture-tab-key-press-event-with/ # for a possible fix. - def __init__(self, statusbar): - super().__init__(statusbar) - self._statusbar = statusbar - self.setStyleSheet(""" - QLineEdit { - border: 0px; - padding-left: 1px; - background-color: transparent; - } - """) + def __init__(self, parent=None): + super().__init__(parent) self.history = History() self._validator = _CommandValidator(self) self.setValidator(self._validator) diff --git a/qutebrowser/widgets/statusbar/_prompt.py b/qutebrowser/widgets/statusbar/_prompt.py index bd2efc0f8..e114c504c 100644 --- a/qutebrowser/widgets/statusbar/_prompt.py +++ b/qutebrowser/widgets/statusbar/_prompt.py @@ -18,11 +18,12 @@ """Prompt shown in the statusbar.""" from PyQt5.QtCore import pyqtSignal, QEventLoop, QObject -from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QWidget +from PyQt5.QtWidgets import QHBoxLayout, QWidget, QLineEdit import qutebrowser.keyinput.modeman as modeman import qutebrowser.commands.utils as cmdutils from qutebrowser.widgets.statusbar._textbase import TextBase +from qutebrowser.widgets.misc import MinimalLineEdit from qutebrowser.utils.usertypes import enum PromptMode = enum('yesno', 'text', 'user_pwd') @@ -193,19 +194,9 @@ class Prompt(QWidget): return self.question.answer -class _QueryInput(QLineEdit): +class _QueryInput(MinimalLineEdit): - """Minimal QLineEdit used for input.""" - - def __init__(self, parent=None): - super().__init__(parent) - self.setStyleSheet(""" - QLineEdit { - border: 0px; - padding-left: 1px; - background-color: transparent; - } - """) + """QLineEdit used for input.""" def focusInEvent(self, e): """Extend focusInEvent to enter command mode."""