File indexing completed on 2025-02-02 04:26:12
0001 /* This file is part of Spectacle, the KDE screenshot utility 0002 * SPDX-FileCopyrightText: 2019 Boudhayan Gupta <bgupta@kde.org> 0003 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QFlags> 0010 #include <QImage> 0011 #include <QObject> 0012 0013 class ImagePlatform : public QObject 0014 { 0015 Q_OBJECT 0016 Q_PROPERTY(GrabModes supportedGrabModes READ supportedGrabModes NOTIFY supportedGrabModesChanged) 0017 // Currently, supportedShutterModes never changes. 0018 // Be sure to add a changed signal if it is ever able to change. 0019 Q_PROPERTY(ShutterModes supportedShutterModes READ supportedShutterModes CONSTANT) 0020 0021 public: 0022 enum GrabMode { 0023 NoGrabModes = 0b0000000, 0024 AllScreens = 0b0000001, 0025 CurrentScreen = 0b0000010, 0026 ActiveWindow = 0b0000100, 0027 WindowUnderCursor = 0b0001000, 0028 TransientWithParent = 0b0010000, 0029 AllScreensScaled = 0b0100000, 0030 PerScreenImageNative = 0b1000000, 0031 }; 0032 Q_DECLARE_FLAGS(GrabModes, GrabMode) 0033 Q_FLAG(GrabModes) 0034 0035 enum ShutterMode { Immediate = 0x01, OnClick = 0x02 }; 0036 Q_DECLARE_FLAGS(ShutterModes, ShutterMode) 0037 Q_FLAG(ShutterModes) 0038 0039 explicit ImagePlatform(QObject *parent = nullptr); 0040 ~ImagePlatform() override = default; 0041 0042 virtual GrabModes supportedGrabModes() const = 0; 0043 virtual ShutterModes supportedShutterModes() const = 0; 0044 0045 public Q_SLOTS: 0046 virtual void 0047 doGrab(ImagePlatform::ShutterMode shutterMode, ImagePlatform::GrabMode grabMode, bool includePointer, bool includeDecorations, bool includeShadow) = 0; 0048 0049 Q_SIGNALS: 0050 void supportedGrabModesChanged(); 0051 0052 void newScreenshotTaken(const QImage &image = {}); 0053 void newCroppableScreenshotTaken(const QImage &image); 0054 0055 void newScreenshotFailed(); 0056 void windowTitleChanged(const QString &windowTitle = {}); 0057 }; 0058 0059 Q_DECLARE_OPERATORS_FOR_FLAGS(ImagePlatform::GrabModes) 0060 Q_DECLARE_OPERATORS_FOR_FLAGS(ImagePlatform::ShutterModes)