Minor tweaks after code review

This commit is contained in:
Jeremy Borgman
2021-02-01 19:35:41 -06:00
committed by borgmanJeremy
parent a944860d12
commit 2ee76addbd
5 changed files with 35 additions and 31 deletions

View File

@@ -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()

View File

@@ -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();

View File

@@ -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<uchar*>(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"));
}
}