Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ option(USE_SINGLEAPPLICATION "Use SingleApplication library" ON)
option(USE_LAUNCHER_ABSOLUTE_PATH "Use absolute path for the desktop launcher" ON)
option(USE_WAYLAND_CLIPBOARD "USE KF Gui Wayland Clipboard" OFF)
option(DISABLE_UPDATE_CHECKER "Disable check for updates" OFF)
option(ENABLE_IMGUR "Enable Imgur Uploader" OFF)

if (ENABLE_IMGUR)
add_compile_definitions(ENABLE_IMGUR)
endif()

if (DISABLE_UPDATE_CHECKER)
add_compile_definitions(DISABLE_UPDATE_CHECKER)
endif ()
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/circlecount>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/copy>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/exit>
if(ENABLE_IMGUR)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/imgur>
endif()
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/launcher>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/line>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/marker>
Expand Down Expand Up @@ -261,7 +263,7 @@
endif ()

if (NOT USE_OPENSSL)
message(WARNING "OpenSSL is required to upload screenshots")

Check warning on line 266 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

OpenSSL is required to upload screenshots

Check warning on line 266 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

OpenSSL is required to upload screenshots

Check warning on line 266 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

OpenSSL is required to upload screenshots

Check warning on line 266 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

OpenSSL is required to upload screenshots
endif ()
endif ()

Expand Down Expand Up @@ -430,7 +432,7 @@
FILES_MATCHING
PATTERN "*.dll")
else ()
message(WARNING "Unable to find OpenSSL dlls.")

Check warning on line 435 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

Unable to find OpenSSL dlls.

Check warning on line 435 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

Unable to find OpenSSL dlls.

Check warning on line 435 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

Unable to find OpenSSL dlls.

Check warning on line 435 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

Unable to find OpenSSL dlls.
endif ()
endif ()

Expand Down
13 changes: 9 additions & 4 deletions src/config/generalconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ GeneralConf::GeneralConf(QWidget* parent)
initCopyOnDoubleClick();
initSaveAfterCopy();
initCopyPathAfterSave();
initAntialiasingPinZoom();
initUndoLimit();
#ifdef ENABLE_IMGUR
initCopyAndCloseAfterUpload();
initUploadWithoutConfirmation();
initHistoryConfirmationToDelete();
initAntialiasingPinZoom();
initUploadHistoryMax();
initUndoLimit();
initUploadClientSecret();
#endif
initPredefinedColorPaletteLarge();
initShowSelectionGeometry();

Expand All @@ -82,15 +84,19 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
m_sysNotifications->setChecked(config.showDesktopNotification());
m_abortNotifications->setChecked(config.showAbortNotification());
m_autostart->setChecked(config.startupLaunch());
m_copyURLAfterUpload->setChecked(config.copyURLAfterUpload());
m_saveAfterCopy->setChecked(config.saveAfterCopy());
m_copyPathAfterSave->setChecked(config.copyPathAfterSave());
m_antialiasingPinZoom->setChecked(config.antialiasingPinZoom());
m_useJpgForClipboard->setChecked(config.useJpgForClipboard());
m_copyOnDoubleClick->setChecked(config.copyOnDoubleClick());
#ifdef ENABLE_IMGUR
m_uploadWithoutConfirmation->setChecked(config.uploadWithoutConfirmation());
m_copyURLAfterUpload->setChecked(config.copyURLAfterUpload());
m_historyConfirmationToDelete->setChecked(
config.historyConfirmationToDelete());

m_uploadHistoryMax->setValue(config.uploadHistoryMax());
#endif
#if !defined(DISABLE_UPDATE_CHECKER)
m_checkForUpdates->setChecked(config.checkForUpdates());
#endif
Expand All @@ -109,7 +115,6 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
m_showStartupLaunchMessage->setChecked(config.showStartupLaunchMessage());
m_showQuitPrompt->setChecked(config.showQuitPrompt());
m_screenshotPathFixedCheck->setChecked(config.savePathFixed());
m_uploadHistoryMax->setValue(config.uploadHistoryMax());
m_undoLimit->setValue(config.undoLimit());

if (allowEmptySavePath || !config.savePath().isEmpty()) {
Expand Down
12 changes: 10 additions & 2 deletions src/config/setshortcutwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ SetShortcutDialog::SetShortcutDialog(QDialog* parent,
msg =
tr("Press Esc to cancel or Backspace to disable the keyboard shortcut.");
#endif
if (shortcutName == "TAKE_SCREENSHOT" ||
shortcutName == "SCREENSHOT_HISTORY") {

auto restartMessageAdded = false;
if (shortcutName == "TAKE_SCREENSHOT" && restartMessageAdded == false) {
msg +=
"\n" + tr("Flameshot must be restarted for changes to take effect.");
restartMessageAdded = true;
}
if (shortcutName == "SCREENSHOT_HISTORY" && restartMessageAdded == false) {
msg +=
"\n" + tr("Flameshot must be restarted for changes to take effect.");
restartMessageAdded = true;
}

auto* infoBottom = new QLabel(msg);
infoBottom->setMargin(10);
infoBottom->setAlignment(Qt::AlignCenter);
Expand Down
5 changes: 5 additions & 0 deletions src/config/shortcutswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,15 @@ void ShortcutsWidget::loadShortcuts()
// Global hotkeys
#if defined(Q_OS_MACOS)
appendShortcut("TAKE_SCREENSHOT", tr("Capture screen"));
#ifdef ENABLE_IMGUR
appendShortcut("SCREENSHOT_HISTORY", tr("Screenshot history"));
#endif
#elif defined(Q_OS_WIN)

#ifdef ENABLE_IMGUR
m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history")
<< "Shift+Print Screen");
#endif
m_shortcuts << (QStringList()
<< "" << QObject::tr("Capture screen") << "Print Screen");
#else
Expand Down
14 changes: 12 additions & 2 deletions src/core/flameshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
#include "src/config/configresolver.h"
#include "src/config/configwindow.h"
#include "src/core/qguiappcurrentscreen.h"

#ifdef ENABLE_IMGUR
#include "src/tools/imgupload/imguploadermanager.h"
#include "src/tools/imgupload/storages/imguploaderbase.h"
#include "src/widgets/imguploaddialog.h"
#include "src/widgets/uploadhistory.h"
#endif

#include "src/utils/confighandler.h"
#include "src/utils/screengrabber.h"
#include "src/widgets/capture/capturewidget.h"
#include "src/widgets/capturelauncher.h"
#include "src/widgets/imguploaddialog.h"
#include "src/widgets/infowindow.h"
#include "src/widgets/uploadhistory.h"
#include <QApplication>
#include <QBuffer>
#include <QDebug>
Expand Down Expand Up @@ -61,13 +65,15 @@ Flameshot::Flameshot()
&QHotkey::activated,
qApp,
[this]() { gui(); });
#ifdef ENABLE_IMGUR
m_HotkeyScreenshotHistory = new QHotkey(
QKeySequence(ConfigHandler().shortcut("SCREENSHOT_HISTORY")), true, this);
QObject::connect(m_HotkeyScreenshotHistory,
&QHotkey::activated,
qApp,
[this]() { history(); });
#endif
#endif
}

Flameshot* Flameshot::instance()
Expand Down Expand Up @@ -245,6 +251,7 @@ void Flameshot::info()
}
}

#ifdef ENABLE_IMGUR
void Flameshot::history()
{
static UploadHistory* historyWidget = nullptr;
Expand All @@ -269,6 +276,7 @@ void Flameshot::history()
historyWidget->raise();
#endif
}
#endif

void Flameshot::openSavePath()
{
Expand Down Expand Up @@ -401,6 +409,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
}
}

#ifdef ENABLE_IMGUR
if (tasks & CR::UPLOAD) {
if (!ConfigHandler().uploadWithoutConfirmation()) {
auto* dialog = new ImgUploadDialog();
Expand All @@ -425,6 +434,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
}
});
}
#endif

if (!(tasks & CR::UPLOAD)) {
emit captureTaken(capture);
Expand Down
5 changes: 5 additions & 0 deletions src/core/flameshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class CaptureWidget;
class ConfigWindow;
class InfoWindow;
class CaptureLauncher;
#ifdef ENABLE_IMGUR
class UploadHistory;
#endif
#if (defined(Q_OS_MAC) || defined(Q_OS_MACOS))
class QHotkey;
#endif
Expand All @@ -39,7 +41,10 @@ public slots:
void config();

void info();

#ifdef ENABLE_IMGUR
void history();
#endif

void openSavePath();

Expand Down
4 changes: 2 additions & 2 deletions src/core/globalshortcutfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ bool GlobalShortcutFilter::nativeEventFilter(const QByteArray& eventType,
// support would need custom shortcuts defined by the user.
const quint32 keycode = HIWORD(msg->lParam);
const quint32 modifiers = LOWORD(msg->lParam);

#ifdef ENABLE_IMGUR
// Show screenshots history
if (VK_SNAPSHOT == keycode && MOD_SHIFT == modifiers) {
Flameshot::instance()->history();
}

#endif
// Capture screen
if (VK_SNAPSHOT == keycode && 0 == modifiers) {
Flameshot::instance()->requestCapture(
Expand Down
3 changes: 3 additions & 0 deletions src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ target_sources(flameshot PRIVATE copy/copytool.h copy/copytool.cpp)
target_sources(flameshot PRIVATE exit/exittool.h exit/exittool.cpp)
target_sources(flameshot PRIVATE sizeincrease/sizeincreasetool.h sizeincrease/sizeincreasetool.cpp)
target_sources(flameshot PRIVATE sizedecrease/sizedecreasetool.h sizedecrease/sizedecreasetool.cpp)

if (ENABLE_IMGUR)
target_sources(
flameshot
PRIVATE imgupload/storages/imgur/imguruploader.h
Expand All @@ -17,6 +19,7 @@ target_sources(
imgupload/imguploadermanager.h
imgupload/imguploadermanager.cpp
)
endif()
target_sources(
flameshot
PRIVATE launcher/applaunchertool.h
Expand Down
2 changes: 2 additions & 0 deletions src/tools/capturetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class CaptureTool : public QObject
TYPE_COPY = 10,
TYPE_SAVE = 11,
TYPE_EXIT = 12,
#ifdef ENABLE_IMGUR
TYPE_IMAGEUPLOADER = 13,
#endif
TYPE_OPEN_APP = 14,
TYPE_PIXELATE = 15,
TYPE_REDO = 16,
Expand Down
4 changes: 4 additions & 0 deletions src/tools/toolfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "circlecount/circlecounttool.h"
#include "copy/copytool.h"
#include "exit/exittool.h"
#ifdef ENABLE_IMGUR
#include "imgupload/imguploadertool.h"
#endif
#include "invert/inverttool.h"
#include "launcher/applaunchertool.h"
#include "line/linetool.h"
Expand Down Expand Up @@ -49,7 +51,9 @@ CaptureTool* ToolFactory::CreateTool(CaptureTool::Type t, QObject* parent)
if_TYPE_return_TOOL(TYPE_COPY, CopyTool);
if_TYPE_return_TOOL(TYPE_SAVE, SaveTool);
if_TYPE_return_TOOL(TYPE_EXIT, ExitTool);
#ifdef ENABLE_IMGUR
if_TYPE_return_TOOL(TYPE_IMAGEUPLOADER, ImgUploaderTool);
#endif
#if !defined(Q_OS_MACOS)
if_TYPE_return_TOOL(TYPE_OPEN_APP, AppLauncher);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {
SHORTCUT("TYPE_ACCEPT" , "Return" ),
SHORTCUT("TYPE_EXIT" , "Ctrl+Q" ),
SHORTCUT("TYPE_CANCEL" , "Ctrl+Backspace" ),
#ifdef ENABLE_IMGUR
SHORTCUT("TYPE_IMAGEUPLOADER" , ),
#endif
#if !defined(Q_OS_MACOS)
SHORTCUT("TYPE_OPEN_APP" , "Ctrl+O" ),
#endif
Expand Down
27 changes: 21 additions & 6 deletions src/widgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ target_sources(
PRIVATE
infowindow.ui
capturelauncher.ui
uploadhistory.ui
uploadlineitem.ui

capturelauncher.h
draggablewidgetmaker.h
Expand All @@ -18,12 +16,22 @@ target_sources(
loadspinner.h
notificationwidget.h
orientablepushbutton.h

colorpickerwidget.h
capture/capturetoolobjects.h
)

if (ENABLE_IMGUR)
target_sources(
flameshot
PRIVATE
uploadhistory.ui
uploadlineitem.ui
uploadhistory.h
uploadlineitem.h
colorpickerwidget.h
imguploaddialog.h
capture/capturetoolobjects.h
)
endif()

target_sources(
flameshot
Expand All @@ -36,12 +44,19 @@ target_sources(
loadspinner.cpp
notificationwidget.cpp
orientablepushbutton.cpp
colorpickerwidget.cpp
capture/capturetoolobjects.cpp
)

if (ENABLE_IMGUR)
target_sources(
flameshot
PRIVATE
uploadhistory.cpp
uploadlineitem.cpp
colorpickerwidget.cpp
imguploaddialog.cpp
capture/capturetoolobjects.cpp
)
endif()

if (NOT DISABLE_UPDATE_CHECKER)
target_sources(
Expand Down
30 changes: 18 additions & 12 deletions src/widgets/capture/capturetoolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ static std::map<CaptureTool::Type, int> buttonTypeOrder
{ CaptureTool::TYPE_CIRCLECOUNT, 10 },
{ CaptureTool::TYPE_MOVESELECTION, 12 }, { CaptureTool::TYPE_UNDO, 13 },
{ CaptureTool::TYPE_REDO, 14 }, { CaptureTool::TYPE_COPY, 15 },
{ CaptureTool::TYPE_SAVE, 16 }, { CaptureTool::TYPE_IMAGEUPLOADER, 17 },
{ CaptureTool::TYPE_SAVE, 16 },
#ifdef ENABLE_IMGUR
{ CaptureTool::TYPE_IMAGEUPLOADER, 17 },
#endif
{ CaptureTool::TYPE_ACCEPT, 18 },
#if !defined(Q_OS_MACOS)
{ CaptureTool::TYPE_OPEN_APP, 19 }, { CaptureTool::TYPE_EXIT, 20 },
Expand All @@ -161,18 +164,21 @@ int CaptureToolButton::getPriorityByButton(CaptureTool::Type b)
}

QList<CaptureTool::Type> CaptureToolButton::iterableButtonTypes = {
CaptureTool::TYPE_PENCIL, CaptureTool::TYPE_DRAWER,
CaptureTool::TYPE_ARROW, CaptureTool::TYPE_SELECTION,
CaptureTool::TYPE_RECTANGLE, CaptureTool::TYPE_CIRCLE,
CaptureTool::TYPE_MARKER, CaptureTool::TYPE_TEXT,
CaptureTool::TYPE_CIRCLECOUNT, CaptureTool::TYPE_PIXELATE,
CaptureTool::TYPE_INVERT, CaptureTool::TYPE_MOVESELECTION,
CaptureTool::TYPE_UNDO, CaptureTool::TYPE_REDO,
CaptureTool::TYPE_COPY, CaptureTool::TYPE_SAVE,
CaptureTool::TYPE_EXIT, CaptureTool::TYPE_IMAGEUPLOADER,
CaptureTool::TYPE_PENCIL, CaptureTool::TYPE_DRAWER,
CaptureTool::TYPE_ARROW, CaptureTool::TYPE_SELECTION,
CaptureTool::TYPE_RECTANGLE, CaptureTool::TYPE_CIRCLE,
CaptureTool::TYPE_MARKER, CaptureTool::TYPE_TEXT,
CaptureTool::TYPE_CIRCLECOUNT, CaptureTool::TYPE_PIXELATE,
CaptureTool::TYPE_INVERT, CaptureTool::TYPE_MOVESELECTION,
CaptureTool::TYPE_UNDO, CaptureTool::TYPE_REDO,
CaptureTool::TYPE_COPY, CaptureTool::TYPE_SAVE,
CaptureTool::TYPE_EXIT,
#ifdef ENABLE_IMGUR
CaptureTool::TYPE_IMAGEUPLOADER,
#endif
#if !defined(Q_OS_MACOS)
CaptureTool::TYPE_OPEN_APP,
#endif
CaptureTool::TYPE_PIN, CaptureTool::TYPE_SIZEINCREASE,
CaptureTool::TYPE_SIZEDECREASE, CaptureTool::TYPE_ACCEPT,
CaptureTool::TYPE_PIN, CaptureTool::TYPE_SIZEINCREASE,
CaptureTool::TYPE_SIZEDECREASE, CaptureTool::TYPE_ACCEPT,
};
2 changes: 2 additions & 0 deletions src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ void CaptureWidget::initButtons()
for (auto* buttonList : { &allButtonTypes, &visibleButtonTypes }) {
buttonList->removeOne(CaptureTool::TYPE_SAVE);
buttonList->removeOne(CaptureTool::TYPE_COPY);
#ifdef ENABLE_IMGUR
buttonList->removeOne(CaptureTool::TYPE_IMAGEUPLOADER);
#endif
buttonList->removeOne(CaptureTool::TYPE_OPEN_APP);
buttonList->removeOne(CaptureTool::TYPE_PIN);
}
Expand Down
Loading
Loading