author | alwin <alwin> | 2004-04-23 13:22:22 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-23 13:22:22 (UTC) |
commit | da6a98dbc555018a29bf140ed8e890015240b322 (patch) (unidiff) | |
tree | 3b8b05451fcd2c653982e1cd63b92eb0fb8b9a72 | |
parent | 33666eb31ae6d35aa527cf7bf22c2c2e0dcd6824 (diff) | |
download | opie-da6a98dbc555018a29bf140ed8e890015240b322.zip opie-da6a98dbc555018a29bf140ed8e890015240b322.tar.gz opie-da6a98dbc555018a29bf140ed8e890015240b322.tar.bz2 |
ok, I think I have all tried to reduce flicker in fullscreen when opie-eye
get focus back. But as long I must repaint the fullScreenwidget my self when
taskbar comes visible I can not do anymore.
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 30 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 16 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 24 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 1 |
4 files changed, 27 insertions, 44 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 03f3c1c..b4f3110 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,168 +1,174 @@ | |||
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 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | 12 | ||
13 | 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 ) |
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 | ||
25 | ImageView::~ImageView() | 25 | ImageView::~ImageView() |
26 | { | 26 | { |
27 | odebug << "Delete Imageview" << oendl; | 27 | odebug << "Delete Imageview" << oendl; |
28 | if (m_viewManager) { | 28 | if (m_viewManager) { |
29 | delete m_viewManager; | 29 | delete m_viewManager; |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | Opie::Core::OKeyConfigManager* ImageView::manager() | 33 | Opie::Core::OKeyConfigManager* ImageView::manager() |
34 | { | 34 | { |
35 | if (!m_viewManager) { | 35 | if (!m_viewManager) { |
36 | initKeys(); | 36 | initKeys(); |
37 | } | 37 | } |
38 | return m_viewManager; | 38 | return m_viewManager; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ImageView::initKeys() | 41 | void ImageView::initKeys() |
42 | { | 42 | { |
43 | odebug << "init imageview keys" << oendl; | 43 | odebug << "init imageview keys" << oendl; |
44 | if (!m_cfg) { | 44 | if (!m_cfg) { |
45 | m_cfg = new Opie::Core::OConfig("phunkview"); | 45 | m_cfg = new Opie::Core::OConfig("phunkview"); |
46 | m_cfg->setGroup("image_view_keys" ); | 46 | m_cfg->setGroup("image_view_keys" ); |
47 | } | 47 | } |
48 | Opie::Core::OKeyPair::List lst; | 48 | Opie::Core::OKeyPair::List lst; |
49 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 49 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
50 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 50 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
51 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 51 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
52 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 52 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
53 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); | 53 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); |
54 | 54 | ||
55 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 55 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
56 | lst, false,this, "image_view_keys" ); | 56 | lst, false,this, "image_view_keys" ); |
57 | 57 | ||
58 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 58 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
59 | Resource::loadPixmap("1to1"), ViewInfo, | 59 | Resource::loadPixmap("1to1"), ViewInfo, |
60 | Opie::Core::OKeyPair(Qt::Key_I,0), | 60 | Opie::Core::OKeyPair(Qt::Key_I,0), |
61 | this, SLOT(slotShowImageInfo()))); | 61 | this, SLOT(slotShowImageInfo()))); |
62 | 62 | ||
63 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", | 63 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", |
64 | Resource::loadPixmap("rotate"), Autorotate, | 64 | Resource::loadPixmap("rotate"), Autorotate, |
65 | Opie::Core::OKeyPair(Qt::Key_R,0), | 65 | Opie::Core::OKeyPair(Qt::Key_R,0), |
66 | this, SIGNAL(toggleAutorotate()))); | 66 | this, SIGNAL(toggleAutorotate()))); |
67 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", | 67 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", |
68 | Resource::loadPixmap("1to1"), Autoscale, | 68 | Resource::loadPixmap("1to1"), Autoscale, |
69 | Opie::Core::OKeyPair(Qt::Key_S,0), | 69 | Opie::Core::OKeyPair(Qt::Key_S,0), |
70 | this, SIGNAL(toggleAutoscale()))); | 70 | this, SIGNAL(toggleAutoscale()))); |
71 | 71 | ||
72 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", | 72 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", |
73 | Resource::loadPixmap("forward"), ShowNext, | 73 | Resource::loadPixmap("forward"), ShowNext, |
74 | Opie::Core::OKeyPair(Qt::Key_Return,0), | 74 | Opie::Core::OKeyPair(Qt::Key_Return,0), |
75 | this, SIGNAL(dispNext()))); | 75 | this, SIGNAL(dispNext()))); |
76 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", | 76 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", |
77 | Resource::loadPixmap("back"), ShowPrevious, | 77 | Resource::loadPixmap("back"), ShowPrevious, |
78 | Opie::Core::OKeyPair(Qt::Key_P,0), | 78 | Opie::Core::OKeyPair(Qt::Key_P,0), |
79 | this, SIGNAL(dispPrev()))); | 79 | this, SIGNAL(dispPrev()))); |
80 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", | 80 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", |
81 | Resource::loadPixmap("fullscreen"), FullScreen, | 81 | Resource::loadPixmap("fullscreen"), FullScreen, |
82 | Opie::Core::OKeyPair(Qt::Key_F,0), | 82 | Opie::Core::OKeyPair(Qt::Key_F,0), |
83 | this, SIGNAL(toggleFullScreen()))); | 83 | this, SIGNAL(toggleFullScreen()))); |
84 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", | 84 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", |
85 | Resource::loadPixmap("mag"), Zoomer, | 85 | Resource::loadPixmap("mag"), Zoomer, |
86 | Opie::Core::OKeyPair(Qt::Key_T,0), | 86 | Opie::Core::OKeyPair(Qt::Key_T,0), |
87 | this, SIGNAL(toggleZoomer()))); | 87 | this, SIGNAL(toggleZoomer()))); |
88 | m_viewManager->handleWidget( this ); | 88 | m_viewManager->handleWidget( this ); |
89 | m_viewManager->load(); | 89 | m_viewManager->load(); |
90 | } | 90 | } |
91 | 91 | ||
92 | void ImageView::keyReleaseEvent(QKeyEvent * e) | 92 | void ImageView::keyReleaseEvent(QKeyEvent * e) |
93 | { | 93 | { |
94 | if (!e || e->state()!=0) { | 94 | if (!e || e->state()!=0) { |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); | 97 | if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); |
98 | } | 98 | } |
99 | 99 | ||
100 | void ImageView::slotShowImageInfo() | 100 | void ImageView::slotShowImageInfo() |
101 | { | 101 | { |
102 | emit dispImageInfo(m_lastName); | 102 | emit dispImageInfo(m_lastName); |
103 | } | 103 | } |
104 | 104 | ||
105 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) | 105 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) |
106 | { | 106 | { |
107 | if (e->button()==1) { | 107 | if (e->button()==1) { |
108 | return OImageScrollView::contentsMousePressEvent(e); | 108 | return OImageScrollView::contentsMousePressEvent(e); |
109 | } | 109 | } |
110 | odebug << "Popup " << oendl; | 110 | odebug << "Popup " << oendl; |
111 | QPopupMenu *m = new QPopupMenu(0); | 111 | QPopupMenu *m = new QPopupMenu(0); |
112 | if (!m) return; | 112 | if (!m) return; |
113 | bool old = fullScreen(); | ||
114 | m->insertItem(tr("Toggle fullscreen"),this, SIGNAL(toggleFullScreen())); | 113 | m->insertItem(tr("Toggle fullscreen"),this, SIGNAL(toggleFullScreen())); |
115 | if (fullScreen()) { | 114 | if (fullScreen()) { |
116 | m->insertSeparator(); | 115 | m->insertSeparator(); |
117 | m->insertItem(tr("Previous image"),this,SIGNAL(dispPrev())); | 116 | m->insertItem(tr("Previous image"),this,SIGNAL(dispPrev())); |
118 | m->insertItem(tr("Next image"),this,SIGNAL(dispNext())); | 117 | m->insertItem(tr("Next image"),this,SIGNAL(dispNext())); |
119 | m->insertSeparator(); | 118 | m->insertSeparator(); |
120 | m->insertItem(tr("Toggle autoscale"),this, SIGNAL(toggleAutoscale())); | 119 | m->insertItem(tr("Toggle autoscale"),this, SIGNAL(toggleAutoscale())); |
121 | m->insertItem(tr("Toggle autorotate"),this, SIGNAL(toggleAutorotate())); | 120 | m->insertItem(tr("Toggle autorotate"),this, SIGNAL(toggleAutorotate())); |
122 | m->insertItem(tr("Toggle thumbnail"),this, SIGNAL(toggleZoomer())); | 121 | m->insertItem(tr("Toggle thumbnail"),this, SIGNAL(toggleZoomer())); |
123 | } | 122 | } |
124 | m->setFocus(); | 123 | m->setFocus(); |
125 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 124 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
126 | delete m; | 125 | delete m; |
127 | } | 126 | } |
128 | 127 | ||
129 | void ImageView::setFullScreen(bool how) | 128 | void ImageView::setFullScreen(bool how) |
130 | { | 129 | { |
131 | m_isFullScreen = how; | 130 | m_isFullScreen = how; |
131 | if (how) { | ||
132 | m_ignore_next_in = true; | ||
133 | setFixedSize(qApp->desktop()->size()); | ||
134 | showFullScreen(); | ||
135 | } else { | ||
136 | setMinimumSize(10,10); | ||
137 | } | ||
132 | } | 138 | } |
133 | 139 | ||
134 | void ImageView::focusInEvent(QFocusEvent *) | 140 | void ImageView::focusInEvent(QFocusEvent *) |
135 | { | 141 | { |
136 | // Always do it here, no matter the size. | 142 | // Always do it here, no matter the size. |
137 | odebug << "Focus in (view)" << oendl; | 143 | odebug << "Focus in (view)" << oendl; |
138 | //if (fullScreen()) parentWidget()->showNormal(); | 144 | //if (fullScreen()) parentWidget()->showNormal(); |
139 | if (m_ignore_next_in){m_ignore_next_in=false;return;} | 145 | if (m_ignore_next_in){m_ignore_next_in=false;return;} |
140 | if (fullScreen()) enableFullscreen(); | 146 | if (fullScreen()) enableFullscreen(); |
141 | } | 147 | } |
142 | 148 | ||
149 | void ImageView::hide() | ||
150 | { | ||
151 | if (fullScreen()) { | ||
152 | m_ignore_next_in = true; | ||
153 | showNormal(); | ||
154 | } | ||
155 | QWidget::hide(); | ||
156 | } | ||
143 | void ImageView::enableFullscreen() | 157 | void ImageView::enableFullscreen() |
144 | { | 158 | { |
145 | // This call is needed because showFullScreen won't work | ||
146 | // correctly if the widget already considers itself to be fullscreen. | ||
147 | if (!fullScreen()) return; | 159 | if (!fullScreen()) return; |
148 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} | 160 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} |
149 | 161 | ||
150 | setUpdatesEnabled(false); | 162 | setUpdatesEnabled(false); |
151 | parentWidget()->showNormal(); | ||
152 | // This is needed because showNormal() forcefully changes the window | 163 | // This is needed because showNormal() forcefully changes the window |
153 | // style to WSTyle_TopLevel. | 164 | // style to WSTyle_TopLevel. |
154 | parentWidget()->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); | 165 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); |
155 | // Enable fullscreen. | 166 | // Enable fullscreen. |
156 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus | 167 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus |
157 | * so we must block it here! */ | 168 | * so we must block it here! */ |
158 | m_ignore_next_in = true; | 169 | m_ignore_next_in = true; |
159 | parentWidget()->showFullScreen(); | 170 | showFullScreen(); |
160 | setUpdatesEnabled(true); | 171 | setUpdatesEnabled(true); |
161 | } | ||
162 | 172 | ||
163 | ImageWidget::ImageWidget(QWidget * parent, const char * name, WFlags f) | ||
164 | : QWidget(parent,name,f) | ||
165 | { | ||
166 | // Make sure size is correct | ||
167 | setFixedSize(qApp->desktop()->size()); | ||
168 | } | 173 | } |
174 | |||
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index f3c37b5..18697e0 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h | |||
@@ -1,77 +1,65 @@ | |||
1 | #ifndef _IMAGE_VIEW_H | 1 | #ifndef _IMAGE_VIEW_H |
2 | #define _IMAGE_VIEW_H | 2 | #define _IMAGE_VIEW_H |
3 | 3 | ||
4 | #include <opie2/oimagescrollview.h> | 4 | #include <opie2/oimagescrollview.h> |
5 | 5 | ||
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | 7 | ||
8 | namespace Opie { | 8 | namespace Opie { |
9 | namespace Core { | 9 | namespace Core { |
10 | class OConfig; | 10 | class OConfig; |
11 | class OKeyConfigManager; | 11 | class OKeyConfigManager; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | class ImageView:public Opie::MM::OImageScrollView | 15 | class ImageView:public Opie::MM::OImageScrollView |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | enum ActionIds { | 19 | enum ActionIds { |
20 | ViewInfo, | 20 | ViewInfo, |
21 | FullScreen, | 21 | FullScreen, |
22 | ShowNext, | 22 | ShowNext, |
23 | ShowPrevious, | 23 | ShowPrevious, |
24 | Zoomer, | 24 | Zoomer, |
25 | Autorotate, | 25 | Autorotate, |
26 | Autoscale | 26 | Autoscale |
27 | }; | 27 | }; |
28 | 28 | ||
29 | public: | 29 | public: |
30 | ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); | 30 | ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); |
31 | virtual ~ImageView(); | 31 | virtual ~ImageView(); |
32 | Opie::Core::OKeyConfigManager* manager(); | 32 | Opie::Core::OKeyConfigManager* manager(); |
33 | void setFullScreen(bool how); | 33 | void setFullScreen(bool how); |
34 | bool fullScreen(){return m_isFullScreen;} | 34 | bool fullScreen(){return m_isFullScreen;} |
35 | virtual void enableFullscreen(); | 35 | virtual void enableFullscreen(); |
36 | 36 | ||
37 | signals: | 37 | signals: |
38 | void dispImageInfo(const QString&); | 38 | void dispImageInfo(const QString&); |
39 | void dispNext(); | 39 | void dispNext(); |
40 | void dispPrev(); | 40 | void dispPrev(); |
41 | void toggleFullScreen(); | 41 | void toggleFullScreen(); |
42 | void hideMe(); | 42 | void hideMe(); |
43 | void toggleZoomer(); | 43 | void toggleZoomer(); |
44 | void toggleAutoscale(); | 44 | void toggleAutoscale(); |
45 | void toggleAutorotate(); | 45 | void toggleAutorotate(); |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | Opie::Core::OConfig * m_cfg; | 48 | Opie::Core::OConfig * m_cfg; |
49 | Opie::Core::OKeyConfigManager*m_viewManager; | 49 | Opie::Core::OKeyConfigManager*m_viewManager; |
50 | void initKeys(); | 50 | void initKeys(); |
51 | bool m_isFullScreen:1; | 51 | bool m_isFullScreen:1; |
52 | bool m_ignore_next_in:1; | 52 | bool m_ignore_next_in:1; |
53 | int focus_in_count; | 53 | int focus_in_count; |
54 | virtual void focusInEvent ( QFocusEvent * ); | 54 | virtual void focusInEvent ( QFocusEvent * ); |
55 | 55 | ||
56 | public slots: | ||
57 | virtual void hide(); | ||
56 | 58 | ||
57 | protected slots: | 59 | protected slots: |
58 | virtual void slotShowImageInfo(); | 60 | virtual void slotShowImageInfo(); |
59 | virtual void keyReleaseEvent(QKeyEvent * e); | 61 | virtual void keyReleaseEvent(QKeyEvent * e); |
60 | virtual void contentsMousePressEvent ( QMouseEvent * e); | 62 | virtual void contentsMousePressEvent ( QMouseEvent * e); |
61 | }; | 63 | }; |
62 | 64 | ||
63 | class ImageWidget:public QWidget | ||
64 | { | ||
65 | Q_OBJECT | ||
66 | public: | ||
67 | ImageWidget(QWidget * parent=0, const char * name=0, WFlags f = WStyle_Customize | WStyle_NoBorder); | ||
68 | virtual ~ImageWidget(){}; | ||
69 | |||
70 | protected: | ||
71 | |||
72 | public slots: | ||
73 | |||
74 | protected slots: | ||
75 | }; | ||
76 | |||
77 | #endif | 65 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index cdaf34c..274a22a 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -1,456 +1,446 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | #include "imageview.h" | 6 | #include "imageview.h" |
7 | 7 | ||
8 | #include "iconview.h" | 8 | #include "iconview.h" |
9 | #include "filesystem.h" | 9 | #include "filesystem.h" |
10 | #include "imageinfoui.h" | 10 | #include "imageinfoui.h" |
11 | #include "viewmodebutton.h" | 11 | #include "viewmodebutton.h" |
12 | 12 | ||
13 | #include <iface/ifaceinfo.h> | 13 | #include <iface/ifaceinfo.h> |
14 | #include <iface/dirview.h> | 14 | #include <iface/dirview.h> |
15 | 15 | ||
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <opie2/owidgetstack.h> | 17 | #include <opie2/owidgetstack.h> |
18 | #include <opie2/oapplicationfactory.h> | 18 | #include <opie2/oapplicationfactory.h> |
19 | #include <opie2/otabwidget.h> | 19 | #include <opie2/otabwidget.h> |
20 | #include <opie2/okeyconfigwidget.h> | 20 | #include <opie2/okeyconfigwidget.h> |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qdialog.h> | 30 | #include <qdialog.h> |
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qframe.h> | 33 | #include <qframe.h> |
34 | 34 | ||
35 | 35 | ||
36 | |||
37 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 36 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
38 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 37 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
39 | 38 | ||
40 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
41 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
42 | { | 41 | { |
43 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
44 | m_cfg = new Opie::Core::OConfig("phunkview"); | 43 | m_cfg = new Opie::Core::OConfig("phunkview"); |
45 | m_cfg->setGroup("Zecke_view" ); | 44 | m_cfg->setGroup("Zecke_view" ); |
46 | tFrame = 0; | ||
47 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); | 45 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); |
48 | /* | 46 | /* |
49 | * Initialize ToolBar and IconView | 47 | * Initialize ToolBar and IconView |
50 | * And Connect Them | 48 | * And Connect Them |
51 | */ | 49 | */ |
52 | QToolBar *bar = new QToolBar( this ); | 50 | QToolBar *bar = new QToolBar( this ); |
53 | bar->setHorizontalStretchable( true ); | 51 | bar->setHorizontalStretchable( true ); |
54 | setToolBarsMovable( false ); | 52 | setToolBarsMovable( false ); |
55 | 53 | ||
56 | m_stack = new Opie::Ui::OWidgetStack( this ); | 54 | m_stack = new Opie::Ui::OWidgetStack( this ); |
57 | setCentralWidget( m_stack ); | 55 | setCentralWidget( m_stack ); |
58 | 56 | ||
59 | m_view = new PIconView( m_stack, m_cfg ); | 57 | m_view = new PIconView( m_stack, m_cfg ); |
60 | m_stack->addWidget( m_view, IconView ); | 58 | m_stack->addWidget( m_view, IconView ); |
61 | m_stack->raiseWidget( IconView ); | 59 | m_stack->raiseWidget( IconView ); |
62 | connect(m_view, SIGNAL(sig_display(const QString&)), | 60 | connect(m_view, SIGNAL(sig_display(const QString&)), |
63 | this, SLOT(slotDisplay(const QString&))); | 61 | this, SLOT(slotDisplay(const QString&))); |
64 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
65 | this, SLOT(slotShowInfo(const QString&)) ); | 63 | this, SLOT(slotShowInfo(const QString&)) ); |
66 | 64 | ||
67 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 65 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
68 | 66 | ||
69 | upButton = new QToolButton( bar ); | 67 | upButton = new QToolButton( bar ); |
70 | upButton->setIconSet( Resource::loadIconSet( "up" ) ); | 68 | upButton->setIconSet( Resource::loadIconSet( "up" ) ); |
71 | connect( upButton, SIGNAL(clicked()), | 69 | connect( upButton, SIGNAL(clicked()), |
72 | m_view, SLOT(slotDirUp()) ); | 70 | m_view, SLOT(slotDirUp()) ); |
73 | 71 | ||
74 | fsButton = new PFileSystem( bar ); | 72 | fsButton = new PFileSystem( bar ); |
75 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 73 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
76 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 74 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
77 | 75 | ||
78 | QToolButton*btn = new QToolButton( bar ); | 76 | QToolButton*btn = new QToolButton( bar ); |
79 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); | 77 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); |
80 | connect( btn, SIGNAL(clicked()), | 78 | connect( btn, SIGNAL(clicked()), |
81 | m_view, SLOT(slotRename()) ); | 79 | m_view, SLOT(slotRename()) ); |
82 | 80 | ||
83 | if ( Ir::supported() ) { | 81 | if ( Ir::supported() ) { |
84 | btn = new QToolButton( bar ); | 82 | btn = new QToolButton( bar ); |
85 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); | 83 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); |
86 | connect( btn, SIGNAL(clicked()), | 84 | connect( btn, SIGNAL(clicked()), |
87 | m_view, SLOT(slotBeam()) ); | 85 | m_view, SLOT(slotBeam()) ); |
88 | } | 86 | } |
89 | 87 | ||
90 | btn = new QToolButton( bar ); | 88 | btn = new QToolButton( bar ); |
91 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 89 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
92 | connect( btn, SIGNAL(clicked() ), | 90 | connect( btn, SIGNAL(clicked() ), |
93 | m_view, SLOT(slotTrash() ) ); | 91 | m_view, SLOT(slotTrash() ) ); |
94 | 92 | ||
95 | 93 | ||
96 | int mode = m_cfg->readNumEntry("ListViewMode", 1); | 94 | int mode = m_cfg->readNumEntry("ListViewMode", 1); |
97 | if (mode < 1 || mode>3) mode = 1; | 95 | if (mode < 1 || mode>3) mode = 1; |
98 | viewModeButton = new ViewModeButton( bar,mode ); | 96 | viewModeButton = new ViewModeButton( bar,mode ); |
99 | connect( viewModeButton, SIGNAL(changeMode(int)), | 97 | connect( viewModeButton, SIGNAL(changeMode(int)), |
100 | m_view, SLOT(slotChangeMode(int))); | 98 | m_view, SLOT(slotChangeMode(int))); |
101 | 99 | ||
102 | btn = new QToolButton( bar ); | 100 | btn = new QToolButton( bar ); |
103 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 101 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
104 | connect( btn, SIGNAL(clicked() ), | 102 | connect( btn, SIGNAL(clicked() ), |
105 | this, SLOT(slotConfig() ) ); | 103 | this, SLOT(slotConfig() ) ); |
106 | 104 | ||
107 | 105 | ||
108 | 106 | ||
109 | prevButton = new QToolButton(bar); | 107 | prevButton = new QToolButton(bar); |
110 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); | 108 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); |
111 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); | 109 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); |
112 | 110 | ||
113 | nextButton = new QToolButton(bar); | 111 | nextButton = new QToolButton(bar); |
114 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); | 112 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); |
115 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); | 113 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); |
116 | 114 | ||
117 | rotateButton = new QToolButton(bar); | 115 | rotateButton = new QToolButton(bar); |
118 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | 116 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); |
119 | rotateButton->setToggleButton(true); | 117 | rotateButton->setToggleButton(true); |
120 | 118 | ||
121 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 119 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
122 | rotateButton->setOn(true); | 120 | rotateButton->setOn(true); |
123 | autoRotate = true; | 121 | autoRotate = true; |
124 | prevButton->hide(); | 122 | prevButton->hide(); |
125 | nextButton->hide(); | 123 | nextButton->hide(); |
126 | } else { | 124 | } else { |
127 | rotateButton->setOn(false); | 125 | rotateButton->setOn(false); |
128 | autoRotate = false; | 126 | autoRotate = false; |
129 | } | 127 | } |
130 | 128 | ||
131 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 129 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
132 | 130 | ||
133 | scaleButton = new QToolButton(bar); | 131 | scaleButton = new QToolButton(bar); |
134 | scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); | 132 | scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); |
135 | scaleButton->setToggleButton(true); | 133 | scaleButton->setToggleButton(true); |
136 | scaleButton->setOn(false); | 134 | scaleButton->setOn(false); |
137 | connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 135 | connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
138 | autoScale = true; | 136 | autoScale = true; |
139 | 137 | ||
140 | zoomButton = new QToolButton(bar); | 138 | zoomButton = new QToolButton(bar); |
141 | zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); | 139 | zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); |
142 | zoomButton->setToggleButton(true); | 140 | zoomButton->setToggleButton(true); |
143 | zoomButton->setOn(true); | 141 | zoomButton->setOn(true); |
144 | connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 142 | connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
145 | zoomerOn = true; | 143 | zoomerOn = true; |
146 | } | 144 | } |
147 | 145 | ||
148 | PMainWindow::~PMainWindow() { | 146 | PMainWindow::~PMainWindow() { |
149 | odebug << "Shutting down" << oendl; | ||
150 | if (tFrame) delete tFrame; | ||
151 | odebug << "Shutting down done" << oendl; | ||
152 | } | 147 | } |
153 | 148 | ||
154 | void PMainWindow::slotToggleZoomer() | 149 | void PMainWindow::slotToggleZoomer() |
155 | { | 150 | { |
156 | if (!m_disp) return; | 151 | if (!m_disp) return; |
157 | bool cur = zoomButton->isOn(); | 152 | bool cur = zoomButton->isOn(); |
158 | zoomButton->setOn(!cur); | 153 | zoomButton->setOn(!cur); |
159 | } | 154 | } |
160 | 155 | ||
161 | void PMainWindow::slotZoomerToggled(bool how) | 156 | void PMainWindow::slotZoomerToggled(bool how) |
162 | { | 157 | { |
163 | zoomerOn = how; | 158 | zoomerOn = how; |
164 | if (m_disp) { | 159 | if (m_disp) { |
165 | m_disp->setShowZoomer(zoomerOn); | 160 | m_disp->setShowZoomer(zoomerOn); |
166 | } | 161 | } |
167 | } | 162 | } |
168 | 163 | ||
169 | void PMainWindow::slotToggleAutorotate() | 164 | void PMainWindow::slotToggleAutorotate() |
170 | { | 165 | { |
171 | if (!m_disp) return; | 166 | if (!m_disp) return; |
172 | if (!rotateButton->isEnabled()) return; | 167 | if (!rotateButton->isEnabled()) return; |
173 | bool cur = rotateButton->isOn(); | 168 | bool cur = rotateButton->isOn(); |
174 | rotateButton->setOn(!cur); | 169 | rotateButton->setOn(!cur); |
175 | } | 170 | } |
176 | 171 | ||
177 | void PMainWindow::slotToggleAutoscale() | 172 | void PMainWindow::slotToggleAutoscale() |
178 | { | 173 | { |
179 | if (!m_disp) return; | 174 | if (!m_disp) return; |
180 | bool cur = scaleButton->isOn(); | 175 | bool cur = scaleButton->isOn(); |
181 | scaleButton->setOn(!cur); | 176 | scaleButton->setOn(!cur); |
182 | } | 177 | } |
183 | 178 | ||
184 | void PMainWindow::slotRotateToggled(bool how) | 179 | void PMainWindow::slotRotateToggled(bool how) |
185 | { | 180 | { |
186 | autoRotate = how; | 181 | autoRotate = how; |
187 | if (m_disp) { | 182 | if (m_disp) { |
188 | m_disp->setAutoRotate(how); | 183 | m_disp->setAutoRotate(how); |
189 | } | 184 | } |
190 | } | 185 | } |
191 | 186 | ||
192 | void PMainWindow::slotScaleToggled(bool how) | 187 | void PMainWindow::slotScaleToggled(bool how) |
193 | { | 188 | { |
194 | autoScale = !how; | 189 | autoScale = !how; |
195 | if (!how) { | 190 | if (!how) { |
196 | autoRotate = how; | 191 | autoRotate = how; |
197 | } | 192 | } |
198 | if (m_disp) { | 193 | if (m_disp) { |
199 | m_disp->setAutoScaleRotate(autoScale,autoRotate); | 194 | m_disp->setAutoScaleRotate(autoScale,autoRotate); |
200 | } | 195 | } |
201 | if (!autoScale) { | 196 | if (!autoScale) { |
202 | rotateButton->setOn(false); | 197 | rotateButton->setOn(false); |
203 | } | 198 | } |
204 | rotateButton->setEnabled(!how); | 199 | rotateButton->setEnabled(!how); |
205 | } | 200 | } |
206 | 201 | ||
207 | void PMainWindow::slotConfig() { | 202 | void PMainWindow::slotConfig() { |
208 | /* | 203 | /* |
209 | * have a tab with the possible views | 204 | * have a tab with the possible views |
210 | * a tab for globals image cache size.. scaled loading | 205 | * a tab for globals image cache size.. scaled loading |
211 | * and one tab for the KeyConfigs | 206 | * and one tab for the KeyConfigs |
212 | */ | 207 | */ |
213 | QDialog dlg(this, 0, true); | 208 | QDialog dlg(this, 0, true); |
214 | dlg.setCaption( tr("Phunk View - Config" ) ); | 209 | dlg.setCaption( tr("Phunk View - Config" ) ); |
215 | 210 | ||
216 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 211 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
217 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 212 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
218 | lay->addWidget( wid ); | 213 | lay->addWidget( wid ); |
219 | ViewMap *vM = viewMap(); | 214 | ViewMap *vM = viewMap(); |
220 | ViewMap::Iterator _it = vM->begin(); | 215 | ViewMap::Iterator _it = vM->begin(); |
221 | QMap<PDirView*, QWidget*> lst; | 216 | QMap<PDirView*, QWidget*> lst; |
222 | 217 | ||
223 | for( ; _it != vM->end(); ++_it ) { | 218 | for( ; _it != vM->end(); ++_it ) { |
224 | PDirView *view = (_it.data())(*m_cfg); | 219 | PDirView *view = (_it.data())(*m_cfg); |
225 | PInterfaceInfo *inf = view->interfaceInfo(); | 220 | PInterfaceInfo *inf = view->interfaceInfo(); |
226 | QWidget *_wid = inf->configWidget( *m_cfg ); | 221 | QWidget *_wid = inf->configWidget( *m_cfg ); |
227 | if (!_wid) continue; | 222 | if (!_wid) continue; |
228 | _wid->reparent(wid, QPoint() ); | 223 | _wid->reparent(wid, QPoint() ); |
229 | lst.insert( view, _wid ); | 224 | lst.insert( view, _wid ); |
230 | wid->addTab( _wid, "fileopen", inf->name() ); | 225 | wid->addTab( _wid, "fileopen", inf->name() ); |
231 | } | 226 | } |
232 | 227 | ||
233 | /* | 228 | /* |
234 | * Add the KeyConfigWidget | 229 | * Add the KeyConfigWidget |
235 | */ | 230 | */ |
236 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 231 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
237 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 232 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
238 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 233 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
239 | 234 | ||
240 | if ( !m_info ) { | 235 | if ( !m_info ) { |
241 | initInfo(); | 236 | initInfo(); |
242 | } | 237 | } |
243 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 238 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
244 | 239 | ||
245 | if ( !m_disp ) { | 240 | if ( !m_disp ) { |
246 | initDisp(); | 241 | initDisp(); |
247 | } | 242 | } |
248 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 243 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
249 | 244 | ||
250 | keyWid->load(); | 245 | keyWid->load(); |
251 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 246 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
252 | 247 | ||
253 | 248 | ||
254 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 249 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
255 | 250 | ||
256 | /* | 251 | /* |
257 | * clean up | 252 | * clean up |
258 | *apply changes | 253 | *apply changes |
259 | */ | 254 | */ |
260 | 255 | ||
261 | QMap<PDirView*, QWidget*>::Iterator it; | 256 | QMap<PDirView*, QWidget*>::Iterator it; |
262 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 257 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
263 | if ( act ) | 258 | if ( act ) |
264 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 259 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
265 | delete it.key(); | 260 | delete it.key(); |
266 | } | 261 | } |
267 | 262 | ||
268 | 263 | ||
269 | if ( act ) { | 264 | if ( act ) { |
270 | m_view->resetView(); | 265 | m_view->resetView(); |
271 | keyWid->save(); | 266 | keyWid->save(); |
272 | m_disp->manager()->save(); | 267 | m_disp->manager()->save(); |
273 | m_info->manager()->save(); | 268 | m_info->manager()->save(); |
274 | m_view->manager()->save(); | 269 | m_view->manager()->save(); |
275 | } | 270 | } |
276 | delete keyWid; | 271 | delete keyWid; |
277 | } | 272 | } |
278 | 273 | ||
279 | /* | 274 | /* |
280 | * create a new image info component | 275 | * create a new image info component |
281 | * and detach the current one | 276 | * and detach the current one |
282 | * we will make the other delete on exit | 277 | * we will make the other delete on exit |
283 | */ | 278 | */ |
284 | template<class T> | 279 | template<class T> |
285 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 280 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
286 | if ( *ptr ) { | 281 | if ( *ptr ) { |
287 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 282 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
288 | (*ptr)->setDestructiveClose(); | 283 | (*ptr)->setDestructiveClose(); |
289 | m_stack->removeWidget( *ptr ); | 284 | m_stack->removeWidget( *ptr ); |
290 | } | 285 | } |
291 | *ptr = new T(m_cfg, m_stack, name ); | 286 | *ptr = new T(m_cfg, m_stack, name ); |
292 | m_stack->addWidget( *ptr, id ); | 287 | m_stack->addWidget( *ptr, id ); |
293 | 288 | ||
294 | connect(*ptr, SIGNAL(sig_return()), | 289 | connect(*ptr, SIGNAL(sig_return()), |
295 | this,SLOT(slotReturn())); | 290 | this,SLOT(slotReturn())); |
296 | 291 | ||
297 | } | 292 | } |
298 | void PMainWindow::initInfo() { | 293 | void PMainWindow::initInfo() { |
299 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 294 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
300 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 295 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
301 | } | 296 | } |
302 | void PMainWindow::initDisp() { | 297 | void PMainWindow::initDisp() { |
303 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 298 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
304 | if (m_disp) { | 299 | if (m_disp) { |
305 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 300 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
306 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 301 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
307 | } | 302 | } |
308 | m_disp->setAutoScale(autoScale); | 303 | m_disp->setAutoScale(autoScale); |
309 | m_disp->setAutoRotate(autoRotate); | 304 | m_disp->setAutoRotate(autoRotate); |
310 | m_disp->setShowZoomer(zoomerOn); | 305 | m_disp->setShowZoomer(zoomerOn); |
311 | m_disp->setBackgroundColor(white); | 306 | m_disp->setBackgroundColor(white); |
312 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 307 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
313 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 308 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
314 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 309 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
315 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); | 310 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); |
316 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 311 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
317 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 312 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
318 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | 313 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); |
319 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | 314 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); |
320 | } | 315 | } |
321 | } | 316 | } |
322 | 317 | ||
323 | void PMainWindow::slotToggleFullScreen() | 318 | void PMainWindow::slotToggleFullScreen() |
324 | { | 319 | { |
325 | odebug << "Toggle full " << oendl; | 320 | odebug << "Toggle full " << oendl; |
326 | if (!m_disp) return; | 321 | if (!m_disp) return; |
327 | bool current = !m_disp->fullScreen(); | 322 | bool current = !m_disp->fullScreen(); |
328 | m_disp->setFullScreen(current); | ||
329 | odebug << "Current = " << current << oendl; | 323 | odebug << "Current = " << current << oendl; |
330 | if (current) { | 324 | if (current) { |
331 | odebug << "full" << oendl; | 325 | odebug << "full" << oendl; |
332 | m_disp->setBackgroundColor(black); | 326 | m_disp->setBackgroundColor(black); |
333 | if (!tFrame) { | 327 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); |
334 | tFrame = new ImageWidget(0,0,WStyle_Customize|WStyle_NoBorder); | ||
335 | tFrame->resize(qApp->desktop()->width(), qApp->desktop()->height()); | ||
336 | tFrame->setMinimumSize(qApp->desktop()->width(), qApp->desktop()->height()); | ||
337 | } | ||
338 | m_disp->reparent(tFrame,QPoint(0,0)); | ||
339 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); | 328 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); |
340 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); | 329 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); |
341 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 330 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
342 | tFrame->showFullScreen(); | 331 | //m_disp->showFullScreen(); |
332 | //qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | ||
343 | } else { | 333 | } else { |
344 | setUpdatesEnabled(false); | 334 | setUpdatesEnabled(false); |
345 | odebug << "window" << oendl; | 335 | odebug << "window" << oendl; |
346 | m_disp->reparent(0,QPoint(0,0)); | 336 | m_disp->reparent(0,QPoint(0,0)); |
347 | m_disp->showNormal(); | 337 | m_disp->showNormal(); |
348 | /* don't forget it! */ | ||
349 | tFrame->hide(); | ||
350 | m_disp->setBackgroundColor(white); | 338 | m_disp->setBackgroundColor(white); |
351 | m_stack->addWidget(m_disp,ImageDisplay); | 339 | m_stack->addWidget(m_disp,ImageDisplay); |
352 | m_disp->setVScrollBarMode(QScrollView::Auto); | 340 | m_disp->setVScrollBarMode(QScrollView::Auto); |
353 | m_disp->setHScrollBarMode(QScrollView::Auto); | 341 | m_disp->setHScrollBarMode(QScrollView::Auto); |
354 | m_stack->raiseWidget(m_disp); | 342 | m_stack->raiseWidget(m_disp); |
355 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 343 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
356 | m_disp->resize(m_disp->minimumSize()); | 344 | m_disp->resize(m_disp->minimumSize()); |
357 | } | 345 | } |
358 | setUpdatesEnabled(true); | 346 | setUpdatesEnabled(true); |
359 | } | 347 | } |
348 | m_disp->setFullScreen(current); | ||
360 | } | 349 | } |
361 | 350 | ||
362 | /** | 351 | /** |
363 | * With big Screen the plan could be to 'detach' the image | 352 | * With big Screen the plan could be to 'detach' the image |
364 | * window if visible and to create a ne wone | 353 | * window if visible and to create a ne wone |
365 | * init* already supports it but I make no use of it for | 354 | * init* already supports it but I make no use of it for |
366 | * now. We set filename and raise | 355 | * now. We set filename and raise |
367 | * | 356 | * |
368 | * ### FIXME and talk to alwin | 357 | * ### FIXME and talk to alwin |
369 | */ | 358 | */ |
370 | void PMainWindow::slotShowInfo( const QString& inf ) { | 359 | void PMainWindow::slotShowInfo( const QString& inf ) { |
371 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 360 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
372 | return; | 361 | return; |
373 | } | 362 | } |
374 | if ( !m_info ) { | 363 | if ( !m_info ) { |
375 | initInfo(); | 364 | initInfo(); |
376 | } | 365 | } |
377 | m_info->setPath( inf ); | 366 | m_info->setPath( inf ); |
378 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 367 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
379 | prevButton->hide(); | 368 | prevButton->hide(); |
380 | nextButton->hide(); | 369 | nextButton->hide(); |
381 | upButton->hide(); | 370 | upButton->hide(); |
382 | fsButton->hide(); | 371 | fsButton->hide(); |
383 | viewModeButton->hide(); | 372 | viewModeButton->hide(); |
384 | } | 373 | } |
385 | m_stack->raiseWidget( ImageInfo ); | 374 | m_stack->raiseWidget( ImageInfo ); |
386 | } | 375 | } |
387 | 376 | ||
388 | void PMainWindow::slotDisplay( const QString& inf ) { | 377 | void PMainWindow::slotDisplay( const QString& inf ) { |
389 | if ( !m_disp ) { | 378 | if ( !m_disp ) { |
390 | initDisp(); | 379 | initDisp(); |
391 | } | 380 | } |
392 | m_disp->setImage( inf ); | 381 | m_disp->setImage( inf ); |
393 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 382 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
394 | prevButton->show(); | 383 | prevButton->show(); |
395 | nextButton->show(); | 384 | nextButton->show(); |
396 | upButton->hide(); | 385 | upButton->hide(); |
397 | fsButton->hide(); | 386 | fsButton->hide(); |
398 | viewModeButton->hide(); | 387 | viewModeButton->hide(); |
399 | } | 388 | } |
400 | if (m_disp->fullScreen()) { | 389 | if (m_disp->fullScreen()) { |
401 | tFrame->show();//FullScreen(); | 390 | //m_disp->showFullScreen(); |
391 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | ||
402 | } else { | 392 | } else { |
403 | m_stack->raiseWidget( ImageDisplay ); | 393 | m_stack->raiseWidget( ImageDisplay ); |
404 | } | 394 | } |
405 | } | 395 | } |
406 | 396 | ||
407 | void PMainWindow::slotReturn() { | 397 | void PMainWindow::slotReturn() { |
408 | raiseIconView(); | 398 | raiseIconView(); |
409 | } | 399 | } |
410 | 400 | ||
411 | 401 | ||
412 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 402 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
413 | /* | 403 | /* |
414 | * return from view | 404 | * return from view |
415 | * or properly quit | 405 | * or properly quit |
416 | */ | 406 | */ |
417 | if ( m_stack->visibleWidget() == m_info || | 407 | if ( m_stack->visibleWidget() == m_info || |
418 | m_stack->visibleWidget() == m_disp ) { | 408 | m_stack->visibleWidget() == m_disp ) { |
419 | ev->ignore(); | 409 | ev->ignore(); |
420 | raiseIconView(); | 410 | raiseIconView(); |
421 | return; | 411 | return; |
422 | } | 412 | } |
423 | if (m_disp && m_disp->fullScreen()) { | 413 | if (m_disp && m_disp->fullScreen()) { |
424 | /* otherwise opie-eye crashes in bigscreen mode! */ | 414 | /* otherwise opie-eye crashes in bigscreen mode! */ |
425 | m_disp->reparent(0,QPoint(0,0)); | 415 | m_disp->reparent(0,QPoint(0,0)); |
426 | m_stack->addWidget(m_disp,ImageDisplay); | 416 | m_stack->addWidget(m_disp,ImageDisplay); |
427 | } | 417 | } |
428 | ev->accept(); | 418 | ev->accept(); |
429 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 419 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
430 | } | 420 | } |
431 | 421 | ||
432 | void PMainWindow::raiseIconView() { | 422 | void PMainWindow::raiseIconView() { |
433 | setUpdatesEnabled(false); | 423 | setUpdatesEnabled(false); |
434 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 424 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
435 | prevButton->hide(); | 425 | prevButton->hide(); |
436 | nextButton->hide(); | 426 | nextButton->hide(); |
437 | upButton->show(); | 427 | upButton->show(); |
438 | fsButton->show(); | 428 | fsButton->show(); |
439 | viewModeButton->show(); | 429 | viewModeButton->show(); |
440 | } | 430 | } |
441 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 431 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
442 | tFrame->hide(); | 432 | m_disp->hide(); |
443 | } | 433 | } |
444 | m_stack->raiseWidget( IconView ); | 434 | m_stack->raiseWidget( IconView ); |
445 | setUpdatesEnabled(true); | 435 | setUpdatesEnabled(true); |
446 | repaint(); | 436 | repaint(); |
447 | } | 437 | } |
448 | 438 | ||
449 | void PMainWindow::setDocument( const QString& showImg ) { | 439 | void PMainWindow::setDocument( const QString& showImg ) { |
450 | QString file = showImg; | 440 | QString file = showImg; |
451 | DocLnk lnk(showImg); | 441 | DocLnk lnk(showImg); |
452 | if (lnk.isValid() ) | 442 | if (lnk.isValid() ) |
453 | file = lnk.file(); | 443 | file = lnk.file(); |
454 | 444 | ||
455 | slotDisplay( file ); | 445 | slotDisplay( file ); |
456 | } | 446 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 9e94c60..6fa1ab6 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h | |||
@@ -1,79 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_MAIN_WINDOW_H | 6 | #ifndef PHUNK_MAIN_WINDOW_H |
7 | #define PHUNK_MAIN_WINDOW_H | 7 | #define PHUNK_MAIN_WINDOW_H |
8 | 8 | ||
9 | #include <opie2/oconfig.h> | 9 | #include <opie2/oconfig.h> |
10 | 10 | ||
11 | #include <qmainwindow.h> | 11 | #include <qmainwindow.h> |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | namespace Opie { | 15 | namespace Opie { |
16 | namespace Ui{ | 16 | namespace Ui{ |
17 | class OWidgetStack; | 17 | class OWidgetStack; |
18 | } | 18 | } |
19 | namespace Core{ | 19 | namespace Core{ |
20 | class OKeyConfigManager; | 20 | class OKeyConfigManager; |
21 | } | 21 | } |
22 | } | 22 | } |
23 | 23 | ||
24 | class ImageView; | 24 | class ImageView; |
25 | class ImageWidget; | 25 | class ImageWidget; |
26 | class PIconView; | 26 | class PIconView; |
27 | class imageinfo; | 27 | class imageinfo; |
28 | 28 | ||
29 | class PMainWindow : public QMainWindow { | 29 | class PMainWindow : public QMainWindow { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | enum Views { IconView, ImageInfo, ImageDisplay }; | 31 | enum Views { IconView, ImageInfo, ImageDisplay }; |
32 | public: | 32 | public: |
33 | static QString appName() { return QString::fromLatin1("opie-eye" ); } | 33 | static QString appName() { return QString::fromLatin1("opie-eye" ); } |
34 | PMainWindow(QWidget*, const char*, WFlags ); | 34 | PMainWindow(QWidget*, const char*, WFlags ); |
35 | ~PMainWindow(); | 35 | ~PMainWindow(); |
36 | 36 | ||
37 | signals: | 37 | signals: |
38 | void configChanged(); | 38 | void configChanged(); |
39 | 39 | ||
40 | public slots: | 40 | public slots: |
41 | void slotShowInfo( const QString& inf ); | 41 | void slotShowInfo( const QString& inf ); |
42 | void slotDisplay( const QString& inf ); | 42 | void slotDisplay( const QString& inf ); |
43 | void slotReturn(); | 43 | void slotReturn(); |
44 | void slotRotateToggled(bool); | 44 | void slotRotateToggled(bool); |
45 | void slotScaleToggled(bool); | 45 | void slotScaleToggled(bool); |
46 | void slotZoomerToggled(bool); | 46 | void slotZoomerToggled(bool); |
47 | void slotToggleZoomer(); | 47 | void slotToggleZoomer(); |
48 | void slotToggleAutorotate(); | 48 | void slotToggleAutorotate(); |
49 | void slotToggleAutoscale(); | 49 | void slotToggleAutoscale(); |
50 | void setDocument( const QString& ); | 50 | void setDocument( const QString& ); |
51 | virtual void slotToggleFullScreen(); | 51 | virtual void slotToggleFullScreen(); |
52 | 52 | ||
53 | protected slots: | 53 | protected slots: |
54 | void raiseIconView(); | 54 | void raiseIconView(); |
55 | void closeEvent( QCloseEvent* ); | 55 | void closeEvent( QCloseEvent* ); |
56 | 56 | ||
57 | private: | 57 | private: |
58 | template<class T> void initT( const char* name, T**, int ); | 58 | template<class T> void initT( const char* name, T**, int ); |
59 | void initInfo(); | 59 | void initInfo(); |
60 | void initDisp(); | 60 | void initDisp(); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | Opie::Core::OConfig *m_cfg; | 63 | Opie::Core::OConfig *m_cfg; |
64 | Opie::Ui::OWidgetStack *m_stack; | 64 | Opie::Ui::OWidgetStack *m_stack; |
65 | PIconView* m_view; | 65 | PIconView* m_view; |
66 | imageinfo *m_info; | 66 | imageinfo *m_info; |
67 | ImageView *m_disp; | 67 | ImageView *m_disp; |
68 | bool autoRotate; | 68 | bool autoRotate; |
69 | bool autoScale; | 69 | bool autoScale; |
70 | bool zoomerOn; | 70 | bool zoomerOn; |
71 | ImageWidget*tFrame; | ||
72 | QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton; | 71 | QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton; |
73 | QToolButton*nextButton,*prevButton,*zoomButton,*scaleButton; | 72 | QToolButton*nextButton,*prevButton,*zoomButton,*scaleButton; |
74 | 73 | ||
75 | private slots: | 74 | private slots: |
76 | void slotConfig(); | 75 | void slotConfig(); |
77 | }; | 76 | }; |
78 | 77 | ||
79 | #endif | 78 | #endif |