summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-15 16:14:56 (UTC)
committer alwin <alwin>2004-04-15 16:14:56 (UTC)
commita002be54e33d64e69c7edf2960d5e68a9a0609e4 (patch) (unidiff)
treec58f7bce41920a86f077d0c371bcf166a03d6489
parentfd31b11688704c214034a0e28ca7c0a56a6a2988 (diff)
downloadopie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.zip
opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.gz
opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.bz2
previous/next image keys implemented
ToDo: make it via keywidget, this moment the keywidget sends a key twice (on press and on release)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp48
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp25
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.h5
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp2
5 files changed, 86 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 5633312..f6e1816 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -247,48 +247,77 @@ void PIconView::slotChangeDir(const QString& path) {
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
272{
273 isDir = false;
274 QIconViewItem* _it1 = m_view->currentItem();
275 if ( !_it1 )
276 return QString::null;
277 QIconViewItem* _it = _it1->nextItem();
278 if ( !_it )
279 return QString::null;
280 IconViewItem* it = static_cast<IconViewItem*>( _it );
281 isDir = it->isDir();
282 m_view->setCurrentItem(_it);
283 return it->path();
284}
285
286QString PIconView::prevFileName(bool &isDir)const{
287 isDir = false;
288 QIconViewItem* _it = m_view->currentItem();
289 if ( !_it )
290 return QString::null;
291 _it = _it->prevItem();
292 if ( !_it )
293 return QString::null;
294 IconViewItem* it = static_cast<IconViewItem*>( _it );
295 isDir = it->isDir();
296 m_view->setCurrentItem(_it);
297 return it->path();
298}
299
271void PIconView::slotTrash() { 300void PIconView::slotTrash() {
272 bool isDir; 301 bool isDir;
273 QString pa = currentFileName( isDir ); 302 QString pa = currentFileName( isDir );
274 if ( isDir && pa.isEmpty() ) 303 if ( isDir && pa.isEmpty() )
275 return; 304 return;
276 305
277 if (!QPEMessageBox::confirmDelete( this, 306 if (!QPEMessageBox::confirmDelete( this,
278 tr("Delete Image" ), 307 tr("Delete Image" ),
279 tr("the Image %1" ).arg(pa))) 308 tr("the Image %1" ).arg(pa)))
280 return 309 return
281 310
282 311
283 currentView()->dirLister()->deleteImage( pa ); 312 currentView()->dirLister()->deleteImage( pa );
284 delete m_view->currentItem(); 313 delete m_view->currentItem();
285} 314}
286 315
287/* 316/*
288 * see what views are available 317 * see what views are available
289 */ 318 */
290void PIconView::loadViews() { 319void PIconView::loadViews() {
291 ViewMap::Iterator it; 320 ViewMap::Iterator it;
292 ViewMap* map = viewMap(); 321 ViewMap* map = viewMap();
293 for ( it = map->begin(); it != map->end(); ++it ) 322 for ( it = map->begin(); it != map->end(); ++it )
294 m_views->insertItem( QObject::tr(it.key() ) ); 323 m_views->insertItem( QObject::tr(it.key() ) );
@@ -425,48 +454,67 @@ void PIconView::slotBeam() {
425 Ir* ir = new Ir( this ); 454 Ir* ir = new Ir( this );
426 connect( ir, SIGNAL(done(Ir*)), 455 connect( ir, SIGNAL(done(Ir*)),
427 this, SLOT(slotBeamDone(Ir*))); 456 this, SLOT(slotBeamDone(Ir*)));
428 ir->send(pa, tr( "Image" ) ); 457 ir->send(pa, tr( "Image" ) );
429} 458}
430 459
431/* 460/*
432 * BEAM done clean up 461 * BEAM done clean up
433 */ 462 */
434void PIconView::slotBeamDone( Ir* ir) { 463void PIconView::slotBeamDone( Ir* ir) {
435 delete ir; 464 delete ir;
436} 465}
437 466
438void PIconView::slotStart() { 467void PIconView::slotStart() {
439 m_view->viewport()->setUpdatesEnabled( false ); 468 m_view->viewport()->setUpdatesEnabled( false );
440} 469}
441 470
442void PIconView::slotEnd() { 471void PIconView::slotEnd() {
443 if ( m_updatet ) 472 if ( m_updatet )
444 m_view->arrangeItemsInGrid( ); 473 m_view->arrangeItemsInGrid( );
445 m_view->viewport()->setUpdatesEnabled( true ); 474 m_view->viewport()->setUpdatesEnabled( true );
446 m_updatet = false; 475 m_updatet = false;
447} 476}
448 477
478void PIconView::slotShowNext()
479{
480 bool isDir = false;
481 QString name = nextFileName(isDir);
482 if (isDir) return;
483 if (name.isEmpty()) return;
484 odebug << "Show next: " << name << oendl;
485 slotShowImage(name);
486}
487
488void PIconView::slotShowPrev()
489{
490 bool isDir = false;
491 QString name = prevFileName(isDir);
492 if (isDir) return;
493 if (name.isEmpty()) return;
494 slotShowImage(name);
495}
496
449void PIconView::slotShowImage() 497void PIconView::slotShowImage()
450{ 498{
451 bool isDir = false; 499 bool isDir = false;
452 QString name = currentFileName(isDir); 500 QString name = currentFileName(isDir);
453 if (isDir) return; 501 if (isDir) return;
454 502
455 slotShowImage( name ); 503 slotShowImage( name );
456} 504}
457void PIconView::slotShowImage( const QString& name) { 505void PIconView::slotShowImage( const QString& name) {
458 emit sig_display( name ); 506 emit sig_display( name );
459} 507}
460void PIconView::slotImageInfo() { 508void PIconView::slotImageInfo() {
461 bool isDir = false; 509 bool isDir = false;
462 QString name = currentFileName(isDir); 510 QString name = currentFileName(isDir);
463 if (isDir) return; 511 if (isDir) return;
464 512
465 slotImageInfo( name ); 513 slotImageInfo( name );
466} 514}
467 515
468void PIconView::slotImageInfo( const QString& name) { 516void PIconView::slotImageInfo( const QString& name) {
469 emit sig_showInfo( name ); 517 emit sig_showInfo( name );
470} 518}
471 519
472 520
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index 903c4fd..14ad168 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -18,54 +18,60 @@ class Ir;
18 18
19namespace Opie { 19namespace Opie {
20namespace Core{ 20namespace Core{
21 class OConfig; 21 class OConfig;
22 class OKeyConfigManager; 22 class OKeyConfigManager;
23} 23}
24} 24}
25 25
26class PIconView : public QVBox { 26class PIconView : public QVBox {
27 Q_OBJECT 27 Q_OBJECT
28 friend class PIconViewItem; 28 friend class PIconViewItem;
29 enum ActionIds { 29 enum ActionIds {
30 BeamItem, DeleteItem, ViewItem, InfoItem 30 BeamItem, DeleteItem, ViewItem, InfoItem
31 }; 31 };
32public: 32public:
33 PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); 33 PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
34 ~PIconView(); 34 ~PIconView();
35 void resetView(); 35 void resetView();
36 Opie::Core::OKeyConfigManager* manager(); 36 Opie::Core::OKeyConfigManager* manager();
37 37
38signals: 38signals:
39 void sig_showInfo( const QString& ); 39 void sig_showInfo( const QString& );
40 void sig_display( const QString& ); 40 void sig_display( const QString& );
41 41
42public slots:
43 virtual void slotShowNext();
44 virtual void slotShowPrev();
45
42protected: 46protected:
43 void resizeEvent( QResizeEvent* ); 47 void resizeEvent( QResizeEvent* );
44 48
45private: 49private:
46 void initKeys(); 50 void initKeys();
47 QString currentFileName(bool &isDir)const; 51 QString currentFileName(bool &isDir)const;
52 QString nextFileName(bool &isDir)const;
53 QString prevFileName(bool &isDir)const;
48 void loadViews(); 54 void loadViews();
49 void calculateGrid(); 55 void calculateGrid();
50 56
51private slots: 57private slots:
52 void slotDirUp(); 58 void slotDirUp();
53 void slotChangeDir(const QString&); 59 void slotChangeDir(const QString&);
54 void slotTrash(); 60 void slotTrash();
55 void slotViewChanged( int ); 61 void slotViewChanged( int );
56 void slotReloadDir(); 62 void slotReloadDir();
57 void slotRename(); 63 void slotRename();
58 void slotBeam(); 64 void slotBeam();
59 void slotBeamDone( Ir* ); 65 void slotBeamDone( Ir* );
60 66
61 void slotShowImage(); 67 void slotShowImage();
62 void slotShowImage( const QString& ); 68 void slotShowImage( const QString& );
63 void slotImageInfo(); 69 void slotImageInfo();
64 void slotImageInfo( const QString& ); 70 void slotImageInfo( const QString& );
65 71
66 void slotStart(); 72 void slotStart();
67 void slotEnd(); 73 void slotEnd();
68 74
69/* for performance reasons make it inline in the future */ 75/* for performance reasons make it inline in the future */
70 void addFolders( const QStringList& ); 76 void addFolders( const QStringList& );
71 void addFiles( const QStringList& ); 77 void addFiles( const QStringList& );
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index db3ae74..aa2b9bc 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -29,32 +29,57 @@ Opie::Core::OKeyConfigManager* ImageView::manager()
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 46
47 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 47 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
48 lst, false,this, "image_view_keys" ); 48 lst, false,this, "image_view_keys" );
49 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 49 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
50 Resource::loadPixmap("1to1"), ViewInfo, 50 Resource::loadPixmap("1to1"), ViewInfo,
51 Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton), 51 Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton),
52 this, SLOT(slotShowImageInfo()))); 52 this, SLOT(slotShowImageInfo())));
53#if 0
54 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage",
55 Resource::loadPixmap("next"), ViewInfo,
56 Opie::Core::OKeyPair(Qt::Key_N,0),
57 this, SLOT(slotDispNext())));
58#endif
53 m_viewManager->handleWidget( this ); 59 m_viewManager->handleWidget( this );
54 m_viewManager->load(); 60 m_viewManager->load();
55} 61}
56 62
63void ImageView::keyReleaseEvent(QKeyEvent * e)
64{
65 if (!e || e->state()!=0) {
66 return;
67 }
68 if (e->key()==Qt::Key_N) slotDispNext();
69 if (e->key()==Qt::Key_P) slotDispPrev();
70}
71
72void ImageView::slotDispNext()
73{
74 emit dispNext();
75}
76
77void ImageView::slotDispPrev()
78{
79 emit dispPrev();
80}
81
57void ImageView::slotShowImageInfo() 82void ImageView::slotShowImageInfo()
58{ 83{
59 emit dispImageInfo(m_lastName); 84 emit dispImageInfo(m_lastName);
60} 85}
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h
index 1790c4f..f467f00 100644
--- a/noncore/graphics/opie-eye/gui/imageview.h
+++ b/noncore/graphics/opie-eye/gui/imageview.h
@@ -4,33 +4,38 @@
4#include <opie2/oimagescrollview.h> 4#include <opie2/oimagescrollview.h>
5 5
6namespace Opie { 6namespace Opie {
7 namespace Core { 7 namespace Core {
8 class OConfig; 8 class OConfig;
9 class OKeyConfigManager; 9 class OKeyConfigManager;
10 } 10 }
11} 11}
12 12
13class ImageView:public Opie::MM::OImageScrollView 13class ImageView:public Opie::MM::OImageScrollView
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16 16
17 enum ActionIds { 17 enum ActionIds {
18 ViewInfo 18 ViewInfo
19 }; 19 };
20 20
21public: 21public:
22 ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); 22 ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 );
23 virtual ~ImageView(); 23 virtual ~ImageView();
24 Opie::Core::OKeyConfigManager* manager(); 24 Opie::Core::OKeyConfigManager* manager();
25 25
26signals: 26signals:
27 void dispImageInfo(const QString&); 27 void dispImageInfo(const QString&);
28 void dispNext();
29 void dispPrev();
28 30
29protected: 31protected:
30 Opie::Core::OConfig * m_cfg; 32 Opie::Core::OConfig * m_cfg;
31 Opie::Core::OKeyConfigManager*m_viewManager; 33 Opie::Core::OKeyConfigManager*m_viewManager;
32 void initKeys(); 34 void initKeys();
33protected slots: 35protected slots:
34 virtual void slotShowImageInfo(); 36 virtual void slotShowImageInfo();
37 virtual void slotDispNext();
38 virtual void slotDispPrev();
39 virtual void keyReleaseEvent(QKeyEvent * e);
35}; 40};
36#endif 41#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 09f562a..57be247 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -245,48 +245,50 @@ void PMainWindow::initT( const char* name, T** ptr, int id) {
245 (*ptr)->setDestructiveClose(); 245 (*ptr)->setDestructiveClose();
246 m_stack->removeWidget( *ptr ); 246 m_stack->removeWidget( *ptr );
247 } 247 }
248 *ptr = new T(m_cfg, m_stack, name ); 248 *ptr = new T(m_cfg, m_stack, name );
249 m_stack->addWidget( *ptr, id ); 249 m_stack->addWidget( *ptr, id );
250 250
251 connect(*ptr, SIGNAL(sig_return()), 251 connect(*ptr, SIGNAL(sig_return()),
252 this,SLOT(slotReturn())); 252 this,SLOT(slotReturn()));
253 253
254} 254}
255void PMainWindow::initInfo() { 255void PMainWindow::initInfo() {
256 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 256 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
257 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 257 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
258} 258}
259void PMainWindow::initDisp() { 259void PMainWindow::initDisp() {
260 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 260 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
261 if (m_disp) { 261 if (m_disp) {
262 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 262 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
263 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 263 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
264 } 264 }
265 m_disp->setAutoScale(autoScale); 265 m_disp->setAutoScale(autoScale);
266 m_disp->setAutoRotate(autoRotate); 266 m_disp->setAutoRotate(autoRotate);
267 m_disp->setShowZoomer(zoomerOn); 267 m_disp->setShowZoomer(zoomerOn);
268 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 268 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
269 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
270 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
269 } 271 }
270} 272}
271 273
272/** 274/**
273 * With big Screen the plan could be to 'detach' the image 275 * With big Screen the plan could be to 'detach' the image
274 * window if visible and to create a ne wone 276 * window if visible and to create a ne wone
275 * init* already supports it but I make no use of it for 277 * init* already supports it but I make no use of it for
276 * now. We set filename and raise 278 * now. We set filename and raise
277 * 279 *
278 * ### FIXME and talk to alwin 280 * ### FIXME and talk to alwin
279 */ 281 */
280void PMainWindow::slotShowInfo( const QString& inf ) { 282void PMainWindow::slotShowInfo( const QString& inf ) {
281 if ( !m_info ) { 283 if ( !m_info ) {
282 initInfo(); 284 initInfo();
283 } 285 }
284 m_info->setPath( inf ); 286 m_info->setPath( inf );
285 m_stack->raiseWidget( ImageInfo ); 287 m_stack->raiseWidget( ImageInfo );
286} 288}
287 289
288void PMainWindow::slotDisplay( const QString& inf ) { 290void PMainWindow::slotDisplay( const QString& inf ) {
289 if ( !m_disp ) { 291 if ( !m_disp ) {
290 initDisp(); 292 initDisp();
291 } 293 }
292 m_disp->setImage( inf ); 294 m_disp->setImage( inf );