diff --git a/flameshot.example.ini b/flameshot.example.ini index 43c566e3..97f330cc 100644 --- a/flameshot.example.ini +++ b/flameshot.example.ini @@ -75,6 +75,9 @@ ;; Use JPG format instead of PNG (bool) ;useJpgForClipboard=false ; +;; Upload to imgur without confirmation (bool) +;uploadWithoutConfirmation=false +; ;; Shortcut Settings for all tools ;[Shortcuts] ;TYPE_ARROW=A diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 28d9eda7..dbd7a9cb 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -44,6 +44,7 @@ GeneralConf::GeneralConf(QWidget* parent) initCopyAndCloseAfterUpload(); initCopyPathAfterSave(); initAntialiasingPinZoom(); + initUploadWithoutConfirmation(); initUseJpgForClipboard(); initSaveAfterCopy(); inituploadHistoryMax(); @@ -68,6 +69,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath) m_copyPathAfterSave->setChecked(config.copyPathAfterSave()); m_antialiasingPinZoom->setChecked(config.antialiasingPinZoom()); m_useJpgForClipboard->setChecked(config.useJpgForClipboard()); + m_uploadWithoutConfirmation->setChecked(config.uploadWithoutConfirmation()); m_historyConfirmationToDelete->setChecked( config.historyConfirmationToDelete()); m_checkForUpdates->setChecked(config.checkForUpdates()); @@ -531,6 +533,18 @@ void GeneralConf::initAntialiasingPinZoom() }); } +void GeneralConf::initUploadWithoutConfirmation() +{ + m_uploadWithoutConfirmation = + new QCheckBox(tr("Upload to Imgur without confirmation"), this); + m_uploadWithoutConfirmation->setToolTip( + tr("Upload to Imgur without confirmation")); + m_scrollAreaLayout->addWidget(m_uploadWithoutConfirmation); + connect(m_uploadWithoutConfirmation, &QCheckBox::clicked, [](bool checked) { + ConfigHandler().setUploadWithoutConfirmation(checked); + }); +} + const QString GeneralConf::chooseFolder(const QString pathDefault) { QString path; diff --git a/src/config/generalconf.h b/src/config/generalconf.h index 50cc70d4..90abdb6c 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -62,6 +62,7 @@ private: void initCopyPathAfterSave(); void initAntialiasingPinZoom(); void initUseJpgForClipboard(); + void initUploadWithoutConfirmation(); void _updateComponents(bool allowEmptySavePath); @@ -79,6 +80,7 @@ private: QCheckBox* m_copyAndCloseAfterUpload; QCheckBox* m_copyPathAfterSave; QCheckBox* m_antialiasingPinZoom; + QCheckBox* m_uploadWithoutConfirmation; QPushButton* m_importButton; QPushButton* m_exportButton; QPushButton* m_resetButton; diff --git a/src/core/capturerequest.cpp b/src/core/capturerequest.cpp index 6668525f..3580ae6a 100644 --- a/src/core/capturerequest.cpp +++ b/src/core/capturerequest.cpp @@ -7,6 +7,7 @@ #include "imguruploader.h" #include "pinwidget.h" #include "src/utils/screenshotsaver.h" +#include "src/widgets/imguruploaddialog.h" #include "systemnotification.h" #include #include @@ -148,6 +149,12 @@ void CaptureRequest::exportCapture(const QPixmap& capture) } if (m_tasks & UPLOAD) { + if (!ConfigHandler().uploadWithoutConfirmation()) { + ImgurUploadDialog* dialog = new ImgurUploadDialog(); + if (dialog->exec() == QDialog::Rejected) { + return; + } + } ImgurUploader* widget = new ImgurUploader(capture); widget->show(); widget->activateWindow(); diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index b848c077..dcfcdcef 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -93,6 +93,7 @@ static QMap> #if !defined(Q_OS_MACOS) OPTION("useJpgForClipboard" ,Bool ( false )), #endif + OPTION("uploadWithoutConfirmation" ,Bool ( false )), OPTION("saveAfterCopy" ,Bool ( false )), OPTION("savePath" ,ExistingDir ( )), OPTION("savePathFixed" ,Bool ( false )), diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 597a6815..bc760a40 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -93,6 +93,9 @@ public: QString) CONFIG_GETTER_SETTER(antialiasingPinZoom, setAntialiasingPinZoom, bool) CONFIG_GETTER_SETTER(useJpgForClipboard, setUseJpgForClipboard, bool) + CONFIG_GETTER_SETTER(uploadWithoutConfirmation, + setUploadWithoutConfirmation, + bool) CONFIG_GETTER_SETTER(ignoreUpdateToVersion, setIgnoreUpdateToVersion, QString) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index a632fe9b..62a5f930 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -13,6 +13,7 @@ target_sources( orientablepushbutton.h historywidget.h updatenotificationwidget.h + imguruploaddialog.h capture/capturetoolobjects.h ) @@ -27,5 +28,6 @@ target_sources( orientablepushbutton.cpp historywidget.cpp updatenotificationwidget.cpp + imguruploaddialog.cpp capture/capturetoolobjects.cpp ) diff --git a/src/widgets/imguruploaddialog.cpp b/src/widgets/imguruploaddialog.cpp new file mode 100644 index 00000000..29615f6e --- /dev/null +++ b/src/widgets/imguruploaddialog.cpp @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors + +#include "imguruploaddialog.h" +#include "src/utils/confighandler.h" +#include +#include +#include +#include + +ImgurUploadDialog::ImgurUploadDialog(QDialog* parent) + : QDialog(parent) +{ + setAttribute(Qt::WA_DeleteOnClose); + setMinimumSize(400, 120); + setWindowIcon(QIcon(":img/app/flameshot.svg")); + setWindowTitle(tr("Upload Confirmation")); + + layout = new QVBoxLayout(this); + + m_uploadLabel = + new QLabel(tr("Do you want to upload this capture to Imgur?"), this); + + layout->addWidget(m_uploadLabel); + + buttonBox = + new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No); + + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + layout->addWidget(buttonBox); + + m_uploadWithoutConfirmation = + new QCheckBox(tr("Upload to Imgur without confirmation"), this); + m_uploadWithoutConfirmation->setToolTip( + tr("Upload to Imgur without confirmation")); + connect(m_uploadWithoutConfirmation, &QCheckBox::clicked, [](bool checked) { + ConfigHandler().setUploadWithoutConfirmation(checked); + }); + + layout->addWidget(m_uploadWithoutConfirmation); +} \ No newline at end of file diff --git a/src/widgets/imguruploaddialog.h b/src/widgets/imguruploaddialog.h new file mode 100644 index 00000000..61490c84 --- /dev/null +++ b/src/widgets/imguruploaddialog.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors + +#pragma once + +#include + +class QCheckBox; +class QLabel; +class QDialogButtonBox; +class QVBoxLayout; + +class ImgurUploadDialog : public QDialog +{ + Q_OBJECT +public: + explicit ImgurUploadDialog(QDialog* parent = nullptr); + +private: + QCheckBox* m_uploadWithoutConfirmation; + QLabel* m_uploadLabel; + QDialogButtonBox* buttonBox; + QVBoxLayout* layout; +};