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..cd8ab793e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,8 +8,11 @@ find_package( Network Svg DBus - LinguistTools - PrintSupport) + LinguistTools) + +if (USE_PRINTER_SUPPORT) + find_package(PrintSupport) +endif() if (USE_WAYLAND_CLIPBOARD) find_package(KF5GuiAddons) @@ -237,6 +240,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