From 2efc0825991524928aff7058c0676487e004153c Mon Sep 17 00:00:00 2001 From: Alfredo Ramos Date: Thu, 14 Jun 2018 17:14:26 -0500 Subject: [PATCH] Remove hard-coded Imgur client_id (#253) This will allow users to set their own Imgur client_id passing the IMGUR_CLIENT_ID variable to qmake. If the users does not set this variable, it will fallback to the default value. --- flameshot.pro | 6 ++++-- src/imgur.pri | 7 +++++++ src/tools/imgur/imguruploader.cpp | 4 +--- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 src/imgur.pri diff --git a/flameshot.pro b/flameshot.pro index 49cc2529..d1f022b5 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -248,13 +248,13 @@ unix:!macx { dbus.path = $${BASEDIR}$${PREFIX}/share/dbus-1/interfaces/ dbus.files = dbus/org.dharkael.Flameshot.xml - + icon.path = $${BASEDIR}$${PREFIX}/share/icons/ icon.files = img/flameshot.png completion.path = $${BASEDIR}$${PREFIX}/share/bash-completion/completions/ completion.files = docs/bash-completion/flameshot - + appdata.path = $${BASEDIR}$${PREFIX}/share/metainfo/ appdata.files = docs/appdata/flameshot.appdata.xml @@ -279,3 +279,5 @@ unix:!macx { appdata } +# Imgur API data +include(src/imgur.pri) diff --git a/src/imgur.pri b/src/imgur.pri new file mode 100644 index 00000000..6e34b1e1 --- /dev/null +++ b/src/imgur.pri @@ -0,0 +1,7 @@ +# Use default Imgur client_id if user did not pass +# this variable to qmake +isEmpty(IMGUR_CLIENT_ID) { + IMGUR_CLIENT_ID = "313baf0c7b4d3ff" +} + +DEFINES += IMGUR_CLIENT_ID=\\\"$${IMGUR_CLIENT_ID}\\\" diff --git a/src/tools/imgur/imguruploader.cpp b/src/tools/imgur/imguruploader.cpp index 2260c9de..c6bece91 100644 --- a/src/tools/imgur/imguruploader.cpp +++ b/src/tools/imgur/imguruploader.cpp @@ -110,7 +110,7 @@ void ImgurUploader::upload() { QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/application/x-www-form-urlencoded"); - request.setRawHeader("Authorization", "Client-ID 313baf0c7b4d3ff"); + request.setRawHeader("Authorization", QString("Client-ID %1").arg(IMGUR_CLIENT_ID).toUtf8()); m_NetworkAM->post(request, byteArray); } @@ -147,7 +147,6 @@ void ImgurUploader::onUploadOk() { this, &ImgurUploader::openDeleteURL); connect(m_toClipboardButton, &QPushButton::clicked, this, &ImgurUploader::copyImage); - } void ImgurUploader::openURL() { @@ -174,4 +173,3 @@ void ImgurUploader::copyImage() { QApplication::clipboard()->setPixmap(m_pixmap); m_notification->showMessage(tr("Screenshot copied to clipboard.")); } -