summaryrefslogtreecommitdiff
path: root/noncore/games/fifteen/fifteenconfigdialog.cpp
Unidiff
Diffstat (limited to 'noncore/games/fifteen/fifteenconfigdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/fifteen/fifteenconfigdialog.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/noncore/games/fifteen/fifteenconfigdialog.cpp b/noncore/games/fifteen/fifteenconfigdialog.cpp
new file mode 100644
index 0000000..3f974f8
--- a/dev/null
+++ b/noncore/games/fifteen/fifteenconfigdialog.cpp
@@ -0,0 +1,112 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29
30#include "fifteenconfigdialog.h"
31
32#include <opie2/ofiledialog.h>
33
34#include <qimage.h>
35#include <qlabel.h>
36#include <qspinbox.h>
37#include <qlineedit.h>
38#include <qcheckbox.h>
39#include <qgroupbox.h>
40
41
42using Opie::Ui::OFileSelector;
43using Opie::Ui::OFileDialog;
44
45
46FifteenConfigDialog::FifteenConfigDialog( QWidget* parent, const char* name, bool modal )
47 : FifteenConfigDialogBase( parent, name, modal )
48{
49 grpGameGrid->hide();
50}
51
52FifteenConfigDialog::~FifteenConfigDialog()
53{}
54
55/**
56 * src.isEmpty() means no Custom Image to be set
57 */
58void FifteenConfigDialog::setImageSrc( const QString& src ) {
59 ckbCustomImage->setChecked( !src.isEmpty() );
60 lneImage->setText( src );
61 lblPreview->setPixmap( preview(src ) );
62}
63
64/*
65 * If the return isEmpty() this means no custom image is wished
66 */
67QString FifteenConfigDialog::imageSrc()const {
68 return ckbCustomImage->isChecked() ? lneImage->text() : QString::null;
69}
70
71void FifteenConfigDialog::setGameboard( int rows, int columns ) {
72 spnRow->setValue( rows );
73 spnCol->setValue( columns );
74}
75
76
77int FifteenConfigDialog::columns()const {
78 return spnCol->value();
79}
80
81int FifteenConfigDialog::rows() const{
82 return spnRow->value();
83}
84
85void FifteenConfigDialog::slotLoadImage() {
86 QStringList lst;
87 lst << "image/*";
88 MimeTypes type;
89 type.insert( tr("All Images" ), lst );
90 type.insert( tr("All Files"), "*/*" );
91
92
93 QString str = OFileDialog::getOpenFileName(OFileSelector::Normal,
94 QString::null, QString::null,
95 type, this,
96 tr("Select board background") );
97 if (!str.isEmpty() )
98 setImageSrc( str );
99}
100
101
102QPixmap FifteenConfigDialog::preview( const QString& file ) {
103 QPixmap pix;
104 QImage img( file );
105 if( img.isNull() )
106 return pix;
107
108 img = img.smoothScale(120, 120 );
109 pix.convertFromImage( img );
110
111 return pix;
112}