author | alwin <alwin> | 2004-04-15 16:14:56 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-15 16:14:56 (UTC) |
commit | a002be54e33d64e69c7edf2960d5e68a9a0609e4 (patch) (unidiff) | |
tree | c58f7bce41920a86f077d0c371bcf166a03d6489 | |
parent | fd31b11688704c214034a0e28ca7c0a56a6a2988 (diff) | |
download | opie-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)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 48 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 25 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 2 |
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 | |||
@@ -263,16 +263,45 @@ QString PIconView::currentFileName(bool &isDir)const { | |||
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 | ||
271 | QString 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 | |||
286 | QString 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 | |||
271 | void PIconView::slotTrash() { | 300 | void 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" ), |
@@ -441,16 +470,35 @@ void PIconView::slotStart() { | |||
441 | 470 | ||
442 | void PIconView::slotEnd() { | 471 | void 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 | ||
478 | void 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 | |||
488 | void 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 | |||
449 | void PIconView::slotShowImage() | 497 | void 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 | } |
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 | |||
@@ -34,22 +34,28 @@ public: | |||
34 | ~PIconView(); | 34 | ~PIconView(); |
35 | void resetView(); | 35 | void resetView(); |
36 | Opie::Core::OKeyConfigManager* manager(); | 36 | Opie::Core::OKeyConfigManager* manager(); |
37 | 37 | ||
38 | signals: | 38 | signals: |
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 | ||
42 | public slots: | ||
43 | virtual void slotShowNext(); | ||
44 | virtual void slotShowPrev(); | ||
45 | |||
42 | protected: | 46 | protected: |
43 | void resizeEvent( QResizeEvent* ); | 47 | void resizeEvent( QResizeEvent* ); |
44 | 48 | ||
45 | private: | 49 | private: |
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 | ||
51 | private slots: | 57 | private 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 ); |
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 | |||
@@ -45,16 +45,41 @@ void ImageView::initKeys() | |||
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 | ||
63 | void 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 | |||
72 | void ImageView::slotDispNext() | ||
73 | { | ||
74 | emit dispNext(); | ||
75 | } | ||
76 | |||
77 | void ImageView::slotDispPrev() | ||
78 | { | ||
79 | emit dispPrev(); | ||
80 | } | ||
81 | |||
57 | void ImageView::slotShowImageInfo() | 82 | void 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 | |||
@@ -20,17 +20,22 @@ class ImageView:public Opie::MM::OImageScrollView | |||
20 | 20 | ||
21 | public: | 21 | public: |
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 | ||
26 | signals: | 26 | signals: |
27 | void dispImageInfo(const QString&); | 27 | void dispImageInfo(const QString&); |
28 | void dispNext(); | ||
29 | void dispPrev(); | ||
28 | 30 | ||
29 | protected: | 31 | protected: |
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(); |
33 | protected slots: | 35 | protected 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 | |||
@@ -261,16 +261,18 @@ void PMainWindow::initDisp() { | |||
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 |