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 | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 88a8bc6..5b34ca2 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,33 +1,37 @@ | |||
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> | ||
9 | #include <qpopupmenu.h> | ||
8 | 10 | ||
9 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
10 | 12 | ||
11 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 13 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
12 | : Opie::MM::OImageScrollView(parent,name,fl) | 14 | : Opie::MM::OImageScrollView(parent,name,fl) |
13 | { | 15 | { |
14 | m_viewManager = 0; | 16 | m_viewManager = 0; |
15 | m_cfg = cfg; | 17 | m_cfg = cfg; |
16 | m_isFullScreen = false; | 18 | m_isFullScreen = false; |
19 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); | ||
17 | initKeys(); | 20 | initKeys(); |
18 | } | 21 | } |
19 | 22 | ||
20 | ImageView::~ImageView() | 23 | ImageView::~ImageView() |
21 | { | 24 | { |
25 | odebug << "Delete Imageview" << oendl; | ||
22 | if (m_viewManager) { | 26 | if (m_viewManager) { |
23 | delete m_viewManager; | 27 | delete m_viewManager; |
24 | } | 28 | } |
25 | } | 29 | } |
26 | 30 | ||
27 | Opie::Core::OKeyConfigManager* ImageView::manager() | 31 | Opie::Core::OKeyConfigManager* ImageView::manager() |
28 | { | 32 | { |
29 | if (!m_viewManager) { | 33 | if (!m_viewManager) { |
30 | initKeys(); | 34 | initKeys(); |
31 | } | 35 | } |
32 | return m_viewManager; | 36 | return m_viewManager; |
33 | } | 37 | } |
@@ -39,32 +43,42 @@ void ImageView::initKeys() | |||
39 | m_cfg = new Opie::Core::OConfig("phunkview"); | 43 | m_cfg = new Opie::Core::OConfig("phunkview"); |
40 | m_cfg->setGroup("image_view_keys" ); | 44 | m_cfg->setGroup("image_view_keys" ); |
41 | } | 45 | } |
42 | Opie::Core::OKeyPair::List lst; | 46 | Opie::Core::OKeyPair::List lst; |
43 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 47 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
44 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 48 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
45 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 49 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
46 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 50 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
47 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); | 51 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); |
48 | 52 | ||
49 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 53 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
50 | lst, false,this, "image_view_keys" ); | 54 | lst, false,this, "image_view_keys" ); |
55 | |||
51 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 56 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
52 | Resource::loadPixmap("1to1"), ViewInfo, | 57 | Resource::loadPixmap("1to1"), ViewInfo, |
53 | Opie::Core::OKeyPair(Qt::Key_I,0), | 58 | Opie::Core::OKeyPair(Qt::Key_I,0), |
54 | this, SLOT(slotShowImageInfo()))); | 59 | this, SLOT(slotShowImageInfo()))); |
55 | 60 | ||
61 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", | ||
62 | Resource::loadPixmap("rotate"), Autorotate, | ||
63 | Opie::Core::OKeyPair(Qt::Key_R,0), | ||
64 | this, SIGNAL(toggleAutorotate()))); | ||
65 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", | ||
66 | Resource::loadPixmap("1to1"), Autoscale, | ||
67 | Opie::Core::OKeyPair(Qt::Key_S,0), | ||
68 | this, SIGNAL(toggleAutoscale()))); | ||
69 | |||
56 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", | 70 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", |
57 | Resource::loadPixmap("forward"), ShowNext, | 71 | Resource::loadPixmap("forward"), ShowNext, |
58 | Opie::Core::OKeyPair(Qt::Key_N,0), | 72 | Opie::Core::OKeyPair(Qt::Key_Return,0), |
59 | this, SIGNAL(dispNext()))); | 73 | this, SIGNAL(dispNext()))); |
60 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", | 74 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", |
61 | Resource::loadPixmap("back"), ShowPrevious, | 75 | Resource::loadPixmap("back"), ShowPrevious, |
62 | Opie::Core::OKeyPair(Qt::Key_P,0), | 76 | Opie::Core::OKeyPair(Qt::Key_P,0), |
63 | this, SIGNAL(dispPrev()))); | 77 | this, SIGNAL(dispPrev()))); |
64 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", | 78 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", |
65 | Resource::loadPixmap("fullscreen"), FullScreen, | 79 | Resource::loadPixmap("fullscreen"), FullScreen, |
66 | Opie::Core::OKeyPair(Qt::Key_F,0), | 80 | Opie::Core::OKeyPair(Qt::Key_F,0), |
67 | this, SIGNAL(toggleFullScreen()))); | 81 | this, SIGNAL(toggleFullScreen()))); |
68 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", | 82 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", |
69 | Resource::loadPixmap("mag"), Zoomer, | 83 | Resource::loadPixmap("mag"), Zoomer, |
70 | Opie::Core::OKeyPair(Qt::Key_T,0), | 84 | Opie::Core::OKeyPair(Qt::Key_T,0), |
@@ -76,12 +90,42 @@ void ImageView::initKeys() | |||
76 | void ImageView::keyReleaseEvent(QKeyEvent * e) | 90 | void ImageView::keyReleaseEvent(QKeyEvent * e) |
77 | { | 91 | { |
78 | if (!e || e->state()!=0) { | 92 | if (!e || e->state()!=0) { |
79 | return; | 93 | return; |
80 | } | 94 | } |
81 | if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); | 95 | if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); |
82 | } | 96 | } |
83 | 97 | ||
84 | void ImageView::slotShowImageInfo() | 98 | void ImageView::slotShowImageInfo() |
85 | { | 99 | { |
86 | emit dispImageInfo(m_lastName); | 100 | emit dispImageInfo(m_lastName); |
87 | } | 101 | } |
102 | |||
103 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) | ||
104 | { | ||
105 | if (e->button()==1) { | ||
106 | return OImageScrollView::contentsMousePressEvent(e); | ||
107 | } | ||
108 | if (!fullScreen()) return; | ||
109 | #if 0 | ||
110 | // doesn't work right (repainting problems) | ||
111 | odebug << "Popup " << oendl; | ||
112 | QPopupMenu *m = new QPopupMenu(0); | ||
113 | if (!m) return; | ||
114 | m->insertItem(tr("Previous image"),ShowPrevious); | ||
115 | m->insertItem(tr("Next image"),ShowNext); | ||
116 | m->insertSeparator(); | ||
117 | m->insertItem(tr("Toggle fullscreen"),FullScreen); | ||
118 | m->insertItem(tr("Toggle autoscale"),Autoscale); | ||
119 | m->insertItem(tr("Toggle autorotate"),Autorotate); | ||
120 | m->insertItem(tr("Toggle thumbnail"),Zoomer); | ||
121 | m->setFocus(); | ||
122 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
123 | delete m; | ||
124 | parentWidget()->showFullScreen(); | ||
125 | #endif | ||
126 | } | ||
127 | |||
128 | void ImageView::setFullScreen(bool how) | ||
129 | { | ||
130 | m_isFullScreen = how; | ||
131 | } | ||