Add config for jpg/png when copy
This commit is contained in:
committed by
borgmanJeremy
parent
b121c6c72b
commit
a944860d12
@@ -51,22 +51,27 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture)
|
||||
}
|
||||
// Otherwise only save to clipboard
|
||||
else {
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("Capture saved to clipboard"));
|
||||
if (ConfigHandler().useJpgInsteadPngWhenCopy()) {
|
||||
QByteArray array;
|
||||
QBuffer buffer{ &array };
|
||||
QImageWriter imageWriter{ &buffer, "JPG" };
|
||||
imageWriter.write(capture.toImage());
|
||||
|
||||
QByteArray array;
|
||||
QBuffer buffer{ &array };
|
||||
QImageWriter imageWriter{ &buffer, "JPG" };
|
||||
imageWriter.write(capture.toImage());
|
||||
|
||||
QPixmap jpgPixmap;
|
||||
bool isLoaded = jpgPixmap.loadFromData(
|
||||
reinterpret_cast<uchar*>(array.data()), array.size(), "JPG");
|
||||
if (isLoaded) {
|
||||
QApplication::clipboard()->setPixmap(jpgPixmap);
|
||||
QPixmap jpgPixmap;
|
||||
bool isLoaded = jpgPixmap.loadFromData(
|
||||
reinterpret_cast<uchar*>(array.data()), array.size(), "JPG");
|
||||
if (isLoaded) {
|
||||
QApplication::clipboard()->setPixmap(jpgPixmap);
|
||||
} else {
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("Error while saving to clipboard"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
QApplication::clipboard()->setPixmap(capture);
|
||||
}
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("Capture saved to clipboard"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user