1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

GM_Manager: Remove no longer needed doDownloadScript helper

downloadScript is now always called from main thread again.
This commit is contained in:
David Rosca 2018-01-29 22:03:43 +01:00
parent f9feab7d9d
commit a89fcf9002
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 20 additions and 26 deletions

View File

@ -64,7 +64,25 @@ void GM_Manager::showSettings(QWidget* parent)
void GM_Manager::downloadScript(const QUrl &url)
{
QMetaObject::invokeMethod(this, "doDownloadScript", Qt::QueuedConnection, Q_ARG(QUrl, url));
GM_Downloader *downloader = new GM_Downloader(url, this);
connect(downloader, &GM_Downloader::finished, this, [=](const QString &fileName) {
bool deleteScript = true;
GM_Script *script = new GM_Script(this, fileName);
if (script->isValid()) {
if (!containsScript(script->fullName())) {
GM_AddScriptDialog dialog(this, script);
deleteScript = dialog.exec() != QDialog::Accepted;
}
else {
showNotification(tr("'%1' is already installed").arg(script->name()));
}
}
if (deleteScript) {
delete script;
QFile(fileName).remove();
}
});
}
QString GM_Manager::settinsPath() const
@ -264,29 +282,6 @@ void GM_Manager::scriptChanged()
collection->insert(script->webScript());
}
void GM_Manager::doDownloadScript(const QUrl &url)
{
GM_Downloader *downloader = new GM_Downloader(url, this);
connect(downloader, &GM_Downloader::finished, this, [=](const QString &fileName) {
bool deleteScript = true;
GM_Script *script = new GM_Script(this, fileName);
if (script->isValid()) {
if (!containsScript(script->fullName())) {
GM_AddScriptDialog dialog(this, script);
deleteScript = dialog.exec() != QDialog::Accepted;
}
else {
showNotification(tr("'%1' is already installed").arg(script->name()));
}
}
if (deleteScript) {
delete script;
QFile(fileName).remove();
}
});
}
bool GM_Manager::canRunOnScheme(const QString &scheme)
{
return (scheme == QLatin1String("http") || scheme == QLatin1String("https")

View File

@ -73,7 +73,6 @@ public slots:
private slots:
void load();
void scriptChanged();
void doDownloadScript(const QUrl &url);
private:
QString m_settingsPath;

View File

@ -41,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec()
spec.name = "GreaseMonkey";
spec.info = "Userscripts for Falkon";
spec.description = "Provides support for userscripts";
spec.version = "0.9.3";
spec.version = "0.9.4";
spec.author = "David Rosca <nowrep@gmail.com>";
spec.icon = QIcon(":gm/data/icon.svg").pixmap(32);
spec.hasSettings = true;