-
Notifications
You must be signed in to change notification settings - Fork 0
/
xclip.patch
37 lines (35 loc) · 1.53 KB
/
xclip.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index def901e..2f81456 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1401,8 +1401,30 @@ bool MainWindow::saveAction(const QPixmap &pix)
if (copyToClipboard) {
Q_ASSERT(!screenShotPix.isNull());
- QClipboard* cb = qApp->clipboard();
- cb->setPixmap(screenShotPix, QClipboard::Clipboard);
+ bool tmpFileCreated = false;
+
+ if (!QFile("/usr/bin/xclip").exists()) {
+ qCritical() << "Copying to clipboard failed. Please install xclip!";
+ return false;
+ } else {
+
+ QTemporaryFile file;
+ if (file.open()) {
+ tmpFileCreated = true;
+ screenShotPix.save(file.fileName(), "PNG");
+ qDebug() << "tmp filename: " << file.fileName();
+ QString command = QString("/usr/bin/xclip -selection clipboard -t image/png -i %1").arg(file.fileName());
+ if(m_saveFileName != "") {
+ command = QString("/usr/bin/xclip -selection clipboard -t image/png -i %1").arg(m_saveFileName); // if auto save + copy to clipboard selected, use saved file
+ }
+ qDebug() << "command: " << command;
+ QProcess::execute(command);
+ } // do not add else part to not distrubt tmp file destruction process
+ }
+ if(!tmpFileCreated) {
+ qCritical() << "Saving image into temporary file failed!";
+ return false;
+ }
}
return true;