From kde-commits Wed Jan 23 21:05:45 2008 From: Andre Moreira Magalhaes Date: Wed, 23 Jan 2008 21:05:45 +0000 To: kde-commits Subject: extragear/plasma/applets/fifteenPuzzle/src Message-Id: <1201122345.430711.26228.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120112235419777 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 + 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 + +#include +#include + #include "fifteenPuzzleConfig.h" -#include - 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(); };