summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index b4f3110..5522131 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -4,78 +4,84 @@
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 10
11using namespace Opie::Core; 11using namespace Opie::Core;
12 12
13ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) 13ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
14 : Opie::MM::OImageScrollView(parent,name,fl) 14 : Opie::MM::OImageScrollView(parent,name,fl)
15{ 15{
16 m_viewManager = 0; 16 m_viewManager = 0;
17 focus_in_count = 0; 17 focus_in_count = 0;
18 m_cfg = cfg; 18 m_cfg = cfg;
19 m_isFullScreen = false; 19 m_isFullScreen = false;
20 m_ignore_next_in = false; 20 m_ignore_next_in = false;
21 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); 21 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
22 initKeys(); 22 initKeys();
23} 23}
24 24
25ImageView::~ImageView() 25ImageView::~ImageView()
26{ 26{
27 odebug << "Delete Imageview" << oendl; 27 odebug << "Delete Imageview" << oendl;
28 if (m_viewManager) { 28 delete m_viewManager;
29 delete m_viewManager;
30 }
31} 29}
32 30
33Opie::Core::OKeyConfigManager* ImageView::manager() 31Opie::Core::OKeyConfigManager* ImageView::manager()
34{ 32{
35 if (!m_viewManager) { 33 if (!m_viewManager) {
36 initKeys(); 34 initKeys();
37 } 35 }
38 return m_viewManager; 36 return m_viewManager;
39} 37}
40 38
41void ImageView::initKeys() 39void ImageView::initKeys()
42{ 40{
43 odebug << "init imageview keys" << oendl; 41 odebug << "init imageview keys" << oendl;
44 if (!m_cfg) { 42 if (!m_cfg) {
45 m_cfg = new Opie::Core::OConfig("phunkview"); 43 m_cfg = new Opie::Core::OConfig("phunkview");
46 m_cfg->setGroup("image_view_keys" ); 44 m_cfg->setGroup("image_view_keys" );
47 } 45 }
48 Opie::Core::OKeyPair::List lst; 46 Opie::Core::OKeyPair::List lst;
49 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 47 lst.append( Opie::Core::OKeyPair::upArrowKey() );
50 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 48 lst.append( Opie::Core::OKeyPair::downArrowKey() );
51 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 49 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
52 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 50 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
53 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); 51 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0));
54 52
55 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 53 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
56 lst, false,this, "image_view_keys" ); 54 lst, false,this, "image_view_keys" );
57 55
56 /**
57 * Handle KeyEvents when they're pressed. This avoids problems
58 * with 'double next' on Return.
59 * The Return press would switch to this view and the return
60 * release would emit the dispNext Signal.
61 */
62 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed );
63
58 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 64 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
59 Resource::loadPixmap("1to1"), ViewInfo, 65 Resource::loadPixmap("1to1"), ViewInfo,
60 Opie::Core::OKeyPair(Qt::Key_I,0), 66 Opie::Core::OKeyPair(Qt::Key_I,0),
61 this, SLOT(slotShowImageInfo()))); 67 this, SLOT(slotShowImageInfo())));
62 68
63 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", 69 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
64 Resource::loadPixmap("rotate"), Autorotate, 70 Resource::loadPixmap("rotate"), Autorotate,
65 Opie::Core::OKeyPair(Qt::Key_R,0), 71 Opie::Core::OKeyPair(Qt::Key_R,0),
66 this, SIGNAL(toggleAutorotate()))); 72 this, SIGNAL(toggleAutorotate())));
67 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", 73 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale",
68 Resource::loadPixmap("1to1"), Autoscale, 74 Resource::loadPixmap("1to1"), Autoscale,
69 Opie::Core::OKeyPair(Qt::Key_S,0), 75 Opie::Core::OKeyPair(Qt::Key_S,0),
70 this, SIGNAL(toggleAutoscale()))); 76 this, SIGNAL(toggleAutoscale())));
71 77
72 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", 78 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext",
73 Resource::loadPixmap("forward"), ShowNext, 79 Resource::loadPixmap("forward"), ShowNext,
74 Opie::Core::OKeyPair(Qt::Key_Return,0), 80 Opie::Core::OKeyPair(Qt::Key_Return,0),
75 this, SIGNAL(dispNext()))); 81 this, SIGNAL(dispNext())));
76 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", 82 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev",
77 Resource::loadPixmap("back"), ShowPrevious, 83 Resource::loadPixmap("back"), ShowPrevious,
78 Opie::Core::OKeyPair(Qt::Key_P,0), 84 Opie::Core::OKeyPair(Qt::Key_P,0),
79 this, SIGNAL(dispPrev()))); 85 this, SIGNAL(dispPrev())));
80 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", 86 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen",
81 Resource::loadPixmap("fullscreen"), FullScreen, 87 Resource::loadPixmap("fullscreen"), FullScreen,
@@ -125,49 +131,49 @@ void ImageView::contentsMousePressEvent ( QMouseEvent * e)
125 delete m; 131 delete m;
126} 132}
127 133
128void ImageView::setFullScreen(bool how) 134void ImageView::setFullScreen(bool how)
129{ 135{
130 m_isFullScreen = how; 136 m_isFullScreen = how;
131 if (how) { 137 if (how) {
132 m_ignore_next_in = true; 138 m_ignore_next_in = true;
133 setFixedSize(qApp->desktop()->size()); 139 setFixedSize(qApp->desktop()->size());
134 showFullScreen(); 140 showFullScreen();
135 } else { 141 } else {
136 setMinimumSize(10,10); 142 setMinimumSize(10,10);
137 } 143 }
138} 144}
139 145
140void ImageView::focusInEvent(QFocusEvent *) 146void ImageView::focusInEvent(QFocusEvent *)
141{ 147{
142 // Always do it here, no matter the size. 148 // Always do it here, no matter the size.
143 odebug << "Focus in (view)" << oendl; 149 odebug << "Focus in (view)" << oendl;
144 //if (fullScreen()) parentWidget()->showNormal(); 150 //if (fullScreen()) parentWidget()->showNormal();
145 if (m_ignore_next_in){m_ignore_next_in=false;return;} 151 if (m_ignore_next_in){m_ignore_next_in=false;return;}
146 if (fullScreen()) enableFullscreen(); 152 if (fullScreen()) enableFullscreen();
147} 153}
148 154
149void ImageView::hide() 155void ImageView::hide()
150{ 156{
151 if (fullScreen()) { 157 if (fullScreen()) {
152 m_ignore_next_in = true; 158 m_ignore_next_in = true;
153 showNormal(); 159 showNormal();
154 } 160 }
155 QWidget::hide(); 161 QWidget::hide();
156} 162}
157void ImageView::enableFullscreen() 163void ImageView::enableFullscreen()
158{ 164{
159 if (!fullScreen()) return; 165 if (!fullScreen()) return;
160 if (m_ignore_next_in) {m_ignore_next_in = false;return;} 166 if (m_ignore_next_in) {m_ignore_next_in = false;return;}
161 167
162 setUpdatesEnabled(false); 168 setUpdatesEnabled(false);
163 // This is needed because showNormal() forcefully changes the window 169 // This is needed because showNormal() forcefully changes the window
164 // style to WSTyle_TopLevel. 170 // style to WSTyle_TopLevel.
165 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 171 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
166 // Enable fullscreen. 172 // Enable fullscreen.
167 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus 173 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus
168 * so we must block it here! */ 174 * so we must block it here! */
169 m_ignore_next_in = true; 175 m_ignore_next_in = true;
170 showFullScreen(); 176 showFullScreen();
171 setUpdatesEnabled(true); 177 setUpdatesEnabled(true);
172 178
173} 179}