[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    [graphics/krita/krita/4.3] libs/ui/widgets: Save edited gradients
From:       Boudewijn Rempt <null () kde ! org>
Date:       2020-12-01 9:38:23
Message-ID: 20201201093823.A64B01242E63 () leptone ! kde ! org
[Download RAW message or body]

Git commit 08f5246359c2a26677fea24fdaf97adf961317cb by Boudewijn Rempt.
Committed on 01/12/2020 at 09:38.
Pushed by rempt into branch 'krita/4.3'.

Save edited gradients

This isn't ideal, since it will save a local copy and next restart
there will be two gradients with the same name, but that can't be
helped with the way 4.3 works.

The dialog also should have a cancel button.

CCMAIL:kimageshop@kde.org

M  +11   -3    libs/ui/widgets/kis_gradient_chooser.cc
M  +1    -1    libs/ui/widgets/kis_gradient_chooser.h

https://invent.kde.org/graphics/krita/commit/08f5246359c2a26677fea24fdaf97adf961317cb

diff --git a/libs/ui/widgets/kis_gradient_chooser.cc \
b/libs/ui/widgets/kis_gradient_chooser.cc index edc0228e51..31bab8ed0e 100644
--- a/libs/ui/widgets/kis_gradient_chooser.cc
+++ b/libs/ui/widgets/kis_gradient_chooser.cc
@@ -195,12 +195,13 @@ void KisGradientChooser::addSegmentedGradient()
 
 void KisGradientChooser::addGradient(KoAbstractGradient* gradient)
 {
+    if (!gradient) return;
+
     KoResourceServer<KoAbstractGradient> * rserver = \
KoResourceServerProvider::instance()->gradientServer();  QString saveLocation = \
rserver->saveLocation();  
     KisCustomGradientDialog dialog(gradient, this, "KisCustomGradientDialog", \
m_foregroundColor, m_backgroundColor);  dialog.exec();
-
     gradient->setFilename(saveLocation + gradient->name() + \
gradient->defaultFileExtension());  gradient->setValid(true);
     rserver->addResource(gradient);
@@ -209,10 +210,17 @@ void KisGradientChooser::addGradient(KoAbstractGradient* \
gradient)  
 void KisGradientChooser::editGradient()
 {
-    KisCustomGradientDialog \
dialog(static_cast<KoAbstractGradient*>(currentResource()), this, \
                "KisCustomGradientDialog", m_foregroundColor, m_backgroundColor);
-    dialog.exec();
+    KoAbstractGradient *gradient = \
dynamic_cast<KoAbstractGradient*>(currentResource()); +    if (!gradient) return;
 
+    KisCustomGradientDialog dialog(gradient, this, "KisCustomGradientDialog", \
m_foregroundColor, m_backgroundColor); +    dialog.exec();
 
+    KoResourceServer<KoAbstractGradient> * rserver = \
KoResourceServerProvider::instance()->gradientServer(); +    QString saveLocation = \
rserver->saveLocation(); +    rserver->updateResource(gradient);
+    gradient->setFilename(saveLocation + gradient->name() + \
gradient->defaultFileExtension()); +    gradient->save();
 }
 
 
diff --git a/libs/ui/widgets/kis_gradient_chooser.h \
b/libs/ui/widgets/kis_gradient_chooser.h index 92ccc19af3..9e5258f176 100644
--- a/libs/ui/widgets/kis_gradient_chooser.h
+++ b/libs/ui/widgets/kis_gradient_chooser.h
@@ -45,7 +45,7 @@ public:
 
 private:
 
-    QWidget * m_page;
+    QWidget *m_page {0};
 
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic