Commit 69dfd182 authored by Pino Toscano's avatar Pino Toscano

Revert "Add option to copy screenshot to clipboard in background mode"

Too late for 19.04, breaks the feature and the string freezes.

This reverts commit ec5e9187.
parent ec5e9187
......@@ -31,8 +31,6 @@
#include <QBuffer>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QMimeData>
#include <QString>
#include <KSharedConfig>
#include <KConfigGroup>
......@@ -493,16 +491,9 @@ bool ExportManager::doSaveAs(QWidget *parentWindow, bool notify)
// misc helpers
void ExportManager::doCopyToClipboard(bool notify)
void ExportManager::doCopyToClipboard()
{
auto data = new QMimeData();
data->setImageData(mSavePixmap.toImage());
data->setData(QStringLiteral("x-kde-force-image-copy"), QByteArray());
QApplication::clipboard()->setMimeData(data, QClipboard::Clipboard);
if (notify) {
emit forceNotify(QUrl());
}
QApplication::clipboard()->setPixmap(mSavePixmap, QClipboard::Clipboard);
}
void ExportManager::doPrint(QPrinter *printer)
......
......@@ -87,7 +87,7 @@ class ExportManager : public QObject
void doSave(const QUrl &url = QUrl(), bool notify = false);
bool doSaveAs(QWidget *parentWindow = nullptr, bool notify = false);
void doCopyToClipboard(bool notify);
void doCopyToClipboard();
void doPrint(QPrinter *printer);
private:
......
......@@ -389,8 +389,7 @@ void KSMainWindow::showImageSharedFeedback(bool error, const QString &message)
void KSMainWindow::sendToClipboard()
{
bool notify = false;
ExportManager::instance()->doCopyToClipboard(notify);
ExportManager::instance()->doCopyToClipboard();
SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()
? quit()
......
......@@ -68,7 +68,6 @@ int main(int argc, char **argv)
{{QStringLiteral("n"), QStringLiteral("nonotify")}, i18n("In background mode, do not pop up a notification when the screenshot is taken")},
{{QStringLiteral("o"), QStringLiteral("output")}, i18n("In background mode, save image to specified file"), QStringLiteral("fileName")},
{{QStringLiteral("d"), QStringLiteral("delay")}, i18n("In background mode, delay before taking the shot (in milliseconds)"), QStringLiteral("delayMsec")},
{{QStringLiteral("c"), QStringLiteral("clipboard")}, i18n("In background mode, copy screenshot to clipboard")},
{{QStringLiteral("w"), QStringLiteral("onclick")}, i18n("Wait for a click before taking screenshot. Invalidates delay")}
});
......@@ -94,7 +93,6 @@ int main(int argc, char **argv)
SpectacleCore::StartMode startMode = SpectacleCore::GuiMode;
bool notify = true;
bool copyToClipboard = false;
qint64 delayMsec = 0;
QString fileName = QString();
......@@ -126,10 +124,6 @@ int main(int argc, char **argv)
delayMsec = -1;
}
if (parser.isSet(QStringLiteral("clipboard"))) {
copyToClipboard = true;
}
app.setQuitOnLastWindowClosed(false);
break;
......@@ -143,7 +137,7 @@ int main(int argc, char **argv)
// release the kraken
SpectacleCore core(startMode, grabMode, fileName, delayMsec, notify, copyToClipboard);
SpectacleCore core(startMode, grabMode, fileName, delayMsec, notify);
QObject::connect(&core, &SpectacleCore::allDone, qApp, &QApplication::quit);
// create the dbus connections
......
......@@ -42,15 +42,14 @@
#include <QTimer>
SpectacleCore::SpectacleCore(StartMode startMode, ImageGrabber::GrabMode grabMode, QString &saveFileName,
qint64 delayMsec, bool notifyOnGrab, bool copyToClipboard, QObject *parent) :
qint64 delayMsec, bool notifyOnGrab, QObject *parent) :
QObject(parent),
mExportManager(ExportManager::instance()),
mStartMode(startMode),
mNotify(notifyOnGrab),
mImageGrabber(nullptr),
mMainWindow(nullptr),
isGuiInited(false),
copyToClipboard(copyToClipboard)
isGuiInited(false)
{
KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("spectaclerc"));
KConfigGroup guiConfig(config, "GuiConfig");
......@@ -218,13 +217,9 @@ void SpectacleCore::screenshotUpdated(const QPixmap &pixmap)
connect(mExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doNotify);
}
if (copyToClipboard) {
mExportManager->doCopyToClipboard(mNotify);
} else {
QUrl savePath = (mStartMode == BackgroundMode && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ?
QUrl savePath = (mStartMode == BackgroundMode && mFileNameUrl.isValid() && mFileNameUrl.isLocalFile()) ?
mFileNameUrl : QUrl();
mExportManager->doSave(savePath);
}
mExportManager->doSave(savePath);
// if we notify, we emit allDone only if the user either dismissed the notification or pressed
// the "Open" button, otherwise the app closes before it can react to it.
......@@ -283,19 +278,15 @@ void SpectacleCore::doNotify(const QUrl &savedAt)
const QString &path = savedAt.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).path();
// a speaking message is prettier than a URL, special case for copy to clipboard and the default pictures location
if (copyToClipboard) {
notify->setText(i18n("A screenshot was saved to your clipboard."));
} else if (path == QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
// a speaking message is prettier than a URL, special case for the default pictures location
if (path == QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
notify->setText(i18nc("Placeholder is filename", "A screenshot was saved as '%1' to your Pictures folder.", savedAt.fileName()));
} else {
notify->setText(i18n("A screenshot was saved as '%1' to '%2'.", savedAt.fileName(), path));
}
if (!copyToClipboard) {
notify->setActions({i18nc("Open the screenshot we just saved", "Open")});
notify->setUrls({savedAt});
}
notify->setActions({i18nc("Open the screenshot we just saved", "Open")});
notify->setUrls({savedAt});
connect(notify, &KNotification::action1Activated, this, [this, savedAt] {
new KRun(savedAt, nullptr);
......
......@@ -42,7 +42,7 @@ class SpectacleCore : public QObject
};
explicit SpectacleCore(StartMode startMode, ImageGrabber::GrabMode grabMode, QString &saveFileName,
qint64 delayMsec, bool notifyOnGrab, bool copyToClipboard, QObject *parent = nullptr);
qint64 delayMsec, bool notifyOnGrab, QObject *parent = nullptr);
~SpectacleCore();
QString filename() const;
......@@ -81,7 +81,6 @@ class SpectacleCore : public QObject
ImageGrabber *mImageGrabber;
KSMainWindow *mMainWindow;
bool isGuiInited;
bool copyToClipboard;
};
#endif // KSCORE_H
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