diff --git a/flameshot.example.ini b/flameshot.example.ini index 580307ff..72ccdb39 100644 --- a/flameshot.example.ini +++ b/flameshot.example.ini @@ -66,6 +66,9 @@ ;; Copy path to image after save (bool) ;copyPathAfterSave=false ; +;; Anti-aliasing image when zoom the pinned image (bool) +;antialiasingPinZoom=true +; ;; Use JPG format instead of PNG (bool) ;useJpgForClipboard=false ; diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 4fba65f1..93c54df2 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -40,6 +40,7 @@ GeneralConf::GeneralConf(QWidget* parent) initShowStartupLaunchMessage(); initCopyAndCloseAfterUpload(); initCopyPathAfterSave(); + initAntialiasingPinZoom(); initUseJpgForClipboard(); initSaveAfterCopy(); inituploadHistoryMax(); @@ -62,6 +63,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath) m_copyAndCloseAfterUpload->setChecked(config.copyAndCloseAfterUpload()); m_saveAfterCopy->setChecked(config.saveAfterCopy()); m_copyPathAfterSave->setChecked(config.copyPathAfterSave()); + m_antialiasingPinZoom->setChecked(config.antialiasingPinZoom()); m_useJpgForClipboard->setChecked(config.useJpgForClipboard()); m_historyConfirmationToDelete->setChecked( config.historyConfirmationToDelete()); @@ -488,6 +490,19 @@ void GeneralConf::initCopyPathAfterSave() }); } +void GeneralConf::initAntialiasingPinZoom() +{ + m_antialiasingPinZoom = + new QCheckBox(tr("Anti-aliasing image when zoom the pinned image"), this); + m_antialiasingPinZoom->setToolTip( + tr("After zooming the pinned image, should the image get smoothened or " + "stay pixelated")); + m_scrollAreaLayout->addWidget(m_antialiasingPinZoom); + connect(m_antialiasingPinZoom, &QCheckBox::clicked, [](bool checked) { + ConfigHandler().setAntialiasingPinZoom(checked); + }); +} + const QString GeneralConf::chooseFolder(const QString pathDefault) { QString path; diff --git a/src/config/generalconf.h b/src/config/generalconf.h index c9c5c458..9b48e42e 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -58,6 +58,7 @@ private: void initCopyAndCloseAfterUpload(); void initSaveAfterCopy(); void initCopyPathAfterSave(); + void initAntialiasingPinZoom(); void initUseJpgForClipboard(); void _updateComponents(bool allowEmptySavePath); @@ -75,6 +76,7 @@ private: QCheckBox* m_showStartupLaunchMessage; QCheckBox* m_copyAndCloseAfterUpload; QCheckBox* m_copyPathAfterSave; + QCheckBox* m_antialiasingPinZoom; QPushButton* m_importButton; QPushButton* m_exportButton; QPushButton* m_resetButton; diff --git a/src/tools/pin/pinwidget.cpp b/src/tools/pin/pinwidget.cpp index b9111bc5..c2d104aa 100644 --- a/src/tools/pin/pinwidget.cpp +++ b/src/tools/pin/pinwidget.cpp @@ -121,9 +121,19 @@ void PinWidget::mouseMoveEvent(QMouseEvent* e) void PinWidget::setScaledPixmap(const QSize& size) { + ConfigHandler config; + QPixmap scaledPixmap; + const qreal scale = qApp->devicePixelRatio(); - QPixmap scaledPixmap = m_pixmap.scaled( - size * scale, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + if (config.antialiasingPinZoom()) { + scaledPixmap = m_pixmap.scaled( + size * scale, Qt::KeepAspectRatio, Qt::SmoothTransformation); + } else { + scaledPixmap = m_pixmap.scaled( + size * scale, Qt::KeepAspectRatio, Qt::FastTransformation); + } + scaledPixmap.setDevicePixelRatio(scale); m_label->setPixmap(scaledPixmap); } diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index af79e453..938c33fa 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -87,6 +87,7 @@ static QMap> OPTION("showStartupLaunchMessage" ,Bool ( true )), OPTION("copyAndCloseAfterUpload" ,Bool ( true )), OPTION("copyPathAfterSave" ,Bool ( false )), + OPTION("antialiasingPinZoom" ,Bool ( true )), #if !defined(Q_OS_MACOS) OPTION("useJpgForClipboard" ,Bool ( false )), #endif diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index f9504cdb..d9b4c82e 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -88,6 +88,7 @@ public: CONFIG_GETTER_SETTER(uploadHistoryMax, setUploadHistoryMax, int) CONFIG_GETTER_SETTER(saveAfterCopy, setSaveAfterCopy, bool) CONFIG_GETTER_SETTER(copyPathAfterSave, setCopyPathAfterSave, bool) + CONFIG_GETTER_SETTER(antialiasingPinZoom, setAntialiasingPinZoom, bool) CONFIG_GETTER_SETTER(useJpgForClipboard, setUseJpgForClipboard, bool) CONFIG_GETTER_SETTER(ignoreUpdateToVersion, setIgnoreUpdateToVersion,