blob: 6251d9f00dbe5bea6c5b8f57e7413f3792e19919 (
plain)
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
|
--- a/src/main_window.cpp 2020-05-09 02:25:59.000000000 -0500
+++ b/src/main_window.cpp 2020-08-09 16:06:00.426504142 -0500
@@ -2493,9 +2493,30 @@
if (m_copyToClipboard) {
Q_ASSERT(!screenShotPix.isNull());
- QClipboard *cb = qApp->clipboard();
-// cb->setPixmap(screenShotPix, QClipboard::Clipboard);
- cb->setMimeData(t_imageData, 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;
+ }
qDebug() << "clip board success!";
}
|