From fc65ba4ced33e82eca4787270ce1a288acf35631 Mon Sep 17 00:00:00 2001 From: ngosang Date: Thu, 24 Sep 2015 18:17:50 +0200 Subject: [PATCH 1/2] [searchengine] Fix invalid plugin message --- src/searchengine/engineselectdlg.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 2841aed12..a0685d7d3 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -248,6 +248,10 @@ bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) con void engineSelectDlg::installPlugin(QString path, QString plugin_name) { qDebug("Asked to install plugin at %s", qPrintable(path)); qreal new_version = SearchEngine::getPluginVersion(path); + if (new_version == 0.0) { + QMessageBox::warning(this, tr("Invalid plugin"), tr("The search engine plugin is invalid, please contact the author.")); + return; + } qDebug("Version to be installed: %.2f", new_version); if (!isUpdateNeeded(plugin_name, new_version)) { qDebug("Apparently update is not needed, we have a more recent version"); From 6a1497de928f6ab9e983f67d95865e2ca74f69e6 Mon Sep 17 00:00:00 2001 From: ngosang Date: Thu, 24 Sep 2015 18:26:59 +0200 Subject: [PATCH 2/2] [searchengine] Detect new plugin URL from clipboard --- src/searchengine/engineselectdlg.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index a0685d7d3..bf63693da 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -46,6 +46,7 @@ #include #include #include +#include enum EngineColumns {ENGINE_NAME, ENGINE_VERSION, ENGINE_URL, ENGINE_STATE, ENGINE_ID}; @@ -351,9 +352,16 @@ void engineSelectDlg::on_installButton_clicked() { void engineSelectDlg::askForPluginUrl() { bool ok(false); + QString clipTxt = qApp->clipboard()->text(); + QString defaultUrl = "http://"; + if ((clipTxt.startsWith("http://", Qt::CaseInsensitive) + || clipTxt.startsWith("https://", Qt::CaseInsensitive) + || clipTxt.startsWith("ftp://", Qt::CaseInsensitive)) + && clipTxt.endsWith(".py")) + defaultUrl = clipTxt; QString url = AutoExpandableDialog::getText(this, tr("New search engine plugin URL"), tr("URL:"), QLineEdit::Normal, - "http://", &ok); + defaultUrl, &ok); while(true) { if (!ok || url.isEmpty())