00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "fifteenconfigdialog.h"
00031
00032 #include <opie2/ofiledialog.h>
00033
00034 #include <qimage.h>
00035 #include <qlabel.h>
00036 #include <qspinbox.h>
00037 #include <qlineedit.h>
00038 #include <qcheckbox.h>
00039 #include <qgroupbox.h>
00040
00041
00042 using Opie::Ui::OFileSelector;
00043 using Opie::Ui::OFileDialog;
00044
00045
00046 FifteenConfigDialog::FifteenConfigDialog( QWidget* parent, const char* name, bool modal )
00047 : FifteenConfigDialogBase( parent, name, modal )
00048 {}
00049
00050 FifteenConfigDialog::~FifteenConfigDialog()
00051 {}
00052
00056 void FifteenConfigDialog::setImageSrc( const QString& src ) {
00057 ckbCustomImage->setChecked( !src.isEmpty() );
00058 lneImage->setText( src );
00059 lblPreview->setPixmap( preview(src ) );
00060 }
00061
00062
00063
00064
00065 QString FifteenConfigDialog::imageSrc()const {
00066 return ckbCustomImage->isChecked() ? lneImage->text() : QString::null;
00067 }
00068
00069 void FifteenConfigDialog::setGameboard( int rows, int columns ) {
00070 spnRow->setValue( rows );
00071 spnCol->setValue( columns );
00072 }
00073
00074
00075 int FifteenConfigDialog::columns()const {
00076 return spnCol->value();
00077 }
00078
00079 int FifteenConfigDialog::rows() const{
00080 return spnRow->value();
00081 }
00082
00083 void FifteenConfigDialog::slotLoadImage() {
00084 QStringList lst;
00085 lst << "image/*";
00086 MimeTypes type;
00087 type.insert( tr("All Images" ), lst );
00088 type.insert( tr("All Files"), "*/*" );
00089
00090
00091 QString str = OFileDialog::getOpenFileName(OFileSelector::Normal,
00092 QString::null, QString::null,
00093 type, this,
00094 tr("Select board background") );
00095 if (!str.isEmpty() )
00096 setImageSrc( str );
00097 }
00098
00099
00100 QPixmap FifteenConfigDialog::preview( const QString& file ) {
00101 QPixmap pix;
00102 QImage img( file );
00103 if( img.isNull() )
00104 return pix;
00105
00106 img = img.smoothScale(120, 120 );
00107 pix.convertFromImage( img );
00108
00109 return pix;
00110 }