Skip to content

Commit

Permalink
PDF and printer support are not enabled by default
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jack9603301 committed Jul 5, 2024
1 parent 650f7c0 commit 0c095b4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ 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")
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions src/core/flameshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
#include <QToolBar>
#include <QUrl>
#include <QVersionNumber>

#ifdef USE_PRINTER_SUPPORT
#include <QtPrintSupport/QPrintPreviewDialog>
#include <QtPrintSupport/QPrinter>
#endif

#ifdef USE_PLUGIN_MANAGER
#include "core/pluginmanager.h"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -520,6 +528,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
});
dialog.exec();
}
#endif

if (!(tasks & CR::UPLOAD)) {
emit captureTaken(PixmapOutputBuffer);
Expand Down
5 changes: 5 additions & 0 deletions src/utils/screenshotsaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <QMessageBox>
#include <QMimeData>
#include <QStandardPaths>
#ifdef USE_PRINTER_SUPPORT
#include <QtPrintSupport/QPrinter>
#endif
#include <qimagewriter.h>
#include <qmimedatabase.h>
#ifdef USE_PLUGIN_MANAGER
Expand Down Expand Up @@ -188,6 +190,7 @@ void saveToClipboard(const QPixmap& capture)
}
}

#ifdef USE_PRINTER_SUPPORT
bool saveToPDF(const QPixmap& capture)
{
bool okay = false;
Expand Down Expand Up @@ -236,6 +239,8 @@ bool saveToPDF(const QPixmap& capture)
return okay;
}

#endif

bool saveToFilesystemGUI(const QPixmap& capture)
{
bool okay = false;
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CaptureToolButton*> vectorButtons;

// Add all buttons but hide those that were disabled in the Interface config
Expand Down

0 comments on commit 0c095b4

Please sign in to comment.