From c7aa2cb684be949bf0ae232cb6a3fa38b97f9adf Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 1 Sep 2013 20:42:44 +0300 Subject: [PATCH] Display a message when a link to a search plugin is invalid. Closes #892. --- src/searchengine/engineselectdlg.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 5b4b24e7e..4bbef26d8 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -326,14 +326,26 @@ void engineSelectDlg::on_installButton_clicked() { } void engineSelectDlg::askForPluginUrl() { - bool ok; + bool ok(false); QString url = AutoExpandableDialog::getText(this, tr("New search engine plugin URL"), tr("URL:"), QLineEdit::Normal, "http://", &ok); - if (ok && !url.isEmpty()) { - setCursor(QCursor(Qt::WaitCursor)); - downloader->downloadUrl(url); + + while(true) { + if (!ok || url.isEmpty()) + return; + if (!url.endsWith(".py")) { + QMessageBox::warning(this, tr("Invlalid link"), tr("The link doesn't seem to point to a search engine plugin.")); + url = AutoExpandableDialog::getText(this, tr("New search engine plugin URL"), + tr("URL:"), QLineEdit::Normal, + url, &ok); + } + else + break; } + + setCursor(QCursor(Qt::WaitCursor)); + downloader->downloadUrl(url); } void engineSelectDlg::askForLocalPlugin() {