Diffstat (limited to 'noncore/graphics/opie-eye/gui/imageview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 86db732..be58c72 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,156 +1,158 @@ | |||
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 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | #include <qtimer.h> | 10 | #include <qtimer.h> |
11 | #include <qaction.h> | 11 | #include <qaction.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | 14 | ||
15 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 15 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
16 | : Opie::MM::OImageScrollView(parent,name,fl) | 16 | : Opie::MM::OImageScrollView(parent,name,fl) |
17 | { | 17 | { |
18 | m_viewManager = 0; | 18 | m_viewManager = 0; |
19 | focus_in_count = 0; | 19 | focus_in_count = 0; |
20 | m_cfg = cfg; | 20 | m_cfg = cfg; |
21 | m_isFullScreen = false; | 21 | m_isFullScreen = false; |
22 | m_ignore_next_in = false; | 22 | m_ignore_next_in = false; |
23 | m_slideTimer = 0; | 23 | m_slideTimer = 0; |
24 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); | 24 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); |
25 | initKeys(); | 25 | initKeys(); |
26 | m_slideValue = 5; | 26 | m_slideValue = 5; |
27 | m_gDisplayType = 0; | 27 | m_gDisplayType = 0; |
28 | m_gPrevNext = 0; | 28 | m_gPrevNext = 0; |
29 | m_hGroup = 0; | 29 | m_hGroup = 0; |
30 | } | 30 | } |
31 | 31 | ||
32 | void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) | 32 | void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) |
33 | { | 33 | { |
34 | m_gDisplayType = disptypeGroup; | 34 | m_gDisplayType = disptypeGroup; |
35 | m_gPrevNext = nextprevGroup; | 35 | m_gPrevNext = nextprevGroup; |
36 | m_hGroup = hGroup; | 36 | m_hGroup = hGroup; |
37 | } | 37 | } |
38 | 38 | ||
39 | ImageView::~ImageView() | 39 | ImageView::~ImageView() |
40 | { | 40 | { |
41 | odebug << "Delete Imageview" << oendl; | ||
42 | delete m_viewManager; | 41 | delete m_viewManager; |
43 | } | 42 | } |
44 | 43 | ||
45 | Opie::Core::OKeyConfigManager* ImageView::manager() | 44 | Opie::Core::OKeyConfigManager* ImageView::manager() |
46 | { | 45 | { |
47 | if (!m_viewManager) { | 46 | if (!m_viewManager) { |
48 | initKeys(); | 47 | initKeys(); |
49 | } | 48 | } |
50 | return m_viewManager; | 49 | return m_viewManager; |
51 | } | 50 | } |
52 | 51 | ||
53 | void ImageView::startSlide(int value) | 52 | void ImageView::startSlide(int value) |
54 | { | 53 | { |
55 | if (!m_slideTimer) { | 54 | if (!m_slideTimer) { |
56 | m_slideTimer = new QTimer(this); | 55 | m_slideTimer = new QTimer(this); |
57 | } | 56 | } |
58 | m_slideValue=value; | 57 | m_slideValue=value; |
59 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); | 58 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); |
60 | m_slideTimer->start(m_slideValue*1000,true); | 59 | /* this "+1" is one millisecond. with that we can setup a slideshowvalue |
60 | of 0. eg "as fast as possible". | ||
61 | */ | ||
62 | m_slideTimer->start(m_slideValue*1000+1,true); | ||
61 | } | 63 | } |
62 | 64 | ||
63 | void ImageView::stopSlide() | 65 | void ImageView::stopSlide() |
64 | { | 66 | { |
65 | if (!m_slideTimer) { | 67 | if (!m_slideTimer) { |
66 | return; | 68 | return; |
67 | } | 69 | } |
68 | m_slideTimer->stop(); | 70 | m_slideTimer->stop(); |
69 | delete m_slideTimer; | 71 | delete m_slideTimer; |
70 | m_slideTimer = 0; | 72 | m_slideTimer = 0; |
71 | } | 73 | } |
72 | 74 | ||
73 | void ImageView::nextSlide() | 75 | void ImageView::nextSlide() |
74 | { | 76 | { |
75 | if (!m_slideTimer) { | 77 | if (!m_slideTimer) { |
76 | return; | 78 | return; |
77 | } | 79 | } |
78 | if (isHidden()) { | 80 | if (isHidden()) { |
79 | delete m_slideTimer; | 81 | delete m_slideTimer; |
80 | m_slideTimer = 0; | 82 | m_slideTimer = 0; |
81 | return; | 83 | return; |
82 | } | 84 | } |
83 | emit dispNext(); | 85 | emit dispNext(); |
84 | m_slideTimer->start(m_slideValue*1000,true); | 86 | m_slideTimer->start(m_slideValue*1000,true); |
85 | } | 87 | } |
86 | void ImageView::initKeys() | 88 | void ImageView::initKeys() |
87 | { | 89 | { |
88 | odebug << "init imageview keys" << oendl; | 90 | odebug << "init imageview keys" << oendl; |
89 | if (!m_cfg) { | 91 | if (!m_cfg) { |
90 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 92 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
91 | m_cfg->setGroup("image_view_keys" ); | 93 | m_cfg->setGroup("image_view_keys" ); |
92 | } | 94 | } |
93 | Opie::Core::OKeyPair::List lst; | 95 | Opie::Core::OKeyPair::List lst; |
94 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 96 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
95 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 97 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
96 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 98 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
97 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 99 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
98 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); | 100 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); |
99 | 101 | ||
100 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 102 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
101 | lst, false,this, "image_view_keys" ); | 103 | lst, false,this, "image_view_keys" ); |
102 | 104 | ||
103 | /** | 105 | /** |
104 | * Handle KeyEvents when they're pressed. This avoids problems | 106 | * Handle KeyEvents when they're pressed. This avoids problems |
105 | * with 'double next' on Return. | 107 | * with 'double next' on Return. |
106 | * The Return press would switch to this view and the return | 108 | * The Return press would switch to this view and the return |
107 | * release would emit the dispNext Signal. | 109 | * release would emit the dispNext Signal. |
108 | */ | 110 | */ |
109 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); | 111 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); |
110 | 112 | ||
111 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 113 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
112 | Resource::loadPixmap("1to1"), ViewInfo, | 114 | Resource::loadPixmap("1to1"), ViewInfo, |
113 | Opie::Core::OKeyPair(Qt::Key_I,0), | 115 | Opie::Core::OKeyPair(Qt::Key_I,0), |
114 | this, SLOT(slotShowImageInfo()))); | 116 | this, SLOT(slotShowImageInfo()))); |
115 | 117 | ||
116 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", | 118 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", |
117 | Resource::loadPixmap("rotate"), Autorotate, | 119 | Resource::loadPixmap("rotate"), Autorotate, |
118 | Opie::Core::OKeyPair(Qt::Key_R,0), | 120 | Opie::Core::OKeyPair(Qt::Key_R,0), |
119 | this, SIGNAL(toggleAutorotate()))); | 121 | this, SIGNAL(toggleAutorotate()))); |
120 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", | 122 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", |
121 | Resource::loadPixmap("1to1"), Autoscale, | 123 | Resource::loadPixmap("1to1"), Autoscale, |
122 | Opie::Core::OKeyPair(Qt::Key_S,0), | 124 | Opie::Core::OKeyPair(Qt::Key_S,0), |
123 | this, SIGNAL(toggleAutoscale()))); | 125 | this, SIGNAL(toggleAutoscale()))); |
124 | 126 | ||
125 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", | 127 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", |
126 | Resource::loadPixmap("forward"), ShowNext, | 128 | Resource::loadPixmap("forward"), ShowNext, |
127 | Opie::Core::OKeyPair(Qt::Key_Return,0), | 129 | Opie::Core::OKeyPair(Qt::Key_Return,0), |
128 | this, SIGNAL(dispNext()))); | 130 | this, SIGNAL(dispNext()))); |
129 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", | 131 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", |
130 | Resource::loadPixmap("back"), ShowPrevious, | 132 | Resource::loadPixmap("back"), ShowPrevious, |
131 | Opie::Core::OKeyPair(Qt::Key_P,0), | 133 | Opie::Core::OKeyPair(Qt::Key_P,0), |
132 | this, SIGNAL(dispPrev()))); | 134 | this, SIGNAL(dispPrev()))); |
133 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", | 135 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", |
134 | Resource::loadPixmap("fullscreen"), FullScreen, | 136 | Resource::loadPixmap("fullscreen"), FullScreen, |
135 | Opie::Core::OKeyPair(Qt::Key_F,0), | 137 | Opie::Core::OKeyPair(Qt::Key_F,0), |
136 | this, SIGNAL(toggleFullScreen()))); | 138 | this, SIGNAL(toggleFullScreen()))); |
137 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", | 139 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", |
138 | Resource::loadPixmap("mag"), Zoomer, | 140 | Resource::loadPixmap("mag"), Zoomer, |
139 | Opie::Core::OKeyPair(Qt::Key_T,0), | 141 | Opie::Core::OKeyPair(Qt::Key_T,0), |
140 | this, SIGNAL(toggleZoomer()))); | 142 | this, SIGNAL(toggleZoomer()))); |
141 | m_viewManager->handleWidget( this ); | 143 | m_viewManager->handleWidget( this ); |
142 | m_viewManager->load(); | 144 | m_viewManager->load(); |
143 | } | 145 | } |
144 | 146 | ||
145 | void ImageView::keyReleaseEvent(QKeyEvent * e) | 147 | void ImageView::keyReleaseEvent(QKeyEvent * e) |
146 | { | 148 | { |
147 | if (!e || e->state()!=0) { | 149 | if (!e || e->state()!=0) { |
148 | return; | 150 | return; |
149 | } | 151 | } |
150 | if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); | 152 | if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); |
151 | } | 153 | } |
152 | 154 | ||
153 | void ImageView::slotShowImageInfo() | 155 | void ImageView::slotShowImageInfo() |
154 | { | 156 | { |
155 | emit dispImageInfo(m_lastName); | 157 | emit dispImageInfo(m_lastName); |
156 | } | 158 | } |