summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/showimg/main.cpp10
-rw-r--r--noncore/multimedia/showimg/showimg.cpp90
-rw-r--r--noncore/multimedia/showimg/showimg.h1
-rw-r--r--noncore/multimedia/showimg/showimg.pro4
4 files changed, 50 insertions, 55 deletions
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp
index c28cc85..efb1c68 100644
--- a/noncore/multimedia/showimg/main.cpp
+++ b/noncore/multimedia/showimg/main.cpp
@@ -1,33 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "showimg.h" 21#include "showimg.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25int main( int argc, char **argv ) 25#include <opie/oapplicationfactory.h>
26{
27 QPEApplication a( argc, argv );
28
29 ImageViewer w(0, "new window", Qt::WResizeNoErase );
30 a.showMainDocumentWidget(&w);
31 26
32 return a.exec(); 27OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) \ No newline at end of file
33}
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp
index d6f0733..56bdecf 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -1,1050 +1,1052 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// 21//
22// Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> 22// Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com>
23// 23//
24 24
25#include "showimg.h" 25#include "showimg.h"
26#include "ImageFileSelector.h" 26#include "ImageFileSelector.h"
27#include "settingsdialog.h" 27#include "settingsdialog.h"
28 28
29 29
30#include <opie/ofiledialog.h> 30#include <opie/ofiledialog.h>
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/fileselector.h> 35#include <qpe/fileselector.h>
36#include <qpe/applnk.h> 36#include <qpe/applnk.h>
37#include <qfileinfo.h> 37#include <qfileinfo.h>
38#include <math.h> 38#include <math.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qwidgetstack.h> 40#include <qwidgetstack.h>
41#include <qpe/qpetoolbar.h> 41#include <qpe/qpetoolbar.h>
42#include <qaction.h> 42#include <qaction.h>
43#include <qfiledialog.h> 43#include <qfiledialog.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qpopupmenu.h> 45#include <qpopupmenu.h>
46#include <qscrollview.h> 46#include <qscrollview.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qpainter.h> 48#include <qpainter.h>
49#include <qkeycode.h> 49#include <qkeycode.h>
50#include <qapplication.h> 50#include <qapplication.h>
51#include <qclipboard.h> 51#include <qclipboard.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qspinbox.h> 53#include <qspinbox.h>
54 54
55 55
56 56
57ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) 57ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent)
58 : QDialog(parent,0,true) 58 : QDialog(parent,0,true)
59{ 59{
60 setCaption(caption); 60 setCaption(caption);
61 61
62 if ( parent ) { 62 if ( parent ) {
63 setPalette(parent->palette()); 63 setPalette(parent->palette());
64 } 64 }
65 65
66 b=brightness; 66 b=brightness;
67 img=image; 67 img=image;
68 68
69 setMinimumSize(140,80); 69 setMinimumSize(140,80);
70 70
71 QGridLayout *gl= new QGridLayout(this,2,2,4,4); 71 QGridLayout *gl= new QGridLayout(this,2,2,4,4);
72 72
73 pixmap =new ImageWidget(this);; 73 pixmap =new ImageWidget(this);;
74 QPixmap pm; 74 QPixmap pm;
75 pm.convertFromImage(img); 75 pm.convertFromImage(img);
76 pixmap->setPixmap(pm); 76 pixmap->setPixmap(pm);
77 pixmap->setMinimumSize(pm.width(),pm.height()); 77 pixmap->setMinimumSize(pm.width(),pm.height());
78 gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); 78 gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter);
79 QLabel *l=new QLabel(tr("Brightness")+":",this); 79 QLabel *l=new QLabel(tr("Brightness")+":",this);
80 gl->addWidget(l,1,0,AlignLeft); 80 gl->addWidget(l,1,0,AlignLeft);
81 spb=new QSpinBox(-100,100,2,this); 81 spb=new QSpinBox(-100,100,2,this);
82 gl->addWidget(spb,1,1,AlignRight); 82 gl->addWidget(spb,1,1,AlignRight);
83 83
84 spb->setValue(0); 84 spb->setValue(0);
85 85
86 connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); 86 connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int)));
87 87
88} 88}
89 89
90void ControlsDialog::bValueChanged(int value) 90void ControlsDialog::bValueChanged(int value)
91{ 91{
92 QImage nImage=img; 92 QImage nImage=img;
93 nImage.detach(); 93 nImage.detach();
94 ImageViewer::intensity(nImage, (float)value/100); 94 ImageViewer::intensity(nImage, (float)value/100);
95 QPixmap pm; 95 QPixmap pm;
96 pm.convertFromImage(nImage); 96 pm.convertFromImage(nImage);
97 pixmap->setPixmap(pm); 97 pixmap->setPixmap(pm);
98 pixmap->repaint(false); 98 pixmap->repaint(false);
99 99
100 100
101} 101}
102 102
103void ControlsDialog::accept() 103void ControlsDialog::accept()
104{ 104{
105 *b=spb->value(); 105 *b=spb->value();
106 done(1); 106 done(1);
107} 107}
108 108
109//=========================================================================== 109//===========================================================================
110 110
111InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) 111InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent)
112 : QDialog(parent,0,true) 112 : QDialog(parent,0,true)
113{ 113{
114 setCaption(caption); 114 setCaption(caption);
115 115
116 if ( parent ) 116 if ( parent )
117 { 117 {
118 setPalette(parent->palette()); 118 setPalette(parent->palette());
119 } 119 }
120 120
121 const char *labels[]={"File Name","Format","File Size","Size","Colors","Alpha"}; 121
122
123 QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") };
122 124
123 setMinimumSize(180,80); 125 setMinimumSize(180,80);
124 int num=ImageViewer::LAST+1; 126 int num=ImageViewer::LAST+1;
125 if ( text[ImageViewer::ALPHA].isEmpty() ) 127 if ( text[ImageViewer::ALPHA].isEmpty() )
126 num--; 128 num--;
127 QGridLayout *gl= new QGridLayout(this,num,2,4,2); 129 QGridLayout *gl= new QGridLayout(this,num,2,4,2);
128 QLabel *l; 130 QLabel *l;
129 int count=0; 131 int count=0;
130 for ( int i=0;i<num;i++ ) 132 for ( int i=0;i<num;i++ )
131 { 133 {
132 if ( i==1 ) 134 if ( i==1 )
133 { 135 {
134 QFrame *frm=new QFrame(this); 136 QFrame *frm=new QFrame(this);
135 frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); 137 frm->setFrameStyle(QFrame::HLine|QFrame::Sunken);
136 gl->addMultiCellWidget(frm,i,i,0,1); 138 gl->addMultiCellWidget(frm,i,i,0,1);
137 } 139 }
138 else 140 else
139 { 141 {
140 l=new QLabel(tr(labels[count])+":",this); 142 l=new QLabel( tr( labels[count] )+":",this);
141 gl->addWidget(l,i,0,AlignLeft); 143 gl->addWidget(l,i,0,AlignLeft);
142 l=new QLabel(text[count],this); 144 l=new QLabel(text[count],this);
143 gl->addWidget(l,i,1,AlignRight); 145 gl->addWidget(l,i,1,AlignRight);
144 count++; 146 count++;
145 } 147 }
146 148
147 } 149 }
148 150
149} 151}
150 152
151void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) 153void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent)
152{ 154{
153 InfoDialog *dlg=new InfoDialog(caption,text,parent); 155 InfoDialog *dlg=new InfoDialog(caption,text,parent);
154 dlg->exec(); 156 dlg->exec();
155 delete dlg; 157 delete dlg;
156} 158}
157 159
158//=========================================================================== 160//===========================================================================
159 161
160 162
161ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) 163ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
162{ 164{
163 vb = new QVBoxLayout( this ); 165 vb = new QVBoxLayout( this );
164 166
165 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); 167 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity);
166 pic=new ImageWidget(image); 168 pic=new ImageWidget(image);
167 image->addChild(pic); 169 image->addChild(pic);
168 170
169 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); 171 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() ));
170 172
171 vb->addWidget( image ); 173 vb->addWidget( image );
172 174
173} 175}
174 176
175void ImagePane::setPixmap( const QPixmap &pm ) 177void ImagePane::setPixmap( const QPixmap &pm )
176{ 178{
177 pic->setPixmap( pm ); 179 pic->setPixmap( pm );
178 pic->resize(pm.width(),pm.height()); 180 pic->resize(pm.width(),pm.height());
179 image->updateScrollBars (); 181 image->updateScrollBars ();
180 pic->repaint(false); 182 pic->repaint(false);
181} 183}
182 184
183void ImagePane::imageClicked() 185void ImagePane::imageClicked()
184{ 186{
185 emit clicked(); 187 emit clicked();
186} 188}
187//=========================================================================== 189//===========================================================================
188/* 190/*
189 Draws the portion of the scaled pixmap that needs to be updated 191 Draws the portion of the scaled pixmap that needs to be updated
190*/ 192*/
191 193
192void ImageWidget::paintEvent( QPaintEvent *e ) 194void ImageWidget::paintEvent( QPaintEvent *e )
193{ 195{
194 QPainter painter(this); 196 QPainter painter(this);
195 197
196 painter.setClipRect(e->rect()); 198 painter.setClipRect(e->rect());
197 painter.fillRect(0,0,width(),height(),QColor(0,0,0)); 199 painter.fillRect(0,0,width(),height(),QColor(0,0,0));
198 200
199 if ( pixmap.size() != QSize( 0, 0 ) ) 201 if ( pixmap.size() != QSize( 0, 0 ) )
200 { // is an image loaded? 202 { // is an image loaded?
201 painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); 203 painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap);
202 } 204 }
203} 205}
204 206
205void ImageWidget::mouseReleaseEvent(QMouseEvent *) 207void ImageWidget::mouseReleaseEvent(QMouseEvent *)
206{ 208{
207 emit clicked(); 209 emit clicked();
208} 210}
209 211
210//=========================================================================== 212//===========================================================================
211 213
212ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) 214ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
213: QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE ) 215: QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE )
214{ 216{
215 setCaption( tr("Image Viewer") ); 217 setCaption( tr("Image Viewer") );
216 setIcon( Resource::loadPixmap( "ImageViewer" ) ); 218 setIcon( Resource::loadPixmap( "ImageViewer" ) );
217 219
218 220
219 Config cfg("Image Viewer"); 221 Config cfg("Image Viewer");
220 cfg.setGroup("Image Viewer"); 222 cfg.setGroup("Image Viewer");
221 223
222 showThumbView=cfg.readBoolEntry("ShowThumbnails",false); 224 showThumbView=cfg.readBoolEntry("ShowThumbnails",false);
223 isSized=cfg.readBoolEntry("SizeToScreen",true); 225 isSized=cfg.readBoolEntry("SizeToScreen",true);
224 226
225 isFullScreen = FALSE; 227 isFullScreen = FALSE;
226 228
227 setToolBarsMovable( FALSE ); 229 setToolBarsMovable( FALSE );
228 230
229 toolBar = new QPEToolBar( this ); 231 toolBar = new QPEToolBar( this );
230 toolBar->setHorizontalStretchable( TRUE ); 232 toolBar->setHorizontalStretchable( TRUE );
231 233
232 menuBar = new QPEMenuBar( toolBar ); 234 menuBar = new QPEMenuBar( toolBar );
233 235
234 current=menuBar; 236 current=menuBar;
235 237
236 238
237 239
238 fileMenuFile = new QPopupMenu(this); 240 fileMenuFile = new QPopupMenu(this);
239 //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); 241 //menuBarmenubarFile->insertItem( tr("File"), fileMenu );
240 fileMenuFile->insertItem(tr("Open"), 242 fileMenuFile->insertItem(tr("Open"),
241 this, SLOT(openFile()), 0); 243 this, SLOT(openFile()), 0);
242 244
243 viewMenuFile = new QPopupMenu( this ); 245 viewMenuFile = new QPopupMenu( this );
244 //menubarFile->insertItem( tr("View"), viewMenu ); 246 //menubarFile->insertItem( tr("View"), viewMenu );
245 viewMenuFile->insertItem( tr("Thumbnail View"), 247 viewMenuFile->insertItem( tr("Thumbnail View"),
246 this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); 248 this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS );
247 249
248 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 250 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
249 251
250 252
251 253
252 254
253 optionsMenuFile = new QPopupMenu( this); 255 optionsMenuFile = new QPopupMenu( this);
254 //menubarFile->insertItem( tr("Options"),optionsMenu ); 256 //menubarFile->insertItem( tr("Options"),optionsMenu );
255 slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), 257 slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ),
256 QString::null, 0, this, 0 ); 258 QString::null, 0, this, 0 );
257 slideAction->setToggleAction( TRUE ); 259 slideAction->setToggleAction( TRUE );
258 connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); 260 connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) );
259 slideAction->addTo( optionsMenuFile); 261 slideAction->addTo( optionsMenuFile);
260// slideAction->addTo( toolBar ); 262// slideAction->addTo( toolBar );
261 263
262 264
263// optionsMenuFile->insertItem( tr("Slideshow") ); 265// optionsMenuFile->insertItem( tr("Slideshow") );
264 optionsMenuFile->insertSeparator(); 266 optionsMenuFile->insertSeparator();
265 optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); 267 optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0);
266// optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); 268// optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0);
267 269
268 QStrList fmt = QImage::outputFormats(); 270 QStrList fmt = QImage::outputFormats();
269 271
270 272
271 fileMenuView = new QPopupMenu( this ); 273 fileMenuView = new QPopupMenu( this );
272 //menubarView->insertItem( tr("File"),fileMenu ); 274 //menubarView->insertItem( tr("File"),fileMenu );
273 fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); 275 fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 );
274 fileMenuView->insertSeparator(); 276 fileMenuView->insertSeparator();
275 277
276 viewMenuView = new QPopupMenu(this ); 278 viewMenuView = new QPopupMenu(this );
277 viewMenuView->setCheckable ( true ); 279 viewMenuView->setCheckable ( true );
278 280
279 //menubarView->insertItem( tr("View"),viewMenu ); 281 //menubarView->insertItem( tr("View"),viewMenu );
280 viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); 282 viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0);
281 viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); 283 viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0);
282 284
283 stack = new QWidgetStack( this ); 285 stack = new QWidgetStack( this );
284 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 286 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
285 setCentralWidget( stack ); 287 setCentralWidget( stack );
286 288
287 289
288 imagePanel = new ImagePane( stack ); 290 imagePanel = new ImagePane( stack );
289 connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); 291 connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView()));
290 292
291 293
292 ImageFileSelector::CURRENT_VIEW cv; 294 ImageFileSelector::CURRENT_VIEW cv;
293 if(showThumbView) 295 if(showThumbView)
294 cv=ImageFileSelector::THUMBNAIL; 296 cv=ImageFileSelector::THUMBNAIL;
295 else 297 else
296 cv=ImageFileSelector::DETAILED; 298 cv=ImageFileSelector::DETAILED;
297 299
298 qDebug("cv = %d",cv); 300 qDebug("cv = %d",cv);
299 301
300 fileSelector = new ImageFileSelector( cv,stack, "fs"); 302 fileSelector = new ImageFileSelector( cv,stack, "fs");
301 303
302 //switchThumbView(); 304 //switchThumbView();
303 305
304 306
305 //fileSelector = new ImageFileSelector("image/*", stack, "fs"); 307 //fileSelector = new ImageFileSelector("image/*", stack, "fs");
306 //fileSelector->setNewVisible(FALSE); 308 //fileSelector->setNewVisible(FALSE);
307 //fileSelector->setCloseVisible(FALSE); 309 //fileSelector->setCloseVisible(FALSE);
308 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); 310 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) );
309 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), 311 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
310 this, SLOT( openFile( const DocLnk & ) ) ); 312 this, SLOT( openFile( const DocLnk & ) ) );
311 313
312 imageList = fileSelector->fileList(); 314 imageList = fileSelector->fileList();
313 slideAction->setEnabled( imageList.count() != 0); 315 slideAction->setEnabled( imageList.count() != 0);
314 316
315 iconToolBar = new QPEToolBar(this); 317 iconToolBar = new QPEToolBar(this);
316 318
317 QAction *a; 319 QAction *a;
318 320
319 a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 321 a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
320 connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); 322 connect( a, SIGNAL( activated() ), this, SLOT( open() ) );
321 a->addTo( fileMenuView); 323 a->addTo( fileMenuView);
322 a->addTo( iconToolBar ); 324 a->addTo( iconToolBar );
323 325
324 326
325 a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); 327 a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0);
326 connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); 328 connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) );
327 a->addTo( iconToolBar ); 329 a->addTo( iconToolBar );
328 a->addTo( viewMenuView ); 330 a->addTo( viewMenuView );
329 331
330 a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); 332 a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 );
331 connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); 333 connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) );
332 a->addTo( iconToolBar ); 334 a->addTo( iconToolBar );
333 a->addTo( viewMenuView ); 335 a->addTo( viewMenuView );
334 336
335 337
336 a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); 338 a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0);
337 connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); 339 connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) );
338 //a->addTo( iconToolBar ); 340 //a->addTo( iconToolBar );
339 a->addTo( viewMenuView ); 341 a->addTo( viewMenuView );
340 342
341 343
342 344
343 viewMenuView->insertSeparator(); 345 viewMenuView->insertSeparator();
344 viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); 346 viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0);
345 viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); 347 viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE);
346 viewMenuView->insertSeparator(); 348 viewMenuView->insertSeparator();
347 349
348 350
349 sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); 351 sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true);
350 connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); 352 connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) );
351 sss->addTo( iconToolBar ); 353 sss->addTo( iconToolBar );
352 sss->addTo( viewMenuView ); 354 sss->addTo( viewMenuView );
353 355
354 sss->setOn(isSized); 356 sss->setOn(isSized);
355 viewMenuView->insertSeparator(); 357 viewMenuView->insertSeparator();
356 358
357 359
358 a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), 360 a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ),
359 QString::null, 0, this, 0 ); 361 QString::null, 0, this, 0 );
360 connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); 362 connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) );
361 a->addTo( iconToolBar ); 363 a->addTo( iconToolBar );
362 a->addTo( viewMenuView); 364 a->addTo( viewMenuView);
363 365
364 a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), 366 a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ),
365 QString::null, 0, this, 0 ); 367 QString::null, 0, this, 0 );
366 connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); 368 connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) );
367 a->addTo( iconToolBar ); 369 a->addTo( iconToolBar );
368 a->addTo( viewMenuView); 370 a->addTo( viewMenuView);
369 371
370 372
371 Config config( "ImageViewer" ); 373 Config config( "ImageViewer" );
372 config.setGroup( "SlideShow" ); 374 config.setGroup( "SlideShow" );
373 slideDelay = config.readNumEntry( "Delay", 2); 375 slideDelay = config.readNumEntry( "Delay", 2);
374 slideRepeat = config.readBoolEntry( "Repeat", FALSE ); 376 slideRepeat = config.readBoolEntry( "Repeat", FALSE );
375 slideReverse = config.readBoolEntry("Reverse", FALSE); 377 slideReverse = config.readBoolEntry("Reverse", FALSE);
376 378
377 config.setGroup("Default"); 379 config.setGroup("Default");
378 rotateOnLoad = config.readBoolEntry("Rotate", FALSE); 380 rotateOnLoad = config.readBoolEntry("Rotate", FALSE);
379 fastLoad = config.readBoolEntry("FastLoad", TRUE); 381 fastLoad = config.readBoolEntry("FastLoad", TRUE);
380 slideTimer = new QTimer( this ); 382 slideTimer = new QTimer( this );
381 connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); 383 connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) );
382 384
383 switchToFileSelector(); 385 switchToFileSelector();
384 386
385 setMouseTracking( TRUE ); 387 setMouseTracking( TRUE );
388
386 389
387
388} 390}
389 391
390ImageViewer::~ImageViewer() 392ImageViewer::~ImageViewer()
391{ 393{
392 Config cfg("Image Viewer"); 394 Config cfg("Image Viewer");
393 cfg.setGroup("Image Viewer"); 395 cfg.setGroup("Image Viewer");
394 396
395 cfg.writeEntry("ShowThumbnails",(int)showThumbView); 397 cfg.writeEntry("ShowThumbnails",(int)showThumbView);
396 cfg.writeEntry("SizeToScreen",(int)isSized); 398 cfg.writeEntry("SizeToScreen",(int)isSized);
397 399
398 cfg.setGroup( "SlideShow" ); 400 cfg.setGroup( "SlideShow" );
399 cfg.writeEntry( "Delay", slideDelay); 401 cfg.writeEntry( "Delay", slideDelay);
400 cfg.writeEntry( "Repeat", slideRepeat ); 402 cfg.writeEntry( "Repeat", slideRepeat );
401 cfg.writeEntry("Reverse", slideReverse); 403 cfg.writeEntry("Reverse", slideReverse);
402 404
403 cfg.setGroup("Default"); 405 cfg.setGroup("Default");
404 cfg.writeEntry("Rotate", rotateOnLoad); 406 cfg.writeEntry("Rotate", rotateOnLoad);
405 cfg.writeEntry("FastLoad", fastLoad); 407 cfg.writeEntry("FastLoad", fastLoad);
406 408
407 delete imagePanel; // in case it is fullscreen 409 delete imagePanel; // in case it is fullscreen
408} 410}
409 411
410void ImageViewer::help() { 412void ImageViewer::help() {
411 413
412} 414}
413 415
414 416
415void ImageViewer::settings() 417void ImageViewer::settings()
416{ 418{
417 SettingsDialog dlg( this, 0, TRUE ); 419 SettingsDialog dlg( this, 0, TRUE );
418 dlg.setDelay( slideDelay ); 420 dlg.setDelay( slideDelay );
419 dlg.setRepeat( slideRepeat ); 421 dlg.setRepeat( slideRepeat );
420 dlg.setReverse( slideReverse ); 422 dlg.setReverse( slideReverse );
421 dlg.setRotate(rotateOnLoad); 423 dlg.setRotate(rotateOnLoad);
422 dlg.setFastLoad(fastLoad); 424 dlg.setFastLoad(fastLoad);
423 425
424 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { 426 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) {
425 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); 427 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>");
426 slideDelay = dlg.delay(); 428 slideDelay = dlg.delay();
427 slideRepeat = dlg.repeat(); 429 slideRepeat = dlg.repeat();
428 slideReverse = dlg.reverse(); 430 slideReverse = dlg.reverse();
429 rotateOnLoad = dlg.rotate(); 431 rotateOnLoad = dlg.rotate();
430 fastLoad = dlg.fastLoad(); 432 fastLoad = dlg.fastLoad();
431 433
432 Config config( "ImageViewer" ); 434 Config config( "ImageViewer" );
433 config.setGroup( "SlideShow" ); 435 config.setGroup( "SlideShow" );
434 config.writeEntry( "Delay", slideDelay ); 436 config.writeEntry( "Delay", slideDelay );
435 config.writeEntry( "Repeat", slideRepeat ); 437 config.writeEntry( "Repeat", slideRepeat );
436 config.writeEntry("Reverse", slideReverse); 438 config.writeEntry("Reverse", slideReverse);
437 439
438 config.setGroup("Default"); 440 config.setGroup("Default");
439 config.writeEntry("Rotate", rotateOnLoad); 441 config.writeEntry("Rotate", rotateOnLoad);
440 config.writeEntry("FastLoad", fastLoad); 442 config.writeEntry("FastLoad", fastLoad);
441 } 443 }
442} 444}
443 445
444void ImageViewer::switchSizeToScreen() 446void ImageViewer::switchSizeToScreen()
445{ 447{
446 isSized=!isSized; 448 isSized=!isSized;
447 sss->setOn(isSized); 449 sss->setOn(isSized);
448 updateImage(); 450 updateImage();
449} 451}
450 452
451void ImageViewer::updateImage() 453void ImageViewer::updateImage()
452{ 454{
453 if ( isSized ) { 455 if ( isSized ) {
454 imagePanel->setPixmap(pmScaled); 456 imagePanel->setPixmap(pmScaled);
455 } else { 457 } else {
456 imagePanel->setPixmap(pm); 458 imagePanel->setPixmap(pm);
457 } 459 }
458} 460}
459 461
460void ImageViewer::switchThumbView() 462void ImageViewer::switchThumbView()
461{ 463{
462 464
463 showThumbView=!showThumbView; 465 showThumbView=!showThumbView;
464 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 466 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
465 fileSelector->switchView(); 467 fileSelector->switchView();
466 468
467} 469}
468 470
469void ImageViewer::switchToFileSelector() 471void ImageViewer::switchToFileSelector()
470{ 472{
471 stack->raiseWidget(fileSelector); 473 stack->raiseWidget(fileSelector);
472 menuBar->clear(); 474 menuBar->clear();
473 menuBar->insertItem( tr("File"), fileMenuFile ); 475 menuBar->insertItem( tr("File"), fileMenuFile );
474 menuBar->insertItem( tr("View"), viewMenuFile ); 476 menuBar->insertItem( tr("View"), viewMenuFile );
475 menuBar->insertItem( tr("Options"), optionsMenuFile ); 477 menuBar->insertItem( tr("Options"), optionsMenuFile );
476 iconToolBar->hide(); 478 iconToolBar->hide();
477 imagePanel->disable(); 479 imagePanel->disable();
478 slideShow(false); 480 slideShow(false);
479 481
480} 482}
481 483
482void ImageViewer::switchToImageView() 484void ImageViewer::switchToImageView()
483{ 485{
484 stack->raiseWidget(imagePanel); 486 stack->raiseWidget(imagePanel);
485 487
486 menuBar->clear(); 488 menuBar->clear();
487 menuBar->insertItem( tr("File"), fileMenuView ); 489 menuBar->insertItem( tr("File"), fileMenuView );
488 menuBar->insertItem( tr("View"), viewMenuView ); 490 menuBar->insertItem( tr("View"), viewMenuView );
489 viewMenuView->setItemEnabled(BLACKANDWHITE,true); 491 viewMenuView->setItemEnabled(BLACKANDWHITE,true);
490 iconToolBar->show(); 492 iconToolBar->show();
491 493
492 imagePanel->setPosition(0,0); 494 imagePanel->setPosition(0,0);
493 495
494} 496}
495 497
496 498
497void ImageViewer::setDocument(const QString& fileref) 499void ImageViewer::setDocument(const QString& fileref)
498{ 500{
499 delayLoad = fileref; 501 delayLoad = fileref;
500 switchToImageView(); 502 switchToImageView();
501 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); 503 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) );
502} 504}
503 505
504void ImageViewer::doDelayedLoad() 506void ImageViewer::doDelayedLoad()
505{ 507{
506 show(delayLoad); 508 show(delayLoad);
507} 509}
508 510
509void ImageViewer::show() 511void ImageViewer::show()
510{ 512{
511 normalView(); 513 normalView();
512 QMainWindow::show(); 514 QMainWindow::show();
513} 515}
514 516
515void ImageViewer::show(const QString& fileref) 517void ImageViewer::show(const QString& fileref)
516{ 518{
517// qDebug("Show "+fileref); 519// qDebug("Show "+fileref);
518 bFromDocView = TRUE; 520 bFromDocView = TRUE;
519 closeFileSelector(); 521 closeFileSelector();
520 DocLnk link(fileref); 522 DocLnk link(fileref);
521 if ( link.isValid() ) { 523 if ( link.isValid() ) {
522 openFile(link); 524 openFile(link);
523 } else { 525 } else {
524 filename = fileref; 526 filename = fileref;
525 updateCaption( fileref ); 527 updateCaption( fileref );
526 loadImage( fileref ); 528 loadImage( fileref );
527 } 529 }
528} 530}
529 531
530void ImageViewer::openFile() { 532void ImageViewer::openFile() {
531 MimeTypes types; 533 MimeTypes types;
532 QStringList image; 534 QStringList image;
533 image << "image/*"; 535 image << "image/*";
534 types.insert("Images", image); 536 types.insert("Images", image);
535 537
536 QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); 538 QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 );
537 DocLnk link(str); 539 DocLnk link(str);
538// if ( link.isValid() ) 540// if ( link.isValid() )
539 openFile(link); 541 openFile(link);
540 542
541} 543}
542 544
543void ImageViewer::openFile( const DocLnk &link ) 545void ImageViewer::openFile( const DocLnk &link )
544{ 546{
545 closeFileSelector(); 547 closeFileSelector();
546// DocLnk link(file); 548// DocLnk link(file);
547 qDebug("open "+link.name()); 549 qDebug("open "+link.name());
548 updateCaption( link.name() ); 550 updateCaption( link.name() );
549 loadImage( link.file() ); 551 loadImage( link.file() );
550 if (slideTimer->isActive()) { 552 if (slideTimer->isActive()) {
551 slideTimer->start(slideDelay * 1000, FALSE); 553 slideTimer->start(slideDelay * 1000, FALSE);
552 } 554 }
553 555
554} 556}
555 557
556void ImageViewer::open() 558void ImageViewer::open()
557{ 559{
558 switchToFileSelector(); 560 switchToFileSelector();
559} 561}
560 562
561void ImageViewer::closeFileSelector() 563void ImageViewer::closeFileSelector()
562{ 564{
563 switchToImageView(); 565 switchToImageView();
564} 566}
565 567
566void ImageViewer::updateCaption( QString name ) 568void ImageViewer::updateCaption( QString name )
567{ 569{
568 int sep = name.findRev( '/' ); 570 int sep = name.findRev( '/' );
569 if ( sep >= 0 ) 571 if ( sep >= 0 )
570 name = name.mid( sep+1 ); 572 name = name.mid( sep+1 );
571 setCaption( name + tr(" - Image Viewer") ); 573 setCaption( name + tr(" - Image Viewer") );
572} 574}
573 575
574/* 576/*
575 This function loads an image from a file. 577 This function loads an image from a file.
576*/ 578*/
577 579
578void ImageViewer::loadImage( const char *fileName ) 580void ImageViewer::loadImage( const char *fileName )
579{ 581{
580 filename = fileName; 582 filename = fileName;
581 if ( filename ) { 583 if ( filename ) {
582 QApplication::setOverrideCursor( waitCursor ); // this might take time 584 QApplication::setOverrideCursor( waitCursor ); // this might take time
583 //imagePanel->statusLabel()->setText( tr("Loading image...") ); 585 //imagePanel->statusLabel()->setText( tr("Loading image...") );
584 qApp->processEvents(); 586 qApp->processEvents();
585 bool ok = image.load(filename, 0); 587 bool ok = image.load(filename, 0);
586 if ( ok ) { 588 if ( ok ) {
587 ok = reconvertImage(); 589 ok = reconvertImage();
588 updateImageInfo(filename); 590 updateImageInfo(filename);
589 } 591 }
590 if ( !ok ) { 592 if ( !ok ) {
591 pm.resize(0,0); // couldn't load image 593 pm.resize(0,0); // couldn't load image
592 update(); 594 update();
593 } 595 }
594 QApplication::restoreOverrideCursor(); // restore original cursor 596 QApplication::restoreOverrideCursor(); // restore original cursor
595 } 597 }
596 598
597// fastLoad ? ", Fast" : "", 599// fastLoad ? ", Fast" : "",
598// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); 600// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1);
599 601
600 602
601// matrix.reset(); 603// matrix.reset();
602 rotated90 = FALSE; 604 rotated90 = FALSE;
603 605
604 if (rotateOnLoad) { 606 if (rotateOnLoad) {
605 rotated90 = TRUE; 607 rotated90 = TRUE;
606 rot90(); 608 rot90();
607// matrix.rotate( -90.0 ); 609// matrix.rotate( -90.0 );
608 } 610 }
609 611
610 switchToImageView(); 612 switchToImageView();
611 updateImage(); 613 updateImage();
612 614
613} 615}
614 616
615bool ImageViewer::loadSelected() 617bool ImageViewer::loadSelected()
616{ 618{
617 bool ok = false; 619 bool ok = false;
618 if ( stack->visibleWidget() == fileSelector ) 620 if ( stack->visibleWidget() == fileSelector )
619 { 621 {
620 const DocLnk *link = fileSelector->selected(); 622 const DocLnk *link = fileSelector->selected();
621 if ( link ) 623 if ( link )
622 { 624 {
623 if ( link->file() != filename ) 625 if ( link->file() != filename )
624 { 626 {
625 updateCaption( link->name() ); 627 updateCaption( link->name() );
626 filename = link->file(); 628 filename = link->file();
627 qApp->processEvents(); 629 qApp->processEvents();
628 ok = image.load(filename, 0); 630 ok = image.load(filename, 0);
629 if ( ok ) 631 if ( ok )
630 { 632 {
631 updateImageInfo(filename); 633 updateImageInfo(filename);
632 ok = reconvertImage(); 634 ok = reconvertImage();
633 } 635 }
634 if ( !ok ) 636 if ( !ok )
635 pm.resize(0,0); 637 pm.resize(0,0);
636 } 638 }
637 } 639 }
638 } 640 }
639 if ( !image.isNull() ) 641 if ( !image.isNull() )
640 { 642 {
641 ok = true; 643 ok = true;
642 closeFileSelector(); 644 closeFileSelector();
643 } 645 }
644 646
645 return ok; 647 return ok;
646} 648}
647 649
648bool ImageViewer::reconvertImage() 650bool ImageViewer::reconvertImage()
649{ 651{
650 bool success = FALSE; 652 bool success = FALSE;
651 653
652 if ( image.isNull() ) return FALSE; 654 if ( image.isNull() ) return FALSE;
653 655
654 QApplication::setOverrideCursor( waitCursor ); // this might take time 656 QApplication::setOverrideCursor( waitCursor ); // this might take time
655 if ( pm.convertFromImage(image /*, conversion_flags */ ) ) 657 if ( pm.convertFromImage(image /*, conversion_flags */ ) )
656 { 658 {
657 pmScaled = QPixmap(); 659 pmScaled = QPixmap();
658 scale(); 660 scale();
659 success = TRUE; // load successful 661 success = TRUE; // load successful
660 } 662 }
661 else 663 else
662 { 664 {
663 pm.resize(0,0); // couldn't load image 665 pm.resize(0,0); // couldn't load image
664 } 666 }
665 QApplication::restoreOverrideCursor(); // restore original cursor 667 QApplication::restoreOverrideCursor(); // restore original cursor
666 668
667 return success; // TRUE if loaded OK 669 return success; // TRUE if loaded OK
668} 670}
669 671
670 672
671int ImageViewer::calcHeight() 673int ImageViewer::calcHeight()
672{ 674{
673 if ( !isFullScreen ) 675 if ( !isFullScreen )
674 return imagePanel->paneHeight(); 676 return imagePanel->paneHeight();
675 else 677 else
676 return qApp->desktop()->height(); 678 return qApp->desktop()->height();
677} 679}
678/* 680/*
679 This functions scales the pixmap in the member variable "pm" to fit the 681 This functions scales the pixmap in the member variable "pm" to fit the
680 widget size and puts the resulting pixmap in the member variable "pmScaled". 682 widget size and puts the resulting pixmap in the member variable "pmScaled".
681*/ 683*/
682void ImageViewer::scale() 684void ImageViewer::scale()
683{ 685{
684 int h = calcHeight(); 686 int h = calcHeight();
685 if ( image.isNull() ) return; 687 if ( image.isNull() ) return;
686 688
687 QApplication::setOverrideCursor( waitCursor ); // this might take time 689 QApplication::setOverrideCursor( waitCursor ); // this might take time
688 if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) 690 if ( imagePanel->paneWidth() == pm.width() && h == pm.height() )
689 { // no need to scale if widget 691 { // no need to scale if widget
690 pmScaled = pm; // size equals pixmap size 692 pmScaled = pm; // size equals pixmap size
691 } 693 }
692 else 694 else
693 { 695 {
694 double hs = (double)h / (double)image.height(); 696 double hs = (double)h / (double)image.height();
695 double ws = (double)imagePanel->paneWidth() / (double)image.width(); 697 double ws = (double)imagePanel->paneWidth() / (double)image.width();
696 double scaleFactor = (hs > ws) ? ws : hs; 698 double scaleFactor = (hs > ws) ? ws : hs;
697 int smoothW = (int)(scaleFactor * image.width()); 699 int smoothW = (int)(scaleFactor * image.width());
698 int smoothH = (int)(scaleFactor * image.height()); 700 int smoothH = (int)(scaleFactor * image.height());
699 701
700 pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); 702 pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ );
701 } 703 }
702 QApplication::restoreOverrideCursor(); // restore original cursor 704 QApplication::restoreOverrideCursor(); // restore original cursor
703} 705}
704 706
705/* 707/*
706 The resize event handler, if a valid pixmap was loaded it will call 708 The resize event handler, if a valid pixmap was loaded it will call
707 scale() to fit the pixmap to the new widget size. 709 scale() to fit the pixmap to the new widget size.
708*/ 710*/
709 711
710void ImageViewer::resizeEvent( QResizeEvent * ) 712void ImageViewer::resizeEvent( QResizeEvent * )
711{ 713{
712 714
713 if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image 715 if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image
714 return; 716 return;
715 717
716 int h = calcHeight(); 718 int h = calcHeight();
717 719
718 if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) 720 if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() )
719 { // if new size, 721 { // if new size,
720 scale(); // scale pmScaled to window 722 scale(); // scale pmScaled to window
721 } 723 }
722 if ( image.hasAlphaBuffer() ) 724 if ( image.hasAlphaBuffer() )
723 erase(); 725 erase();
724} 726}
725 727
726 728
727void ImageViewer::hFlip() 729void ImageViewer::hFlip()
728{ 730{
729// matrix.scale( -1.0, 1.0 ); 731// matrix.scale( -1.0, 1.0 );
730 732
731 setImage(image.mirror(TRUE,FALSE)); 733 setImage(image.mirror(TRUE,FALSE));
732} 734}
733 735
734void ImageViewer::vFlip() 736void ImageViewer::vFlip()
735{ 737{
736// matrix.scale( 1.0, -1.0 ); 738// matrix.scale( 1.0, -1.0 );
737 setImage(image.mirror(FALSE,TRUE)); 739 setImage(image.mirror(FALSE,TRUE));
738} 740}
739 741
740void ImageViewer::rot180() 742void ImageViewer::rot180()
741{ 743{
742// matrix.rotate( 180.0 ); 744// matrix.rotate( 180.0 );
743 setImage(image.mirror(TRUE,TRUE)); 745 setImage(image.mirror(TRUE,TRUE));
744} 746}
745 747
746void ImageViewer::rot90() 748void ImageViewer::rot90()
747{ 749{
748 QImage oldimage; 750 QImage oldimage;
749 oldimage = image.convertDepth(32); 751 oldimage = image.convertDepth(32);
750// matrix.rotate( -90.0 ); 752// matrix.rotate( -90.0 );
751 setImage(rotate(oldimage,Rotate90)); 753 setImage(rotate(oldimage,Rotate90));
752 754
753} 755}
754void ImageViewer::rot270() 756void ImageViewer::rot270()
755{ 757{
756 758
757 QImage oldimage; 759 QImage oldimage;
758 oldimage = image.convertDepth(32); 760 oldimage = image.convertDepth(32);
759// matrix.rotate(90.0); 761// matrix.rotate(90.0);
760 setImage(rotate(oldimage,Rotate270)); 762 setImage(rotate(oldimage,Rotate270));
761 763
762} 764}
763 765
764void ImageViewer::blackAndWhite() 766void ImageViewer::blackAndWhite()
765{ 767{
766 768
767 viewMenuView->setItemEnabled(BLACKANDWHITE,false); 769 viewMenuView->setItemEnabled(BLACKANDWHITE,false);
768 setImage(toGray(image,false)); 770 setImage(toGray(image,false));
769} 771}
770 772
771void ImageViewer::displayControlsDialog() 773void ImageViewer::displayControlsDialog()
772{ 774{
773 int w=80; 775 int w=80;
774 int h=w; 776 int h=w;
775 QImage small; 777 QImage small;
776 778
777 if ( image.width()<w ||image.height()<h ) 779 if ( image.width()<w ||image.height()<h )
778 small=image.smoothScale(w,h); 780 small=image.smoothScale(w,h);
779 else 781 else
780 small=image.copy(0,0,w,h); 782 small=image.copy(0,0,w,h);
781 783
782 int newB=0; 784 int newB=0;
783 ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); 785 ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this);
784 dlg->exec(); 786 dlg->exec();
785 if ( newB ) { 787 if ( newB ) {
786 intensity(image,(float)newB/100); 788 intensity(image,(float)newB/100);
787 setImage(image); 789 setImage(image);
788 } 790 }
789 791
790} 792}
791 793
792 794
793void ImageViewer::displayInfoDialog() 795void ImageViewer::displayInfoDialog()
794{ 796{
795 797
796 QStringList ls; 798 QStringList ls;
797 799
798 for ( int i=0;i<LAST;i++ ) 800 for ( int i=0;i<LAST;i++ )
799 ls.append(imageInfo[i]); 801 ls.append(imageInfo[i]);
800 802
801 InfoDialog::displayInfo("Image Viewer",ls,this); 803 InfoDialog::displayInfo("Image Viewer",ls,this);
802} 804}
803void ImageViewer::normalView() 805void ImageViewer::normalView()
804{ 806{
805 if ( !imagePanel->parentWidget() ) 807 if ( !imagePanel->parentWidget() )
806 { 808 {
807 809
808 isFullScreen = FALSE; 810 isFullScreen = FALSE;
809 stack->addWidget( imagePanel, 1 ); 811 stack->addWidget( imagePanel, 1 );
810 switchToImageView(); 812 switchToImageView();
811 if ( isSized ) 813 if ( isSized )
812 scale(); 814 scale();
813 815
814 updateImage(); 816 updateImage();
815 817
816 } 818 }
817} 819}
818 820
819void ImageViewer::stopSlideShow() { 821void ImageViewer::stopSlideShow() {
820 if (slideTimer->isActive()) 822 if (slideTimer->isActive())
821 slideTimer->stop(); 823 slideTimer->stop();
822} 824}
823 825
824void ImageViewer::fullScreen() 826void ImageViewer::fullScreen()
825{ 827{
826 // Full-screen option 828 // Full-screen option
827 // contributed by Robert Wittams <robert@wittams.com> 829 // contributed by Robert Wittams <robert@wittams.com>
828 if ( imagePanel->parentWidget() && loadSelected() ) 830 if ( imagePanel->parentWidget() && loadSelected() )
829 { 831 {
830 isFullScreen = TRUE; 832 isFullScreen = TRUE;
831 imagePanel->reparent(0,QPoint(0,0)); 833 imagePanel->reparent(0,QPoint(0,0));
832 imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); 834 imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height());
833 835
834 if ( isSized ) 836 if ( isSized )
835 scale(); 837 scale();
836 updateImage(); 838 updateImage();
837 imagePanel->showFullScreen(); 839 imagePanel->showFullScreen();
838 } 840 }
839} 841}
840 842
841void ImageViewer::setImage(const QImage& newimage) 843void ImageViewer::setImage(const QImage& newimage)
842{ 844{
843 image = newimage; 845 image = newimage;
844 reconvertImage(); 846 reconvertImage();
845 updateImage(); 847 updateImage();
846} 848}
847 849
848void ImageViewer::updateImageInfo(QString &filePath) 850void ImageViewer::updateImageInfo(QString &filePath)
849{ 851{
850 852
851 for ( int i=0;i<LAST;i++ ) 853 for ( int i=0;i<LAST;i++ )
852 { 854 {
853 imageInfo[i]=""; 855 imageInfo[i]="";
854 } 856 }
855 857
856 imageInfo[FORMAT]=QImage::imageFormat (filePath ); 858 imageInfo[FORMAT]=QImage::imageFormat (filePath );
857 QFileInfo fi(filePath); 859 QFileInfo fi(filePath);
858 imageInfo[PATH]=fi.fileName(); 860 imageInfo[PATH]=fi.fileName();
859 imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; 861 imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)";
860 QString message("%1x%2"); 862 QString message("%1x%2");
861 imageInfo[SIZE]=QString("%1x%2"); 863 imageInfo[SIZE]=QString("%1x%2");
862 imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); 864 imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height());
863 if ( image.numColors() > 0 ) 865 if ( image.numColors() > 0 )
864 { 866 {
865 imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); 867 imageInfo[COLORS]=tr("%1 colors").arg(image.numColors());
866 } 868 }
867 else if ( image.depth() >= 16 ) 869 else if ( image.depth() >= 16 )
868 { 870 {
869 imageInfo[COLORS]=tr(" True color"); 871 imageInfo[COLORS]=tr(" True color");
870 } 872 }
871 if ( image.hasAlphaBuffer() ) 873 if ( image.hasAlphaBuffer() )
872 { 874 {
873 if ( image.depth() == 8 ) 875 if ( image.depth() == 8 )
874 { 876 {
875 int i; 877 int i;
876 bool alpha[256]; 878 bool alpha[256];
877 int nalpha=0; 879 int nalpha=0;
878 880
879 for ( i=0; i<256; i++ ) 881 for ( i=0; i<256; i++ )
880 alpha[i] = FALSE; 882 alpha[i] = FALSE;
881 883
882 for ( i=0; i<image.numColors(); i++ ) 884 for ( i=0; i<image.numColors(); i++ )
883 { 885 {
884 int alevel = image.color(i) >> 24; 886 int alevel = image.color(i) >> 24;
885 if ( !alpha[alevel] ) 887 if ( !alpha[alevel] )
886 { 888 {
887 alpha[alevel] = TRUE; 889 alpha[alevel] = TRUE;
888 nalpha++; 890 nalpha++;
889 } 891 }
890 } 892 }
891 imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); 893 imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha);
892 } 894 }
893 else 895 else
894 { 896 {
895 imageInfo[ALPHA]=tr("8-bit alpha channel"); 897 imageInfo[ALPHA]=tr("8-bit alpha channel");
896 } 898 }
897 } 899 }
898 900
899} 901}
900 902
901void ImageViewer::closeEvent( QCloseEvent *e ) 903void ImageViewer::closeEvent( QCloseEvent *e )
902{ 904{
903 if ( stack->visibleWidget() == imagePanel && !bFromDocView ) 905 if ( stack->visibleWidget() == imagePanel && !bFromDocView )
904 { 906 {
905 e->ignore(); 907 e->ignore();
906 open(); 908 open();
907 } 909 }
908 else 910 else
909 { 911 {
910 bFromDocView = FALSE; 912 bFromDocView = FALSE;
911 e->accept(); 913 e->accept();
912 } 914 }
913} 915}
914 916
915// Intensity,toGray and rotate code courtesy of KDE project. 917// Intensity,toGray and rotate code courtesy of KDE project.
916 918
917 919
918QImage& ImageViewer::intensity(QImage &image, float percent) 920QImage& ImageViewer::intensity(QImage &image, float percent)
919{ 921{
920 922
921 int segColors = image.depth() > 8 ? 256 : image.numColors(); 923 int segColors = image.depth() > 8 ? 256 : image.numColors();
922 unsigned char *segTbl = new unsigned char[segColors]; 924 unsigned char *segTbl = new unsigned char[segColors];
923 int pixels = image.depth() > 8 ? image.width()*image.height() : 925 int pixels = image.depth() > 8 ? image.width()*image.height() :
924 image.numColors(); 926 image.numColors();
925 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : 927 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
926 (unsigned int *)image.colorTable(); 928 (unsigned int *)image.colorTable();
927 929
928 bool brighten = (percent >= 0); 930 bool brighten = (percent >= 0);
929 if ( percent < 0 ) 931 if ( percent < 0 )
930 percent = -percent; 932 percent = -percent;
931 933
932 if ( brighten ) 934 if ( brighten )
933 { // keep overflow check out of loops 935 { // keep overflow check out of loops
934 for ( int i=0; i < segColors; ++i ) 936 for ( int i=0; i < segColors; ++i )
935 { 937 {
936 int tmp = (int)(i*percent); 938 int tmp = (int)(i*percent);
937 if ( tmp > 255 ) 939 if ( tmp > 255 )
938 tmp = 255; 940 tmp = 255;
939 segTbl[i] = tmp; 941 segTbl[i] = tmp;
940 } 942 }
941 } 943 }
942 else 944 else
943 { 945 {
944 for ( int i=0; i < segColors; ++i ) 946 for ( int i=0; i < segColors; ++i )
945 { 947 {
946 int tmp = (int)(i*percent); 948 int tmp = (int)(i*percent);
947 if ( tmp < 0 ) 949 if ( tmp < 0 )
948 tmp = 0; 950 tmp = 0;
949 segTbl[i] = tmp; 951 segTbl[i] = tmp;
950 } 952 }
951 } 953 }
952 954
953 if ( brighten ) 955 if ( brighten )
954 { // same here 956 { // same here
955 for ( int i=0; i < pixels; ++i ) 957 for ( int i=0; i < pixels; ++i )
956 { 958 {
957 int r = qRed(data[i]); 959 int r = qRed(data[i]);
958 int g = qGreen(data[i]); 960 int g = qGreen(data[i]);
959 int b = qBlue(data[i]); 961 int b = qBlue(data[i]);
960 int a = qAlpha(data[i]); 962 int a = qAlpha(data[i]);
961 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; 963 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
962 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; 964 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
963 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; 965 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
964 data[i] = qRgba(r, g, b,a); 966 data[i] = qRgba(r, g, b,a);
965 } 967 }
966 } 968 }
967 else 969 else
968 { 970 {
969 for ( int i=0; i < pixels; ++i ) 971 for ( int i=0; i < pixels; ++i )
970 { 972 {
971 int r = qRed(data[i]); 973 int r = qRed(data[i]);
972 int g = qGreen(data[i]); 974 int g = qGreen(data[i]);
973 int b = qBlue(data[i]); 975 int b = qBlue(data[i]);
974 int a = qAlpha(data[i]); 976 int a = qAlpha(data[i]);
975 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; 977 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r];
976 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; 978 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g];
977 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; 979 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b];
978 data[i] = qRgba(r, g, b, a); 980 data[i] = qRgba(r, g, b, a);
979 } 981 }
980 } 982 }
981 delete [] segTbl; 983 delete [] segTbl;
982 984
983 return image; 985 return image;
984} 986}
985 987
986QImage& ImageViewer::toGray(QImage &img, bool fast) 988QImage& ImageViewer::toGray(QImage &img, bool fast)
987{ 989{
988 if ( img.width() == 0 || img.height() == 0 ) 990 if ( img.width() == 0 || img.height() == 0 )
989 return img; 991 return img;
990 992
991 if ( fast ) 993 if ( fast )
992 { 994 {
993 if ( img.depth() == 32 ) 995 if ( img.depth() == 32 )
994 { 996 {
995 register uchar * r(img.bits()); 997 register uchar * r(img.bits());
996 register uchar * g(img.bits() + 1); 998 register uchar * g(img.bits() + 1);
997 register uchar * b(img.bits() + 2); 999 register uchar * b(img.bits() + 2);
998 1000
999 uchar * end(img.bits() + img.numBytes()); 1001 uchar * end(img.bits() + img.numBytes());
1000 1002
1001 while ( r != end ) 1003 while ( r != end )
1002 { 1004 {
1003 1005
1004 *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3 1006 *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3
1005 1007
1006 r += 4; 1008 r += 4;
1007 g += 4; 1009 g += 4;
1008 b += 4; 1010 b += 4;
1009 } 1011 }
1010 } 1012 }
1011 else 1013 else
1012 { 1014 {
1013 for ( int i = 0; i < img.numColors(); i++ ) 1015 for ( int i = 0; i < img.numColors(); i++ )
1014 { 1016 {
1015 register uint r = qRed(img.color(i)); 1017 register uint r = qRed(img.color(i));
1016 register uint g = qGreen(img.color(i)); 1018 register uint g = qGreen(img.color(i));
1017 register uint b = qBlue(img.color(i)); 1019 register uint b = qBlue(img.color(i));
1018 1020
1019 register uint gray = (((r + g) >> 1) + b) >> 1; 1021 register uint gray = (((r + g) >> 1) + b) >> 1;
1020 img.setColor(i, qRgba(gray, gray, gray, qAlpha(img.color(i)))); 1022 img.setColor(i, qRgba(gray, gray, gray, qAlpha(img.color(i))));
1021 } 1023 }
1022 } 1024 }
1023 } 1025 }
1024 else 1026 else
1025 { 1027 {
1026 int pixels = img.depth() > 8 ? img.width()*img.height() : 1028 int pixels = img.depth() > 8 ? img.width()*img.height() :
1027 img.numColors(); 1029 img.numColors();
1028 unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : 1030 unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() :
1029 (unsigned int *)img.colorTable(); 1031 (unsigned int *)img.colorTable();
1030 int val, i; 1032 int val, i;
1031 for ( i=0; i < pixels; ++i ) 1033 for ( i=0; i < pixels; ++i )
1032 { 1034 {
1033 val = qGray(data[i]); 1035 val = qGray(data[i]);
1034 data[i] = qRgba(val, val, val, qAlpha(data[i])); 1036 data[i] = qRgba(val, val, val, qAlpha(data[i]));
1035 } 1037 }
1036 } 1038 }
1037 return img; 1039 return img;
1038} 1040}
1039 1041
1040 1042
1041QImage ImageViewer::rotate(QImage &img, RotateDirection r) 1043QImage ImageViewer::rotate(QImage &img, RotateDirection r)
1042{ 1044{
1043 QImage dest; 1045 QImage dest;
1044 int x, y; 1046 int x, y;
1045 if ( img.depth() > 8 ) 1047 if ( img.depth() > 8 )
1046 { 1048 {
1047 unsigned int *srcData, *destData; 1049 unsigned int *srcData, *destData;
1048 switch ( r ) 1050 switch ( r )
1049 { 1051 {
1050 case Rotate90: 1052 case Rotate90:
diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h
index 8555ff0..abbd976 100644
--- a/noncore/multimedia/showimg/showimg.h
+++ b/noncore/multimedia/showimg/showimg.h
@@ -1,288 +1,289 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef SHOWIMG_H 21#ifndef SHOWIMG_H
22#define SHOWIMG_H 22#define SHOWIMG_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qscrollview.h> 29#include <qscrollview.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32#include <qvaluelist.h> 32#include <qvaluelist.h>
33#include <qwmatrix.h> 33#include <qwmatrix.h>
34 34
35 35
36class QAction; 36class QAction;
37class QPEToolBar; 37class QPEToolBar;
38class QPEMenuBar; 38class QPEMenuBar;
39class QPopupMenu; 39class QPopupMenu;
40class QWidgetStack; 40class QWidgetStack;
41class FileSelector; 41class FileSelector;
42class DocLnk; 42class DocLnk;
43class QLabel; 43class QLabel;
44class QAction; 44class QAction;
45class QSpinBox; 45class QSpinBox;
46class ImageFileSelector; 46class ImageFileSelector;
47class QTimer; 47class QTimer;
48 48
49 49
50class ImageWidget : public QWidget 50class ImageWidget : public QWidget
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 ImageWidget( QWidget *parent=0 ) 54 ImageWidget( QWidget *parent=0 )
55 : QWidget( parent ) { 55 : QWidget( parent ) {
56 setBackgroundMode(NoBackground); 56 setBackgroundMode(NoBackground);
57 } 57 }
58 ~ImageWidget() { } 58 ~ImageWidget() { }
59 59
60 void setPixmap( const QPixmap &pm ) { 60 void setPixmap( const QPixmap &pm ) {
61 pixmap = pm; 61 pixmap = pm;
62 show(); 62 show();
63 } 63 }
64 64
65signals: 65signals:
66 void clicked(); 66 void clicked();
67 67
68protected: 68protected:
69 void paintEvent( QPaintEvent * ); 69 void paintEvent( QPaintEvent * );
70 void mouseReleaseEvent(QMouseEvent* event); 70 void mouseReleaseEvent(QMouseEvent* event);
71 71
72private: 72private:
73 QPixmap pixmap; 73 QPixmap pixmap;
74}; 74};
75 75
76class InfoDialog:public QDialog 76class InfoDialog:public QDialog
77{ 77{
78 Q_OBJECT 78 Q_OBJECT
79 79
80public: 80public:
81 81
82 static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); 82 static void displayInfo(const QString &caption, const QStringList text, QWidget *parent);
83 83
84private: 84private:
85 85
86 InfoDialog(const QString &caption,const QStringList text, QWidget *parent); 86 InfoDialog(const QString &caption,const QStringList text, QWidget *parent);
87 87
88}; 88};
89 89
90class ControlsDialog:public QDialog 90class ControlsDialog:public QDialog
91{ 91{
92 Q_OBJECT 92 Q_OBJECT
93 93
94public: 94public:
95 ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent); 95 ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent);
96 96
97 97
98private slots: 98private slots:
99 99
100 void bValueChanged(int); 100 void bValueChanged(int);
101 void accept(); 101 void accept();
102 102
103 103
104private: 104private:
105 ImageWidget *pixmap; 105 ImageWidget *pixmap;
106 QSpinBox *spb; 106 QSpinBox *spb;
107 QImage img; 107 QImage img;
108 int *b; 108 int *b;
109}; 109};
110 110
111 111
112class ImagePane : public QWidget 112class ImagePane : public QWidget
113{ 113{
114 Q_OBJECT 114 Q_OBJECT
115public: 115public:
116 ImagePane( QWidget *parent=0 ); 116 ImagePane( QWidget *parent=0 );
117 ~ImagePane() { } 117 ~ImagePane() { }
118 118
119 //void showStatus(); 119 //void showStatus();
120 //void hideStatus(); 120 //void hideStatus();
121 //QLabel *statusLabel() 121 //QLabel *statusLabel()
122 //{ 122 //{
123 // return status; 123 // return status;
124 //} 124 //}
125 void setPixmap( const QPixmap &pm ); 125 void setPixmap( const QPixmap &pm );
126 126
127 127
128 int paneWidth() const { 128 int paneWidth() const {
129 return image->visibleWidth(); 129 return image->visibleWidth();
130 } 130 }
131 131
132 int paneHeight() const { 132 int paneHeight() const {
133 return image->visibleHeight(); 133 return image->visibleHeight();
134 } 134 }
135 135
136 void setPosition(int x, int y) { 136 void setPosition(int x, int y) {
137 image->setContentsPos (x,y ); 137 image->setContentsPos (x,y );
138 } 138 }
139 139
140 void disable() { 140 void disable() {
141 pic->hide(); 141 pic->hide();
142 } 142 }
143 143
144signals: 144signals:
145 void clicked(); 145 void clicked();
146 146
147private: 147private:
148 QScrollView *image; 148 QScrollView *image;
149 ImageWidget *pic; 149 ImageWidget *pic;
150 QVBoxLayout *vb; 150 QVBoxLayout *vb;
151 151
152private slots: 152private slots:
153 void imageClicked(); 153 void imageClicked();
154}; 154};
155 155
156 156
157class ImageViewer : public QMainWindow 157class ImageViewer : public QMainWindow
158{ 158{
159 Q_OBJECT 159 Q_OBJECT
160public: 160public:
161 static QString appName() { return QString::fromLatin1("showimg"); }
161 ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); 162 ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 );
162 ~ImageViewer(); 163 ~ImageViewer();
163 164
164 void loadImage( const char *fileName ); 165 void loadImage( const char *fileName );
165 void show(const QString& fileref); 166 void show(const QString& fileref);
166 void show(); 167 void show();
167 168
168 169
169 enum INFO_STRINGS { 170 enum INFO_STRINGS {
170 PATH, 171 PATH,
171 FORMAT, 172 FORMAT,
172 FILE_SIZE, 173 FILE_SIZE,
173 SIZE, 174 SIZE,
174 COLORS, 175 COLORS,
175 ALPHA, 176 ALPHA,
176 LAST 177 LAST
177 }; 178 };
178 179
179 enum RotateDirection { 180 enum RotateDirection {
180 Rotate90, Rotate180, Rotate270 181 Rotate90, Rotate180, Rotate270
181 }; 182 };
182 183
183 184
184 static QImage rotate(QImage &img, RotateDirection r); 185 static QImage rotate(QImage &img, RotateDirection r);
185 static QImage& intensity(QImage &image, float percent); 186 static QImage& intensity(QImage &image, float percent);
186 static QImage& toGray(QImage &image, bool fast = false); 187 static QImage& toGray(QImage &image, bool fast = false);
187 bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view 188 bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view
188 189
189protected: 190protected:
190 void resizeEvent( QResizeEvent * ); 191 void resizeEvent( QResizeEvent * );
191 void closeEvent( QCloseEvent * ); 192 void closeEvent( QCloseEvent * );
192 193
193private: 194private:
194 int imageIndex(void); 195 int imageIndex(void);
195 196
196 void updateCaption( QString name ); 197 void updateCaption( QString name );
197 bool loadSelected(); 198 bool loadSelected();
198 void scale(); 199 void scale();
199 bool reconvertImage(); 200 bool reconvertImage();
200 int calcHeight(); 201 int calcHeight();
201 void setImage(const QImage& newimage); 202 void setImage(const QImage& newimage);
202 void updateImageInfo(QString &filePath); 203 void updateImageInfo(QString &filePath);
203 void switchToFileSelector(); 204 void switchToFileSelector();
204 void switchToImageView(); 205 void switchToImageView();
205 206
206 void updateImage(); 207 void updateImage();
207 208
208private slots: 209private slots:
209 210
210 void slideShow( bool on ); 211 void slideShow( bool on );
211 void help(); 212 void help();
212 void slideUpdate(); 213 void slideUpdate();
213 bool nextImage(); 214 bool nextImage();
214 bool prevImage(); 215 bool prevImage();
215 void settings(); 216 void settings();
216 217
217 void switchThumbView(); 218 void switchThumbView();
218 void switchSizeToScreen(); 219 void switchSizeToScreen();
219 void setDocument(const QString& fileref); 220 void setDocument(const QString& fileref);
220 void doDelayedLoad(); 221 void doDelayedLoad();
221 void openFile( const DocLnk &file ); 222 void openFile( const DocLnk &file );
222 void openFile(); 223 void openFile();
223 void open(); 224 void open();
224 void closeFileSelector(); 225 void closeFileSelector();
225 void hFlip(); 226 void hFlip();
226 void vFlip(); 227 void vFlip();
227 void rot180(); 228 void rot180();
228 void rot90(); 229 void rot90();
229 void rot270(); 230 void rot270();
230 void normalView(); 231 void normalView();
231 void fullScreen(); 232 void fullScreen();
232 void stopSlideShow(); 233 void stopSlideShow();
233 void blackAndWhite(); 234 void blackAndWhite();
234 void displayInfoDialog(); 235 void displayInfoDialog();
235 void displayControlsDialog(); 236 void displayControlsDialog();
236private: 237private:
237 QWMatrix matrix; 238 QWMatrix matrix;
238 bool rotated90; 239 bool rotated90;
239 enum MENU_ITEMS { 240 enum MENU_ITEMS {
240 SHOW_THUMBNAILS, 241 SHOW_THUMBNAILS,
241 SIZE_TO_SCREEN, 242 SIZE_TO_SCREEN,
242 BLACKANDWHITE 243 BLACKANDWHITE
243 }; 244 };
244 245
245 QString filename; 246 QString filename;
246 QString delayLoad; 247 QString delayLoad;
247 QImage image; // the loaded image 248 QImage image; // the loaded image
248 QPixmap pm; // the converted pixmap 249 QPixmap pm; // the converted pixmap
249 QPixmap pmScaled; // the scaled pixmap 250 QPixmap pmScaled; // the scaled pixmap
250 QPEToolBar *toolBar; 251 QPEToolBar *toolBar;
251 QPEToolBar *iconToolBar; 252 QPEToolBar *iconToolBar;
252 QPEMenuBar *menuBar; 253 QPEMenuBar *menuBar;
253 QPEMenuBar *current; 254 QPEMenuBar *current;
254 255
255 256
256 QPopupMenu *fileMenuFile; 257 QPopupMenu *fileMenuFile;
257 QPopupMenu *viewMenuFile; 258 QPopupMenu *viewMenuFile;
258 QPopupMenu *optionsMenuFile; 259 QPopupMenu *optionsMenuFile;
259 QPopupMenu *fileMenuView; 260 QPopupMenu *fileMenuView;
260 QPopupMenu *viewMenuView; 261 QPopupMenu *viewMenuView;
261 262
262 QAction *sss; // scale to screen size 263 QAction *sss; // scale to screen size
263 264
264 QLabel *lab; 265 QLabel *lab;
265 ImagePane *imagePanel; 266 ImagePane *imagePanel;
266 QWidgetStack *stack; 267 QWidgetStack *stack;
267 //FileSelector *fileSelector; 268 //FileSelector *fileSelector;
268 ImageFileSelector *fileSelector; 269 ImageFileSelector *fileSelector;
269 bool isFullScreen; 270 bool isFullScreen;
270 bool isSized; // true if image is to be resized to fit the window size 271 bool isSized; // true if image is to be resized to fit the window size
271 bool bFromDocView; // a flag to indicate whether or not we were 272 bool bFromDocView; // a flag to indicate whether or not we were
272 // launched from the document view... 273 // launched from the document view...
273 274
274 int slideDelay; 275 int slideDelay;
275 bool slideRepeat; 276 bool slideRepeat;
276 bool slideReverse; // show slideshow in reverse order 277 bool slideReverse; // show slideshow in reverse order
277 bool rotateOnLoad; // rotate by 90 degrees on loading 278 bool rotateOnLoad; // rotate by 90 degrees on loading
278 bool fastLoad; 279 bool fastLoad;
279 QTimer *slideTimer; 280 QTimer *slideTimer;
280 QValueList<DocLnk> imageList; 281 QValueList<DocLnk> imageList;
281 QAction *slideAction; 282 QAction *slideAction;
282 283
283 284
284 QString imageInfo[LAST]; 285 QString imageInfo[LAST];
285}; 286};
286 287
287 288
288#endif // SHOWIMG_H 289#endif // SHOWIMG_H
diff --git a/noncore/multimedia/showimg/showimg.pro b/noncore/multimedia/showimg/showimg.pro
index d369e62..e8d753b 100644
--- a/noncore/multimedia/showimg/showimg.pro
+++ b/noncore/multimedia/showimg/showimg.pro
@@ -1,31 +1,29 @@
1TEMPLATE = app 1CONFIG += qt warn_on release quick-app
2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h 2HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h
5SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp 3SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp
6TARGET = showimg 4TARGET = showimg
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopie 7LIBS += -lqpe -lopie
10 8
11TRANSLATIONS = ../../../i18n/de/showimg.ts \ 9TRANSLATIONS = ../../../i18n/de/showimg.ts \
12 ../../../i18n/nl/showimg.ts \ 10 ../../../i18n/nl/showimg.ts \
13 ../../../i18n/xx/showimg.ts \ 11 ../../../i18n/xx/showimg.ts \
14 ../../../i18n/en/showimg.ts \ 12 ../../../i18n/en/showimg.ts \
15 ../../../i18n/es/showimg.ts \ 13 ../../../i18n/es/showimg.ts \
16 ../../../i18n/fr/showimg.ts \ 14 ../../../i18n/fr/showimg.ts \
17 ../../../i18n/hu/showimg.ts \ 15 ../../../i18n/hu/showimg.ts \
18 ../../../i18n/ja/showimg.ts \ 16 ../../../i18n/ja/showimg.ts \
19 ../../../i18n/ko/showimg.ts \ 17 ../../../i18n/ko/showimg.ts \
20 ../../../i18n/no/showimg.ts \ 18 ../../../i18n/no/showimg.ts \
21 ../../../i18n/pl/showimg.ts \ 19 ../../../i18n/pl/showimg.ts \
22 ../../../i18n/pt/showimg.ts \ 20 ../../../i18n/pt/showimg.ts \
23 ../../../i18n/pt_BR/showimg.ts \ 21 ../../../i18n/pt_BR/showimg.ts \
24 ../../../i18n/sl/showimg.ts \ 22 ../../../i18n/sl/showimg.ts \
25 ../../../i18n/zh_CN/showimg.ts \ 23 ../../../i18n/zh_CN/showimg.ts \
26 ../../../i18n/zh_TW/showimg.ts \ 24 ../../../i18n/zh_TW/showimg.ts \
27 ../../../i18n/da/showimg.ts 25 ../../../i18n/da/showimg.ts
28 26
29 27
30 28
31include ( $(OPIEDIR)/include.pro ) 29include ( $(OPIEDIR)/include.pro )