mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-05-20 12:57:51 +00:00
Make Imgur conditionally compiled in (#4034)
* Make Imgur conditionally compiled in * Fix Macos build issues * Fix windows and clang-format
This commit is contained in:
@@ -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 ()
|
||||
|
||||
@@ -173,7 +173,9 @@ target_include_directories(
|
||||
$<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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -61,6 +65,7 @@ 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,
|
||||
@@ -68,6 +73,7 @@ Flameshot::Flameshot()
|
||||
qApp,
|
||||
[this]() { history(); });
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
Flameshot* Flameshot::instance()
|
||||
@@ -245,6 +251,7 @@ void Flameshot::info()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IMGUR
|
||||
void Flameshot::history()
|
||||
{
|
||||
static UploadHistory* historyWidget = nullptr;
|
||||
@@ -269,6 +276,7 @@ void Flameshot::history()
|
||||
historyWidget->raise();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void Flameshot::openSavePath()
|
||||
{
|
||||
@@ -401,6 +409,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IMGUR
|
||||
if (tasks & CR::UPLOAD) {
|
||||
if (!ConfigHandler().uploadWithoutConfirmation()) {
|
||||
auto* dialog = new ImgUploadDialog();
|
||||
@@ -425,6 +434,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
|
||||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(tasks & CR::UPLOAD)) {
|
||||
emit captureTaken(capture);
|
||||
|
||||
@@ -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
|
||||
@@ -39,7 +41,10 @@ public slots:
|
||||
void config();
|
||||
|
||||
void info();
|
||||
|
||||
#ifdef ENABLE_IMGUR
|
||||
void history();
|
||||
#endif
|
||||
|
||||
void openSavePath();
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
@@ -17,6 +19,7 @@ target_sources(
|
||||
imgupload/imguploadermanager.h
|
||||
imgupload/imguploadermanager.cpp
|
||||
)
|
||||
endif()
|
||||
target_sources(
|
||||
flameshot
|
||||
PRIVATE launcher/applaunchertool.h
|
||||
|
||||
@@ -36,7 +36,9 @@ public:
|
||||
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,
|
||||
|
||||
@@ -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"
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,8 +7,6 @@ target_sources(
|
||||
PRIVATE
|
||||
infowindow.ui
|
||||
capturelauncher.ui
|
||||
uploadhistory.ui
|
||||
uploadlineitem.ui
|
||||
|
||||
capturelauncher.h
|
||||
draggablewidgetmaker.h
|
||||
@@ -18,13 +16,23 @@ target_sources(
|
||||
loadspinner.h
|
||||
notificationwidget.h
|
||||
orientablepushbutton.h
|
||||
uploadhistory.h
|
||||
uploadlineitem.h
|
||||
|
||||
colorpickerwidget.h
|
||||
imguploaddialog.h
|
||||
capture/capturetoolobjects.h
|
||||
)
|
||||
|
||||
if (ENABLE_IMGUR)
|
||||
target_sources(
|
||||
flameshot
|
||||
PRIVATE
|
||||
uploadhistory.ui
|
||||
uploadlineitem.ui
|
||||
uploadhistory.h
|
||||
uploadlineitem.h
|
||||
imguploaddialog.h
|
||||
)
|
||||
endif()
|
||||
|
||||
target_sources(
|
||||
flameshot
|
||||
PRIVATE
|
||||
@@ -36,13 +44,20 @@ target_sources(
|
||||
loadspinner.cpp
|
||||
notificationwidget.cpp
|
||||
orientablepushbutton.cpp
|
||||
uploadhistory.cpp
|
||||
uploadlineitem.cpp
|
||||
colorpickerwidget.cpp
|
||||
imguploaddialog.cpp
|
||||
capture/capturetoolobjects.cpp
|
||||
)
|
||||
|
||||
if (ENABLE_IMGUR)
|
||||
target_sources(
|
||||
flameshot
|
||||
PRIVATE
|
||||
uploadhistory.cpp
|
||||
uploadlineitem.cpp
|
||||
imguploaddialog.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT DISABLE_UPDATE_CHECKER)
|
||||
target_sources(
|
||||
flameshot
|
||||
|
||||
@@ -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 },
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -149,13 +149,14 @@ void TrayIcon::initMenu()
|
||||
QAction* quitAction = new QAction(tr("&Quit"), this);
|
||||
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
||||
|
||||
#ifdef ENABLE_IMGUR
|
||||
// recent screenshots
|
||||
QAction* recentAction = new QAction(tr("&Latest Uploads"), this);
|
||||
connect(recentAction,
|
||||
&QAction::triggered,
|
||||
Flameshot::instance(),
|
||||
&Flameshot::history);
|
||||
|
||||
#endif
|
||||
auto* openSavePathAction = new QAction(tr("&Open Save Path"), this);
|
||||
connect(openSavePathAction,
|
||||
&QAction::triggered,
|
||||
@@ -165,7 +166,9 @@ void TrayIcon::initMenu()
|
||||
m_menu->addAction(captureAction);
|
||||
m_menu->addAction(launcherAction);
|
||||
m_menu->addSeparator();
|
||||
#ifdef ENABLE_IMGUR
|
||||
m_menu->addAction(recentAction);
|
||||
#endif
|
||||
m_menu->addAction(openSavePathAction);
|
||||
m_menu->addSeparator();
|
||||
m_menu->addAction(configAction);
|
||||
|
||||
Reference in New Issue
Block a user