From a64b9803d7fb86a42939c21fe199e9a76c17fd88 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 25 Feb 2021 14:03:45 +0200 Subject: [PATCH] fix - MacOS - Image is not copied to the clipboard when the 'Use JPG format for clipboard' checkbox is set (cherry picked from commit 802d8bc3dfd2644d264938b4fc1e0adbc39d110b) --- src/config/generalconf.cpp | 4 ++++ src/utils/confighandler.cpp | 3 +++ src/utils/screenshotsaver.cpp | 4 +--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 4fc0743a..e3c163c8 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -386,6 +386,10 @@ void GeneralConf::initUseJpgForClipboard() tr("Use JPG format for clipboard (PNG default)")); m_layout->addWidget(m_useJpgForClipboard); +#if defined(Q_OS_MACOS) + // FIXME - temporary fix to disable option for MacOS + m_useJpgForClipboard->hide(); +#endif connect(m_useJpgForClipboard, &QCheckBox::clicked, this, diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index a9b87c25..61235057 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -506,9 +506,12 @@ void ConfigHandler::setCopyPathAfterSaveEnabled(const bool value) bool ConfigHandler::useJpgForClipboard() const { +#if not defined(Q_OS_MACOS) + // FIXME - temporary fix to disable option for MacOS if (m_settings.contains(QStringLiteral("useJpgForClipboard"))) { return m_settings.value(QStringLiteral("useJpgForClipboard")).toBool(); } +#endif return false; } diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 63990035..34b9ab5d 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -29,7 +29,6 @@ ScreenshotSaver::ScreenshotSaver(const unsigned id) // dbus, the application freezes. void ScreenshotSaver::saveToClipboard(const QPixmap& capture) { - // If we are able to properly save the file, save the file and copy to // clipboard. if ((ConfigHandler().saveAfterCopyValue()) && @@ -42,6 +41,7 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture) // Otherwise only save to clipboard else { if (ConfigHandler().useJpgForClipboard()) { + // FIXME - it doesn't work on MacOS QByteArray array; QBuffer buffer{ &array }; QImageWriter imageWriter{ &buffer, "JPEG" }; @@ -58,14 +58,12 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture) QMimeData* mimeData = new QMimeData; mimeData->setData("image/jpeg", array); QApplication::clipboard()->setMimeData(mimeData); - } else { SystemNotification().sendMessage( QObject::tr("Error while saving to clipboard")); return; } } else { - // Need to send message before copying to clipboard SystemNotification().sendMessage( QObject::tr("Capture saved to clipboard"));