summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-16 00:54:42 (UTC)
committer alwin <alwin>2004-04-16 00:54:42 (UTC)
commit7c29eeaecc8301fb500851382b3d94092ae72719 (patch) (unidiff)
treeaa93d419a5b5752f080a6dc66afd5d8a3ec4ace0
parentde3d551d3b07617653c01e540ee3c6262a2cd595 (diff)
downloadopie-7c29eeaecc8301fb500851382b3d94092ae72719.zip
opie-7c29eeaecc8301fb500851382b3d94092ae72719.tar.gz
opie-7c29eeaecc8301fb500851382b3d94092ae72719.tar.bz2
not all buttons will showed in every view, small beauties
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp11
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp2
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp43
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h4
4 files changed, 45 insertions, 15 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index f6e1816..7231bfb 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -218,143 +218,141 @@ void PIconView::slotDirUp() {
218 slotChangeDir( dir.absPath() ); 218 slotChangeDir( dir.absPath() );
219} 219}
220 220
221/* 221/*
222 * change the dir 222 * change the dir
223 */ 223 */
224void PIconView::slotChangeDir(const QString& path) { 224void PIconView::slotChangeDir(const QString& path) {
225 if ( !currentView() ) 225 if ( !currentView() )
226 return; 226 return;
227 227
228 PDirLister *lister = currentView()->dirLister(); 228 PDirLister *lister = currentView()->dirLister();
229 if (!lister ) 229 if (!lister )
230 return; 230 return;
231 231
232 /* 232 /*
233 * Say what we want and take what we get 233 * Say what we want and take what we get
234 */ 234 */
235 lister->setStartPath( path ); 235 lister->setStartPath( path );
236 m_path = lister->currentPath(); 236 m_path = lister->currentPath();
237 237
238 m_view->viewport()->setUpdatesEnabled( false ); 238 m_view->viewport()->setUpdatesEnabled( false );
239 m_view->clear(); 239 m_view->clear();
240 240
241 /* 241 /*
242 * add files and folders 242 * add files and folders
243 */ 243 */
244 addFolders( lister->folders() ); 244 addFolders( lister->folders() );
245 addFiles( lister->files() ); 245 addFiles( lister->files() );
246 m_view->viewport()->setUpdatesEnabled( true ); 246 m_view->viewport()->setUpdatesEnabled( true );
247 247
248 // Also invalidate the cache. We can't cancel the operations anyway 248 // Also invalidate the cache. We can't cancel the operations anyway
249 g_stringPix.clear(); 249 g_stringPix.clear();
250 g_stringInf.clear(); 250 g_stringInf.clear();
251 251
252 // looks ugly 252 // looks ugly
253 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 253 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
254} 254}
255 255
256/** 256/**
257 * get the current file name 257 * get the current file name
258 * @param isDir see if this is a dir or real file 258 * @param isDir see if this is a dir or real file
259 */ 259 */
260QString PIconView::currentFileName(bool &isDir)const { 260QString PIconView::currentFileName(bool &isDir)const {
261 isDir = false; 261 isDir = false;
262 QIconViewItem* _it = m_view->currentItem(); 262 QIconViewItem* _it = m_view->currentItem();
263 if ( !_it ) 263 if ( !_it )
264 return QString::null; 264 return QString::null;
265 265
266 IconViewItem* it = static_cast<IconViewItem*>( _it ); 266 IconViewItem* it = static_cast<IconViewItem*>( _it );
267 isDir = it->isDir(); 267 isDir = it->isDir();
268 return it->path(); 268 return it->path();
269} 269}
270 270
271QString PIconView::nextFileName(bool &isDir)const 271QString PIconView::nextFileName(bool &isDir)const
272{ 272{
273 isDir = false; 273 isDir = false;
274 QIconViewItem* _it1 = m_view->currentItem(); 274 QIconViewItem* _it1 = m_view->currentItem();
275 if ( !_it1 ) 275 if ( !_it1 )
276 return QString::null; 276 return QString::null;
277 QIconViewItem* _it = _it1->nextItem(); 277 QIconViewItem* _it = _it1->nextItem();
278 if ( !_it ) 278 if ( !_it )
279 return QString::null; 279 return QString::null;
280 IconViewItem* it = static_cast<IconViewItem*>( _it ); 280 IconViewItem* it = static_cast<IconViewItem*>( _it );
281 isDir = it->isDir(); 281 isDir = it->isDir();
282 m_view->setCurrentItem(_it);
283 return it->path(); 282 return it->path();
284} 283}
285 284
286QString PIconView::prevFileName(bool &isDir)const{ 285QString PIconView::prevFileName(bool &isDir)const{
287 isDir = false; 286 isDir = false;
288 QIconViewItem* _it = m_view->currentItem(); 287 QIconViewItem* _it = m_view->currentItem();
289 if ( !_it ) 288 if ( !_it )
290 return QString::null; 289 return QString::null;
291 _it = _it->prevItem(); 290 _it = _it->prevItem();
292 if ( !_it ) 291 if ( !_it )
293 return QString::null; 292 return QString::null;
294 IconViewItem* it = static_cast<IconViewItem*>( _it ); 293 IconViewItem* it = static_cast<IconViewItem*>( _it );
295 isDir = it->isDir(); 294 isDir = it->isDir();
296 m_view->setCurrentItem(_it);
297 return it->path(); 295 return it->path();
298} 296}
299 297
300void PIconView::slotTrash() { 298void PIconView::slotTrash() {
301 bool isDir; 299 bool isDir;
302 QString pa = currentFileName( isDir ); 300 QString pa = currentFileName( isDir );
303 if ( isDir && pa.isEmpty() ) 301 if ( isDir && pa.isEmpty() )
304 return; 302 return;
305 303
306 if (!QPEMessageBox::confirmDelete( this, 304 if (!QPEMessageBox::confirmDelete( this,
307 tr("Delete Image" ), 305 tr("Delete Image" ),
308 tr("the Image %1" ).arg(pa))) 306 tr("the Image %1" ).arg(pa)))
309 return 307 return
310 308
311 309
312 currentView()->dirLister()->deleteImage( pa ); 310 currentView()->dirLister()->deleteImage( pa );
313 delete m_view->currentItem(); 311 delete m_view->currentItem();
314} 312}
315 313
316/* 314/*
317 * see what views are available 315 * see what views are available
318 */ 316 */
319void PIconView::loadViews() { 317void PIconView::loadViews() {
320 ViewMap::Iterator it; 318 ViewMap::Iterator it;
321 ViewMap* map = viewMap(); 319 ViewMap* map = viewMap();
322 for ( it = map->begin(); it != map->end(); ++it ) 320 for ( it = map->begin(); it != map->end(); ++it )
323 m_views->insertItem( QObject::tr(it.key() ) ); 321 m_views->insertItem( QObject::tr(it.key() ) );
324} 322}
325 323
326void PIconView::resetView() { 324void PIconView::resetView() {
327 slotViewChanged(m_views->currentItem()); 325 slotViewChanged(m_views->currentItem());
328} 326}
329 327
330/* 328/*
331 *swicth view reloadDir and connect signals 329 *swicth view reloadDir and connect signals
332 */ 330 */
333void PIconView::slotViewChanged( int i) { 331void PIconView::slotViewChanged( int i) {
334 if (!m_views->count() ) { 332 if (!m_views->count() ) {
335 setCurrentView( 0l); 333 setCurrentView( 0l);
336 return; 334 return;
337 } 335 }
338 336
339 PDirView* cur = currentView(); 337 PDirView* cur = currentView();
340 delete cur; 338 delete cur;
341 QString str = m_views->text(i); 339 QString str = m_views->text(i);
342 cur = (*(*viewMap())[str])(*m_cfg); 340 cur = (*(*viewMap())[str])(*m_cfg);
343 setCurrentView( cur ); 341 setCurrentView( cur );
344 342
345 /* connect to the signals of the lister */ 343 /* connect to the signals of the lister */
346 PDirLister* lis = cur->dirLister(); 344 PDirLister* lis = cur->dirLister();
347 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 345 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
348 this, SLOT( slotThumbInfo(const QString&, const QString&))); 346 this, SLOT( slotThumbInfo(const QString&, const QString&)));
349 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 347 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
350 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 348 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
351 connect(lis, SIGNAL(sig_start()), 349 connect(lis, SIGNAL(sig_start()),
352 this, SLOT(slotStart())); 350 this, SLOT(slotStart()));
353 connect(lis, SIGNAL(sig_end()) , 351 connect(lis, SIGNAL(sig_end()) ,
354 this, SLOT(slotEnd()) ); 352 this, SLOT(slotEnd()) );
355 353
356 354
357 /* reload now */ 355 /* reload now */
358 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 356 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
359} 357}
360 358
@@ -418,134 +416,137 @@ void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
418 * got thumbnail and see if it is visible so we need to update later 416 * got thumbnail and see if it is visible so we need to update later
419 */ 417 */
420void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 418void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
421 IconViewItem* item = g_stringPix[_path]; 419 IconViewItem* item = g_stringPix[_path];
422 if (!item ) 420 if (!item )
423 return; 421 return;
424 422
425 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 423 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
426 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 424 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
427 m_updatet = true; 425 m_updatet = true;
428 426
429 if (pix.width()>0) 427 if (pix.width()>0)
430 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 428 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
431 429
432 430
433 g_stringPix.remove( _path ); 431 g_stringPix.remove( _path );
434} 432}
435 433
436 434
437/* 435/*
438 * FIXME rename 436 * FIXME rename
439 */ 437 */
440void PIconView::slotRename() { 438void PIconView::slotRename() {
441 439
442} 440}
443 441
444 442
445/* 443/*
446 * BEAM the current file 444 * BEAM the current file
447 */ 445 */
448void PIconView::slotBeam() { 446void PIconView::slotBeam() {
449 bool isDir; 447 bool isDir;
450 QString pa = currentFileName( isDir ); 448 QString pa = currentFileName( isDir );
451 if ( isDir && pa.isEmpty() ) 449 if ( isDir && pa.isEmpty() )
452 return; 450 return;
453 451
454 Ir* ir = new Ir( this ); 452 Ir* ir = new Ir( this );
455 connect( ir, SIGNAL(done(Ir*)), 453 connect( ir, SIGNAL(done(Ir*)),
456 this, SLOT(slotBeamDone(Ir*))); 454 this, SLOT(slotBeamDone(Ir*)));
457 ir->send(pa, tr( "Image" ) ); 455 ir->send(pa, tr( "Image" ) );
458} 456}
459 457
460/* 458/*
461 * BEAM done clean up 459 * BEAM done clean up
462 */ 460 */
463void PIconView::slotBeamDone( Ir* ir) { 461void PIconView::slotBeamDone( Ir* ir) {
464 delete ir; 462 delete ir;
465} 463}
466 464
467void PIconView::slotStart() { 465void PIconView::slotStart() {
468 m_view->viewport()->setUpdatesEnabled( false ); 466 m_view->viewport()->setUpdatesEnabled( false );
469} 467}
470 468
471void PIconView::slotEnd() { 469void PIconView::slotEnd() {
472 if ( m_updatet ) 470 if ( m_updatet )
473 m_view->arrangeItemsInGrid( ); 471 m_view->arrangeItemsInGrid( );
474 m_view->viewport()->setUpdatesEnabled( true ); 472 m_view->viewport()->setUpdatesEnabled( true );
475 m_updatet = false; 473 m_updatet = false;
476} 474}
477 475
478void PIconView::slotShowNext() 476void PIconView::slotShowNext()
479{ 477{
480 bool isDir = false; 478 bool isDir = false;
481 QString name = nextFileName(isDir); 479 QString name = nextFileName(isDir);
482 if (isDir) return;
483 if (name.isEmpty()) return; 480 if (name.isEmpty()) return;
484 odebug << "Show next: " << name << oendl; 481 if (isDir) return;
482 /* if we got a name we have a next item */
483 m_view->setCurrentItem(m_view->currentItem()->nextItem());
485 slotShowImage(name); 484 slotShowImage(name);
486} 485}
487 486
488void PIconView::slotShowPrev() 487void PIconView::slotShowPrev()
489{ 488{
490 bool isDir = false; 489 bool isDir = false;
491 QString name = prevFileName(isDir); 490 QString name = prevFileName(isDir);
492 if (isDir) return;
493 if (name.isEmpty()) return; 491 if (name.isEmpty()) return;
492 if (isDir) return;
493 /* if we got a name we have a prev item */
494 m_view->setCurrentItem(m_view->currentItem()->prevItem());
494 slotShowImage(name); 495 slotShowImage(name);
495} 496}
496 497
497void PIconView::slotShowImage() 498void PIconView::slotShowImage()
498{ 499{
499 bool isDir = false; 500 bool isDir = false;
500 QString name = currentFileName(isDir); 501 QString name = currentFileName(isDir);
501 if (isDir) return; 502 if (isDir) return;
502 503
503 slotShowImage( name ); 504 slotShowImage( name );
504} 505}
505void PIconView::slotShowImage( const QString& name) { 506void PIconView::slotShowImage( const QString& name) {
506 emit sig_display( name ); 507 emit sig_display( name );
507} 508}
508void PIconView::slotImageInfo() { 509void PIconView::slotImageInfo() {
509 bool isDir = false; 510 bool isDir = false;
510 QString name = currentFileName(isDir); 511 QString name = currentFileName(isDir);
511 if (isDir) return; 512 if (isDir) return;
512 513
513 slotImageInfo( name ); 514 slotImageInfo( name );
514} 515}
515 516
516void PIconView::slotImageInfo( const QString& name) { 517void PIconView::slotImageInfo( const QString& name) {
517 emit sig_showInfo( name ); 518 emit sig_showInfo( name );
518} 519}
519 520
520 521
521void PIconView::slotChangeMode( int mode ) { 522void PIconView::slotChangeMode( int mode ) {
522 if ( mode >= 1 && mode <= 3 ) 523 if ( mode >= 1 && mode <= 3 )
523 m_mode = mode; 524 m_mode = mode;
524 525
525 QIconView::ItemTextPos pos; 526 QIconView::ItemTextPos pos;
526 switch( m_mode ) { 527 switch( m_mode ) {
527 case 2: 528 case 2:
528 pos = QIconView::Bottom; 529 pos = QIconView::Bottom;
529 break; 530 break;
530 case 3: 531 case 3:
531 case 1: 532 case 1:
532 default: 533 default:
533 pos = QIconView::Right; 534 pos = QIconView::Right;
534 break; 535 break;
535 } 536 }
536 m_view->setItemTextPos( pos ); 537 m_view->setItemTextPos( pos );
537 538
538 calculateGrid(); 539 calculateGrid();
539 slotReloadDir(); 540 slotReloadDir();
540} 541}
541 542
542 543
543void PIconView::resizeEvent( QResizeEvent* re ) { 544void PIconView::resizeEvent( QResizeEvent* re ) {
544 QVBox::resizeEvent( re ); 545 QVBox::resizeEvent( re );
545 calculateGrid(); 546 calculateGrid();
546} 547}
547 548
548 549
549void PIconView::calculateGrid() { 550void PIconView::calculateGrid() {
550 551
551} 552}
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index aa2b9bc..fbc4494 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,85 +1,87 @@
1#include "imageview.h" 1#include "imageview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4#include <opie2/oconfig.h> 4#include <opie2/oconfig.h>
5#include <opie2/okeyconfigwidget.h> 5#include <opie2/okeyconfigwidget.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8 8
9using namespace Opie::Core; 9using namespace Opie::Core;
10 10
11ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) 11ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
12 : Opie::MM::OImageScrollView(parent,name,fl) 12 : Opie::MM::OImageScrollView(parent,name,fl)
13{ 13{
14 m_viewManager = 0; 14 m_viewManager = 0;
15 m_cfg = cfg; 15 m_cfg = cfg;
16 initKeys(); 16 initKeys();
17} 17}
18 18
19ImageView::~ImageView() 19ImageView::~ImageView()
20{ 20{
21 if (m_viewManager) { 21 if (m_viewManager) {
22 delete m_viewManager; 22 delete m_viewManager;
23 } 23 }
24} 24}
25 25
26Opie::Core::OKeyConfigManager* ImageView::manager() 26Opie::Core::OKeyConfigManager* ImageView::manager()
27{ 27{
28 if (!m_viewManager) { 28 if (!m_viewManager) {
29 initKeys(); 29 initKeys();
30 } 30 }
31 return m_viewManager; 31 return m_viewManager;
32} 32}
33 33
34void ImageView::initKeys() 34void ImageView::initKeys()
35{ 35{
36 odebug << "init imageview keys" << oendl; 36 odebug << "init imageview keys" << oendl;
37 if (!m_cfg) { 37 if (!m_cfg) {
38 m_cfg = new Opie::Core::OConfig("phunkview"); 38 m_cfg = new Opie::Core::OConfig("phunkview");
39 m_cfg->setGroup("image_view_keys" ); 39 m_cfg->setGroup("image_view_keys" );
40 } 40 }
41 Opie::Core::OKeyPair::List lst; 41 Opie::Core::OKeyPair::List lst;
42 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 42 lst.append( Opie::Core::OKeyPair::upArrowKey() );
43 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 43 lst.append( Opie::Core::OKeyPair::downArrowKey() );
44 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 44 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
45 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 45 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
46 lst.append( Opie::Core::OKeyPair(Qt::Key_N,0));
47 lst.append( Opie::Core::OKeyPair(Qt::Key_P,0));
46 48
47 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 49 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
48 lst, false,this, "image_view_keys" ); 50 lst, false,this, "image_view_keys" );
49 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 51 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
50 Resource::loadPixmap("1to1"), ViewInfo, 52 Resource::loadPixmap("1to1"), ViewInfo,
51 Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton), 53 Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton),
52 this, SLOT(slotShowImageInfo()))); 54 this, SLOT(slotShowImageInfo())));
53#if 0 55#if 0
54 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage", 56 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage",
55 Resource::loadPixmap("next"), ViewInfo, 57 Resource::loadPixmap("next"), ViewInfo,
56 Opie::Core::OKeyPair(Qt::Key_N,0), 58 Opie::Core::OKeyPair(Qt::Key_N,0),
57 this, SLOT(slotDispNext()))); 59 this, SLOT(slotDispNext())));
58#endif 60#endif
59 m_viewManager->handleWidget( this ); 61 m_viewManager->handleWidget( this );
60 m_viewManager->load(); 62 m_viewManager->load();
61} 63}
62 64
63void ImageView::keyReleaseEvent(QKeyEvent * e) 65void ImageView::keyReleaseEvent(QKeyEvent * e)
64{ 66{
65 if (!e || e->state()!=0) { 67 if (!e || e->state()!=0) {
66 return; 68 return;
67 } 69 }
68 if (e->key()==Qt::Key_N) slotDispNext(); 70 if (e->key()==Qt::Key_N) slotDispNext();
69 if (e->key()==Qt::Key_P) slotDispPrev(); 71 if (e->key()==Qt::Key_P) slotDispPrev();
70} 72}
71 73
72void ImageView::slotDispNext() 74void ImageView::slotDispNext()
73{ 75{
74 emit dispNext(); 76 emit dispNext();
75} 77}
76 78
77void ImageView::slotDispPrev() 79void ImageView::slotDispPrev()
78{ 80{
79 emit dispPrev(); 81 emit dispPrev();
80} 82}
81 83
82void ImageView::slotShowImageInfo() 84void ImageView::slotShowImageInfo()
83{ 85{
84 emit dispImageInfo(m_lastName); 86 emit dispImageInfo(m_lastName);
85} 87}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 57be247..6f3f255 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -3,164 +3,176 @@
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include "imageview.h" 6#include "imageview.h"
7 7
8#include "iconview.h" 8#include "iconview.h"
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12 12
13#include <iface/ifaceinfo.h> 13#include <iface/ifaceinfo.h>
14#include <iface/dirview.h> 14#include <iface/dirview.h>
15 15
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/owidgetstack.h> 17#include <opie2/owidgetstack.h>
18#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
19#include <opie2/otabwidget.h> 19#include <opie2/otabwidget.h>
20#include <opie2/okeyconfigwidget.h> 20#include <opie2/okeyconfigwidget.h>
21 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qmap.h> 31#include <qmap.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34 34
35 35
36 36
37OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 37OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
38 38
39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
40 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 40 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
41{ 41{
42 setCaption( QObject::tr("Opie Eye Caramba" ) ); 42 setCaption( QObject::tr("Opie Eye Caramba" ) );
43 m_cfg = new Opie::Core::OConfig("phunkview"); 43 m_cfg = new Opie::Core::OConfig("phunkview");
44 m_cfg->setGroup("Zecke_view" ); 44 m_cfg->setGroup("Zecke_view" );
45// qDebug( "Process-wide OApplication object @ %0x", oApp ); 45// qDebug( "Process-wide OApplication object @ %0x", oApp );
46 /* 46 /*
47 * Initialize ToolBar and IconView 47 * Initialize ToolBar and IconView
48 * And Connect Them 48 * And Connect Them
49 */ 49 */
50 QToolBar *bar = new QToolBar( this ); 50 QToolBar *bar = new QToolBar( this );
51 bar->setHorizontalStretchable( true ); 51 bar->setHorizontalStretchable( true );
52 setToolBarsMovable( false ); 52 setToolBarsMovable( false );
53 53
54 m_stack = new Opie::Ui::OWidgetStack( this ); 54 m_stack = new Opie::Ui::OWidgetStack( this );
55 setCentralWidget( m_stack ); 55 setCentralWidget( m_stack );
56 56
57 m_view = new PIconView( m_stack, m_cfg ); 57 m_view = new PIconView( m_stack, m_cfg );
58 m_stack->addWidget( m_view, IconView ); 58 m_stack->addWidget( m_view, IconView );
59 m_stack->raiseWidget( IconView ); 59 m_stack->raiseWidget( IconView );
60 connect(m_view, SIGNAL(sig_display(const QString&)), 60 connect(m_view, SIGNAL(sig_display(const QString&)),
61 this, SLOT(slotDisplay(const QString&))); 61 this, SLOT(slotDisplay(const QString&)));
62 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 62 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
63 this, SLOT(slotShowInfo(const QString&)) ); 63 this, SLOT(slotShowInfo(const QString&)) );
64 64
65 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 65 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
66 66
67 QToolButton *btn = new QToolButton( bar ); 67 upButton = new QToolButton( bar );
68 btn->setIconSet( Resource::loadIconSet( "up" ) ); 68 upButton->setIconSet( Resource::loadIconSet( "up" ) );
69 connect( btn, SIGNAL(clicked()), 69 connect( upButton, SIGNAL(clicked()),
70 m_view, SLOT(slotDirUp()) ); 70 m_view, SLOT(slotDirUp()) );
71 71
72 btn = new PFileSystem( bar ); 72 fsButton = new PFileSystem( bar );
73 connect( btn, SIGNAL( changeDir( const QString& ) ), 73 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
74 m_view, SLOT(slotChangeDir( const QString& ) ) ); 74 m_view, SLOT(slotChangeDir( const QString& ) ) );
75 75
76 btn = new QToolButton( bar ); 76 QToolButton*btn = new QToolButton( bar );
77 btn->setIconSet( Resource::loadIconSet( "edit" ) ); 77 btn->setIconSet( Resource::loadIconSet( "edit" ) );
78 connect( btn, SIGNAL(clicked()), 78 connect( btn, SIGNAL(clicked()),
79 m_view, SLOT(slotRename()) ); 79 m_view, SLOT(slotRename()) );
80 80
81 if ( Ir::supported() ) { 81 if ( Ir::supported() ) {
82 btn = new QToolButton( bar ); 82 btn = new QToolButton( bar );
83 btn->setIconSet( Resource::loadIconSet( "beam" ) ); 83 btn->setIconSet( Resource::loadIconSet( "beam" ) );
84 connect( btn, SIGNAL(clicked()), 84 connect( btn, SIGNAL(clicked()),
85 m_view, SLOT(slotBeam()) ); 85 m_view, SLOT(slotBeam()) );
86 } 86 }
87 87
88 btn = new QToolButton( bar ); 88 btn = new QToolButton( bar );
89 btn->setIconSet( Resource::loadIconSet( "trash" ) ); 89 btn->setIconSet( Resource::loadIconSet( "trash" ) );
90 connect( btn, SIGNAL(clicked() ), 90 connect( btn, SIGNAL(clicked() ),
91 m_view, SLOT(slotTrash() ) ); 91 m_view, SLOT(slotTrash() ) );
92 92
93 93
94 btn = new ViewModeButton( bar ); 94 viewModeButton = new ViewModeButton( bar );
95 connect( btn, SIGNAL(changeMode(int)), 95 connect( viewModeButton, SIGNAL(changeMode(int)),
96 m_view, SLOT(slotChangeMode(int))); 96 m_view, SLOT(slotChangeMode(int)));
97 97
98 btn = new QToolButton( bar ); 98 btn = new QToolButton( bar );
99 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); 99 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
100 connect( btn, SIGNAL(clicked() ), 100 connect( btn, SIGNAL(clicked() ),
101 this, SLOT(slotConfig() ) ); 101 this, SLOT(slotConfig() ) );
102 102
103
104
105 prevButton = new QToolButton(bar);
106 prevButton->setIconSet( Resource::loadIconSet( "back" ) );
107 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev()));
108 prevButton->hide();
109
110 nextButton = new QToolButton(bar);
111 nextButton->setIconSet( Resource::loadIconSet( "forward" ) );
112 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext()));
113 nextButton->hide();
114
103 rotateButton = new QToolButton(bar); 115 rotateButton = new QToolButton(bar);
104 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); 116 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
105 rotateButton->setToggleButton(true); 117 rotateButton->setToggleButton(true);
106 118
107 odebug << "Mode = " << m_stack->mode() << oendl; 119 odebug << "Mode = " << m_stack->mode() << oendl;
108 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 120 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
109 rotateButton->setOn(true); 121 rotateButton->setOn(true);
110 autoRotate = true; 122 autoRotate = true;
111 } else { 123 } else {
112 rotateButton->setOn(false); 124 rotateButton->setOn(false);
113 autoRotate = false; 125 autoRotate = false;
114 } 126 }
115 127
116 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 128 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
117 129
118 btn = new QToolButton(bar); 130 btn = new QToolButton(bar);
119 btn->setIconSet( Resource::loadIconSet( "1to1" ) ); 131 btn->setIconSet( Resource::loadIconSet( "1to1" ) );
120 btn->setToggleButton(true); 132 btn->setToggleButton(true);
121 btn->setOn(false); 133 btn->setOn(false);
122 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 134 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
123 autoScale = true; 135 autoScale = true;
124 136
125 btn = new QToolButton(bar); 137 btn = new QToolButton(bar);
126 btn->setIconSet( Resource::loadIconSet( "mag" ) ); 138 btn->setIconSet( Resource::loadIconSet( "mag" ) );
127 btn->setToggleButton(true); 139 btn->setToggleButton(true);
128 btn->setOn(true); 140 btn->setOn(true);
129 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 141 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
130 zoomerOn = true; 142 zoomerOn = true;
131} 143}
132 144
133PMainWindow::~PMainWindow() { 145PMainWindow::~PMainWindow() {
134 odebug << "Shutting down" << oendl; 146 odebug << "Shutting down" << oendl;
135} 147}
136 148
137void PMainWindow::slotZoomerToggled(bool how) 149void PMainWindow::slotZoomerToggled(bool how)
138{ 150{
139 zoomerOn = how; 151 zoomerOn = how;
140 if (m_disp) { 152 if (m_disp) {
141 m_disp->setShowZoomer(zoomerOn); 153 m_disp->setShowZoomer(zoomerOn);
142 } 154 }
143} 155}
144 156
145void PMainWindow::slotRotateToggled(bool how) 157void PMainWindow::slotRotateToggled(bool how)
146{ 158{
147 autoRotate = how; 159 autoRotate = how;
148 if (m_disp) { 160 if (m_disp) {
149 m_disp->setAutoRotate(how); 161 m_disp->setAutoRotate(how);
150 } 162 }
151} 163}
152 164
153void PMainWindow::slotScaleToggled(bool how) 165void PMainWindow::slotScaleToggled(bool how)
154{ 166{
155 autoScale = !how; 167 autoScale = !how;
156 if (m_disp) { 168 if (m_disp) {
157 m_disp->setAutoScale(autoScale); 169 m_disp->setAutoScale(autoScale);
158 } 170 }
159 if (!autoScale && autoRotate) { 171 if (!autoScale && autoRotate) {
160 rotateButton->setOn(false); 172 rotateButton->setOn(false);
161 } 173 }
162 rotateButton->setEnabled(!how); 174 rotateButton->setEnabled(!how);
163} 175}
164 176
165void PMainWindow::slotConfig() { 177void PMainWindow::slotConfig() {
166 /* 178 /*
@@ -223,107 +235,122 @@ void PMainWindow::slotConfig() {
223 } 235 }
224 236
225 237
226 if ( act ) { 238 if ( act ) {
227 m_view->resetView(); 239 m_view->resetView();
228 keyWid->save(); 240 keyWid->save();
229 m_disp->manager()->save(); 241 m_disp->manager()->save();
230 m_info->manager()->save(); 242 m_info->manager()->save();
231 m_view->manager()->save(); 243 m_view->manager()->save();
232 } 244 }
233 delete keyWid; 245 delete keyWid;
234} 246}
235 247
236/* 248/*
237 * create a new image info component 249 * create a new image info component
238 * and detach the current one 250 * and detach the current one
239 * we will make the other delete on exit 251 * we will make the other delete on exit
240 */ 252 */
241template<class T> 253template<class T>
242void PMainWindow::initT( const char* name, T** ptr, int id) { 254void PMainWindow::initT( const char* name, T** ptr, int id) {
243 if ( *ptr ) { 255 if ( *ptr ) {
244 (*ptr)->disconnect(this, SLOT(slotReturn())); 256 (*ptr)->disconnect(this, SLOT(slotReturn()));
245 (*ptr)->setDestructiveClose(); 257 (*ptr)->setDestructiveClose();
246 m_stack->removeWidget( *ptr ); 258 m_stack->removeWidget( *ptr );
247 } 259 }
248 *ptr = new T(m_cfg, m_stack, name ); 260 *ptr = new T(m_cfg, m_stack, name );
249 m_stack->addWidget( *ptr, id ); 261 m_stack->addWidget( *ptr, id );
250 262
251 connect(*ptr, SIGNAL(sig_return()), 263 connect(*ptr, SIGNAL(sig_return()),
252 this,SLOT(slotReturn())); 264 this,SLOT(slotReturn()));
253 265
254} 266}
255void PMainWindow::initInfo() { 267void PMainWindow::initInfo() {
256 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 268 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
257 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 269 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
258} 270}
259void PMainWindow::initDisp() { 271void PMainWindow::initDisp() {
260 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 272 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
261 if (m_disp) { 273 if (m_disp) {
262 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 274 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
263 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 275 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
264 } 276 }
265 m_disp->setAutoScale(autoScale); 277 m_disp->setAutoScale(autoScale);
266 m_disp->setAutoRotate(autoRotate); 278 m_disp->setAutoRotate(autoRotate);
267 m_disp->setShowZoomer(zoomerOn); 279 m_disp->setShowZoomer(zoomerOn);
268 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 280 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
269 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 281 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
270 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 282 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
271 } 283 }
272} 284}
273 285
274/** 286/**
275 * With big Screen the plan could be to 'detach' the image 287 * With big Screen the plan could be to 'detach' the image
276 * window if visible and to create a ne wone 288 * window if visible and to create a ne wone
277 * init* already supports it but I make no use of it for 289 * init* already supports it but I make no use of it for
278 * now. We set filename and raise 290 * now. We set filename and raise
279 * 291 *
280 * ### FIXME and talk to alwin 292 * ### FIXME and talk to alwin
281 */ 293 */
282void PMainWindow::slotShowInfo( const QString& inf ) { 294void PMainWindow::slotShowInfo( const QString& inf ) {
283 if ( !m_info ) { 295 if ( !m_info ) {
284 initInfo(); 296 initInfo();
285 } 297 }
286 m_info->setPath( inf ); 298 m_info->setPath( inf );
299 prevButton->hide();
300 nextButton->hide();
301 upButton->hide();
302 fsButton->hide();
303 viewModeButton->hide();
287 m_stack->raiseWidget( ImageInfo ); 304 m_stack->raiseWidget( ImageInfo );
288} 305}
289 306
290void PMainWindow::slotDisplay( const QString& inf ) { 307void PMainWindow::slotDisplay( const QString& inf ) {
291 if ( !m_disp ) { 308 if ( !m_disp ) {
292 initDisp(); 309 initDisp();
293 } 310 }
294 m_disp->setImage( inf ); 311 m_disp->setImage( inf );
312 prevButton->show();
313 nextButton->show();
314 upButton->hide();
315 fsButton->hide();
316 viewModeButton->hide();
295 m_stack->raiseWidget( ImageDisplay ); 317 m_stack->raiseWidget( ImageDisplay );
296} 318}
297 319
298void PMainWindow::slotReturn() { 320void PMainWindow::slotReturn() {
299 raiseIconView(); 321 raiseIconView();
300} 322}
301 323
302 324
303void PMainWindow::closeEvent( QCloseEvent* ev ) { 325void PMainWindow::closeEvent( QCloseEvent* ev ) {
304 /* 326 /*
305 * return from view 327 * return from view
306 * or properly quit 328 * or properly quit
307 */ 329 */
308 if ( m_stack->visibleWidget() == m_info || 330 if ( m_stack->visibleWidget() == m_info ||
309 m_stack->visibleWidget() == m_disp ) { 331 m_stack->visibleWidget() == m_disp ) {
310 raiseIconView(); 332 raiseIconView();
311 ev->ignore(); 333 ev->ignore();
312 return; 334 return;
313 } 335 }
314 ev->accept(); 336 ev->accept();
315 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 337 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
316} 338}
317 339
318void PMainWindow::raiseIconView() { 340void PMainWindow::raiseIconView() {
341 prevButton->hide();
342 nextButton->hide();
343 upButton->show();
344 fsButton->show();
345 viewModeButton->show();
319 m_stack->raiseWidget( IconView ); 346 m_stack->raiseWidget( IconView );
320} 347}
321 348
322void PMainWindow::setDocument( const QString& showImg ) { 349void PMainWindow::setDocument( const QString& showImg ) {
323 QString file = showImg; 350 QString file = showImg;
324 DocLnk lnk(showImg); 351 DocLnk lnk(showImg);
325 if (lnk.isValid() ) 352 if (lnk.isValid() )
326 file = lnk.file(); 353 file = lnk.file();
327 354
328 slotDisplay( file ); 355 slotDisplay( file );
329} 356}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index adb5dc2..1967ef7 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -2,72 +2,72 @@
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#ifndef PHUNK_MAIN_WINDOW_H 6#ifndef PHUNK_MAIN_WINDOW_H
7#define PHUNK_MAIN_WINDOW_H 7#define PHUNK_MAIN_WINDOW_H
8 8
9#include <opie2/oconfig.h> 9#include <opie2/oconfig.h>
10 10
11#include <qmainwindow.h> 11#include <qmainwindow.h>
12 12
13 13
14 14
15namespace Opie { 15namespace Opie {
16namespace Ui{ 16namespace Ui{
17 class OWidgetStack; 17 class OWidgetStack;
18} 18}
19namespace Core{ 19namespace Core{
20 class OKeyConfigManager; 20 class OKeyConfigManager;
21} 21}
22} 22}
23 23
24class ImageView; 24class ImageView;
25class PIconView; 25class PIconView;
26class imageinfo; 26class imageinfo;
27 27
28class PMainWindow : public QMainWindow { 28class PMainWindow : public QMainWindow {
29 Q_OBJECT 29 Q_OBJECT
30 enum Views { IconView, ImageInfo, ImageDisplay }; 30 enum Views { IconView, ImageInfo, ImageDisplay };
31public: 31public:
32 static QString appName() { return QString::fromLatin1("opie-eye" ); } 32 static QString appName() { return QString::fromLatin1("opie-eye" ); }
33 PMainWindow(QWidget*, const char*, WFlags ); 33 PMainWindow(QWidget*, const char*, WFlags );
34 ~PMainWindow(); 34 ~PMainWindow();
35 35
36signals: 36signals:
37 void configChanged(); 37 void configChanged();
38 38
39public slots: 39public slots:
40 void slotShowInfo( const QString& inf ); 40 void slotShowInfo( const QString& inf );
41 void slotDisplay( const QString& inf ); 41 void slotDisplay( const QString& inf );
42 void slotReturn(); 42 void slotReturn();
43 void slotRotateToggled(bool); 43 void slotRotateToggled(bool);
44 void slotScaleToggled(bool); 44 void slotScaleToggled(bool);
45 void slotZoomerToggled(bool); 45 void slotZoomerToggled(bool);
46 void setDocument( const QString& ); 46 void setDocument( const QString& );
47 47
48protected: 48protected:
49 void raiseIconView(); 49 void raiseIconView();
50 void closeEvent( QCloseEvent* ); 50 void closeEvent( QCloseEvent* );
51 51
52private: 52private:
53 template<class T> void initT( const char* name, T**, int ); 53 template<class T> void initT( const char* name, T**, int );
54 void initInfo(); 54 void initInfo();
55 void initDisp(); 55 void initDisp();
56 56
57private: 57private:
58 Opie::Core::OConfig *m_cfg; 58 Opie::Core::OConfig *m_cfg;
59 Opie::Ui::OWidgetStack *m_stack; 59 Opie::Ui::OWidgetStack *m_stack;
60 PIconView* m_view; 60 PIconView* m_view;
61 imageinfo *m_info; 61 imageinfo *m_info;
62 ImageView *m_disp; 62 ImageView *m_disp;
63 bool autoRotate; 63 bool autoRotate;
64 bool autoScale; 64 bool autoScale;
65 bool zoomerOn; 65 bool zoomerOn;
66 QToolButton*rotateButton; 66 QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton;
67 67 QToolButton*nextButton,*prevButton;
68 68
69private slots: 69private slots:
70 void slotConfig(); 70 void slotConfig();
71}; 71};
72 72
73#endif 73#endif