mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-03-25 09:29:49 +00:00
Minor tweaks after code review
This commit is contained in:
committed by
borgmanJeremy
parent
a944860d12
commit
2ee76addbd
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user