File indexing completed on 2024-05-12 16:02:07

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2007 C. Boemann <cbo@boemann.dk>
0003  * SPDX-FileCopyrightText: 2007 Fredy Yanardi <fyanardi@gmail.com>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #ifndef KOCOLORPOPUPACTION_H
0009 #define KOCOLORPOPUPACTION_H
0010 
0011 #include <QAction>
0012 
0013 #include "kritawidgets_export.h"
0014 
0015 class KoColor;
0016 
0017 /**
0018  * KoColorPopupAction makes use of KoColorSetWidget to show a widget for for choosing a color (colormanaged via pigment).
0019  * @see KoColorPopupAction
0020  */
0021 
0022 class KRITAWIDGETS_EXPORT KoColorPopupAction : public QAction
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     /**
0028       * Constructs a KoColorPopupAction with the specified parent.
0029       *
0030       * @param parent The parent for this action.
0031       */
0032     explicit KoColorPopupAction(QObject *parent = 0);
0033 
0034     /**
0035      * Destructor
0036      */
0037     ~KoColorPopupAction() override;
0038 
0039 public Q_SLOTS:
0040     /// Sets a new color to be displayed
0041     void setCurrentColor( const QColor &color );
0042 
0043     /// Sets a new color to be displayed
0044     void setCurrentColor( const KoColor &color );
0045 
0046     /// Returns the current color
0047     QColor currentColor() const;
0048 
0049     /// Returns the current color as a KoColor
0050     KoColor currentKoColor() const;
0051 
0052     /// update the icon - only needed if you resize the iconsize in the widget that shows the action
0053     void updateIcon();
0054 
0055 Q_SIGNALS:
0056     /**
0057      * Emitted every time the color changes (by calling setColor() or
0058      * by user interaction.
0059      * @param color the new color
0060      */
0061     void colorChanged(const KoColor &color);
0062 
0063 private Q_SLOTS:
0064     void emitColorChanged();
0065     void colorWasSelected(const KoColor &color, bool final);
0066     void colorWasEdited( const QColor &color );
0067     void opacityWasChanged( int opacity );
0068 
0069 private:
0070     class KoColorPopupActionPrivate;
0071     KoColorPopupActionPrivate * const d;
0072 };
0073 
0074 #endif
0075