Commit e0642ac5 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[imgur] Copy link to clipboard and show notification

Currently it is up to the application to present the result url to the user, and they do that quite inconsistently.

Some apps open the url, some show it in an inline message, some copy it to the clipboard.

With this patch the link is always copied to the clipboard and a notification informs the user that this has been done.

This also removes the url property from the output which automatically removes the applications's own message handling

BUG: 437347
parent 14183759
add_definitions(-DTRANSLATION_DOMAIN=\"purpose_imgur\")
add_share_plugin(imgurplugin imgurplugin.cpp mpform.cpp)
target_link_libraries(imgurplugin KF5::KIOCore KF5::I18n)
target_link_libraries(imgurplugin KF5::KIOCore KF5::I18n KF5::Notifications)
......@@ -9,8 +9,11 @@
#include <KIO/TransferJob>
#include <KJob>
#include <KLocalizedString>
#include <KNotification>
#include <KPluginFactory>
#include <QClipboard>
#include <QDebug>
#include <QGuiApplication>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
......@@ -138,7 +141,14 @@ public:
if (m_pendingJobs == 0) {
const QString finalUrl = m_albumId.isEmpty() ? url : QStringLiteral("https://imgur.com/a/") + m_albumId;
const QString deleteUrl = QStringLiteral("https://imgur.com/delete/") + deletehash;
setOutput({{QStringLiteral("url"), finalUrl}, {QStringLiteral("deleteUrl"), deleteUrl}});
QGuiApplication::clipboard()->setText(url);
KNotification::event(KNotification::Notification,
i18n("Imgur Upload"),
i18n("The shared image link (<a href=\"%1\">%1</a>) has been copied to the clipboard.", finalUrl),
nullptr,
KNotification::Persistent);
emitResult();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment