Warning, file /office/calligra/libs/widgets/KoGradientEditWidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2001-2002 Beno�t Vautrin <benoit.vautrin@free.fr> 0003 Copyright (C) 2002 Rob Buis <buis@kde.org> 0004 Copyright (C) 2006-2008 Jan Hambrecht <jaham@gmx.net> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef KO_GRADIENT_EDIT_WIDGET_H 0023 #define KO_GRADIENT_EDIT_WIDGET_H 0024 0025 #include <kowidgets_export.h> 0026 #include <KoCheckerBoardPainter.h> 0027 #include <QWidget> 0028 0029 class KoSliderCombo; 0030 class QComboBox; 0031 class QDoubleSpinBox; 0032 class KoColorPopupAction; 0033 class QToolButton; 0034 class QPushButton; 0035 0036 /** 0037 * A tab widget for managing gradients. 0038 * 0039 * It has one tab to edit a selected gradients type, spread method and color stops. 0040 * Another tab contains a list with predefined gradients to choose from. 0041 */ 0042 class KOWIDGETS_EXPORT KoGradientEditWidget : public QWidget 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 enum GradientTarget { 0048 StrokeGradient, 0049 FillGradient 0050 }; 0051 0052 /** 0053 * Creates a new gradient tab widget with the given parent. 0054 * @param parent the widgets parent 0055 */ 0056 explicit KoGradientEditWidget(QWidget* parent = nullptr); 0057 0058 /// Destroys the widget 0059 ~KoGradientEditWidget() override = default; 0060 0061 /** 0062 * Sets a new gradient to edit. 0063 * @param gradient the gradient to edit 0064 */ 0065 void setGradient(const QGradient & gradient); 0066 0067 /// Returns the gradient target (fill/stroke) 0068 GradientTarget target(); 0069 0070 /// Sets a new gradient target 0071 void setTarget(GradientTarget target); 0072 0073 /// Returns the gradient opacity 0074 qreal opacity() const; 0075 0076 /// Sets the gradients opacity to @p opacity 0077 void setOpacity(qreal opacity); 0078 0079 /// Sets the index of the stop to edit 0080 void setStopIndex(int index); 0081 0082 /// Returns the gradient spread 0083 QGradient::Spread spread() const; 0084 0085 /// Sets the gradient spread 0086 void setSpread(QGradient::Spread spread); 0087 0088 /// Returns the gradient type 0089 QGradient::Type type() const; 0090 0091 /// Sets the gradient type 0092 void setType(QGradient::Type type); 0093 0094 /// Returns the gradient stops 0095 QGradientStops stops() const; 0096 0097 /// Sets the gradient stops 0098 void setStops(const QGradientStops &stops); 0099 0100 Q_SIGNALS: 0101 /// Is emitted a soon as the gradient changes 0102 void changed(); 0103 0104 protected Q_SLOTS: 0105 void combosChange(int); 0106 void addGradientToPredefs(); 0107 void opacityChanged(qreal value, bool final); 0108 void stopChanged(); 0109 protected: 0110 void setupUI(); 0111 void updateUI(); 0112 void updatePredefGradients(); 0113 void setupConnections(); 0114 void blockChildSignals(bool block); 0115 0116 private: 0117 QComboBox *m_gradientTarget; 0118 QComboBox *m_gradientRepeat; 0119 QComboBox *m_gradientType; 0120 QPushButton *m_addToPredefs; 0121 KoSliderCombo *m_opacity; 0122 QDoubleSpinBox *m_stopPosition; 0123 QToolButton *m_stopColor; 0124 qreal m_gradOpacity; ///< the gradient opacity 0125 int m_stopIndex; ///< the index of the selected gradient stop 0126 KoCheckerBoardPainter m_checkerPainter; 0127 QGradient::Type m_type; 0128 QGradient::Spread m_spread; 0129 QGradientStops m_stops; 0130 KoColorPopupAction *m_actionStopColor; 0131 }; 0132 0133 #endif // KARBONGRADIENTEDITWIDGET_H