use message.error instead of a tooltip

This commit is contained in:
Daniel Schadt 2017-03-29 17:07:53 +02:00
parent 99f7bfa712
commit 186eab8eb1
2 changed files with 8 additions and 14 deletions

View File

@ -643,15 +643,11 @@ class FilenamePrompt(_BasePrompt):
self._file_model.directoryLoaded.connect( self._file_model.directoryLoaded.connect(
lambda: self._file_model.sort(0)) 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): def accept(self, value=None):
text = value if value is not None else self._lineedit.text() text = value if value is not None else self._lineedit.text()
text = downloads.transform_path(text) text = downloads.transform_path(text)
if text is None: if text is None:
self._show_error("Invalid filename") message.error("Invalid filename")
return False return False
self.question.answer = text self.question.answer = text
return True return True
@ -703,13 +699,11 @@ class DownloadFilenamePrompt(FilenamePrompt):
self._file_model.setFilter(QDir.AllDirs | QDir.Drives | QDir.NoDot) self._file_model.setFilter(QDir.AllDirs | QDir.Drives | QDir.NoDot)
def accept(self, value=None): def accept(self, value=None):
text = value if value is not None else self._lineedit.text() done = super().accept(value)
text = downloads.transform_path(text) answer = self.question.answer
if text is None: if answer is not None:
self._show_error("Invalid filename") self.question.answer = downloads.FileDownloadTarget(answer)
return False return done
self.question.answer = downloads.FileDownloadTarget(text)
return True
def download_open(self, cmdline): def download_open(self, cmdline):
self.question.answer = downloads.OpenFileDownloadTarget(cmdline) self.question.answer = downloads.OpenFileDownloadTarget(cmdline)

View File

@ -133,7 +133,7 @@ Feature: Downloading things from a website.
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='*' mode=<PromptMode.download: 5> text='Please enter a location for <b>http://localhost:*/data/downloads/download.bin</b>' title='Save file to:'>, *" in the log And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='*' mode=<PromptMode.download: 5> text='Please enter a location for <b>http://localhost:*/data/downloads/download.bin</b>' title='Save file to:'>, *" in the log
And I run :prompt-accept COM1 And I run :prompt-accept COM1
And I run :leave-mode And I run :leave-mode
Then "Invalid filename" should be logged Then the error "Invalid filename" should be shown
@windows @windows
Scenario: Downloading a file to a drive-relative working directory 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 <qutebrowser.utils.usertypes.Question default='*' mode=<PromptMode.download: 5> text='Please enter a location for <b>http://localhost:*/data/downloads/download.bin</b>' title='Save file to:'>, *" in the log And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='*' mode=<PromptMode.download: 5> text='Please enter a location for <b>http://localhost:*/data/downloads/download.bin</b>' title='Save file to:'>, *" in the log
And I run :prompt-accept C:foobar And I run :prompt-accept C:foobar
And I run :leave-mode And I run :leave-mode
Then "Invalid filename" should be logged Then the error "Invalid filename" should be shown
@windows @windows
Scenario: Downloading a file to a reserved path with :download Scenario: Downloading a file to a reserved path with :download