diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp index d7b18b27..e9d6a18d 100644 --- a/src/config/geneneralconf.cpp +++ b/src/config/geneneralconf.cpp @@ -39,11 +39,11 @@ GeneneralConf::GeneneralConf(QWidget* parent) initShowDesktopNotification(); initShowTrayIcon(); initAutostart(); - initUseJpgInsteadPngWhenCopy(); + initUseJpgForClipboard(); initSaveAfterCopy(); // this has to be at the end - initConfingButtons(); + initConfigButtons(); updateComponents(); } @@ -55,7 +55,7 @@ void GeneneralConf::updateComponents() m_sysNotifications->setChecked(config.desktopNotificationValue()); m_autostart->setChecked(config.startupLaunchValue()); m_saveAfterCopy->setChecked(config.saveAfterCopyValue()); - m_useJpgInsteadPngCheck->setChecked(config.useJpgInsteadPngWhenCopy()); + m_useJpgForClipboard->setChecked(config.useJpgForClipboard()); if (!config.saveAfterCopyPathValue().isEmpty()) { m_savePath->setText(config.saveAfterCopyPathValue()); @@ -216,7 +216,7 @@ void GeneneralConf::initShowTrayIcon() #endif } -void GeneneralConf::initConfingButtons() +void GeneneralConf::initConfigButtons() { QHBoxLayout* buttonLayout = new QHBoxLayout(); m_layout->addStretch(); @@ -306,21 +306,21 @@ void GeneneralConf::initSaveAfterCopy() vboxLayout->addWidget(m_screenshotPathFixedCheck); } -void GeneneralConf::initUseJpgInsteadPngWhenCopy() +void GeneneralConf::initUseJpgForClipboard() { - m_useJpgInsteadPngCheck = - new QCheckBox(tr("Use JPG format instead of PNG when copy"), this); + m_useJpgForClipboard = + new QCheckBox(tr("Use JPG format for clipboard (PNG default)"), this); ConfigHandler config; - bool checked = config.useJpgInsteadPngWhenCopy(); - m_useJpgInsteadPngCheck->setChecked(checked); - m_useJpgInsteadPngCheck->setToolTip( - tr("Use JPG format instead of PNG when copy")); - m_layout->addWidget(m_useJpgInsteadPngCheck); + bool checked = config.useJpgForClipboard(); + m_useJpgForClipboard->setChecked(checked); + m_useJpgForClipboard->setToolTip( + tr("Use JPG format for clipboard (PNG default)")); + m_layout->addWidget(m_useJpgForClipboard); - connect(m_useJpgInsteadPngCheck, + connect(m_useJpgForClipboard, &QCheckBox::clicked, this, - &GeneneralConf::useJpgInsteadPngChanged); + &GeneneralConf::useJpgForClipboardChanged); } void GeneneralConf::saveAfterCopyChanged(bool checked) @@ -368,7 +368,7 @@ void GeneneralConf::togglePathFixed() ConfigHandler().setSavePathFixed(m_screenshotPathFixedCheck->isChecked()); } -void GeneneralConf::useJpgInsteadPngChanged(bool checked) +void GeneneralConf::useJpgForClipboardChanged(bool checked) { - ConfigHandler().setUseJpgInsteadPngWhenCopy(checked); + ConfigHandler().setUseJpgForClipboard(checked); } diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index ce6418a7..e82f01e0 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -46,7 +46,7 @@ private slots: void exportFileConfiguration(); void resetConfiguration(); void togglePathFixed(); - void useJpgInsteadPngChanged(bool checked); + void useJpgForClipboardChanged(bool checked); private: const QString chooseFolder(const QString currentPath = ""); @@ -55,10 +55,10 @@ private: void initShowSidePanelButton(); void initShowDesktopNotification(); void initShowTrayIcon(); - void initConfingButtons(); + void initConfigButtons(); void initAutostart(); void initSaveAfterCopy(); - void initUseJpgInsteadPngWhenCopy(); + void initUseJpgForClipboard(); // class members QVBoxLayout* m_layout; @@ -74,5 +74,5 @@ private: QLineEdit* m_savePath; QPushButton* m_changeSaveButton; QCheckBox* m_screenshotPathFixedCheck; - QCheckBox* m_useJpgInsteadPngCheck; + QCheckBox* m_useJpgForClipboard; }; diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 61697e81..1c0a6b92 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -431,18 +431,17 @@ void ConfigHandler::setCopyPathAfterSaveEnabled(const bool value) m_settings.setValue(QStringLiteral("copyPathAfterSave"), value); } -bool ConfigHandler::useJpgInsteadPngWhenCopy() const +bool ConfigHandler::useJpgForClipboard() const { - if (m_settings.contains(QStringLiteral("useJpgInsteadPngWhenCopy"))) { - return m_settings.value(QStringLiteral("useJpgInsteadPngWhenCopy")) - .toBool(); + if (m_settings.contains(QStringLiteral("useJpgForClipboard"))) { + return m_settings.value(QStringLiteral("useJpgForClipboard")).toBool(); } return false; } -void ConfigHandler::setUseJpgInsteadPngWhenCopy(const bool value) +void ConfigHandler::setUseJpgForClipboard(const bool value) { - m_settings.setValue(QStringLiteral("useJpgInsteadPngWhenCopy"), value); + m_settings.setValue(QStringLiteral("useJpgForClipboard"), value); } QString ConfigHandler::saveAfterCopyPathValue() diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 66fb9617..e39de691 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -86,8 +86,8 @@ public: bool copyPathAfterSaveEnabled(); void setCopyPathAfterSaveEnabled(const bool); - bool useJpgInsteadPngWhenCopy() const; - void setUseJpgInsteadPngWhenCopy(const bool); + bool useJpgForClipboard() const; + void setUseJpgForClipboard(const bool); void setDefaults(); void setAllTheButtons(); diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 5273da3f..1c475d2b 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -51,7 +51,7 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture) } // Otherwise only save to clipboard else { - if (ConfigHandler().useJpgInsteadPngWhenCopy()) { + if (ConfigHandler().useJpgForClipboard()) { QByteArray array; QBuffer buffer{ &array }; QImageWriter imageWriter{ &buffer, "JPG" }; @@ -61,6 +61,9 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture) bool isLoaded = jpgPixmap.loadFromData( reinterpret_cast(array.data()), array.size(), "JPG"); if (isLoaded) { + // Need to send message before copying to clipboard + SystemNotification().sendMessage( + QObject::tr("Capture saved to clipboard")); QApplication::clipboard()->setPixmap(jpgPixmap); } else { SystemNotification().sendMessage( @@ -68,10 +71,12 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture) return; } } else { + + // Need to send message before copying to clipboard + SystemNotification().sendMessage( + QObject::tr("Capture saved to clipboard")); QApplication::clipboard()->setPixmap(capture); } - SystemNotification().sendMessage( - QObject::tr("Capture saved to clipboard")); } }