diff --git a/CMakeLists.txt b/CMakeLists.txt index d152d6c90e..51801c60b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0a3b7d78f..f408314cd1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -173,7 +173,9 @@ target_include_directories( $ $ $ + if(ENABLE_IMGUR) $ + endif() $ $ $ diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index f0636ef56a..a95680899e 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -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()) { diff --git a/src/config/setshortcutwidget.cpp b/src/config/setshortcutwidget.cpp index 8c0de2d0a0..af9318fd75 100644 --- a/src/config/setshortcutwidget.cpp +++ b/src/config/setshortcutwidget.cpp @@ -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); diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 9f59d85ca3..0423dad633 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -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 diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index 99e73d442b..3eb1432668 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -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 #include #include @@ -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); diff --git a/src/core/flameshot.h b/src/core/flameshot.h index 595d63322a..15a58c2d06 100644 --- a/src/core/flameshot.h +++ b/src/core/flameshot.h @@ -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(); diff --git a/src/core/globalshortcutfilter.cpp b/src/core/globalshortcutfilter.cpp index 9f40f9b41a..a17df9825f 100644 --- a/src/core/globalshortcutfilter.cpp +++ b/src/core/globalshortcutfilter.cpp @@ -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( diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index d2a629242b..ed8de18bb2 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -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 diff --git a/src/tools/capturetool.h b/src/tools/capturetool.h index 827093c095..be613edd87 100644 --- a/src/tools/capturetool.h +++ b/src/tools/capturetool.h @@ -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, diff --git a/src/tools/toolfactory.cpp b/src/tools/toolfactory.cpp index 98ed0ab3d7..352124037e 100644 --- a/src/tools/toolfactory.cpp +++ b/src/tools/toolfactory.cpp @@ -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 diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index d763c94a22..e09d2d157e 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -154,7 +154,9 @@ static QMap> 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 diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index c9107bff1e..09695f2b80 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -7,8 +7,6 @@ target_sources( PRIVATE infowindow.ui capturelauncher.ui - uploadhistory.ui - uploadlineitem.ui capturelauncher.h draggablewidgetmaker.h @@ -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 @@ -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( diff --git a/src/widgets/capture/capturetoolbutton.cpp b/src/widgets/capture/capturetoolbutton.cpp index a7973d7cfb..f683f46b9b 100644 --- a/src/widgets/capture/capturetoolbutton.cpp +++ b/src/widgets/capture/capturetoolbutton.cpp @@ -140,7 +140,10 @@ static std::map 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 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, }; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index d25f7fde64..2766d4b768 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -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); } diff --git a/src/widgets/trayicon.cpp b/src/widgets/trayicon.cpp index a6385ddd7f..df37c19d39 100644 --- a/src/widgets/trayicon.cpp +++ b/src/widgets/trayicon.cpp @@ -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);