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

List:       kde-commits
Subject:    extragear/plasma/applets/fifteenPuzzle/src
From:       Andre Moreira Magalhaes <andrunko () yahoo ! com ! br>
Date:       2008-01-23 21:05:45
Message-ID: 1201122345.430711.26228.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 765322 by andrunko:

Checks if the user enters a valid image when selecting custom image
(Patch from Thomas Coopman).


 M  +4 -1      fifteenPuzzle.cpp  
 M  +30 -2     fifteenPuzzleConfig.cpp  
 M  +3 -0      fifteenPuzzleConfig.h  


--- trunk/extragear/plasma/applets/fifteenPuzzle/src/fifteenPuzzle.cpp #765321:765322
@@ -19,6 +19,8 @@
 
 #include "fifteenPuzzle.h"
 
+#include <QtCore/QFile>
+
 FifteenPuzzle::FifteenPuzzle(QObject *parent, const QVariantList &args)
     : Plasma::Applet(parent, args), configDialog(0)
 {
@@ -39,9 +41,10 @@
 
   // make sure nobody messed up with the config file
   if (!usePlainPieces &&
-      (imagePath.isEmpty() ||
+      (!QFile::exists(imagePath) ||
        QPixmap(imagePath).isNull())) {
     usePlainPieces = true;
+    imagePath = QString();
   }
 
   updateBoard();
--- trunk/extragear/plasma/applets/fifteenPuzzle/src/fifteenPuzzleConfig.cpp #765321:765322
@@ -17,10 +17,13 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
  ***************************************************************************/
 
+#include <kmessagebox.h>
+
+#include <QtCore/QFile>
+#include <QtGui/QPixmap>
+
 #include "fifteenPuzzleConfig.h"
 
-#include <QMessageBox>
-
 FifteenPuzzleConfig::FifteenPuzzleConfig(QWidget *parent)
     : KDialog(parent)
 {
@@ -32,5 +35,30 @@
   connect(ui.pb_shuffle, SIGNAL(clicked()), this, SIGNAL(shuffle()));
 }
 
+void FifteenPuzzleConfig::slotButtonClicked(int button)
+{
+  if (ui.rb_identical->isChecked() == false) {
+    switch (button) {
+      case KDialog::Ok:
+      case KDialog::Apply: {
+        QString path = ui.urlRequester->url().path();
+        if (!QFile::exists(path) ||
+            QPixmap(path).isNull()) {
+          KMessageBox::sorry(this,
+            i18nc("@body:window", "You have to provide a valid image"),
+            i18nc("@title:window", "Configure Fifteen Puzzle"),
+            KMessageBox::Notify);
+        } else {
+          KDialog::slotButtonClicked(button);
+        }
+        return;
+      }
+      default:
+        break;
+    }
+  }
+  KDialog::slotButtonClicked(button);
+}
+
 #include "fifteenPuzzleConfig.moc"
 
--- trunk/extragear/plasma/applets/fifteenPuzzle/src/fifteenPuzzleConfig.h #765321:765322
@@ -33,6 +33,9 @@
 
     Ui::fifteenPuzzleConfig ui;
 
+  protected Q_SLOTS:
+    void slotButtonClicked(int button);
+
   signals:
     void shuffle();
 };
[prev in list] [next in list] [prev in thread] [next in thread] 

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