Commit 2f68711d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Correctly switch between stop and segment gradient editor

parent 1d5e5403
......@@ -32,7 +32,7 @@
/****************************** KisAutogradient ******************************/
KisAutogradient::KisAutogradient(KoSegmentGradient* gradient, QWidget *parent, const char* name, const QString& caption)
KisAutogradientEditor::KisAutogradientEditor(KoSegmentGradient* gradient, QWidget *parent, const char* name, const QString& caption)
: QWidget(parent)
, m_autogradientResource(gradient)
{
......@@ -59,12 +59,12 @@ KisAutogradient::KisAutogradient(KoSegmentGradient* gradient, QWidget *parent, c
}
void KisAutogradient::activate()
void KisAutogradientEditor::activate()
{
paramChanged();
}
void KisAutogradient::slotSelectedSegment(KoGradientSegment* segment)
void KisAutogradientEditor::slotSelectedSegment(KoGradientSegment* segment)
{
leftColorButton->setColor(segment->startColor());
......@@ -83,12 +83,12 @@ void KisAutogradient::slotSelectedSegment(KoGradientSegment* segment)
paramChanged();
}
void KisAutogradient::slotChangedSegment(KoGradientSegment*)
void KisAutogradientEditor::slotChangedSegment(KoGradientSegment*)
{
paramChanged();
}
void KisAutogradient::slotChangedInterpolation(int type)
void KisAutogradientEditor::slotChangedInterpolation(int type)
{
KoGradientSegment* segment = gradientSlider->selectedSegment();
if (segment)
......@@ -98,7 +98,7 @@ void KisAutogradient::slotChangedInterpolation(int type)
paramChanged();
}
void KisAutogradient::slotChangedColorInterpolation(int type)
void KisAutogradientEditor::slotChangedColorInterpolation(int type)
{
KoGradientSegment* segment = gradientSlider->selectedSegment();
if (segment)
......@@ -108,7 +108,7 @@ void KisAutogradient::slotChangedColorInterpolation(int type)
paramChanged();
}
void KisAutogradient::slotChangedLeftColor(const KoColor& color)
void KisAutogradientEditor::slotChangedLeftColor(const KoColor& color)
{
KoGradientSegment* segment = gradientSlider->selectedSegment();
if (segment) {
......@@ -121,7 +121,7 @@ void KisAutogradient::slotChangedLeftColor(const KoColor& color)
paramChanged();
}
void KisAutogradient::slotChangedRightColor(const KoColor& color)
void KisAutogradientEditor::slotChangedRightColor(const KoColor& color)
{
KoGradientSegment* segment = gradientSlider->selectedSegment();
if (segment) {
......@@ -134,7 +134,7 @@ void KisAutogradient::slotChangedRightColor(const KoColor& color)
paramChanged();
}
void KisAutogradient::slotChangedLeftOpacity(int value)
void KisAutogradientEditor::slotChangedLeftOpacity(int value)
{
KoGradientSegment* segment = gradientSlider->selectedSegment();
if (segment) {
......@@ -147,7 +147,7 @@ void KisAutogradient::slotChangedLeftOpacity(int value)
paramChanged();
}
void KisAutogradient::slotChangedRightOpacity(int value)
void KisAutogradientEditor::slotChangedRightOpacity(int value)
{
KoGradientSegment* segment = gradientSlider->selectedSegment();
if (segment) {
......@@ -160,12 +160,12 @@ void KisAutogradient::slotChangedRightOpacity(int value)
paramChanged();
}
void KisAutogradient::slotChangedName()
void KisAutogradientEditor::slotChangedName()
{
m_autogradientResource->setName(nameedit->text());
}
void KisAutogradient::paramChanged()
void KisAutogradientEditor::paramChanged()
{
m_autogradientResource->updatePreview();
}
......
......@@ -25,12 +25,12 @@
class KoGradientSegment;
class KoSegmentGradient;
class KisAutogradient : public QWidget, public Ui::KisWdgAutogradient
class KisAutogradientEditor : public QWidget, public Ui::KisWdgAutogradient
{
Q_OBJECT
public:
KisAutogradient(KoSegmentGradient* gradient, QWidget *parent, const char* name, const QString& caption);
KisAutogradientEditor(KoSegmentGradient* gradient, QWidget *parent, const char* name, const QString& caption);
void activate();
private:
KoSegmentGradient* m_autogradientResource;
......
......@@ -67,7 +67,6 @@ KisStopGradientEditor::KisStopGradientEditor(KoStopGradient* gradient, QWidget *
{
setObjectName(name);
setWindowTitle(caption);
setGradient(gradient);
}
......
......@@ -45,10 +45,9 @@
#include "kis_canvas_resource_provider.h"
#include "kis_stopgradient_editor.h"
KisCustomGradientDialog::KisCustomGradientDialog(KoAbstractGradient* gradient, QWidget * parent, const char *name)
: KoDialog(parent)
KisCustomGradientDialog::KisCustomGradientDialog(KoAbstractGradient* gradient, QWidget *parent, const char *name)
: KoDialog(parent, Qt::Dialog)
{
setCaption(i18n("Custom Gradient"));
setButtons(Close);
setDefaultButton(Close);
setObjectName(name);
......@@ -56,12 +55,15 @@ KisCustomGradientDialog::KisCustomGradientDialog(KoAbstractGradient* gradient, Q
KoStopGradient* stopGradient = dynamic_cast<KoStopGradient*>(gradient);
if (stopGradient) {
m_page = new KisStopGradientEditor(stopGradient, this, "autogradient", i18n("Custom Gradient"));
m_page = new KisStopGradientEditor(stopGradient, this, "autogradient", i18n("Custom Stop Gradient"));
}
KoSegmentGradient* segmentedGradient = dynamic_cast<KoSegmentGradient*>(gradient);
if (segmentedGradient) {
m_page = new KisAutogradient(segmentedGradient, this, "autogradient", i18n("Custom Gradient"));
else {
KoSegmentGradient* segmentedGradient = dynamic_cast<KoSegmentGradient*>(gradient);
if (segmentedGradient) {
m_page = new KisAutogradientEditor(segmentedGradient, this, "autogradient", i18n("Custom Segmented Gradient"));
}
}
setCaption(m_page->windowTitle());
setMainWidget(m_page);
}
......@@ -185,7 +187,7 @@ void KisGradientChooser::addGradient(KoAbstractGradient* gradient)
KoResourceServer<KoAbstractGradient> * rserver = KoResourceServerProvider::instance()->gradientServer();
QString saveLocation = rserver->saveLocation();
KisCustomGradientDialog dialog(gradient, this, "autogradient");
KisCustomGradientDialog dialog(gradient, this, "KisCustomGradientDialog");
dialog.exec();
gradient->setFilename(saveLocation + gradient->name() + gradient->defaultFileExtension());
......@@ -196,8 +198,10 @@ void KisGradientChooser::addGradient(KoAbstractGradient* gradient)
void KisGradientChooser::editGradient()
{
KisCustomGradientDialog dialog(static_cast<KoAbstractGradient*>(currentResource()), this, "autogradient");
KisCustomGradientDialog dialog(static_cast<KoAbstractGradient*>(currentResource()), this, "KisCustomGradientDialog");
dialog.exec();
}
......
......@@ -29,7 +29,7 @@ class KoStopGradient;
class KisViewManager;
class QLabel;
class QPushButton;
class KisAutogradient;
class KisAutogradientEditor;
class KoResource;
class KoResourceItemChooser;
......@@ -40,7 +40,7 @@ class KisCustomGradientDialog : public KoDialog
public:
KisCustomGradientDialog(KoAbstractGradient* gradient, QWidget * parent, const char *name);
KisCustomGradientDialog(KoAbstractGradient* gradient, QWidget *parent, const char *name);
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment