File indexing completed on 2023-12-03 04:55:09
0001 /* 0002 SPDX-FileCopyrightText: 2010 Till Theato <root@ttill.de> 0003 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QWidget> 0010 0011 class KColorButton; 0012 class QLabel; 0013 0014 /** @class ChooseColorWidget 0015 @brief Provides options to choose a color. 0016 Two mechanisms are provided: color-picking directly on the screen and choosing from a list 0017 @author Till Theato 0018 */ 0019 class ChooseColorWidget : public QWidget 0020 { 0021 Q_OBJECT 0022 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY modified USER true) 0023 Q_PROPERTY(bool alphaChannelEnabled READ isAlphaChannelEnabled WRITE setAlphaChannelEnabled) 0024 0025 public: 0026 /** @brief Sets up the widget. 0027 * @param parent(optional) Parent widget 0028 * @param color (optional) initial color 0029 * @param alphaEnabled (optional) Should transparent colors be enabled 0030 */ 0031 explicit ChooseColorWidget(QWidget *parent = nullptr, const QColor &color = QColor(), bool alphaEnabled = false); 0032 0033 /** @brief Gets the choosen color. */ 0034 QColor color() const; 0035 /** @brief Returns true if the user is allowed to change the alpha component. */ 0036 bool isAlphaChannelEnabled() const; 0037 0038 private: 0039 KColorButton *m_button; 0040 QLabel *m_nameLabel; 0041 0042 public Q_SLOTS: 0043 /** @brief Updates the different color choosing options to have all selected @param color. */ 0044 void setColor(const QColor &color); 0045 /** @brief Updates the color to @param color without emitting signals. */ 0046 void slotColorModified(const QColor &color); 0047 0048 private Q_SLOTS: 0049 void setAlphaChannelEnabled(bool alpha); 0050 0051 Q_SIGNALS: 0052 /** @brief Emitted whenever a different color was chosen. */ 0053 void modified(QColor = QColor()); 0054 /** @brief Request disabling / enabling current filter. */ 0055 void disableCurrentFilter(bool); 0056 };