mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Add JPEG Quality Option (#3285)
* fixes #3188 (#3254) Add JPEG quality option Signed-off-by: Mike Phillips <mdphillips375@gmail.com> Revert "Add JPEG quality option" This reverts commit 046497d8273a69ea1cc0f134a996a5ada818ed8c. * Add JPEG Quality Option * Fix local variable name * JPEG Quality: Add .ini example and minor fixes. * JPEG Quality: Add .ini example and minor fixes. * Fix Formatting --------- Co-authored-by: Mehrad Mahmoudian <m.mahmoudian@gmail.com>
This commit is contained in:
@@ -87,6 +87,9 @@
|
|||||||
;; Use larger color palette as the default one
|
;; Use larger color palette as the default one
|
||||||
; predefinedColorPaletteLarge=false
|
; predefinedColorPaletteLarge=false
|
||||||
;
|
;
|
||||||
|
;; Set JPEG Quality (int in range 0-100)
|
||||||
|
; jpegQuality=75
|
||||||
|
;
|
||||||
;; Shortcut Settings for all tools
|
;; Shortcut Settings for all tools
|
||||||
;[Shortcuts]
|
;[Shortcuts]
|
||||||
;TYPE_ARROW=A
|
;TYPE_ARROW=A
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ GeneralConf::GeneralConf(QWidget* parent)
|
|||||||
|
|
||||||
initShowMagnifier();
|
initShowMagnifier();
|
||||||
initSquareMagnifier();
|
initSquareMagnifier();
|
||||||
|
initJpegQuality();
|
||||||
// this has to be at the end
|
// this has to be at the end
|
||||||
initConfigButtons();
|
initConfigButtons();
|
||||||
updateComponents();
|
updateComponents();
|
||||||
@@ -777,11 +778,36 @@ void GeneralConf::initShowSelectionGeometry()
|
|||||||
vboxLayout->addStretch();
|
vboxLayout->addStretch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralConf::initJpegQuality()
|
||||||
|
{
|
||||||
|
auto* tobox = new QHBoxLayout();
|
||||||
|
|
||||||
|
int quality = ConfigHandler().value("jpegQuality").toInt();
|
||||||
|
m_jpegQuality = new QSpinBox();
|
||||||
|
m_jpegQuality->setRange(0, 100);
|
||||||
|
m_jpegQuality->setToolTip(tr("Quality range of 0-100; Higher number is "
|
||||||
|
"better quality and larger file size"));
|
||||||
|
m_jpegQuality->setValue(quality);
|
||||||
|
tobox->addWidget(m_jpegQuality);
|
||||||
|
tobox->addWidget(new QLabel(tr("JPEG Quality")));
|
||||||
|
|
||||||
|
m_scrollAreaLayout->addLayout(tobox);
|
||||||
|
connect(m_jpegQuality,
|
||||||
|
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||||
|
this,
|
||||||
|
&GeneralConf::setJpegQuality);
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralConf::setSelGeoHideTime(int v)
|
void GeneralConf::setSelGeoHideTime(int v)
|
||||||
{
|
{
|
||||||
ConfigHandler().setValue("showSelectionGeometryHideTime", v);
|
ConfigHandler().setValue("showSelectionGeometryHideTime", v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralConf::setJpegQuality(int v)
|
||||||
|
{
|
||||||
|
ConfigHandler().setJpegQuality(v);
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralConf::setGeometryLocation(int index)
|
void GeneralConf::setGeometryLocation(int index)
|
||||||
{
|
{
|
||||||
ConfigHandler().setValue("showSelectionGeometry",
|
ConfigHandler().setValue("showSelectionGeometry",
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ private slots:
|
|||||||
void setSaveAsFileExtension(const QString& extension);
|
void setSaveAsFileExtension(const QString& extension);
|
||||||
void setGeometryLocation(int index);
|
void setGeometryLocation(int index);
|
||||||
void setSelGeoHideTime(int v);
|
void setSelGeoHideTime(int v);
|
||||||
|
void setJpegQuality(int v);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString chooseFolder(const QString& currentPath = "");
|
const QString chooseFolder(const QString& currentPath = "");
|
||||||
@@ -90,6 +91,7 @@ private:
|
|||||||
void initUploadClientSecret();
|
void initUploadClientSecret();
|
||||||
void initSaveLastRegion();
|
void initSaveLastRegion();
|
||||||
void initShowSelectionGeometry();
|
void initShowSelectionGeometry();
|
||||||
|
void initJpegQuality();
|
||||||
|
|
||||||
void _updateComponents(bool allowEmptySavePath);
|
void _updateComponents(bool allowEmptySavePath);
|
||||||
|
|
||||||
@@ -133,4 +135,5 @@ private:
|
|||||||
QCheckBox* m_showSelectionGeometry;
|
QCheckBox* m_showSelectionGeometry;
|
||||||
QComboBox* m_selectGeometryLocation;
|
QComboBox* m_selectGeometryLocation;
|
||||||
QSpinBox* m_xywhTimeout;
|
QSpinBox* m_xywhTimeout;
|
||||||
|
QSpinBox* m_jpegQuality;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
|
|||||||
OPTION("copyOnDoubleClick" ,Bool ( false )),
|
OPTION("copyOnDoubleClick" ,Bool ( false )),
|
||||||
OPTION("uploadClientSecret" ,String ( "313baf0c7b4d3ff" )),
|
OPTION("uploadClientSecret" ,String ( "313baf0c7b4d3ff" )),
|
||||||
OPTION("showSelectionGeometry" , BoundedInt (0,5,4)),
|
OPTION("showSelectionGeometry" , BoundedInt (0,5,4)),
|
||||||
OPTION("showSelectionGeometryHideTime", LowerBoundedInt (0, 3000))
|
OPTION("showSelectionGeometryHideTime", LowerBoundedInt (0, 3000)),
|
||||||
|
OPTION("jpegQuality", BoundedInt (0,100,75))
|
||||||
};
|
};
|
||||||
|
|
||||||
static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {
|
static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ public:
|
|||||||
CONFIG_GETTER_SETTER(uploadClientSecret, setUploadClientSecret, QString)
|
CONFIG_GETTER_SETTER(uploadClientSecret, setUploadClientSecret, QString)
|
||||||
CONFIG_GETTER_SETTER(saveLastRegion, setSaveLastRegion, bool)
|
CONFIG_GETTER_SETTER(saveLastRegion, setSaveLastRegion, bool)
|
||||||
CONFIG_GETTER_SETTER(showSelectionGeometry, setShowSelectionGeometry, int)
|
CONFIG_GETTER_SETTER(showSelectionGeometry, setShowSelectionGeometry, int)
|
||||||
|
CONFIG_GETTER_SETTER(jpegQuality, setJpegQuality, int)
|
||||||
CONFIG_GETTER_SETTER(showSelectionGeometryHideTime,
|
CONFIG_GETTER_SETTER(showSelectionGeometryHideTime,
|
||||||
showSelectionGeometryHideTime,
|
showSelectionGeometryHideTime,
|
||||||
int)
|
int)
|
||||||
|
|||||||
@@ -35,7 +35,16 @@ bool saveToFilesystem(const QPixmap& capture,
|
|||||||
path, ConfigHandler().saveAsFileExtension());
|
path, ConfigHandler().saveAsFileExtension());
|
||||||
QFile file{ completePath };
|
QFile file{ completePath };
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
bool okay = capture.save(&file);
|
|
||||||
|
bool okay;
|
||||||
|
QString saveExtension;
|
||||||
|
saveExtension = QFileInfo(completePath).suffix().toLower();
|
||||||
|
if (saveExtension == "jpg" || saveExtension == "jpeg") {
|
||||||
|
okay = capture.save(&file, nullptr, ConfigHandler().jpegQuality());
|
||||||
|
} else {
|
||||||
|
okay = capture.save(&file);
|
||||||
|
}
|
||||||
|
|
||||||
QString saveMessage = messagePrefix;
|
QString saveMessage = messagePrefix;
|
||||||
QString notificationPath = completePath;
|
QString notificationPath = completePath;
|
||||||
if (!saveMessage.isEmpty()) {
|
if (!saveMessage.isEmpty()) {
|
||||||
@@ -97,6 +106,9 @@ void saveToClipboardMime(const QPixmap& capture, const QString& imageType)
|
|||||||
QByteArray array;
|
QByteArray array;
|
||||||
QBuffer buffer{ &array };
|
QBuffer buffer{ &array };
|
||||||
QImageWriter imageWriter{ &buffer, imageType.toUpper().toUtf8() };
|
QImageWriter imageWriter{ &buffer, imageType.toUpper().toUtf8() };
|
||||||
|
if (imageType == "jpeg") {
|
||||||
|
imageWriter.setQuality(ConfigHandler().jpegQuality());
|
||||||
|
}
|
||||||
imageWriter.write(capture.toImage());
|
imageWriter.write(capture.toImage());
|
||||||
|
|
||||||
QPixmap formattedPixmap;
|
QPixmap formattedPixmap;
|
||||||
@@ -189,7 +201,13 @@ bool saveToFilesystemGUI(const QPixmap& capture)
|
|||||||
QFile file{ savePath };
|
QFile file{ savePath };
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
okay = capture.save(&file);
|
QString saveExtension;
|
||||||
|
saveExtension = QFileInfo(savePath).suffix().toLower();
|
||||||
|
if (saveExtension == "jpg" || saveExtension == "jpeg") {
|
||||||
|
okay = capture.save(&file, nullptr, ConfigHandler().jpegQuality());
|
||||||
|
} else {
|
||||||
|
okay = capture.save(&file);
|
||||||
|
}
|
||||||
|
|
||||||
if (okay) {
|
if (okay) {
|
||||||
QString pathNoFile =
|
QString pathNoFile =
|
||||||
|
|||||||
Reference in New Issue
Block a user