[Kst] branches/work/kst/portto4/kst/src

Mike Fenton mike at staikos.net
Fri Aug 8 17:21:06 CEST 2008


SVN commit 844062 by fenton:

Fix gradient resetting in GradientEditor and make it more robust.


 M  +6 -1      libkstapp/applicationsettingsdialog.cpp  
 M  +1 -3      libkstapp/filltab.cpp  
 M  +3 -1      libkstapp/filltab.h  
 M  +1 -1      libkstapp/view.h  
 M  +4 -9      widgets/gradienteditor.cpp  
 M  +2 -2      widgets/gradienteditor.h  


--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettingsdialog.cpp #844061:844062
@@ -28,7 +28,7 @@
 
   _generalTab = new GeneralTab(this);
   _gridTab = new GridTab(this);
-  _fillTab = new FillTab(false, this);
+  _fillTab = new FillTab(this);
 
   connect(_generalTab, SIGNAL(apply()), this, SLOT(generalChanged()));
   connect(_gridTab, SIGNAL(apply()), this, SLOT(gridChanged()));
@@ -79,6 +79,11 @@
 
 
 void ApplicationSettingsDialog::setupFill() {
+  QGradientStops stops;
+  stops.append(qMakePair(1.0, QColor(Qt::white)));
+  stops.append(qMakePair(0.0, QColor(Qt::lightGray)));
+  _fillTab->gradientEditor()->setDefaultGradientStops(stops);
+
   QBrush b = ApplicationSettings::self()->backgroundBrush();
 
   _fillTab->setColor(b.color());
--- branches/work/kst/portto4/kst/src/libkstapp/filltab.cpp #844061:844062
@@ -15,7 +15,7 @@
 
 namespace Kst {
 
-FillTab::FillTab(bool resetFullMono, QWidget *parent)
+FillTab::FillTab(QWidget *parent)
   : DialogTab(parent) {
 
   setupUi(this);
@@ -37,8 +37,6 @@
   _style->addItem("FDiagPattern", Qt::FDiagPattern);
   _style->addItem("DiagCrossPattern", Qt::DiagCrossPattern);
 
-  _gradientEditor->setResetMode(resetFullMono);
-
   connect(_color, SIGNAL(changed(const QColor &)), this, SIGNAL(modified()));
   connect(_style, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
   connect(_gradientEditor, SIGNAL(changed(const QGradient &)), this, SIGNAL(modified()));
--- branches/work/kst/portto4/kst/src/libkstapp/filltab.h #844061:844062
@@ -22,7 +22,7 @@
 class KST_EXPORT FillTab : public DialogTab, Ui::FillTab {
   Q_OBJECT
   public:
-    FillTab(bool resetFullMono = true, QWidget *parent = 0);
+    FillTab(QWidget *parent = 0);
     virtual ~FillTab();
 
     QColor color() const;
@@ -34,6 +34,8 @@
     QGradient gradient() const;
     void setGradient(const QGradient &gradient);
 
+    GradientEditor *gradientEditor() { return _gradientEditor; }
+
   public Q_SLOTS:
     void updateButtons();
 };
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #844061:844062
@@ -104,8 +104,8 @@
 
   private Q_SLOTS:
     void updateSettings();
+    void updateFont();
     void updateBrush();
-    void updateFont();
 
   private:
     void updateChildGeometry(const QRectF &oldSceneRect);
--- branches/work/kst/portto4/kst/src/widgets/gradienteditor.cpp #844061:844062
@@ -21,7 +21,7 @@
 namespace Kst {
 
 GradientEditor::GradientEditor(QWidget *parent)
-  : QWidget(parent), _gradient(0), _movingStop(-1), _fullResetMode(true) {
+  : QWidget(parent), _gradient(0), _movingStop(-1) {
   setMouseTracking(true);
   setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
 
@@ -52,20 +52,15 @@
 }
 
 
-void GradientEditor::setResetMode(bool full) {
-  _fullResetMode = full;
+void GradientEditor::setDefaultGradientStops(QGradientStops stops) {
+  _defaultGradientStops = stops;
 }
 
 
 void GradientEditor::resetGradient() {
   QLinearGradient defaultGradient(1,0,0,0);
   clearGradientStops();
-  if (!_fullResetMode) {
-    QGradientStops stops;
-    stops.append(qMakePair(1.0, QColor(Qt::white)));
-    stops.append(qMakePair(0.0, QColor(Qt::lightGray)));
-    setGradientStops(stops);
-  }
+  setGradientStops(_defaultGradientStops);
   update();
 }
 
--- branches/work/kst/portto4/kst/src/widgets/gradienteditor.h #844061:844062
@@ -30,7 +30,7 @@
 
   QGradient gradient() const;
 
-  void setResetMode(bool full);
+  void setDefaultGradientStops(QGradientStops stops);
 
 public Q_SLOTS:
   void setGradient(const QGradient &gradient);
@@ -63,7 +63,7 @@
   QGradient *_gradient;
   QHash<int, Stop> _stopHash;
   int _movingStop;
-  bool _fullResetMode;
+  QGradientStops _defaultGradientStops;
 };
 
 }


More information about the Kst mailing list