mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
GM_Manager: Remove no longer needed doDownloadScript helper
downloadScript is now always called from main thread again.
This commit is contained in:
parent
f9feab7d9d
commit
a89fcf9002
@ -64,7 +64,25 @@ void GM_Manager::showSettings(QWidget* parent)
|
|||||||
|
|
||||||
void GM_Manager::downloadScript(const QUrl &url)
|
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
|
QString GM_Manager::settinsPath() const
|
||||||
@ -264,29 +282,6 @@ void GM_Manager::scriptChanged()
|
|||||||
collection->insert(script->webScript());
|
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)
|
bool GM_Manager::canRunOnScheme(const QString &scheme)
|
||||||
{
|
{
|
||||||
return (scheme == QLatin1String("http") || scheme == QLatin1String("https")
|
return (scheme == QLatin1String("http") || scheme == QLatin1String("https")
|
||||||
|
@ -73,7 +73,6 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void load();
|
void load();
|
||||||
void scriptChanged();
|
void scriptChanged();
|
||||||
void doDownloadScript(const QUrl &url);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_settingsPath;
|
QString m_settingsPath;
|
||||||
|
@ -41,7 +41,7 @@ PluginSpec GM_Plugin::pluginSpec()
|
|||||||
spec.name = "GreaseMonkey";
|
spec.name = "GreaseMonkey";
|
||||||
spec.info = "Userscripts for Falkon";
|
spec.info = "Userscripts for Falkon";
|
||||||
spec.description = "Provides support for userscripts";
|
spec.description = "Provides support for userscripts";
|
||||||
spec.version = "0.9.3";
|
spec.version = "0.9.4";
|
||||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||||
spec.icon = QIcon(":gm/data/icon.svg").pixmap(32);
|
spec.icon = QIcon(":gm/data/icon.svg").pixmap(32);
|
||||||
spec.hasSettings = true;
|
spec.hasSettings = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user