Add a new MinimalLineEdit widget

This commit is contained in:
Florian Bruhin 2014-05-20 10:11:05 +02:00
parent 1a959a39b2
commit 20f8c2b8b4
3 changed files with 44 additions and 26 deletions

View File

@ -0,0 +1,35 @@
# 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/>.
"""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;
}
""")

View File

@ -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)

View File

@ -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."""