File indexing completed on 2024-03-24 17:24:30
0001 /** 0002 * SPDX-FileCopyrightText: (C) 2003 Sébastien Laoût <slaout@linux62.org> 0003 * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #ifndef _WIN32 0011 0012 #include <QObject> 0013 #include <QColor> 0014 0015 /** 0016 * @brief This class allows to pick a color on the screen. 0017 * 0018 * Internally this class wrap the PickColor function from the 0019 * Screenshot xdg-portal and should work on X and wayland. 0020 * 0021 * @author Carl Schwan 0022 */ 0023 class ColorPicker : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 explicit ColorPicker(QObject *parent = nullptr); 0028 virtual ~ColorPicker() override = default; 0029 0030 public Q_SLOTS: 0031 /** 0032 * Begin color picking. 0033 * This function returns immediately, and colorGrabbed() is emitted if user has 0034 * chosen a color, and not canceled the process (by pressing Escape). 0035 */ 0036 void grabColor(); 0037 0038 Q_SIGNALS: 0039 /** 0040 * When user picked a color, this signal is emitted. 0041 */ 0042 void colorGrabbed(const QColor &color); 0043 0044 protected Q_SLOTS: 0045 void gotColorResponse(uint response, const QVariantMap& results); 0046 }; 0047 0048 #endif