Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

fifteenconfigdialog.cpp

Go to the documentation of this file.
00001 /*
00002                =.            This file is part of the OPIE Project
00003              .=l.            Copyright (c)  2002 <>
00004            .>+-=
00005  _;:,     .>    :=|.         This program is free software; you can
00006 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00007 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00008 .="- .-=="i,     .._         License as published by the Free Software
00009  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00010      ._= =}       :          or (at your option) any later version.
00011     .%`+i>       _;_.
00012     .i_,=:_.      -<s.       This program is distributed in the hope that
00013      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00014     : ..    .:,     . . .    without even the implied warranty of
00015     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00016   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00017 ..}^=.=       =       ;      Library General Public License for more
00018 ++=   -.     .`     .:       details.
00019  :     =  ...= . :.=-
00020  -.   .:....=;==+<;          You should have received a copy of the GNU
00021   -_. . .   )=.  =           General Public License along with
00022     --        :-=`           this library; see the file COPYING.LIB.
00023                              If not, write to the Free Software Foundation,
00024                              Inc., 59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
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  * If the return isEmpty() this means no custom image is wished
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 }

Generated on Sat Nov 5 16:17:19 2005 for OPIE by  doxygen 1.4.2