From e9e13dccf9bec212d53fc0121a28e4d40ff9a898 Mon Sep 17 00:00:00 2001 From: Ouyang Chunhui Date: Fri, 5 Jul 2024 17:56:24 +0800 Subject: [PATCH] PDF and printer support are not enabled by default This is to counter PR checks, because it seems that the PR's qt environment does not support some specific parameters of this function - the latest version of qt5 compiles fine on Linux Signed-off-by: Ouyang Chunhui --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 ++++ src/core/flameshot.cpp | 9 +++++++++ src/utils/screenshotsaver.cpp | 5 +++++ src/widgets/capture/capturewidget.cpp | 6 ++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a49d96a7f6..83580857b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,7 @@ option(USE_LAUNCHER_ABSOLUTE_PATH "Use absolute path for the desktop launcher" O option(USE_WAYLAND_CLIPBOARD "USE KF Gui Wayland Clipboard" OFF) option(DISABLE_UPDATE_CHECKER "Disable check for updates" OFF) option(USE_PLUGIN_MANAGER "Activate the Plugin Manager" ON) -option(USE_WAYLAND_GRIM "Activate the Wayland GRIM screenshot adapter" OFF) +option(USE_PRINTER_SUPPORT "Enable printer and PDF output support" OFF) if (USE_PLUGIN_MANAGER) set(PLUGIN_DIRECTORY "app_plugins" CACHE PATH "Setting the Plugin Manager Plugin Directory") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a3078d7ad..d4233e404c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -237,6 +237,10 @@ if (USE_WAYLAND_GRIM) target_compile_definitions(flameshot PRIVATE USE_WAYLAND_GRIM=1) endif() +if (USE_PRINTER_SUPPORT) + target_compile_definitions(flameshot PRIVATE USE_PRINTER_SUPPORT=1) +endif() + if (APPLE) set(MACOSX_BUNDLE_IDENTIFIER "org.flameshot") set_target_properties( diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index 0550dc222e..ed0031bf44 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -34,8 +34,11 @@ #include #include #include + +#ifdef USE_PRINTER_SUPPORT #include #include +#endif #ifdef USE_PLUGIN_MANAGER #include "core/pluginmanager.h" @@ -398,12 +401,15 @@ void Flameshot::exportCapture(const QPixmap& capture, } } +#ifdef USE_PRINTER_SUPPORT + if (tasks & CR::SAVE_TO_PDF) { #ifdef USE_PLUGIN_MANAGER PluginManager::getInstance()->CallImageToPDFPost(PixmapOutputBuffer); #endif saveToPDF(PixmapOutputBuffer); } +#endif if (tasks & CR::COPY) { #ifdef USE_PLUGIN_MANAGER @@ -452,6 +458,8 @@ void Flameshot::exportCapture(const QPixmap& capture, }); } +#ifdef USE_PRINTER_SUPPORT + if (tasks & CR::PRINT_SYSTEM) { QPixmap pixmap = capture; #ifdef USE_PLUGIN_MANAGER @@ -520,6 +528,7 @@ void Flameshot::exportCapture(const QPixmap& capture, }); dialog.exec(); } +#endif if (!(tasks & CR::UPLOAD)) { emit captureTaken(PixmapOutputBuffer); diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 235e0f6207..402793dbc0 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -21,7 +21,9 @@ #include #include #include +#ifdef USE_PRINTER_SUPPORT #include +#endif #include #include #ifdef USE_PLUGIN_MANAGER @@ -188,6 +190,7 @@ void saveToClipboard(const QPixmap& capture) } } +#ifdef USE_PRINTER_SUPPORT bool saveToPDF(const QPixmap& capture) { bool okay = false; @@ -236,6 +239,8 @@ bool saveToPDF(const QPixmap& capture) return okay; } +#endif + bool saveToFilesystemGUI(const QPixmap& capture) { bool okay = false; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 9245694680..04cb90b567 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -303,6 +303,12 @@ void CaptureWidget::initButtons() buttonList->removeOne(CaptureTool::TYPE_PIN); } } + +#ifdef USE_PRINTER_SUPPORT + buttonList->removeOne(CaptureTool::TYPE_SAVE_TO_PDF); + buttonList->removeOne(CaptureTool::TYPE_PRINT); +#endif + QVector vectorButtons; // Add all buttons but hide those that were disabled in the Interface config