summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/showimg/showimg.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp
index 0fbffe7..d6f0733 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -154,769 +154,769 @@ void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWi
154 dlg->exec(); 154 dlg->exec();
155 delete dlg; 155 delete dlg;
156} 156}
157 157
158//=========================================================================== 158//===========================================================================
159 159
160 160
161ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) 161ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
162{ 162{
163 vb = new QVBoxLayout( this ); 163 vb = new QVBoxLayout( this );
164 164
165 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); 165 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity);
166 pic=new ImageWidget(image); 166 pic=new ImageWidget(image);
167 image->addChild(pic); 167 image->addChild(pic);
168 168
169 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); 169 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() ));
170 170
171 vb->addWidget( image ); 171 vb->addWidget( image );
172 172
173} 173}
174 174
175void ImagePane::setPixmap( const QPixmap &pm ) 175void ImagePane::setPixmap( const QPixmap &pm )
176{ 176{
177 pic->setPixmap( pm ); 177 pic->setPixmap( pm );
178 pic->resize(pm.width(),pm.height()); 178 pic->resize(pm.width(),pm.height());
179 image->updateScrollBars (); 179 image->updateScrollBars ();
180 pic->repaint(false); 180 pic->repaint(false);
181} 181}
182 182
183void ImagePane::imageClicked() 183void ImagePane::imageClicked()
184{ 184{
185 emit clicked(); 185 emit clicked();
186} 186}
187//=========================================================================== 187//===========================================================================
188/* 188/*
189 Draws the portion of the scaled pixmap that needs to be updated 189 Draws the portion of the scaled pixmap that needs to be updated
190*/ 190*/
191 191
192void ImageWidget::paintEvent( QPaintEvent *e ) 192void ImageWidget::paintEvent( QPaintEvent *e )
193{ 193{
194 QPainter painter(this); 194 QPainter painter(this);
195 195
196 painter.setClipRect(e->rect()); 196 painter.setClipRect(e->rect());
197 painter.fillRect(0,0,width(),height(),QColor(0,0,0)); 197 painter.fillRect(0,0,width(),height(),QColor(0,0,0));
198 198
199 if ( pixmap.size() != QSize( 0, 0 ) ) 199 if ( pixmap.size() != QSize( 0, 0 ) )
200 { // is an image loaded? 200 { // is an image loaded?
201 painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); 201 painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap);
202 } 202 }
203} 203}
204 204
205void ImageWidget::mouseReleaseEvent(QMouseEvent *) 205void ImageWidget::mouseReleaseEvent(QMouseEvent *)
206{ 206{
207 emit clicked(); 207 emit clicked();
208} 208}
209 209
210//=========================================================================== 210//===========================================================================
211 211
212ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) 212ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
213: QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE ) 213: QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE )
214{ 214{
215 setCaption( tr("Image Viewer") ); 215 setCaption( tr("Image Viewer") );
216 setIcon( Resource::loadPixmap( "ImageViewer" ) ); 216 setIcon( Resource::loadPixmap( "ImageViewer" ) );
217 217
218 218
219 Config cfg("Image Viewer"); 219 Config cfg("Image Viewer");
220 cfg.setGroup("Image Viewer"); 220 cfg.setGroup("Image Viewer");
221 221
222 showThumbView=cfg.readBoolEntry("ShowThumbnails",false); 222 showThumbView=cfg.readBoolEntry("ShowThumbnails",false);
223 isSized=cfg.readBoolEntry("SizeToScreen",true); 223 isSized=cfg.readBoolEntry("SizeToScreen",true);
224 224
225 isFullScreen = FALSE; 225 isFullScreen = FALSE;
226 226
227 setToolBarsMovable( FALSE ); 227 setToolBarsMovable( FALSE );
228 228
229 toolBar = new QPEToolBar( this ); 229 toolBar = new QPEToolBar( this );
230 toolBar->setHorizontalStretchable( TRUE ); 230 toolBar->setHorizontalStretchable( TRUE );
231 231
232 menuBar = new QPEMenuBar( toolBar ); 232 menuBar = new QPEMenuBar( toolBar );
233 233
234 current=menuBar; 234 current=menuBar;
235 235
236 236
237 237
238 fileMenuFile = new QPopupMenu(this); 238 fileMenuFile = new QPopupMenu(this);
239 //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); 239 //menuBarmenubarFile->insertItem( tr("File"), fileMenu );
240 fileMenuFile->insertItem(tr("Open"), 240 fileMenuFile->insertItem(tr("Open"),
241 this, SLOT(openFile()), 0); 241 this, SLOT(openFile()), 0);
242 242
243 viewMenuFile = new QPopupMenu( this ); 243 viewMenuFile = new QPopupMenu( this );
244 //menubarFile->insertItem( tr("View"), viewMenu ); 244 //menubarFile->insertItem( tr("View"), viewMenu );
245 viewMenuFile->insertItem( tr("Thumbnail View"), 245 viewMenuFile->insertItem( tr("Thumbnail View"),
246 this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); 246 this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS );
247 247
248 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 248 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
249 249
250 250
251 251
252 252
253 optionsMenuFile = new QPopupMenu( this); 253 optionsMenuFile = new QPopupMenu( this);
254 //menubarFile->insertItem( tr("Options"),optionsMenu ); 254 //menubarFile->insertItem( tr("Options"),optionsMenu );
255 slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), 255 slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ),
256 QString::null, 0, this, 0 ); 256 QString::null, 0, this, 0 );
257 slideAction->setToggleAction( TRUE ); 257 slideAction->setToggleAction( TRUE );
258 connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); 258 connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) );
259 slideAction->addTo( optionsMenuFile); 259 slideAction->addTo( optionsMenuFile);
260// slideAction->addTo( toolBar ); 260// slideAction->addTo( toolBar );
261 261
262 262
263// optionsMenuFile->insertItem( tr("Slideshow") ); 263// optionsMenuFile->insertItem( tr("Slideshow") );
264 optionsMenuFile->insertSeparator(); 264 optionsMenuFile->insertSeparator();
265 optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); 265 optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0);
266// optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); 266// optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0);
267 267
268 QStrList fmt = QImage::outputFormats(); 268 QStrList fmt = QImage::outputFormats();
269 269
270 270
271 fileMenuView = new QPopupMenu( this ); 271 fileMenuView = new QPopupMenu( this );
272 //menubarView->insertItem( tr("File"),fileMenu ); 272 //menubarView->insertItem( tr("File"),fileMenu );
273 fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); 273 fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 );
274 fileMenuView->insertSeparator(); 274 fileMenuView->insertSeparator();
275 275
276 viewMenuView = new QPopupMenu(this ); 276 viewMenuView = new QPopupMenu(this );
277 viewMenuView->setCheckable ( true ); 277 viewMenuView->setCheckable ( true );
278 278
279 //menubarView->insertItem( tr("View"),viewMenu ); 279 //menubarView->insertItem( tr("View"),viewMenu );
280 viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); 280 viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0);
281 viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); 281 viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0);
282 282
283 stack = new QWidgetStack( this ); 283 stack = new QWidgetStack( this );
284 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 284 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
285 setCentralWidget( stack ); 285 setCentralWidget( stack );
286 286
287 287
288 imagePanel = new ImagePane( stack ); 288 imagePanel = new ImagePane( stack );
289 connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); 289 connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView()));
290 290
291 291
292 ImageFileSelector::CURRENT_VIEW cv; 292 ImageFileSelector::CURRENT_VIEW cv;
293 if(showThumbView) 293 if(showThumbView)
294 cv=ImageFileSelector::THUMBNAIL; 294 cv=ImageFileSelector::THUMBNAIL;
295 else 295 else
296 cv=ImageFileSelector::DETAILED; 296 cv=ImageFileSelector::DETAILED;
297 297
298 qDebug("cv = %d",cv); 298 qDebug("cv = %d",cv);
299 299
300 fileSelector = new ImageFileSelector( cv,stack, "fs"); 300 fileSelector = new ImageFileSelector( cv,stack, "fs");
301 301
302 //switchThumbView(); 302 //switchThumbView();
303 303
304 304
305 //fileSelector = new ImageFileSelector("image/*", stack, "fs"); 305 //fileSelector = new ImageFileSelector("image/*", stack, "fs");
306 //fileSelector->setNewVisible(FALSE); 306 //fileSelector->setNewVisible(FALSE);
307 //fileSelector->setCloseVisible(FALSE); 307 //fileSelector->setCloseVisible(FALSE);
308 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); 308 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) );
309 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), 309 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
310 this, SLOT( openFile( const DocLnk & ) ) ); 310 this, SLOT( openFile( const DocLnk & ) ) );
311 311
312 imageList = fileSelector->fileList(); 312 imageList = fileSelector->fileList();
313 slideAction->setEnabled( imageList.count() != 0); 313 slideAction->setEnabled( imageList.count() != 0);
314 314
315 iconToolBar = new QPEToolBar(this); 315 iconToolBar = new QPEToolBar(this);
316 316
317 QAction *a; 317 QAction *a;
318 318
319 a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 319 a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
320 connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); 320 connect( a, SIGNAL( activated() ), this, SLOT( open() ) );
321 a->addTo( fileMenuView); 321 a->addTo( fileMenuView);
322 a->addTo( iconToolBar ); 322 a->addTo( iconToolBar );
323 323
324 324
325 a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); 325 a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0);
326 connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); 326 connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) );
327 a->addTo( iconToolBar ); 327 a->addTo( iconToolBar );
328 a->addTo( viewMenuView ); 328 a->addTo( viewMenuView );
329 329
330 a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); 330 a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 );
331 connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); 331 connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) );
332 a->addTo( iconToolBar ); 332 a->addTo( iconToolBar );
333 a->addTo( viewMenuView ); 333 a->addTo( viewMenuView );
334 334
335 335
336 a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); 336 a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0);
337 connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); 337 connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) );
338 //a->addTo( iconToolBar ); 338 //a->addTo( iconToolBar );
339 a->addTo( viewMenuView ); 339 a->addTo( viewMenuView );
340 340
341 341
342 342
343 viewMenuView->insertSeparator(); 343 viewMenuView->insertSeparator();
344 viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); 344 viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0);
345 viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); 345 viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE);
346 viewMenuView->insertSeparator(); 346 viewMenuView->insertSeparator();
347 347
348 348
349 sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); 349 sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true);
350 connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); 350 connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) );
351 sss->addTo( iconToolBar ); 351 sss->addTo( iconToolBar );
352 sss->addTo( viewMenuView ); 352 sss->addTo( viewMenuView );
353 353
354 sss->setOn(isSized); 354 sss->setOn(isSized);
355 viewMenuView->insertSeparator(); 355 viewMenuView->insertSeparator();
356 356
357 357
358 a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), 358 a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ),
359 QString::null, 0, this, 0 ); 359 QString::null, 0, this, 0 );
360 connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); 360 connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) );
361 a->addTo( iconToolBar ); 361 a->addTo( iconToolBar );
362 a->addTo( viewMenuView); 362 a->addTo( viewMenuView);
363 363
364 a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), 364 a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ),
365 QString::null, 0, this, 0 ); 365 QString::null, 0, this, 0 );
366 connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); 366 connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) );
367 a->addTo( iconToolBar ); 367 a->addTo( iconToolBar );
368 a->addTo( viewMenuView); 368 a->addTo( viewMenuView);
369 369
370 370
371 Config config( "ImageViewer" ); 371 Config config( "ImageViewer" );
372 config.setGroup( "SlideShow" ); 372 config.setGroup( "SlideShow" );
373 slideDelay = config.readNumEntry( "Delay", 2); 373 slideDelay = config.readNumEntry( "Delay", 2);
374 slideRepeat = config.readBoolEntry( "Repeat", FALSE ); 374 slideRepeat = config.readBoolEntry( "Repeat", FALSE );
375 slideReverse = config.readBoolEntry("Reverse", FALSE); 375 slideReverse = config.readBoolEntry("Reverse", FALSE);
376 376
377 config.setGroup("Default"); 377 config.setGroup("Default");
378 rotateOnLoad = config.readBoolEntry("Rotate", FALSE); 378 rotateOnLoad = config.readBoolEntry("Rotate", FALSE);
379 fastLoad = config.readBoolEntry("FastLoad", TRUE); 379 fastLoad = config.readBoolEntry("FastLoad", TRUE);
380 slideTimer = new QTimer( this ); 380 slideTimer = new QTimer( this );
381 connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); 381 connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) );
382 382
383 switchToFileSelector(); 383 switchToFileSelector();
384 384
385 setMouseTracking( TRUE ); 385 setMouseTracking( TRUE );
386 386
387 387
388} 388}
389 389
390ImageViewer::~ImageViewer() 390ImageViewer::~ImageViewer()
391{ 391{
392 Config cfg("Image Viewer"); 392 Config cfg("Image Viewer");
393 cfg.setGroup("Image Viewer"); 393 cfg.setGroup("Image Viewer");
394 394
395 cfg.writeEntry("ShowThumbnails",(int)showThumbView); 395 cfg.writeEntry("ShowThumbnails",(int)showThumbView);
396 cfg.writeEntry("SizeToScreen",(int)isSized); 396 cfg.writeEntry("SizeToScreen",(int)isSized);
397 397
398 cfg.setGroup( "SlideShow" ); 398 cfg.setGroup( "SlideShow" );
399 cfg.writeEntry( "Delay", slideDelay); 399 cfg.writeEntry( "Delay", slideDelay);
400 cfg.writeEntry( "Repeat", slideRepeat ); 400 cfg.writeEntry( "Repeat", slideRepeat );
401 cfg.writeEntry("Reverse", slideReverse); 401 cfg.writeEntry("Reverse", slideReverse);
402 402
403 cfg.setGroup("Default"); 403 cfg.setGroup("Default");
404 cfg.writeEntry("Rotate", rotateOnLoad); 404 cfg.writeEntry("Rotate", rotateOnLoad);
405 cfg.writeEntry("FastLoad", fastLoad); 405 cfg.writeEntry("FastLoad", fastLoad);
406 406
407 delete imagePanel; // in case it is fullscreen 407 delete imagePanel; // in case it is fullscreen
408} 408}
409 409
410void ImageViewer::help() { 410void ImageViewer::help() {
411 411
412} 412}
413 413
414 414
415void ImageViewer::settings() 415void ImageViewer::settings()
416{ 416{
417 SettingsDialog dlg( this, 0, TRUE ); 417 SettingsDialog dlg( this, 0, TRUE );
418 dlg.setDelay( slideDelay ); 418 dlg.setDelay( slideDelay );
419 dlg.setRepeat( slideRepeat ); 419 dlg.setRepeat( slideRepeat );
420 dlg.setReverse( slideReverse ); 420 dlg.setReverse( slideReverse );
421 dlg.setRotate(rotateOnLoad); 421 dlg.setRotate(rotateOnLoad);
422 dlg.setFastLoad(fastLoad); 422 dlg.setFastLoad(fastLoad);
423 423
424 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { 424 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) {
425 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); 425 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>");
426 slideDelay = dlg.delay(); 426 slideDelay = dlg.delay();
427 slideRepeat = dlg.repeat(); 427 slideRepeat = dlg.repeat();
428 slideReverse = dlg.reverse(); 428 slideReverse = dlg.reverse();
429 rotateOnLoad = dlg.rotate(); 429 rotateOnLoad = dlg.rotate();
430 fastLoad = dlg.fastLoad(); 430 fastLoad = dlg.fastLoad();
431 431
432 Config config( "ImageViewer" ); 432 Config config( "ImageViewer" );
433 config.setGroup( "SlideShow" ); 433 config.setGroup( "SlideShow" );
434 config.writeEntry( "Delay", slideDelay ); 434 config.writeEntry( "Delay", slideDelay );
435 config.writeEntry( "Repeat", slideRepeat ); 435 config.writeEntry( "Repeat", slideRepeat );
436 config.writeEntry("Reverse", slideReverse); 436 config.writeEntry("Reverse", slideReverse);
437 437
438 config.setGroup("Default"); 438 config.setGroup("Default");
439 config.writeEntry("Rotate", rotateOnLoad); 439 config.writeEntry("Rotate", rotateOnLoad);
440 config.writeEntry("FastLoad", fastLoad); 440 config.writeEntry("FastLoad", fastLoad);
441 } 441 }
442} 442}
443 443
444void ImageViewer::switchSizeToScreen() 444void ImageViewer::switchSizeToScreen()
445{ 445{
446 isSized=!isSized; 446 isSized=!isSized;
447 sss->setOn(isSized); 447 sss->setOn(isSized);
448 updateImage(); 448 updateImage();
449} 449}
450 450
451void ImageViewer::updateImage() 451void ImageViewer::updateImage()
452{ 452{
453 if ( isSized ) { 453 if ( isSized ) {
454 imagePanel->setPixmap(pmScaled); 454 imagePanel->setPixmap(pmScaled);
455 } else { 455 } else {
456 imagePanel->setPixmap(pm); 456 imagePanel->setPixmap(pm);
457 } 457 }
458} 458}
459 459
460void ImageViewer::switchThumbView() 460void ImageViewer::switchThumbView()
461{ 461{
462 462
463 showThumbView=!showThumbView; 463 showThumbView=!showThumbView;
464 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 464 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
465 fileSelector->switchView(); 465 fileSelector->switchView();
466 466
467} 467}
468 468
469void ImageViewer::switchToFileSelector() 469void ImageViewer::switchToFileSelector()
470{ 470{
471 stack->raiseWidget(fileSelector); 471 stack->raiseWidget(fileSelector);
472 menuBar->clear(); 472 menuBar->clear();
473 menuBar->insertItem( tr("File"), fileMenuFile ); 473 menuBar->insertItem( tr("File"), fileMenuFile );
474 menuBar->insertItem( tr("View"), viewMenuFile ); 474 menuBar->insertItem( tr("View"), viewMenuFile );
475 menuBar->insertItem( tr("Options"), optionsMenuFile ); 475 menuBar->insertItem( tr("Options"), optionsMenuFile );
476 iconToolBar->hide(); 476 iconToolBar->hide();
477 imagePanel->disable(); 477 imagePanel->disable();
478 slideShow(false); 478 slideShow(false);
479 479
480} 480}
481 481
482void ImageViewer::switchToImageView() 482void ImageViewer::switchToImageView()
483{ 483{
484 stack->raiseWidget(imagePanel); 484 stack->raiseWidget(imagePanel);
485 485
486 menuBar->clear(); 486 menuBar->clear();
487 menuBar->insertItem( tr("File"), fileMenuView ); 487 menuBar->insertItem( tr("File"), fileMenuView );
488 menuBar->insertItem( tr("View"), viewMenuView ); 488 menuBar->insertItem( tr("View"), viewMenuView );
489 viewMenuView->setItemEnabled(BLACKANDWHITE,true); 489 viewMenuView->setItemEnabled(BLACKANDWHITE,true);
490 iconToolBar->show(); 490 iconToolBar->show();
491 491
492 imagePanel->setPosition(0,0); 492 imagePanel->setPosition(0,0);
493 493
494} 494}
495 495
496 496
497void ImageViewer::setDocument(const QString& fileref) 497void ImageViewer::setDocument(const QString& fileref)
498{ 498{
499 delayLoad = fileref; 499 delayLoad = fileref;
500 switchToImageView(); 500 switchToImageView();
501 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); 501 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) );
502} 502}
503 503
504void ImageViewer::doDelayedLoad() 504void ImageViewer::doDelayedLoad()
505{ 505{
506 show(delayLoad); 506 show(delayLoad);
507} 507}
508 508
509void ImageViewer::show() 509void ImageViewer::show()
510{ 510{
511 normalView(); 511 normalView();
512 QMainWindow::show(); 512 QMainWindow::show();
513} 513}
514 514
515void ImageViewer::show(const QString& fileref) 515void ImageViewer::show(const QString& fileref)
516{ 516{
517// qDebug("Show "+fileref); 517// qDebug("Show "+fileref);
518 bFromDocView = TRUE; 518 bFromDocView = TRUE;
519 closeFileSelector(); 519 closeFileSelector();
520 DocLnk link(fileref); 520 DocLnk link(fileref);
521 if ( link.isValid() ) { 521 if ( link.isValid() ) {
522 openFile(link); 522 openFile(link);
523 } else { 523 } else {
524 filename = fileref; 524 filename = fileref;
525 updateCaption( fileref ); 525 updateCaption( fileref );
526 loadImage( fileref ); 526 loadImage( fileref );
527 } 527 }
528} 528}
529 529
530void ImageViewer::openFile() { 530void ImageViewer::openFile() {
531 MimeTypes types; 531 MimeTypes types;
532 QStringList image; 532 QStringList image;
533 image << "image/*"; 533 image << "image/*";
534 types.insert("Images", image); 534 types.insert("Images", image);
535 535
536 QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); 536 QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 );
537 DocLnk link(str); 537 DocLnk link(str);
538 if ( link.isValid() ) 538// if ( link.isValid() )
539 openFile(link); 539 openFile(link);
540 540
541} 541}
542 542
543void ImageViewer::openFile( const DocLnk &link ) 543void ImageViewer::openFile( const DocLnk &link )
544{ 544{
545 closeFileSelector(); 545 closeFileSelector();
546// DocLnk link(file); 546// DocLnk link(file);
547 qDebug("open "+link.name()); 547 qDebug("open "+link.name());
548 updateCaption( link.name() ); 548 updateCaption( link.name() );
549 loadImage( link.file() ); 549 loadImage( link.file() );
550 if (slideTimer->isActive()) { 550 if (slideTimer->isActive()) {
551 slideTimer->start(slideDelay * 1000, FALSE); 551 slideTimer->start(slideDelay * 1000, FALSE);
552 } 552 }
553 553
554} 554}
555 555
556void ImageViewer::open() 556void ImageViewer::open()
557{ 557{
558 switchToFileSelector(); 558 switchToFileSelector();
559} 559}
560 560
561void ImageViewer::closeFileSelector() 561void ImageViewer::closeFileSelector()
562{ 562{
563 switchToImageView(); 563 switchToImageView();
564} 564}
565 565
566void ImageViewer::updateCaption( QString name ) 566void ImageViewer::updateCaption( QString name )
567{ 567{
568 int sep = name.findRev( '/' ); 568 int sep = name.findRev( '/' );
569 if ( sep >= 0 ) 569 if ( sep >= 0 )
570 name = name.mid( sep+1 ); 570 name = name.mid( sep+1 );
571 setCaption( name + tr(" - Image Viewer") ); 571 setCaption( name + tr(" - Image Viewer") );
572} 572}
573 573
574/* 574/*
575 This function loads an image from a file. 575 This function loads an image from a file.
576*/ 576*/
577 577
578void ImageViewer::loadImage( const char *fileName ) 578void ImageViewer::loadImage( const char *fileName )
579{ 579{
580 filename = fileName; 580 filename = fileName;
581 if ( filename ) { 581 if ( filename ) {
582 QApplication::setOverrideCursor( waitCursor ); // this might take time 582 QApplication::setOverrideCursor( waitCursor ); // this might take time
583 //imagePanel->statusLabel()->setText( tr("Loading image...") ); 583 //imagePanel->statusLabel()->setText( tr("Loading image...") );
584 qApp->processEvents(); 584 qApp->processEvents();
585 bool ok = image.load(filename, 0); 585 bool ok = image.load(filename, 0);
586 if ( ok ) { 586 if ( ok ) {
587 ok = reconvertImage(); 587 ok = reconvertImage();
588 updateImageInfo(filename); 588 updateImageInfo(filename);
589 } 589 }
590 if ( !ok ) { 590 if ( !ok ) {
591 pm.resize(0,0); // couldn't load image 591 pm.resize(0,0); // couldn't load image
592 update(); 592 update();
593 } 593 }
594 QApplication::restoreOverrideCursor(); // restore original cursor 594 QApplication::restoreOverrideCursor(); // restore original cursor
595 } 595 }
596 596
597// fastLoad ? ", Fast" : "", 597// fastLoad ? ", Fast" : "",
598// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); 598// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1);
599 599
600 600
601// matrix.reset(); 601// matrix.reset();
602 rotated90 = FALSE; 602 rotated90 = FALSE;
603 603
604 if (rotateOnLoad) { 604 if (rotateOnLoad) {
605 rotated90 = TRUE; 605 rotated90 = TRUE;
606 rot90(); 606 rot90();
607// matrix.rotate( -90.0 ); 607// matrix.rotate( -90.0 );
608 } 608 }
609 609
610 switchToImageView(); 610 switchToImageView();
611 updateImage(); 611 updateImage();
612 612
613} 613}
614 614
615bool ImageViewer::loadSelected() 615bool ImageViewer::loadSelected()
616{ 616{
617 bool ok = false; 617 bool ok = false;
618 if ( stack->visibleWidget() == fileSelector ) 618 if ( stack->visibleWidget() == fileSelector )
619 { 619 {
620 const DocLnk *link = fileSelector->selected(); 620 const DocLnk *link = fileSelector->selected();
621 if ( link ) 621 if ( link )
622 { 622 {
623 if ( link->file() != filename ) 623 if ( link->file() != filename )
624 { 624 {
625 updateCaption( link->name() ); 625 updateCaption( link->name() );
626 filename = link->file(); 626 filename = link->file();
627 qApp->processEvents(); 627 qApp->processEvents();
628 ok = image.load(filename, 0); 628 ok = image.load(filename, 0);
629 if ( ok ) 629 if ( ok )
630 { 630 {
631 updateImageInfo(filename); 631 updateImageInfo(filename);
632 ok = reconvertImage(); 632 ok = reconvertImage();
633 } 633 }
634 if ( !ok ) 634 if ( !ok )
635 pm.resize(0,0); 635 pm.resize(0,0);
636 } 636 }
637 } 637 }
638 } 638 }
639 if ( !image.isNull() ) 639 if ( !image.isNull() )
640 { 640 {
641 ok = true; 641 ok = true;
642 closeFileSelector(); 642 closeFileSelector();
643 } 643 }
644 644
645 return ok; 645 return ok;
646} 646}
647 647
648bool ImageViewer::reconvertImage() 648bool ImageViewer::reconvertImage()
649{ 649{
650 bool success = FALSE; 650 bool success = FALSE;
651 651
652 if ( image.isNull() ) return FALSE; 652 if ( image.isNull() ) return FALSE;
653 653
654 QApplication::setOverrideCursor( waitCursor ); // this might take time 654 QApplication::setOverrideCursor( waitCursor ); // this might take time
655 if ( pm.convertFromImage(image /*, conversion_flags */ ) ) 655 if ( pm.convertFromImage(image /*, conversion_flags */ ) )
656 { 656 {
657 pmScaled = QPixmap(); 657 pmScaled = QPixmap();
658 scale(); 658 scale();
659 success = TRUE; // load successful 659 success = TRUE; // load successful
660 } 660 }
661 else 661 else
662 { 662 {
663 pm.resize(0,0); // couldn't load image 663 pm.resize(0,0); // couldn't load image
664 } 664 }
665 QApplication::restoreOverrideCursor(); // restore original cursor 665 QApplication::restoreOverrideCursor(); // restore original cursor
666 666
667 return success; // TRUE if loaded OK 667 return success; // TRUE if loaded OK
668} 668}
669 669
670 670
671int ImageViewer::calcHeight() 671int ImageViewer::calcHeight()
672{ 672{
673 if ( !isFullScreen ) 673 if ( !isFullScreen )
674 return imagePanel->paneHeight(); 674 return imagePanel->paneHeight();
675 else 675 else
676 return qApp->desktop()->height(); 676 return qApp->desktop()->height();
677} 677}
678/* 678/*
679 This functions scales the pixmap in the member variable "pm" to fit the 679 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". 680 widget size and puts the resulting pixmap in the member variable "pmScaled".
681*/ 681*/
682void ImageViewer::scale() 682void ImageViewer::scale()
683{ 683{
684 int h = calcHeight(); 684 int h = calcHeight();
685 if ( image.isNull() ) return; 685 if ( image.isNull() ) return;
686 686
687 QApplication::setOverrideCursor( waitCursor ); // this might take time 687 QApplication::setOverrideCursor( waitCursor ); // this might take time
688 if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) 688 if ( imagePanel->paneWidth() == pm.width() && h == pm.height() )
689 { // no need to scale if widget 689 { // no need to scale if widget
690 pmScaled = pm; // size equals pixmap size 690 pmScaled = pm; // size equals pixmap size
691 } 691 }
692 else 692 else
693 { 693 {
694 double hs = (double)h / (double)image.height(); 694 double hs = (double)h / (double)image.height();
695 double ws = (double)imagePanel->paneWidth() / (double)image.width(); 695 double ws = (double)imagePanel->paneWidth() / (double)image.width();
696 double scaleFactor = (hs > ws) ? ws : hs; 696 double scaleFactor = (hs > ws) ? ws : hs;
697 int smoothW = (int)(scaleFactor * image.width()); 697 int smoothW = (int)(scaleFactor * image.width());
698 int smoothH = (int)(scaleFactor * image.height()); 698 int smoothH = (int)(scaleFactor * image.height());
699 699
700 pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); 700 pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ );
701 } 701 }
702 QApplication::restoreOverrideCursor(); // restore original cursor 702 QApplication::restoreOverrideCursor(); // restore original cursor
703} 703}
704 704
705/* 705/*
706 The resize event handler, if a valid pixmap was loaded it will call 706 The resize event handler, if a valid pixmap was loaded it will call
707 scale() to fit the pixmap to the new widget size. 707 scale() to fit the pixmap to the new widget size.
708*/ 708*/
709 709
710void ImageViewer::resizeEvent( QResizeEvent * ) 710void ImageViewer::resizeEvent( QResizeEvent * )
711{ 711{
712 712
713 if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image 713 if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image
714 return; 714 return;
715 715
716 int h = calcHeight(); 716 int h = calcHeight();
717 717
718 if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) 718 if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() )
719 { // if new size, 719 { // if new size,
720 scale(); // scale pmScaled to window 720 scale(); // scale pmScaled to window
721 } 721 }
722 if ( image.hasAlphaBuffer() ) 722 if ( image.hasAlphaBuffer() )
723 erase(); 723 erase();
724} 724}
725 725
726 726
727void ImageViewer::hFlip() 727void ImageViewer::hFlip()
728{ 728{
729// matrix.scale( -1.0, 1.0 ); 729// matrix.scale( -1.0, 1.0 );
730 730
731 setImage(image.mirror(TRUE,FALSE)); 731 setImage(image.mirror(TRUE,FALSE));
732} 732}
733 733
734void ImageViewer::vFlip() 734void ImageViewer::vFlip()
735{ 735{
736// matrix.scale( 1.0, -1.0 ); 736// matrix.scale( 1.0, -1.0 );
737 setImage(image.mirror(FALSE,TRUE)); 737 setImage(image.mirror(FALSE,TRUE));
738} 738}
739 739
740void ImageViewer::rot180() 740void ImageViewer::rot180()
741{ 741{
742// matrix.rotate( 180.0 ); 742// matrix.rotate( 180.0 );
743 setImage(image.mirror(TRUE,TRUE)); 743 setImage(image.mirror(TRUE,TRUE));
744} 744}
745 745
746void ImageViewer::rot90() 746void ImageViewer::rot90()
747{ 747{
748 QImage oldimage; 748 QImage oldimage;
749 oldimage = image.convertDepth(32); 749 oldimage = image.convertDepth(32);
750// matrix.rotate( -90.0 ); 750// matrix.rotate( -90.0 );
751 setImage(rotate(oldimage,Rotate90)); 751 setImage(rotate(oldimage,Rotate90));
752 752
753} 753}
754void ImageViewer::rot270() 754void ImageViewer::rot270()
755{ 755{
756 756
757 QImage oldimage; 757 QImage oldimage;
758 oldimage = image.convertDepth(32); 758 oldimage = image.convertDepth(32);
759// matrix.rotate(90.0); 759// matrix.rotate(90.0);
760 setImage(rotate(oldimage,Rotate270)); 760 setImage(rotate(oldimage,Rotate270));
761 761
762} 762}
763 763
764void ImageViewer::blackAndWhite() 764void ImageViewer::blackAndWhite()
765{ 765{
766 766
767 viewMenuView->setItemEnabled(BLACKANDWHITE,false); 767 viewMenuView->setItemEnabled(BLACKANDWHITE,false);
768 setImage(toGray(image,false)); 768 setImage(toGray(image,false));
769} 769}
770 770
771void ImageViewer::displayControlsDialog() 771void ImageViewer::displayControlsDialog()
772{ 772{
773 int w=80; 773 int w=80;
774 int h=w; 774 int h=w;
775 QImage small; 775 QImage small;
776 776
777 if ( image.width()<w ||image.height()<h ) 777 if ( image.width()<w ||image.height()<h )
778 small=image.smoothScale(w,h); 778 small=image.smoothScale(w,h);
779 else 779 else
780 small=image.copy(0,0,w,h); 780 small=image.copy(0,0,w,h);
781 781
782 int newB=0; 782 int newB=0;
783 ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); 783 ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this);
784 dlg->exec(); 784 dlg->exec();
785 if ( newB ) { 785 if ( newB ) {
786 intensity(image,(float)newB/100); 786 intensity(image,(float)newB/100);
787 setImage(image); 787 setImage(image);
788 } 788 }
789 789
790} 790}
791 791
792 792
793void ImageViewer::displayInfoDialog() 793void ImageViewer::displayInfoDialog()
794{ 794{
795 795
796 QStringList ls; 796 QStringList ls;
797 797
798 for ( int i=0;i<LAST;i++ ) 798 for ( int i=0;i<LAST;i++ )
799 ls.append(imageInfo[i]); 799 ls.append(imageInfo[i]);
800 800
801 InfoDialog::displayInfo("Image Viewer",ls,this); 801 InfoDialog::displayInfo("Image Viewer",ls,this);
802} 802}
803void ImageViewer::normalView() 803void ImageViewer::normalView()
804{ 804{
805 if ( !imagePanel->parentWidget() ) 805 if ( !imagePanel->parentWidget() )
806 { 806 {
807 807
808 isFullScreen = FALSE; 808 isFullScreen = FALSE;
809 stack->addWidget( imagePanel, 1 ); 809 stack->addWidget( imagePanel, 1 );
810 switchToImageView(); 810 switchToImageView();
811 if ( isSized ) 811 if ( isSized )
812 scale(); 812 scale();
813 813
814 updateImage(); 814 updateImage();
815 815
816 } 816 }
817} 817}
818 818
819void ImageViewer::stopSlideShow() { 819void ImageViewer::stopSlideShow() {
820 if (slideTimer->isActive()) 820 if (slideTimer->isActive())
821 slideTimer->stop(); 821 slideTimer->stop();
822} 822}
823 823
824void ImageViewer::fullScreen() 824void ImageViewer::fullScreen()
825{ 825{
826 // Full-screen option 826 // Full-screen option
827 // contributed by Robert Wittams <robert@wittams.com> 827 // contributed by Robert Wittams <robert@wittams.com>
828 if ( imagePanel->parentWidget() && loadSelected() ) 828 if ( imagePanel->parentWidget() && loadSelected() )
829 { 829 {
830 isFullScreen = TRUE; 830 isFullScreen = TRUE;
831 imagePanel->reparent(0,QPoint(0,0)); 831 imagePanel->reparent(0,QPoint(0,0));
832 imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); 832 imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height());
833 833
834 if ( isSized ) 834 if ( isSized )
835 scale(); 835 scale();
836 updateImage(); 836 updateImage();
837 imagePanel->showFullScreen(); 837 imagePanel->showFullScreen();
838 } 838 }
839} 839}
840 840
841void ImageViewer::setImage(const QImage& newimage) 841void ImageViewer::setImage(const QImage& newimage)
842{ 842{
843 image = newimage; 843 image = newimage;
844 reconvertImage(); 844 reconvertImage();
845 updateImage(); 845 updateImage();
846} 846}
847 847
848void ImageViewer::updateImageInfo(QString &filePath) 848void ImageViewer::updateImageInfo(QString &filePath)
849{ 849{
850 850
851 for ( int i=0;i<LAST;i++ ) 851 for ( int i=0;i<LAST;i++ )
852 { 852 {
853 imageInfo[i]=""; 853 imageInfo[i]="";
854 } 854 }
855 855
856 imageInfo[FORMAT]=QImage::imageFormat (filePath ); 856 imageInfo[FORMAT]=QImage::imageFormat (filePath );
857 QFileInfo fi(filePath); 857 QFileInfo fi(filePath);
858 imageInfo[PATH]=fi.fileName(); 858 imageInfo[PATH]=fi.fileName();
859 imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; 859 imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)";
860 QString message("%1x%2"); 860 QString message("%1x%2");
861 imageInfo[SIZE]=QString("%1x%2"); 861 imageInfo[SIZE]=QString("%1x%2");
862 imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); 862 imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height());
863 if ( image.numColors() > 0 ) 863 if ( image.numColors() > 0 )
864 { 864 {
865 imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); 865 imageInfo[COLORS]=tr("%1 colors").arg(image.numColors());
866 } 866 }
867 else if ( image.depth() >= 16 ) 867 else if ( image.depth() >= 16 )
868 { 868 {
869 imageInfo[COLORS]=tr(" True color"); 869 imageInfo[COLORS]=tr(" True color");
870 } 870 }
871 if ( image.hasAlphaBuffer() ) 871 if ( image.hasAlphaBuffer() )
872 { 872 {
873 if ( image.depth() == 8 ) 873 if ( image.depth() == 8 )
874 { 874 {
875 int i; 875 int i;
876 bool alpha[256]; 876 bool alpha[256];
877 int nalpha=0; 877 int nalpha=0;
878 878
879 for ( i=0; i<256; i++ ) 879 for ( i=0; i<256; i++ )
880 alpha[i] = FALSE; 880 alpha[i] = FALSE;
881 881
882 for ( i=0; i<image.numColors(); i++ ) 882 for ( i=0; i<image.numColors(); i++ )
883 { 883 {
884 int alevel = image.color(i) >> 24; 884 int alevel = image.color(i) >> 24;
885 if ( !alpha[alevel] ) 885 if ( !alpha[alevel] )
886 { 886 {
887 alpha[alevel] = TRUE; 887 alpha[alevel] = TRUE;
888 nalpha++; 888 nalpha++;
889 } 889 }
890 } 890 }
891 imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); 891 imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha);
892 } 892 }
893 else 893 else
894 { 894 {
895 imageInfo[ALPHA]=tr("8-bit alpha channel"); 895 imageInfo[ALPHA]=tr("8-bit alpha channel");
896 } 896 }
897 } 897 }
898 898
899} 899}
900 900
901void ImageViewer::closeEvent( QCloseEvent *e ) 901void ImageViewer::closeEvent( QCloseEvent *e )
902{ 902{
903 if ( stack->visibleWidget() == imagePanel && !bFromDocView ) 903 if ( stack->visibleWidget() == imagePanel && !bFromDocView )
904 { 904 {
905 e->ignore(); 905 e->ignore();
906 open(); 906 open();
907 } 907 }
908 else 908 else
909 { 909 {
910 bFromDocView = FALSE; 910 bFromDocView = FALSE;
911 e->accept(); 911 e->accept();
912 } 912 }
913} 913}
914 914
915// Intensity,toGray and rotate code courtesy of KDE project. 915// Intensity,toGray and rotate code courtesy of KDE project.
916 916
917 917
918QImage& ImageViewer::intensity(QImage &image, float percent) 918QImage& ImageViewer::intensity(QImage &image, float percent)
919{ 919{
920 920
921 int segColors = image.depth() > 8 ? 256 : image.numColors(); 921 int segColors = image.depth() > 8 ? 256 : image.numColors();
922 unsigned char *segTbl = new unsigned char[segColors]; 922 unsigned char *segTbl = new unsigned char[segColors];