Slightly re-style prompts

See #2104
This commit is contained in:
Florian Bruhin 2017-09-26 21:28:01 +02:00
parent 6af879887f
commit b879f5e648
3 changed files with 40 additions and 12 deletions

View File

@ -55,6 +55,7 @@
|<<colors.messages.warning.border,colors.messages.warning.border>>|Border color of an error message.
|<<colors.messages.warning.fg,colors.messages.warning.fg>>|Foreground color a warning message.
|<<colors.prompts.bg,colors.prompts.bg>>|Background color for prompts.
|<<colors.prompts.border,colors.prompts.border>>|Border used around UI elements in prompts.
|<<colors.prompts.fg,colors.prompts.fg>>|Foreground color for prompts.
|<<colors.prompts.selected.bg,colors.prompts.selected.bg>>|Background color for the selected item in filename prompts.
|<<colors.statusbar.caret.bg,colors.statusbar.caret.bg>>|Background color of the statusbar in caret mode.
@ -967,7 +968,15 @@ Background color for prompts.
Type: <<types,QssColor>>
Default: +pass:[darkblue]+
Default: +pass:[dimgrey]+
[[colors.prompts.border]]
=== colors.prompts.border
Border used around UI elements in prompts.
Type: <<types,String>>
Default: +pass:[1px solid gray]+
[[colors.prompts.fg]]
=== colors.prompts.fg
@ -983,7 +992,7 @@ Background color for the selected item in filename prompts.
Type: <<types,QssColor>>
Default: +pass:[#308cc6]+
Default: +pass:[grey]+
[[colors.statusbar.caret.bg]]
=== colors.statusbar.caret.bg

View File

@ -1551,13 +1551,18 @@ colors.prompts.fg:
type: QssColor
desc: Foreground color for prompts.
colors.prompts.border:
default: 1px solid gray
type: String
desc: Border used around UI elements in prompts.
colors.prompts.bg:
default: darkblue
default: dimgrey
type: QssColor
desc: Background color for prompts.
colors.prompts.selected.bg:
default: '#308cc6'
default: grey
type: QssColor
desc: Background color for the selected item in filename prompts.

View File

@ -28,7 +28,8 @@ import sip
from PyQt5.QtCore import (pyqtSlot, pyqtSignal, Qt, QTimer, QDir, QModelIndex,
QItemSelectionModel, QObject, QEventLoop)
from PyQt5.QtWidgets import (QWidget, QGridLayout, QVBoxLayout, QLineEdit,
QLabel, QFileSystemModel, QTreeView, QSizePolicy)
QLabel, QFileSystemModel, QTreeView, QSizePolicy,
QSpacerItem)
from qutebrowser.browser import downloads
from qutebrowser.config import config
@ -256,11 +257,21 @@ class PromptContainer(QWidget):
background-color: {{ conf.colors.prompts.bg }};
}
QTreeView {
selection-background-color: {{ conf.colors.prompts.selected.bg }};
QLineEdit {
border: {{ conf.colors.prompts.border }};
}
QTreeView::item:selected, QTreeView::item:selected:hover {
QTreeView {
selection-background-color: {{ conf.colors.prompts.selected.bg }};
border: {{ conf.colors.prompts.border }};
}
QTreeView::branch {
background-color: {{ conf.colors.prompts.bg }};
}
QTreeView::item:selected, QTreeView::item:selected:hover,
QTreeView::branch:selected {
background-color: {{ conf.colors.prompts.selected.bg }};
}
"""
@ -433,7 +444,6 @@ class LineEdit(QLineEdit):
super().__init__(parent)
self.setStyleSheet("""
QLineEdit {
border: 1px solid grey;
background-color: transparent;
}
""")
@ -511,6 +521,9 @@ class _BasePrompt(QWidget):
self._key_grid.addWidget(key_label, i, 0)
self._key_grid.addWidget(text_label, i, 1)
spacer = QSpacerItem(0, 0, QSizePolicy.Expanding)
self._key_grid.addItem(spacer, 0, 2)
self._vbox.addLayout(self._key_grid)
def accept(self, value=None):
@ -559,8 +572,7 @@ class FilenamePrompt(_BasePrompt):
def __init__(self, question, parent=None):
super().__init__(question, parent)
self._init_texts(question)
self._init_fileview()
self._set_fileview_root(question.default)
self._init_key_label()
self._lineedit = LineEdit(self)
if question.default:
@ -569,7 +581,9 @@ class FilenamePrompt(_BasePrompt):
self._vbox.addWidget(self._lineedit)
self.setFocusProxy(self._lineedit)
self._init_key_label()
self._init_fileview()
self._set_fileview_root(question.default)
if config.val.prompt.filebrowser:
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)