From 99f7bfa712984a9647b0d2fd3ee5187a996ea13d Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 29 Mar 2017 16:44:29 +0200 Subject: [PATCH 1/3] show messages on top of the prompt Otherwise, errors are hidden behind the prompt, which makes it hard to use them in the filename prompt. --- qutebrowser/mainwindow/mainwindow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 9858abf7d..fbc86d010 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -184,8 +184,6 @@ class MainWindow(QWidget): self._keyhint = keyhintwidget.KeyHintView(self.win_id, self) self._add_overlay(self._keyhint, self._keyhint.update_geometry) - self._messageview = messageview.MessageView(parent=self) - self._add_overlay(self._messageview, self._messageview.update_geometry) self._prompt_container = prompt.PromptContainer(self.win_id, self) self._add_overlay(self._prompt_container, @@ -195,6 +193,9 @@ class MainWindow(QWidget): scope='window', window=self.win_id) self._prompt_container.hide() + self._messageview = messageview.MessageView(parent=self) + self._add_overlay(self._messageview, self._messageview.update_geometry) + if geometry is not None: self._load_geometry(geometry) elif self.win_id == 0: From 186eab8eb154b6d35e429354e9f22016b633f3a5 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 29 Mar 2017 17:07:53 +0200 Subject: [PATCH 2/3] use message.error instead of a tooltip --- qutebrowser/mainwindow/prompt.py | 18 ++++++------------ tests/end2end/features/downloads.feature | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index 8a469cb00..b3c7c23dd 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -643,15 +643,11 @@ class FilenamePrompt(_BasePrompt): self._file_model.directoryLoaded.connect( lambda: self._file_model.sort(0)) - def _show_error(self, msg): - log.prompt.error(msg) - QToolTip.showText(self._lineedit.mapToGlobal(QPoint(0, 0)), msg) - def accept(self, value=None): text = value if value is not None else self._lineedit.text() text = downloads.transform_path(text) if text is None: - self._show_error("Invalid filename") + message.error("Invalid filename") return False self.question.answer = text return True @@ -703,13 +699,11 @@ class DownloadFilenamePrompt(FilenamePrompt): self._file_model.setFilter(QDir.AllDirs | QDir.Drives | QDir.NoDot) def accept(self, value=None): - text = value if value is not None else self._lineedit.text() - text = downloads.transform_path(text) - if text is None: - self._show_error("Invalid filename") - return False - self.question.answer = downloads.FileDownloadTarget(text) - return True + done = super().accept(value) + answer = self.question.answer + if answer is not None: + self.question.answer = downloads.FileDownloadTarget(answer) + return done def download_open(self, cmdline): self.question.answer = downloads.OpenFileDownloadTarget(cmdline) diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature index 1e4587740..fe312944f 100644 --- a/tests/end2end/features/downloads.feature +++ b/tests/end2end/features/downloads.feature @@ -133,7 +133,7 @@ Feature: Downloading things from a website. And I wait for "Asking question text='Please enter a location for http://localhost:*/data/downloads/download.bin' title='Save file to:'>, *" in the log And I run :prompt-accept COM1 And I run :leave-mode - Then "Invalid filename" should be logged + Then the error "Invalid filename" should be shown @windows Scenario: Downloading a file to a drive-relative working directory @@ -142,7 +142,7 @@ Feature: Downloading things from a website. And I wait for "Asking question text='Please enter a location for http://localhost:*/data/downloads/download.bin' title='Save file to:'>, *" in the log And I run :prompt-accept C:foobar And I run :leave-mode - Then "Invalid filename" should be logged + Then the error "Invalid filename" should be shown @windows Scenario: Downloading a file to a reserved path with :download From 563a5431e35831cb0a8c418835c54d0264d92c78 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 29 Mar 2017 18:32:07 +0200 Subject: [PATCH 3/3] fixup! use message.error instead of a tooltip --- qutebrowser/mainwindow/prompt.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index b3c7c23dd..f57e2cad6 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -25,10 +25,9 @@ import collections import sip from PyQt5.QtCore import (pyqtSlot, pyqtSignal, Qt, QTimer, QDir, QModelIndex, - QItemSelectionModel, QObject, QEventLoop, QPoint) + QItemSelectionModel, QObject, QEventLoop) from PyQt5.QtWidgets import (QWidget, QGridLayout, QVBoxLayout, QLineEdit, - QLabel, QFileSystemModel, QTreeView, QSizePolicy, - QToolTip) + QLabel, QFileSystemModel, QTreeView, QSizePolicy) from qutebrowser.browser import downloads from qutebrowser.config import style, config