author | zecke <zecke> | 2004-07-24 15:02:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-24 15:02:13 (UTC) |
commit | c94b8aee4873dc382d3fe2673c7ac1db7080fe0e (patch) (unidiff) | |
tree | da5d98b9e429ad845651e731e93a978cea54a65b /noncore/games/fifteen/fifteenconfigdialog.cpp | |
parent | 2da1cf47a5c1429d8ad010880ff1da3e97b437ad (diff) | |
download | opie-c94b8aee4873dc382d3fe2673c7ac1db7080fe0e.zip opie-c94b8aee4873dc382d3fe2673c7ac1db7080fe0e.tar.gz opie-c94b8aee4873dc382d3fe2673c7ac1db7080fe0e.tar.bz2 |
Custom Image as the background for the board tiles.
This is later needed for the puzzle game mode
Diffstat (limited to 'noncore/games/fifteen/fifteenconfigdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/fifteen/fifteenconfigdialog.cpp | 112 |
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 | |||
42 | using Opie::Ui::OFileSelector; | ||
43 | using Opie::Ui::OFileDialog; | ||
44 | |||
45 | |||
46 | FifteenConfigDialog::FifteenConfigDialog( QWidget* parent, const char* name, bool modal ) | ||
47 | : FifteenConfigDialogBase( parent, name, modal ) | ||
48 | { | ||
49 | grpGameGrid->hide(); | ||
50 | } | ||
51 | |||
52 | FifteenConfigDialog::~FifteenConfigDialog() | ||
53 | {} | ||
54 | |||
55 | /** | ||
56 | * src.isEmpty() means no Custom Image to be set | ||
57 | */ | ||
58 | void 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 | */ | ||
67 | QString FifteenConfigDialog::imageSrc()const { | ||
68 | return ckbCustomImage->isChecked() ? lneImage->text() : QString::null; | ||
69 | } | ||
70 | |||
71 | void FifteenConfigDialog::setGameboard( int rows, int columns ) { | ||
72 | spnRow->setValue( rows ); | ||
73 | spnCol->setValue( columns ); | ||
74 | } | ||
75 | |||
76 | |||
77 | int FifteenConfigDialog::columns()const { | ||
78 | return spnCol->value(); | ||
79 | } | ||
80 | |||
81 | int FifteenConfigDialog::rows() const{ | ||
82 | return spnRow->value(); | ||
83 | } | ||
84 | |||
85 | void 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 | |||
102 | QPixmap 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 | } | ||