author | alwin <alwin> | 2004-10-30 02:18:52 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-30 02:18:52 (UTC) |
commit | 3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25 (patch) (unidiff) | |
tree | 087361e8ec23fcae50ab146d6d2e2d366a54fe74 /noncore/graphics/opie-eye | |
parent | dca4423e3b0966fe26ba4183e5b6ad4666c61e86 (diff) | |
download | opie-3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25.zip opie-3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25.tar.gz opie-3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25.tar.bz2 |
slide show implemented
on next/previous images: if end/begin of list is reached it starts
again on begin/end (it was required for slideshow so what ;)
zecke: so we have a feature for OPIE 1.1.7 ;)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 94 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 28 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 1 |
5 files changed, 131 insertions, 4 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 7196aba..0499af9 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -241,8 +241,12 @@ void PIconView::initKeys() { | |||
241 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 241 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
242 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 242 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
243 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 243 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
244 | this, SLOT(slotImageInfo()) ) ); | 244 | this, SLOT(slotImageInfo()) ) ); |
245 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", | ||
246 | Resource::loadPixmap("1to1"), SlideItem, | ||
247 | Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), | ||
248 | this, SLOT(slotStartSlide()))); | ||
245 | m_viewManager->load(); | 249 | m_viewManager->load(); |
246 | m_viewManager->handleWidget( m_view ); | 250 | m_viewManager->handleWidget( m_view ); |
247 | } | 251 | } |
248 | 252 | ||
@@ -563,13 +567,78 @@ void PIconView::slotEnd() { | |||
563 | m_view->viewport()->setUpdatesEnabled( true ); | 567 | m_view->viewport()->setUpdatesEnabled( true ); |
564 | m_updatet = false; | 568 | m_updatet = false; |
565 | } | 569 | } |
566 | 570 | ||
571 | void PIconView::slotShowLast() | ||
572 | { | ||
573 | QIconViewItem* last_it = m_view->lastItem(); | ||
574 | if (!last_it) return; | ||
575 | m_view->setCurrentItem(last_it); | ||
576 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); | ||
577 | bool isDir = it->isDir(); | ||
578 | QString name = it->path(); | ||
579 | if (!isDir && !name.isEmpty()) { | ||
580 | slotShowImage(name); | ||
581 | return; | ||
582 | } | ||
583 | bool first_loop = true; | ||
584 | while(isDir==true) { | ||
585 | if (!first_loop) { | ||
586 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | ||
587 | } else { | ||
588 | first_loop = false; | ||
589 | } | ||
590 | name = prevFileName(isDir); | ||
591 | } | ||
592 | |||
593 | if (name.isEmpty()) return; | ||
594 | /* if we got a name we have a prev item */ | ||
595 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | ||
596 | slotShowImage(name); | ||
597 | } | ||
598 | |||
599 | bool PIconView::slotShowFirst() | ||
600 | { | ||
601 | /* stop when reached - otherwise we may get an endless loop */ | ||
602 | QIconViewItem* first_it = m_view->firstItem(); | ||
603 | if (!first_it) return false; | ||
604 | m_view->setCurrentItem(first_it); | ||
605 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); | ||
606 | bool isDir = it->isDir(); | ||
607 | QString name = it->path(); | ||
608 | if (!isDir && !name.isEmpty()) { | ||
609 | slotShowImage(name); | ||
610 | return false; | ||
611 | } | ||
612 | bool first_loop = true; | ||
613 | while(isDir==true) { | ||
614 | /* if name is empty isDir is false, too. */ | ||
615 | if (!first_loop) { | ||
616 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | ||
617 | } else { | ||
618 | first_loop = false; | ||
619 | } | ||
620 | name = nextFileName(isDir); | ||
621 | } | ||
622 | if (name.isEmpty()) return false; | ||
623 | /* if we got a name we have a next item */ | ||
624 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | ||
625 | slotShowImage(name); | ||
626 | return true; | ||
627 | } | ||
628 | |||
567 | void PIconView::slotShowNext() | 629 | void PIconView::slotShowNext() |
568 | { | 630 | { |
569 | bool isDir = false; | 631 | bool isDir = false; |
570 | QString name = nextFileName(isDir); | 632 | QString name = nextFileName(isDir); |
571 | if (name.isEmpty()) return; | 633 | while (isDir==true) { |
634 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | ||
635 | name = nextFileName(isDir); | ||
636 | } | ||
637 | if (name.isEmpty()) { | ||
638 | slotShowFirst(); | ||
639 | return; | ||
640 | } | ||
572 | if (isDir) return; | 641 | if (isDir) return; |
573 | /* if we got a name we have a next item */ | 642 | /* if we got a name we have a next item */ |
574 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 643 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
575 | slotShowImage(name); | 644 | slotShowImage(name); |
@@ -578,9 +647,17 @@ void PIconView::slotShowNext() | |||
578 | void PIconView::slotShowPrev() | 647 | void PIconView::slotShowPrev() |
579 | { | 648 | { |
580 | bool isDir = false; | 649 | bool isDir = false; |
581 | QString name = prevFileName(isDir); | 650 | QString name = prevFileName(isDir); |
582 | if (name.isEmpty()) return; | 651 | while (isDir==true) { |
652 | /* if name is empty isDir is false, too. */ | ||
653 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | ||
654 | name = prevFileName(isDir); | ||
655 | } | ||
656 | if (name.isEmpty()) { | ||
657 | slotShowLast(); | ||
658 | return; | ||
659 | } | ||
583 | if (isDir) return; | 660 | if (isDir) return; |
584 | /* if we got a name we have a prev item */ | 661 | /* if we got a name we have a prev item */ |
585 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 662 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
586 | slotShowImage(name); | 663 | slotShowImage(name); |
@@ -597,8 +674,21 @@ void PIconView::slotShowImage( const QString& name) { | |||
597 | PDirLister *lister = currentView()->dirLister(); | 674 | PDirLister *lister = currentView()->dirLister(); |
598 | QString r_name = lister->nameToFname(name); | 675 | QString r_name = lister->nameToFname(name); |
599 | emit sig_display( r_name ); | 676 | emit sig_display( r_name ); |
600 | } | 677 | } |
678 | |||
679 | void PIconView::slotStartSlide() { | ||
680 | bool isDir = false; | ||
681 | QString name = currentFileName(isDir); | ||
682 | if (isDir) { | ||
683 | if (!slotShowFirst()) | ||
684 | return; | ||
685 | } else { | ||
686 | slotShowImage( name ); | ||
687 | } | ||
688 | emit sig_startslide(2); | ||
689 | } | ||
690 | |||
601 | void PIconView::slotImageInfo() { | 691 | void PIconView::slotImageInfo() { |
602 | bool isDir = false; | 692 | bool isDir = false; |
603 | QString name = currentFileName(isDir); | 693 | QString name = currentFileName(isDir); |
604 | if (isDir) return; | 694 | if (isDir) return; |
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index a424c5c..bccbb0e 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -26,9 +26,9 @@ namespace Core{ | |||
26 | class PIconView : public QVBox { | 26 | class 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,SlideItem |
31 | }; | 31 | }; |
32 | public: | 32 | public: |
33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); | 33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
34 | ~PIconView(); | 34 | ~PIconView(); |
@@ -37,12 +37,15 @@ public: | |||
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 | void sig_startslide(int timeout); | ||
41 | 42 | ||
42 | public slots: | 43 | public slots: |
43 | virtual void slotShowNext(); | 44 | virtual void slotShowNext(); |
44 | virtual void slotShowPrev(); | 45 | virtual void slotShowPrev(); |
46 | virtual void slotShowLast(); | ||
47 | virtual bool slotShowFirst(); | ||
45 | 48 | ||
46 | protected: | 49 | protected: |
47 | void resizeEvent( QResizeEvent* ); | 50 | void resizeEvent( QResizeEvent* ); |
48 | 51 | ||
@@ -67,8 +70,9 @@ private slots: | |||
67 | void slotShowImage(); | 70 | void slotShowImage(); |
68 | void slotShowImage( const QString& ); | 71 | void slotShowImage( const QString& ); |
69 | void slotImageInfo(); | 72 | void slotImageInfo(); |
70 | void slotImageInfo( const QString& ); | 73 | void slotImageInfo( const QString& ); |
74 | void slotStartSlide(); | ||
71 | 75 | ||
72 | void slotStart(); | 76 | void slotStart(); |
73 | void slotEnd(); | 77 | void slotEnd(); |
74 | 78 | ||
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 5522131..b699aa1 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -6,8 +6,9 @@ | |||
6 | 6 | ||
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | #include <qtimer.h> | ||
10 | 11 | ||
11 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
12 | 13 | ||
13 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 14 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
@@ -17,10 +18,12 @@ ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name | |||
17 | focus_in_count = 0; | 18 | focus_in_count = 0; |
18 | m_cfg = cfg; | 19 | m_cfg = cfg; |
19 | m_isFullScreen = false; | 20 | m_isFullScreen = false; |
20 | m_ignore_next_in = false; | 21 | m_ignore_next_in = false; |
22 | m_slideTimer = 0; | ||
21 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); | 23 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); |
22 | initKeys(); | 24 | initKeys(); |
25 | m_slideValue = 5; | ||
23 | } | 26 | } |
24 | 27 | ||
25 | ImageView::~ImageView() | 28 | ImageView::~ImageView() |
26 | { | 29 | { |
@@ -35,8 +38,31 @@ Opie::Core::OKeyConfigManager* ImageView::manager() | |||
35 | } | 38 | } |
36 | return m_viewManager; | 39 | return m_viewManager; |
37 | } | 40 | } |
38 | 41 | ||
42 | void ImageView::startSlide(int value) | ||
43 | { | ||
44 | if (!m_slideTimer) { | ||
45 | m_slideTimer = new QTimer(this); | ||
46 | } | ||
47 | m_slideValue=value; | ||
48 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); | ||
49 | m_slideTimer->start(m_slideValue*1000,true); | ||
50 | } | ||
51 | |||
52 | void ImageView::nextSlide() | ||
53 | { | ||
54 | if (!m_slideTimer) { | ||
55 | return; | ||
56 | } | ||
57 | if (isHidden()) { | ||
58 | delete m_slideTimer; | ||
59 | m_slideTimer = 0; | ||
60 | return; | ||
61 | } | ||
62 | emit dispNext(); | ||
63 | m_slideTimer->start(m_slideValue*1000,true); | ||
64 | } | ||
39 | void ImageView::initKeys() | 65 | void ImageView::initKeys() |
40 | { | 66 | { |
41 | odebug << "init imageview keys" << oendl; | 67 | odebug << "init imageview keys" << oendl; |
42 | if (!m_cfg) { | 68 | if (!m_cfg) { |
@@ -138,9 +164,9 @@ void ImageView::setFullScreen(bool how) | |||
138 | m_ignore_next_in = true; | 164 | m_ignore_next_in = true; |
139 | setFixedSize(qApp->desktop()->size()); | 165 | setFixedSize(qApp->desktop()->size()); |
140 | showFullScreen(); | 166 | showFullScreen(); |
141 | } else { | 167 | } else { |
142 | setMinimumSize(10,10); | 168 | setMinimumSize(10,10); |
143 | } | 169 | } |
144 | } | 170 | } |
145 | 171 | ||
146 | void ImageView::focusInEvent(QFocusEvent *) | 172 | void ImageView::focusInEvent(QFocusEvent *) |
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 18697e0..f0e6541 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h | |||
@@ -4,8 +4,10 @@ | |||
4 | #include <opie2/oimagescrollview.h> | 4 | #include <opie2/oimagescrollview.h> |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | 7 | ||
8 | class QTimer; | ||
9 | |||
8 | namespace Opie { | 10 | namespace Opie { |
9 | namespace Core { | 11 | namespace Core { |
10 | class OConfig; | 12 | class OConfig; |
11 | class OKeyConfigManager; | 13 | class OKeyConfigManager; |
@@ -50,12 +52,16 @@ protected: | |||
50 | void initKeys(); | 52 | void initKeys(); |
51 | bool m_isFullScreen:1; | 53 | bool m_isFullScreen:1; |
52 | bool m_ignore_next_in:1; | 54 | bool m_ignore_next_in:1; |
53 | int focus_in_count; | 55 | int focus_in_count; |
56 | QTimer*m_slideTimer; | ||
57 | int m_slideValue; | ||
54 | virtual void focusInEvent ( QFocusEvent * ); | 58 | virtual void focusInEvent ( QFocusEvent * ); |
55 | 59 | ||
56 | public slots: | 60 | public slots: |
57 | virtual void hide(); | 61 | virtual void hide(); |
62 | virtual void startSlide(int); | ||
63 | virtual void nextSlide(); | ||
58 | 64 | ||
59 | protected slots: | 65 | protected slots: |
60 | virtual void slotShowImageInfo(); | 66 | virtual void slotShowImageInfo(); |
61 | virtual void keyReleaseEvent(QKeyEvent * e); | 67 | virtual void keyReleaseEvent(QKeyEvent * e); |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 438fbf2..3c946b6 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -310,8 +310,9 @@ void PMainWindow::initDisp() { | |||
310 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 310 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
311 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 311 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
312 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | 312 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); |
313 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | 313 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); |
314 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); | ||
314 | } | 315 | } |
315 | } | 316 | } |
316 | 317 | ||
317 | void PMainWindow::slotToggleFullScreen() | 318 | void PMainWindow::slotToggleFullScreen() |