From b879f5e648d27624ca5648b314223299442cba86 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 26 Sep 2017 21:28:01 +0200 Subject: [PATCH] Slightly re-style prompts See #2104 --- doc/help/settings.asciidoc | 13 +++++++++++-- qutebrowser/config/configdata.yml | 9 +++++++-- qutebrowser/mainwindow/prompt.py | 30 ++++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index c600e820b..b40d03237 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -55,6 +55,7 @@ |<>|Border color of an error message. |<>|Foreground color a warning message. |<>|Background color for prompts. +|<>|Border used around UI elements in prompts. |<>|Foreground color for prompts. |<>|Background color for the selected item in filename prompts. |<>|Background color of the statusbar in caret mode. @@ -967,7 +968,15 @@ Background color for prompts. Type: <> -Default: +pass:[darkblue]+ +Default: +pass:[dimgrey]+ + +[[colors.prompts.border]] +=== colors.prompts.border +Border used around UI elements in prompts. + +Type: <> + +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: <> -Default: +pass:[#308cc6]+ +Default: +pass:[grey]+ [[colors.statusbar.caret.bg]] === colors.statusbar.caret.bg diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index a3b0023b1..a4467ac08 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -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. diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index 4242ceb8e..1f4c47c78 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -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)