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

List:       kde-commits
Subject:    KDE/kdeplasma-addons/wallpapers/mandelbrot
From:       BenoƮt Jacob <jacob.benoit.1 () gmail ! com>
Date:       2010-03-14 18:06:06
Message-ID: 1268589966.275195.17360.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1103260 by bjacob:

Implement import/export of configuration to user's files.
Thanks a lot to ossi on IRC.



 M  +1 -1      config.ui  
 M  +34 -16    mandelbrot.cpp  
 M  +3 -0      mandelbrot.h  
 M  +0 -1      renderthread.h  


--- trunk/KDE/kdeplasma-addons/wallpapers/mandelbrot/config.ui #1103259:1103260
@@ -268,7 +268,7 @@
       <enum>Qt::LeftToRight</enum>
      </property>
      <property name="text">
-      <string>With most mice, use the mouse wheel or drag with the middle button to \
zoom, and drag with the left button to move around.</string> +      <string>Mouse \
navigation: use the mouse wheel or drag with the middle button to zoom, and drag with \
the left button to move around.</string>  </property>
      <property name="scaledContents">
       <bool>false</bool>
--- trunk/KDE/kdeplasma-addons/wallpapers/mandelbrot/mandelbrot.cpp #1103259:1103260
@@ -17,7 +17,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "mandelbrot.h"
-#include<iostream>
+#include <iostream>
 
 #include <cmath>
 #include <QGraphicsSceneMouseEvent>
@@ -119,23 +119,26 @@
     updateCache();
 }
 
-void Mandelbrot::init(const KConfigGroup &config)
+void Mandelbrot::readConfig(const KConfigGroup &config, int options)
 {
     QString old_key = key();
 
-    if (m_firstInit)
+    if(options & ReadViewpoint)
     {
         m_center = config.readEntry(MANDELBROT_CENTER_KEY, \
QPointF(qreal(-0.25),qreal(0)));  m_zoom = config.readEntry(MANDELBROT_ZOOM_KEY, \
                qreal(4));
-        m_firstInit = false;
     }
 
     m_color1 = config.readEntry(MANDELBROT_COLOR1_KEY, QColor(0,0,0));
     m_color2 = config.readEntry(MANDELBROT_COLOR2_KEY, QColor(255,255,255));
     m_color3 = config.readEntry(MANDELBROT_COLOR3_KEY, QColor(0,0,255));
-    m_lock = Qt::CheckState(config.readEntry(MANDELBROT_LOCK_KEY, \
                int(Qt::Unchecked)));
     m_quality = qBound(0, config.readEntry(MANDELBROT_QUALITY_KEY, 1), 4);
 
+    if(options & ReadLockStatus)
+    {
+      m_lock = Qt::CheckState(config.readEntry(MANDELBROT_LOCK_KEY, \
int(Qt::Unchecked))); +    }
+
     if(key() != old_key)
     {
         abortRendering();
@@ -151,6 +154,12 @@
     }
 }
 
+void Mandelbrot::init(const KConfigGroup &config)
+{
+    readConfig(config, (m_firstInit?ReadViewpoint:0) | ReadLockStatus);
+    m_firstInit = false;
+}
+
 QWidget* Mandelbrot::createConfigurationInterface(QWidget* parent)
 {
     QWidget *widget = new QWidget(parent);
@@ -483,11 +492,11 @@
 
 void Mandelbrot::exportImage()
 {
-    KUrl url = KFileDialog::getSaveUrl(
+    KUrl url = KFileDialog::getSaveFileName(
                    KUrl(),
                    "*.png|PNG images",
                    0,
-                   i18n("Save File"),
+                   QString(),
                    KFileDialog::ConfirmOverwrite
                  );
     QByteArray ba;
@@ -500,14 +509,14 @@
 
 void Mandelbrot::exportConfig()
 {
-    KUrl url = KFileDialog::getSaveUrl(
-                   KUrl(),
-                   "*.txt|Text files",
-                   0,
-                   i18n("Save File"),
-                   KFileDialog::ConfirmOverwrite
-                 );
-    KConfig config(url.fileName());
+    QString file = KFileDialog::getSaveFileName(
+                     KUrl(),
+                     "*.txt|Text files",
+                     0,
+                     QString(),
+                     KFileDialog::ConfirmOverwrite
+                   );
+    KConfig config(file, KConfig::SimpleConfig);
     KConfigGroup configgroup(&config, "Mandelbrot");
     save(configgroup);
     configgroup.config()->sync();
@@ -515,6 +524,15 @@
 
 void Mandelbrot::importConfig()
 {
-}
+    QString file = KFileDialog::getOpenFileName(
+                     KUrl(),
+                     "*.txt|Text files",
+                     0,
+                     QString()
+                   );
+    KConfig config(file, KConfig::SimpleConfig);
+    KConfigGroup configgroup(&config, "Mandelbrot");
+    readConfig(configgroup, ReadViewpoint); // reading colors and quality level is \
implicit +}                                           // but we dont want to read the \
lock status  
 #include "mandelbrot.moc"
--- trunk/KDE/kdeplasma-addons/wallpapers/mandelbrot/mandelbrot.h #1103259:1103260
@@ -148,6 +148,9 @@
         /** removes the current cache entry if it is obsolete, and inserts the new \
image into cache if it is ready */  void updateCache();
 
+        enum { ReadViewpoint=0x1, ReadLockStatus=0x4 };
+        void readConfig(const KConfigGroup &config, int options);
+
     protected slots:
         void setColor1(const QColor& color1);
         void setColor2(const QColor& color2);
--- trunk/KDE/kdeplasma-addons/wallpapers/mandelbrot/renderthread.h #1103259:1103260
@@ -28,7 +28,6 @@
     Q_OBJECT
     friend class Mandelbrot;
     Mandelbrot * const m_mandelbrot;
-    long long total_iter;
 
   public:
     MandelbrotRenderThread(Mandelbrot *m);


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

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