diff --git a/.gitignore b/.gitignore index a886f32c..65b32146 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# common + +.idea + # C++ objects and libs *.slo diff --git a/appveyor.yml b/appveyor.yml index d4c0ebee..7ef8935b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ image: Visual Studio 2015 -version: 0.6.{build}.0 +version: 0.7.0.{build} # Major_Version_Number.Minor_Version_Number.Build_Number.Revision_Number branches: @@ -19,7 +19,7 @@ environment: init: - ps: | $version = new-object System.Version $env:APPVEYOR_BUILD_VERSION - $packageVersion = "{0}.{1}.{2}" -f $version.Major, $version.Minor, $version.Revision + $packageVersion = "{0}.{1}.{2}.{3}" -f $version.Major, $version.Minor, $version.Build, $version.Revision $env:build_number = $version.Build $env:flameshot_version = $packageVersion @@ -65,6 +65,7 @@ after_build: - cd distrib - 7z a flameshot_%flameshot_version%_win_%PLATFORM%.zip flameshot - appveyor-retry curl --upload-file ./flameshot_%flameshot_version%_win_%PLATFORM%.zip https://transfer.sh/flameshot_%flameshot_version%_win_%PLATFORM%.zip + # build installation - cp ..\..\win_setup\flameshot.iss flameshot.iss - C:\InnoSetup\Compil32.exe /cc flameshot.iss - appveyor-retry curl --upload-file ./Output/FlameShot-Setup-is.exe https://transfer.sh/flameshot_%flameshot_version%_win_%PLATFORM%_setup.exe diff --git a/flameshot.pro b/flameshot.pro index e48f4dd8..8508c04d 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -6,9 +6,10 @@ win32:LIBS += -luser32 -lshell32 +BASE_VERSION = 0.7.0 TAG_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags) isEmpty(TAG_VERSION){ - TAG_VERSION = v0.6.0 + TAG_VERSION = $$BASE_VERSION } DEFINES += APP_VERSION=\\\"$$TAG_VERSION\\\" @@ -26,6 +27,10 @@ TARGET = flameshot TEMPLATE = app win32:RC_ICONS += img/app/flameshot.ico +QMAKE_TARGET_COMPANY = "NameCheap" +QMAKE_TARGET_COPYRIGHT = "GNU General Public License v3.0" +QMAKE_TARGET_DESCRIPTION = "FlameShot - S3 bucket edition" +VERSION = $$BASE_VERSION + "." + $$TAG_VERSION #release: DESTDIR = build/release #debug: DESTDIR = build/debug @@ -293,5 +298,3 @@ unix:!macx { # Imgur API data include(src/imgur.pri) -# ImgS3 API data -include(src/imgs3.pri) diff --git a/src/imgs3.pri b/src/imgs3.pri deleted file mode 100644 index 662abfde..00000000 --- a/src/imgs3.pri +++ /dev/null @@ -1,7 +0,0 @@ -# Use default ImgS3 client_id if user did not pass -# this variable to qmake -isEmpty(IMG_S3_CLIENT_ID) { - IMG_S3_CLIENT_ID = "313baf0c7b4d3f0" -} - -DEFINES += IMG_S3_CLIENT_ID=\\\"$${IMG_S3_CLIENT_ID}\\\" diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index ee8f7a09..0d292e1d 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -42,9 +42,15 @@ #include #include -ImgS3Uploader::ImgS3Uploader(const QPixmap &capture, QWidget *parent) : +ImgS3Uploader::ImgS3Uploader(const QPixmap &capture, + const QString &s3CredsUrl, + const QString &s3XApiKey, + QWidget *parent) : QWidget(parent), m_pixmap(capture) { + m_s3CredsUrl = s3CredsUrl; + m_s3XApiKey = s3XApiKey; + setWindowTitle(tr("Upload to ImgS3")); setWindowIcon(QIcon(":img/app/flameshot.svg")); @@ -108,7 +114,12 @@ void ImgS3Uploader::handleCredsReply(QNetworkReply *reply){ QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); uploadToS3(response); } else { - m_infoLabel->setText(reply->errorString()); + if(m_s3CredsUrl.length() == 0){ + m_infoLabel->setText("S3 Creds URL is not found in your configuration file"); + } + else { + m_infoLabel->setText(reply->errorString()); + } } new QShortcut(Qt::Key_Escape, this, SLOT(close())); } @@ -209,8 +220,11 @@ void ImgS3Uploader::uploadToS3(QJsonDocument &response) { void ImgS3Uploader::upload() { // get creads - QUrl creds("https://api.img.rnd.namecheap.net/"); + QUrl creds(m_s3CredsUrl); QNetworkRequest requestCreds(creds); + if(m_s3XApiKey.length() > 0) { + requestCreds.setRawHeader(QByteArray("X-API-Key"), QByteArray(m_s3XApiKey.toLocal8Bit())); + } m_NetworkAMCreds->get(requestCreds); } diff --git a/src/tools/imgs3/imgs3uploader.h b/src/tools/imgs3/imgs3uploader.h index 4be2f95a..ac950be5 100644 --- a/src/tools/imgs3/imgs3uploader.h +++ b/src/tools/imgs3/imgs3uploader.h @@ -33,7 +33,11 @@ class NotificationWidget; class ImgS3Uploader : public QWidget { Q_OBJECT public: - explicit ImgS3Uploader(const QPixmap &capture, QWidget *parent = nullptr); + explicit ImgS3Uploader(const QPixmap &capture, + const QString &s3CredsUrl, + const QString &s3XApiKey, + QWidget *parent = nullptr +); private slots: void handleReply(QNetworkReply *reply); @@ -49,6 +53,9 @@ private: void uploadToS3(QJsonDocument &response); private: + QString m_s3CredsUrl; + QString m_s3XApiKey; + QString m_hostName; QPixmap m_pixmap; QNetworkAccessManager *m_NetworkAM; diff --git a/src/tools/imgs3/imgs3uploadertool.cpp b/src/tools/imgs3/imgs3uploadertool.cpp index e803df5e..2d5ec0a2 100644 --- a/src/tools/imgs3/imgs3uploadertool.cpp +++ b/src/tools/imgs3/imgs3uploadertool.cpp @@ -17,10 +17,17 @@ #include "imgs3uploadertool.h" #include "imgs3uploader.h" +#include +#include #include +#include + ImgS3UploaderTool::ImgS3UploaderTool(QObject *parent) : AbstractActionTool(parent) { - + QSettings *pSettings = new QSettings(QDir::currentPath() + "/config.ini", QSettings::IniFormat); + pSettings->beginGroup("S3"); + m_s3CredsUrl = pSettings->value("S3_CREDS_URL").toString(); + m_s3XApiKey = pSettings->value("S3_X_API_KEY").toString(); } bool ImgS3UploaderTool::closeOnButtonPressed() const { @@ -44,7 +51,7 @@ QString ImgS3UploaderTool::description() const { } QWidget* ImgS3UploaderTool::widget() { - return new ImgS3Uploader(capture); + return new ImgS3Uploader(capture, m_s3CredsUrl, m_s3XApiKey); } CaptureTool* ImgS3UploaderTool::copy(QObject *parent) { diff --git a/src/tools/imgs3/imgs3uploadertool.h b/src/tools/imgs3/imgs3uploadertool.h index 43bc4d1f..f3f7d05f 100644 --- a/src/tools/imgs3/imgs3uploadertool.h +++ b/src/tools/imgs3/imgs3uploadertool.h @@ -40,4 +40,6 @@ public slots: private: QPixmap capture; + QString m_s3CredsUrl; + QString m_s3XApiKey; }; diff --git a/win-setup/flameshot.iss b/win-setup/flameshot.iss deleted file mode 100644 index aaab83a0..00000000 --- a/win-setup/flameshot.iss +++ /dev/null @@ -1,54 +0,0 @@ -; -- Example3.iss -- -; Same as Example1.iss, but creates some registry entries too and allows the end -; use to choose the install mode (administrative or non administrative). - -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES! - -[Setup] -AppName=FlameShot -AppVersion=1.0.0.1 -AppCopyright=NameCheap inc. -VersionInfoVersion=1.0.0.1 -WizardStyle=modern -DefaultDirName={autopf}\FlameShot -DefaultGroupName=FlameShot -UninstallDisplayIcon={app}\flameshot.exe -Compression=lzma2 -SolidCompression=yes -;OutputDir=userdocs:Inno Setup Examples Output -OutputBaseFilename=FlameShot-Setup-is -ChangesAssociations=yes -UserInfoPage=yes -PrivilegesRequiredOverridesAllowed=dialog -AppPublisher=Namecheap, Inc. -AppPublisherURL=https://www.namecheap.com/ -; "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\signtool.exe" sign /f "C:\MY_CODE_SIGNING.PFX" /t http://timestamp.comodoca.com/authenticode /p MY_PASSWORD $f - - -[Files] -Source: "flameshot\*"; DestDir: "{app}" -Source: "flameshot\bearer\*"; DestDir: "{app}\bearer" -Source: "flameshot\iconengines\*"; DestDir: "{app}\iconengines" -Source: "flameshot\imageformats\*"; DestDir: "{app}\imageformats" -Source: "flameshot\platforms\*"; DestDir: "{app}\platforms" -Source: "flameshot\translations\*"; DestDir: "{app}\translations" - -[Icons] -Name: "{group}\FlameShot"; Filename: "{app}\flameshot.exe" - -; NOTE: Most apps do not need registry entries to be pre-created. If you -; don't know what the registry is or if you need to use it, then chances are -; you don't need a [Registry] section. - - -[UninstallRun] -Filename: "taskkill"; Parameters: "/im ""flameshot.exe"" /f"; Flags: runhidden - -[Code] -function ShouldSkipPage(PageID: Integer): Boolean; -begin - // User specific pages should be skipped in administrative install mode - Result := IsAdminInstallMode and (PageID = wpUserInfo); -end; - -