diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7168a0a82..06bcd39672 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -258,7 +258,6 @@ else() endif () target_compile_definitions(flameshot PRIVATE APP_PREFIX="${CMAKE_INSTALL_PREFIX}") target_compile_definitions(flameshot PRIVATE APP_VERSION="v${PROJECT_VERSION}") -target_compile_definitions(flameshot PRIVATE IMGUR_CLIENT_ID="313baf0c7b4d3ff") #target_compile_definitions(flameshot PRIVATE QAPPLICATION_CLASS=QApplication) target_compile_definitions(flameshot PRIVATE FLAMESHOT_APP_VERSION_URL="${GIT_API_URL}") # Enable easier debugging of screenshot capture mode diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 759d0c5a37..191b3e02e8 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors - #include "generalconf.h" #include "src/core/flameshot.h" #include "src/utils/confighandler.h" @@ -49,6 +48,7 @@ GeneralConf::GeneralConf(QWidget* parent) initSaveAfterCopy(); initUploadHistoryMax(); initUndoLimit(); + initUploadClientSecret(); initAllowMultipleGuiInstances(); #if !defined(Q_OS_WIN) initAutoCloseIdleDaemon(); @@ -516,6 +516,32 @@ void GeneralConf::initUploadHistoryMax() vboxLayout->addWidget(m_uploadHistoryMax); } +void GeneralConf::initUploadClientSecret() +{ + auto* box = new QGroupBox(tr("Imgur API Key")); + box->setFlat(true); + m_layout->addWidget(box); + + auto* vboxLayout = new QVBoxLayout(); + box->setLayout(vboxLayout); + + m_uploadClientKey = new QLineEdit(this); + QString foreground = this->palette().windowText().color().name(); + m_uploadClientKey->setStyleSheet( + QStringLiteral("color: %1").arg(foreground)); + m_uploadClientKey->setText(ConfigHandler().uploadClientSecret()); + connect(m_uploadClientKey, + SIGNAL(editingFinished()), + this, + SLOT(uploadClientKeyEdited())); + vboxLayout->addWidget(m_uploadClientKey); +} + +void GeneralConf::uploadClientKeyEdited() +{ + ConfigHandler().setUploadClientSecret(m_uploadClientKey->text()); +} + void GeneralConf::uploadHistoryMaxChanged(int max) { ConfigHandler().setUploadHistoryMax(max); diff --git a/src/config/generalconf.h b/src/config/generalconf.h index 787abb6580..a24498817d 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -40,6 +40,7 @@ private slots: void exportFileConfiguration(); void resetConfiguration(); void togglePathFixed(); + void uploadClientKeyEdited(); void useJpgForClipboardChanged(bool checked); void setSaveAsFileExtension(QString extension); @@ -70,6 +71,7 @@ private slots: void initUploadWithoutConfirmation(); void initUseJpgForClipboard(); void initUploadHistoryMax(); + void initUploadClientSecret(); void _updateComponents(bool allowEmptySavePath); @@ -95,6 +97,7 @@ private slots: QPushButton* m_resetButton; QCheckBox* m_saveAfterCopy; QLineEdit* m_savePath; + QLineEdit* m_uploadClientKey; QPushButton* m_changeSaveButton; QCheckBox* m_screenshotPathFixedCheck; QCheckBox* m_historyConfirmationToDelete; diff --git a/src/tools/imgupload/storages/imgur/imguruploader.cpp b/src/tools/imgupload/storages/imgur/imguruploader.cpp index bb14b15f3f..d6748b5a42 100644 --- a/src/tools/imgupload/storages/imgur/imguruploader.cpp +++ b/src/tools/imgupload/storages/imgur/imguruploader.cpp @@ -75,9 +75,10 @@ void ImgurUploader::upload() QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/application/x-www-form-urlencoded"); - request.setRawHeader( - "Authorization", - QStringLiteral("Client-ID %1").arg(IMGUR_CLIENT_ID).toUtf8()); + request.setRawHeader("Authorization", + QStringLiteral("Client-ID %1") + .arg(ConfigHandler().uploadClientSecret()) + .toUtf8()); m_NetworkAM->post(request, byteArray); } diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index b8a707661b..fdf0891f05 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -101,11 +101,11 @@ static QMap> OPTION("savePath" ,ExistingDir ( )), OPTION("savePathFixed" ,Bool ( false )), OPTION("saveAsFileExtension" ,SaveFileExtension ( )), - OPTION("uploadHistoryMax" ,LowerBoundedInt (0, 25 )), + OPTION("uploadHistoryMax" ,LowerBoundedInt (0, 25 )), OPTION("undoLimit" ,BoundedInt (0, 999, 100 )), // Interface tab - OPTION("uiColor" ,Color ( {116, 0, 150} )), - OPTION("contrastUiColor" ,Color ( {39, 0, 50} )), + OPTION("uiColor" ,Color ( {116, 0, 150} )), + OPTION("contrastUiColor" ,Color ( {39, 0, 50} )), OPTION("contrastOpacity" ,BoundedInt ( 0, 255, 190 )), OPTION("buttons" ,ButtonList ( {} )), // Filename Editor tab @@ -123,6 +123,7 @@ static QMap> // NOTE: If another tool size is added besides drawThickness and // drawFontSize, remember to update ConfigHandler::toolSize OPTION("copyOnDoubleClick" ,Bool ( false )), + OPTION("uploadClientSecret" ,String ( "313baf0c7b4d3ff" )), }; static QMap> recognizedShortcuts = { diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 5e80868a36..3e8322d29c 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -118,6 +118,7 @@ class ConfigHandler : public QObject CONFIG_GETTER_SETTER(showMagnifier, setShowMagnifier, bool) CONFIG_GETTER_SETTER(squareMagnifier, setSquareMagnifier, bool) CONFIG_GETTER_SETTER(copyOnDoubleClick, setCopyOnDoubleClick, bool) + CONFIG_GETTER_SETTER(uploadClientSecret, setUploadClientSecret, QString) // SPECIAL CASES bool startupLaunch();