Allow users to override imgur key (#2503)

* Allow users to override imgur key

* Remove debug statements
This commit is contained in:
borgmanJeremy
2022-03-30 15:15:54 -05:00
committed by GitHub
parent 54690d5be8
commit c01ffeccf0
6 changed files with 39 additions and 8 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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:
void initUploadWithoutConfirmation();
void initUseJpgForClipboard();
void initUploadHistoryMax();
void initUploadClientSecret();
void _updateComponents(bool allowEmptySavePath);
@@ -95,6 +97,7 @@ private:
QPushButton* m_resetButton;
QCheckBox* m_saveAfterCopy;
QLineEdit* m_savePath;
QLineEdit* m_uploadClientKey;
QPushButton* m_changeSaveButton;
QCheckBox* m_screenshotPathFixedCheck;
QCheckBox* m_historyConfirmationToDelete;

View File

@@ -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);
}

View File

@@ -101,11 +101,11 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
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<class QString, QSharedPointer<ValueHandler>>
// 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<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {

View File

@@ -118,6 +118,7 @@ public:
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();