File indexing completed on 2024-02-25 17:31:02

0001 /*
0002  * SPDX-FileCopyrightText: 2016 Red Hat Inc
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  *
0006  * SPDX-FileCopyrightText: 2016 Jan Grulich <jgrulich@redhat.com>
0007  */
0008 
0009 #ifndef XDG_DESKTOP_PORTAL_KDE_PRINT_H
0010 #define XDG_DESKTOP_PORTAL_KDE_PRINT_H
0011 
0012 #include <QDBusAbstractAdaptor>
0013 #include <QDBusObjectPath>
0014 #include <QDBusUnixFileDescriptor>
0015 #include <QPrinter>
0016 
0017 class PrintPortal : public QDBusAbstractAdaptor
0018 {
0019     Q_OBJECT
0020     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.impl.portal.Print")
0021 public:
0022     explicit PrintPortal(QObject *parent);
0023     ~PrintPortal() override;
0024 
0025 public Q_SLOTS:
0026     uint Print(const QDBusObjectPath &handle,
0027                const QString &app_id,
0028                const QString &parent_window,
0029                const QString &title,
0030                const QDBusUnixFileDescriptor &fd,
0031                const QVariantMap &options,
0032                QVariantMap &results);
0033 
0034     uint PreparePrint(const QDBusObjectPath &handle,
0035                       const QString &app_id,
0036                       const QString &parent_window,
0037                       const QString &title,
0038                       const QVariantMap &settings,
0039                       const QVariantMap &page_setup,
0040                       const QVariantMap &options,
0041                       QVariantMap &results);
0042 
0043 private:
0044     QMap<uint, QPrinter *> m_printers;
0045 
0046     bool cupsAvailable();
0047     QStringList printArguments(const QPrinter *printer, bool useCupsOptions, const QString &version, QPageLayout::Orientation documentOrientation);
0048     QStringList destination(const QPrinter *printer, const QString &version);
0049     QStringList copies(const QPrinter *printer, const QString &version);
0050     QStringList jobname(const QPrinter *printer, const QString &version);
0051     QStringList cupsOptions(const QPrinter *printer, QPageLayout::Orientation documentOrientation);
0052     QStringList pages(const QPrinter *printer, bool useCupsOptions, const QString &version);
0053     QStringList optionMedia(const QPrinter *printer);
0054     QString mediaPaperSource(const QPrinter *printer);
0055     QStringList optionOrientation(const QPrinter *printer, QPageLayout::Orientation documentOrientation);
0056     QStringList optionDoubleSidedPrinting(const QPrinter *printer);
0057     QStringList optionPageOrder(const QPrinter *printer);
0058     QStringList optionCollateCopies(const QPrinter *printer);
0059     QStringList optionPageMargins(const QPrinter *printer);
0060     QStringList optionCupsProperties(const QPrinter *printer);
0061 };
0062 
0063 #endif // XDG_DESKTOP_PORTAL_KDE_PRINT_H