author | alwin <alwin> | 2005-03-02 12:05:55 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-02 12:05:55 (UTC) |
commit | b9d921e98946ee787ec995f44eb1b937d669b430 (patch) (unidiff) | |
tree | 7136aa32ca3d90c0b03ec21f855f32b7536eb339 | |
parent | 374cb9f45664c307ab7d0ed88fea5e76631518d9 (diff) | |
download | opie-b9d921e98946ee787ec995f44eb1b937d669b430.zip opie-b9d921e98946ee787ec995f44eb1b937d669b430.tar.gz opie-b9d921e98946ee787ec995f44eb1b937d669b430.tar.bz2 |
fixed some problems in bigscreen mode and when rotating
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 37 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 22 |
3 files changed, 55 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index ac6474c..03df321 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,255 +1,286 @@ | |||
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 <qpe/qcopenvelope_qws.h> | ||
10 | |||
9 | #include <qpopupmenu.h> | 11 | #include <qpopupmenu.h> |
10 | #include <qtimer.h> | 12 | #include <qtimer.h> |
11 | #include <qaction.h> | 13 | #include <qaction.h> |
12 | 14 | ||
13 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
14 | 16 | ||
15 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 17 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
16 | : Opie::MM::OImageScrollView(parent,name,fl) | 18 | : Opie::MM::OImageScrollView(parent,name,fl) |
17 | { | 19 | { |
18 | m_viewManager = 0; | 20 | m_viewManager = 0; |
19 | focus_in_count = 0; | 21 | focus_in_count = 0; |
20 | m_cfg = cfg; | 22 | m_cfg = cfg; |
21 | m_isFullScreen = false; | 23 | m_isFullScreen = false; |
22 | m_ignore_next_in = false; | 24 | m_ignore_next_in = false; |
23 | m_slideTimer = 0; | 25 | m_slideTimer = 0; |
24 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); | 26 | QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); |
25 | initKeys(); | 27 | initKeys(); |
26 | m_slideValue = 5; | 28 | m_slideValue = 5; |
27 | m_gDisplayType = 0; | 29 | m_gDisplayType = 0; |
28 | m_gPrevNext = 0; | 30 | m_gPrevNext = 0; |
29 | m_hGroup = 0; | 31 | m_hGroup = 0; |
32 | m_Rotated = false; | ||
30 | closeIfHide = false; | 33 | closeIfHide = false; |
34 | int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? | ||
35 | QApplication::desktop()->size().height():QApplication::desktop()->size().width(); | ||
36 | if (min>320) { | ||
37 | // bigscreen | ||
38 | setMinimumSize(min/3,min/3); | ||
39 | } else { | ||
40 | setMinimumSize(10,10); | ||
41 | } | ||
42 | m_sysChannel = new QCopChannel( "QPE/System", this ); | ||
43 | connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | ||
44 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | ||
45 | } | ||
46 | |||
47 | void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) | ||
48 | { | ||
49 | int _newrotation; | ||
50 | QDataStream stream( data, IO_ReadOnly ); | ||
51 | odebug << "received system message: " << msg << oendl; | ||
52 | if ( msg == "setCurrentRotation(int)" ) | ||
53 | { | ||
54 | stream >> _newrotation; | ||
55 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; | ||
56 | if (!fullScreen()) { | ||
57 | m_rotation = _newrotation; | ||
58 | return; | ||
59 | } | ||
60 | } | ||
31 | } | 61 | } |
32 | 62 | ||
33 | void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) | 63 | void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) |
34 | { | 64 | { |
35 | m_gDisplayType = disptypeGroup; | 65 | m_gDisplayType = disptypeGroup; |
36 | m_gPrevNext = nextprevGroup; | 66 | m_gPrevNext = nextprevGroup; |
37 | m_hGroup = hGroup; | 67 | m_hGroup = hGroup; |
38 | } | 68 | } |
39 | 69 | ||
40 | ImageView::~ImageView() | 70 | ImageView::~ImageView() |
41 | { | 71 | { |
42 | odebug << "Destructor imageview" << oendl; | 72 | odebug << "Destructor imageview" << oendl; |
43 | delete m_viewManager; | 73 | delete m_viewManager; |
44 | } | 74 | } |
45 | 75 | ||
46 | Opie::Core::OKeyConfigManager* ImageView::manager() | 76 | Opie::Core::OKeyConfigManager* ImageView::manager() |
47 | { | 77 | { |
48 | if (!m_viewManager) { | 78 | if (!m_viewManager) { |
49 | initKeys(); | 79 | initKeys(); |
50 | } | 80 | } |
51 | return m_viewManager; | 81 | return m_viewManager; |
52 | } | 82 | } |
53 | 83 | ||
54 | void ImageView::startSlide(int value) | 84 | void ImageView::startSlide(int value) |
55 | { | 85 | { |
56 | if (!m_slideTimer) { | 86 | if (!m_slideTimer) { |
57 | m_slideTimer = new QTimer(this); | 87 | m_slideTimer = new QTimer(this); |
58 | } | 88 | } |
59 | m_slideValue=value; | 89 | m_slideValue=value; |
60 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); | 90 | connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); |
61 | /* this "+1" is one millisecond. with that we can setup a slideshowvalue | 91 | /* this "+1" is one millisecond. with that we can setup a slideshowvalue |
62 | of 0. eg "as fast as possible". | 92 | of 0. eg "as fast as possible". |
63 | */ | 93 | */ |
64 | m_slideTimer->start(m_slideValue*1000+1,true); | 94 | m_slideTimer->start(m_slideValue*1000+1,true); |
65 | } | 95 | } |
66 | 96 | ||
67 | void ImageView::stopSlide() | 97 | void ImageView::stopSlide() |
68 | { | 98 | { |
69 | if (!m_slideTimer) { | 99 | if (!m_slideTimer) { |
70 | return; | 100 | return; |
71 | } | 101 | } |
72 | m_slideTimer->stop(); | 102 | m_slideTimer->stop(); |
73 | delete m_slideTimer; | 103 | delete m_slideTimer; |
74 | m_slideTimer = 0; | 104 | m_slideTimer = 0; |
75 | } | 105 | } |
76 | 106 | ||
77 | void ImageView::nextSlide() | 107 | void ImageView::nextSlide() |
78 | { | 108 | { |
79 | if (!m_slideTimer) { | 109 | if (!m_slideTimer) { |
80 | return; | 110 | return; |
81 | } | 111 | } |
82 | #if 0 | 112 | #if 0 |
83 | if (isHidden()) { | 113 | if (isHidden()) { |
84 | delete m_slideTimer; | 114 | delete m_slideTimer; |
85 | m_slideTimer = 0; | 115 | m_slideTimer = 0; |
86 | return; | 116 | return; |
87 | } | 117 | } |
88 | #endif | 118 | #endif |
89 | emit dispNext(); | 119 | emit dispNext(); |
90 | m_slideTimer->start(m_slideValue*1000,true); | 120 | m_slideTimer->start(m_slideValue*1000,true); |
91 | } | 121 | } |
92 | void ImageView::initKeys() | 122 | void ImageView::initKeys() |
93 | { | 123 | { |
94 | odebug << "init imageview keys" << oendl; | 124 | odebug << "init imageview keys" << oendl; |
95 | if (!m_cfg) { | 125 | if (!m_cfg) { |
96 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 126 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
97 | m_cfg->setGroup("image_view_keys" ); | 127 | m_cfg->setGroup("image_view_keys" ); |
98 | } | 128 | } |
99 | Opie::Core::OKeyPair::List lst; | 129 | Opie::Core::OKeyPair::List lst; |
100 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 130 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
101 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 131 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
102 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 132 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
103 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 133 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
104 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); | 134 | lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); |
105 | 135 | ||
106 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 136 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
107 | lst, false,this, "image_view_keys" ); | 137 | lst, false,this, "image_view_keys" ); |
108 | 138 | ||
109 | /** | 139 | /** |
110 | * Handle KeyEvents when they're pressed. This avoids problems | 140 | * Handle KeyEvents when they're pressed. This avoids problems |
111 | * with 'double next' on Return. | 141 | * with 'double next' on Return. |
112 | * The Return press would switch to this view and the return | 142 | * The Return press would switch to this view and the return |
113 | * release would emit the dispNext Signal. | 143 | * release would emit the dispNext Signal. |
114 | */ | 144 | */ |
115 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); | 145 | m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); |
116 | 146 | ||
117 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 147 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
118 | Resource::loadPixmap("1to1"), ViewInfo, | 148 | Resource::loadPixmap("1to1"), ViewInfo, |
119 | Opie::Core::OKeyPair(Qt::Key_I,0), | 149 | Opie::Core::OKeyPair(Qt::Key_I,0), |
120 | this, SLOT(slotShowImageInfo()))); | 150 | this, SLOT(slotShowImageInfo()))); |
121 | 151 | ||
122 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", | 152 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", |
123 | Resource::loadPixmap("rotate"), Autorotate, | 153 | Resource::loadPixmap("rotate"), Autorotate, |
124 | Opie::Core::OKeyPair(Qt::Key_R,0), | 154 | Opie::Core::OKeyPair(Qt::Key_R,0), |
125 | this, SIGNAL(toggleAutorotate()))); | 155 | this, SIGNAL(toggleAutorotate()))); |
126 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", | 156 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", |
127 | Resource::loadPixmap("1to1"), Autoscale, | 157 | Resource::loadPixmap("1to1"), Autoscale, |
128 | Opie::Core::OKeyPair(Qt::Key_S,0), | 158 | Opie::Core::OKeyPair(Qt::Key_S,0), |
129 | this, SIGNAL(toggleAutoscale()))); | 159 | this, SIGNAL(toggleAutoscale()))); |
130 | 160 | ||
131 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", | 161 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", |
132 | Resource::loadPixmap("forward"), ShowNext, | 162 | Resource::loadPixmap("forward"), ShowNext, |
133 | Opie::Core::OKeyPair(Qt::Key_Return,0), | 163 | Opie::Core::OKeyPair(Qt::Key_Return,0), |
134 | this, SIGNAL(dispNext()))); | 164 | this, SIGNAL(dispNext()))); |
135 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", | 165 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", |
136 | Resource::loadPixmap("back"), ShowPrevious, | 166 | Resource::loadPixmap("back"), ShowPrevious, |
137 | Opie::Core::OKeyPair(Qt::Key_P,0), | 167 | Opie::Core::OKeyPair(Qt::Key_P,0), |
138 | this, SIGNAL(dispPrev()))); | 168 | this, SIGNAL(dispPrev()))); |
139 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", | 169 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", |
140 | Resource::loadPixmap("fullscreen"), FullScreen, | 170 | Resource::loadPixmap("fullscreen"), FullScreen, |
141 | Opie::Core::OKeyPair(Qt::Key_F,0), | 171 | Opie::Core::OKeyPair(Qt::Key_F,0), |
142 | this, SIGNAL(toggleFullScreen()))); | 172 | this, SIGNAL(toggleFullScreen()))); |
143 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", | 173 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", |
144 | Resource::loadPixmap("mag"), Zoomer, | 174 | Resource::loadPixmap("mag"), Zoomer, |
145 | Opie::Core::OKeyPair(Qt::Key_T,0), | 175 | Opie::Core::OKeyPair(Qt::Key_T,0), |
146 | this, SIGNAL(toggleZoomer()))); | 176 | this, SIGNAL(toggleZoomer()))); |
147 | m_viewManager->handleWidget( this ); | 177 | m_viewManager->handleWidget( this ); |
148 | m_viewManager->load(); | 178 | m_viewManager->load(); |
149 | } | 179 | } |
150 | 180 | ||
151 | void ImageView::keyReleaseEvent(QKeyEvent * e) | 181 | void ImageView::keyReleaseEvent(QKeyEvent * e) |
152 | { | 182 | { |
153 | if (!e || e->state()!=0) { | 183 | if (!e || e->state()!=0) { |
154 | return; | 184 | return; |
155 | } | 185 | } |
156 | if (e->key()==Qt::Key_Escape) { | 186 | if (e->key()==Qt::Key_Escape) { |
157 | if (fullScreen()) { | 187 | if (fullScreen()) { |
158 | emit hideMe(); | 188 | emit hideMe(); |
159 | } | 189 | } |
160 | if (closeIfHide) { | 190 | if (closeIfHide) { |
161 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 191 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
162 | } | 192 | } |
163 | } | 193 | } |
164 | } | 194 | } |
165 | 195 | ||
166 | void ImageView::setCloseIfHide(bool how) | 196 | void ImageView::setCloseIfHide(bool how) |
167 | { | 197 | { |
168 | closeIfHide = how; | 198 | closeIfHide = how; |
169 | } | 199 | } |
170 | 200 | ||
171 | void ImageView::slotShowImageInfo() | 201 | void ImageView::slotShowImageInfo() |
172 | { | 202 | { |
173 | emit dispImageInfo(m_lastName); | 203 | emit dispImageInfo(m_lastName); |
174 | } | 204 | } |
175 | 205 | ||
176 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) | 206 | void ImageView::contentsMousePressEvent ( QMouseEvent * e) |
177 | { | 207 | { |
178 | if (e->button()==1) { | 208 | if (e->button()==1) { |
179 | return OImageScrollView::contentsMousePressEvent(e); | 209 | return OImageScrollView::contentsMousePressEvent(e); |
180 | } | 210 | } |
181 | odebug << "Popup " << oendl; | 211 | odebug << "Popup " << oendl; |
182 | QPopupMenu *m = new QPopupMenu(0); | 212 | QPopupMenu *m = new QPopupMenu(this); |
183 | if (!m) return; | 213 | if (!m) return; |
184 | if (m_hGroup) { | 214 | if (m_hGroup) { |
185 | m_hGroup->addTo(m); | 215 | m_hGroup->addTo(m); |
186 | } | 216 | } |
187 | if (fullScreen()) { | 217 | if (fullScreen()) { |
188 | if (m_gPrevNext) { | 218 | if (m_gPrevNext) { |
189 | m->insertSeparator(); | 219 | m->insertSeparator(); |
190 | m_gPrevNext->addTo(m); | 220 | m_gPrevNext->addTo(m); |
191 | } | 221 | } |
192 | if (m_gDisplayType) { | 222 | if (m_gDisplayType) { |
193 | m->insertSeparator(); | 223 | m->insertSeparator(); |
194 | m_gDisplayType->addTo(m); | 224 | m_gDisplayType->addTo(m); |
195 | } | 225 | } |
196 | } | 226 | } |
197 | m->setFocus(); | 227 | m->setFocus(); |
198 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 228 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
199 | if (m_hGroup) { | 229 | if (m_hGroup) { |
200 | m_hGroup->removeFrom(m); | 230 | m_hGroup->removeFrom(m); |
201 | } | 231 | } |
202 | if (m_gPrevNext) { | 232 | if (m_gPrevNext) { |
203 | m_gPrevNext->removeFrom(m); | 233 | m_gPrevNext->removeFrom(m); |
204 | } | 234 | } |
205 | if (m_gDisplayType) { | 235 | if (m_gDisplayType) { |
206 | m_gDisplayType->removeFrom(m); | 236 | m_gDisplayType->removeFrom(m); |
207 | } | 237 | } |
208 | delete m; | 238 | delete m; |
209 | } | 239 | } |
210 | 240 | ||
211 | void ImageView::setFullScreen(bool how,bool force) | 241 | void ImageView::setFullScreen(bool how,bool force) |
212 | { | 242 | { |
213 | m_isFullScreen = how; | 243 | m_isFullScreen = how; |
214 | if (how) { | 244 | if (how) { |
215 | m_ignore_next_in = true; | 245 | m_ignore_next_in = true; |
216 | setFixedSize(qApp->desktop()->size()); | 246 | // setFixedSize(qApp->desktop()->size()); |
247 | setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); | ||
217 | if (force) showFullScreen(); | 248 | if (force) showFullScreen(); |
218 | } else { | 249 | } else { |
219 | setMinimumSize(10,10); | 250 | // setMinimumSize(10,10); |
220 | } | 251 | } |
221 | } | 252 | } |
222 | 253 | ||
223 | void ImageView::focusInEvent(QFocusEvent *) | 254 | void ImageView::focusInEvent(QFocusEvent *) |
224 | { | 255 | { |
225 | // Always do it here, no matter the size. | 256 | // Always do it here, no matter the size. |
226 | odebug << "Focus in (view)" << oendl; | 257 | odebug << "Focus in (view)" << oendl; |
227 | //if (fullScreen()) parentWidget()->showNormal(); | 258 | //if (fullScreen()) parentWidget()->showNormal(); |
228 | if (m_ignore_next_in){m_ignore_next_in=false;return;} | 259 | if (m_ignore_next_in){m_ignore_next_in=false;return;} |
229 | if (fullScreen()) enableFullscreen(); | 260 | if (fullScreen()) enableFullscreen(); |
230 | } | 261 | } |
231 | 262 | ||
232 | void ImageView::hide() | 263 | void ImageView::hide() |
233 | { | 264 | { |
234 | if (fullScreen()) { | 265 | if (fullScreen()) { |
235 | m_ignore_next_in = true; | 266 | m_ignore_next_in = true; |
236 | showNormal(); | 267 | showNormal(); |
237 | } | 268 | } |
238 | QWidget::hide(); | 269 | QWidget::hide(); |
239 | } | 270 | } |
240 | void ImageView::enableFullscreen() | 271 | void ImageView::enableFullscreen() |
241 | { | 272 | { |
242 | if (!fullScreen()) return; | 273 | if (!fullScreen()) return; |
243 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} | 274 | if (m_ignore_next_in) {m_ignore_next_in = false;return;} |
244 | 275 | ||
245 | setUpdatesEnabled(false); | 276 | setUpdatesEnabled(false); |
246 | // This is needed because showNormal() forcefully changes the window | 277 | // This is needed because showNormal() forcefully changes the window |
247 | // style to WSTyle_TopLevel. | 278 | // style to WSTyle_TopLevel. |
248 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); | 279 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); |
249 | // Enable fullscreen. | 280 | // Enable fullscreen. |
250 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus | 281 | /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus |
251 | * so we must block it here! */ | 282 | * so we must block it here! */ |
252 | m_ignore_next_in = true; | 283 | m_ignore_next_in = true; |
253 | showFullScreen(); | 284 | showFullScreen(); |
254 | setUpdatesEnabled(true); | 285 | setUpdatesEnabled(true); |
255 | } | 286 | } |
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index f1067bb..e8c8df7 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h | |||
@@ -1,78 +1,85 @@ | |||
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 | class QTimer; | 8 | class QTimer; |
9 | class QActionGroup; | 9 | class QActionGroup; |
10 | class QAction; | 10 | class QAction; |
11 | 11 | ||
12 | class QCopChannel; | ||
13 | |||
12 | namespace Opie { | 14 | namespace Opie { |
13 | namespace Core { | 15 | namespace Core { |
14 | class OConfig; | 16 | class OConfig; |
15 | class OKeyConfigManager; | 17 | class OKeyConfigManager; |
16 | } | 18 | } |
17 | } | 19 | } |
18 | 20 | ||
19 | class ImageView:public Opie::MM::OImageScrollView | 21 | class ImageView:public Opie::MM::OImageScrollView |
20 | { | 22 | { |
21 | Q_OBJECT | 23 | Q_OBJECT |
22 | 24 | ||
23 | enum ActionIds { | 25 | enum ActionIds { |
24 | ViewInfo, | 26 | ViewInfo, |
25 | FullScreen, | 27 | FullScreen, |
26 | ShowNext, | 28 | ShowNext, |
27 | ShowPrevious, | 29 | ShowPrevious, |
28 | Zoomer, | 30 | Zoomer, |
29 | Autorotate, | 31 | Autorotate, |
30 | Autoscale | 32 | Autoscale |
31 | }; | 33 | }; |
32 | 34 | ||
33 | public: | 35 | public: |
34 | ImageView(Opie::Core::OConfig *cfg,QWidget* parent,const char* name = 0, WFlags fl = 0 ); | 36 | ImageView(Opie::Core::OConfig *cfg,QWidget* parent,const char* name = 0, WFlags fl = 0 ); |
35 | virtual ~ImageView(); | 37 | virtual ~ImageView(); |
36 | Opie::Core::OKeyConfigManager* manager(); | 38 | Opie::Core::OKeyConfigManager* manager(); |
37 | void setFullScreen(bool how,bool force=true); | 39 | void setFullScreen(bool how,bool force=true); |
38 | bool fullScreen(){return m_isFullScreen;} | 40 | bool fullScreen(){return m_isFullScreen;} |
39 | virtual void enableFullscreen(); | 41 | virtual void enableFullscreen(); |
40 | void stopSlide(); | 42 | void stopSlide(); |
41 | void setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup); | 43 | void setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup); |
42 | void setCloseIfHide(bool); | 44 | void setCloseIfHide(bool); |
43 | 45 | ||
44 | signals: | 46 | signals: |
45 | void dispImageInfo(const QString&); | 47 | void dispImageInfo(const QString&); |
46 | void dispNext(); | 48 | void dispNext(); |
47 | void dispPrev(); | 49 | void dispPrev(); |
48 | void toggleFullScreen(); | 50 | void toggleFullScreen(); |
49 | void hideMe(); | 51 | void hideMe(); |
50 | void toggleZoomer(); | 52 | void toggleZoomer(); |
51 | void toggleAutoscale(); | 53 | void toggleAutoscale(); |
52 | void toggleAutorotate(); | 54 | void toggleAutorotate(); |
53 | 55 | ||
54 | protected: | 56 | protected: |
55 | Opie::Core::OConfig * m_cfg; | 57 | Opie::Core::OConfig * m_cfg; |
56 | Opie::Core::OKeyConfigManager*m_viewManager; | 58 | Opie::Core::OKeyConfigManager*m_viewManager; |
57 | void initKeys(); | 59 | void initKeys(); |
58 | bool m_isFullScreen:1; | 60 | bool m_isFullScreen:1; |
59 | bool m_ignore_next_in:1; | 61 | bool m_ignore_next_in:1; |
62 | bool m_Rotated:1; | ||
63 | |||
60 | int focus_in_count; | 64 | int focus_in_count; |
61 | QTimer*m_slideTimer; | 65 | QTimer*m_slideTimer; |
62 | int m_slideValue; | 66 | int m_slideValue; |
63 | virtual void focusInEvent ( QFocusEvent * ); | 67 | virtual void focusInEvent ( QFocusEvent * ); |
64 | QActionGroup *m_gDisplayType,*m_gPrevNext,*m_hGroup; | 68 | QActionGroup *m_gDisplayType,*m_gPrevNext,*m_hGroup; |
65 | bool closeIfHide:1; | 69 | bool closeIfHide:1; |
70 | QCopChannel* m_sysChannel; | ||
71 | int m_rotation; | ||
66 | 72 | ||
67 | public slots: | 73 | public slots: |
68 | virtual void hide(); | 74 | virtual void hide(); |
69 | virtual void startSlide(int); | 75 | virtual void startSlide(int); |
70 | virtual void nextSlide(); | 76 | virtual void nextSlide(); |
77 | virtual void systemMessage( const QCString&, const QByteArray& ); | ||
71 | 78 | ||
72 | protected slots: | 79 | protected slots: |
73 | virtual void slotShowImageInfo(); | 80 | virtual void slotShowImageInfo(); |
74 | virtual void keyReleaseEvent(QKeyEvent * e); | 81 | virtual void keyReleaseEvent(QKeyEvent * e); |
75 | virtual void contentsMousePressEvent ( QMouseEvent * e); | 82 | virtual void contentsMousePressEvent ( QMouseEvent * e); |
76 | }; | 83 | }; |
77 | 84 | ||
78 | #endif | 85 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 7570ee3..90e2e99 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -1,707 +1,713 @@ | |||
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 | #include "basesetup.h" | 12 | #include "basesetup.h" |
13 | 13 | ||
14 | #include <iface/ifaceinfo.h> | 14 | #include <iface/ifaceinfo.h> |
15 | #include <iface/dirview.h> | 15 | #include <iface/dirview.h> |
16 | 16 | ||
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <opie2/owidgetstack.h> | 18 | #include <opie2/owidgetstack.h> |
19 | #include <opie2/oapplicationfactory.h> | 19 | #include <opie2/oapplicationfactory.h> |
20 | #include <opie2/otabwidget.h> | 20 | #include <opie2/otabwidget.h> |
21 | #include <opie2/okeyconfigwidget.h> | 21 | #include <opie2/okeyconfigwidget.h> |
22 | 22 | ||
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/ir.h> | 25 | #include <qpe/ir.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | 28 | ||
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qframe.h> | 35 | #include <qframe.h> |
36 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | 38 | ||
39 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 39 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
40 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 40 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
41 | 41 | ||
42 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 42 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
43 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 43 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
44 | { | 44 | { |
45 | setCaption( QObject::tr("Opie Eye" ) ); | 45 | setCaption( QObject::tr("Opie Eye" ) ); |
46 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 46 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
47 | m_cfg->setGroup("main" ); | 47 | m_cfg->setGroup("main" ); |
48 | readConfig(); | 48 | readConfig(); |
49 | m_setDocCalled = false; | 49 | m_setDocCalled = false; |
50 | m_polishDone = false; | 50 | m_polishDone = false; |
51 | 51 | ||
52 | m_storage = new StorageInfo(); | 52 | m_storage = new StorageInfo(); |
53 | connect(m_storage, SIGNAL(disksChanged() ), | 53 | connect(m_storage, SIGNAL(disksChanged() ), |
54 | this, SLOT( dirChanged() ) ); | 54 | this, SLOT( dirChanged() ) ); |
55 | 55 | ||
56 | m_stack = new Opie::Ui::OWidgetStack( this ); | 56 | m_stack = new Opie::Ui::OWidgetStack( this ); |
57 | setCentralWidget( m_stack ); | 57 | setCentralWidget( m_stack ); |
58 | 58 | ||
59 | m_view = new PIconView( m_stack, m_cfg ); | 59 | m_view = new PIconView( m_stack, m_cfg ); |
60 | m_stack->addWidget( m_view, IconView ); | 60 | m_stack->addWidget( m_view, IconView ); |
61 | m_stack->raiseWidget( IconView ); | 61 | m_stack->raiseWidget( IconView ); |
62 | 62 | ||
63 | connect(m_view, SIGNAL(sig_display(const QString&)), | 63 | connect(m_view, SIGNAL(sig_display(const QString&)), |
64 | this, SLOT(slotDisplay(const QString&))); | 64 | this, SLOT(slotDisplay(const QString&))); |
65 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 65 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
66 | this, SLOT(slotShowInfo(const QString&)) ); | 66 | this, SLOT(slotShowInfo(const QString&)) ); |
67 | connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); | 67 | connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); |
68 | 68 | ||
69 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 69 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
70 | 70 | ||
71 | listviewMenu = 0; | 71 | listviewMenu = 0; |
72 | /* setup menu and toolbar */ | 72 | /* setup menu and toolbar */ |
73 | setupActions(); | 73 | setupActions(); |
74 | setupToolbar(); | 74 | setupToolbar(); |
75 | setupMenu(); | 75 | setupMenu(); |
76 | m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); | 76 | m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); |
77 | m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); | 77 | m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); |
78 | odebug << "mainwindow constructor done" << oendl; | 78 | odebug << "mainwindow constructor done" << oendl; |
79 | } | 79 | } |
80 | 80 | ||
81 | PMainWindow::~PMainWindow() { | 81 | PMainWindow::~PMainWindow() { |
82 | } | 82 | } |
83 | 83 | ||
84 | void PMainWindow::slotToggleZoomer() | 84 | void PMainWindow::slotToggleZoomer() |
85 | { | 85 | { |
86 | m_aZoomer->setOn(!m_aZoomer->isOn()); | 86 | m_aZoomer->setOn(!m_aZoomer->isOn()); |
87 | } | 87 | } |
88 | 88 | ||
89 | void PMainWindow::slotZoomerToggled(bool how) | 89 | void PMainWindow::slotZoomerToggled(bool how) |
90 | { | 90 | { |
91 | if (m_disp) { | 91 | if (m_disp) { |
92 | m_disp->setShowZoomer(how); | 92 | m_disp->setShowZoomer(how); |
93 | } | 93 | } |
94 | if (autoSave) { | 94 | if (autoSave) { |
95 | m_cfg->writeEntry("zoomeron",how); | 95 | m_cfg->writeEntry("zoomeron",how); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void PMainWindow::slotToggleAutorotate() | 99 | void PMainWindow::slotToggleAutorotate() |
100 | { | 100 | { |
101 | if (!m_aAutoRotate->isEnabled()) return; | 101 | if (!m_aAutoRotate->isEnabled()) return; |
102 | m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); | 102 | m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); |
103 | } | 103 | } |
104 | 104 | ||
105 | void PMainWindow::slotToggleAutoscale() | 105 | void PMainWindow::slotToggleAutoscale() |
106 | { | 106 | { |
107 | m_aUnscaled->setOn(!m_aUnscaled->isOn()); | 107 | m_aUnscaled->setOn(!m_aUnscaled->isOn()); |
108 | } | 108 | } |
109 | 109 | ||
110 | void PMainWindow::slotRotateToggled(bool how) | 110 | void PMainWindow::slotRotateToggled(bool how) |
111 | { | 111 | { |
112 | if (autoSave) { | 112 | if (autoSave) { |
113 | m_cfg->writeEntry("autorotate",how); | 113 | m_cfg->writeEntry("autorotate",how); |
114 | } | 114 | } |
115 | if (m_disp) { | 115 | if (m_disp) { |
116 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); | 116 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | void PMainWindow::slotScaleToggled(bool how) | 120 | void PMainWindow::slotScaleToggled(bool how) |
121 | { | 121 | { |
122 | if (autoSave) { | 122 | if (autoSave) { |
123 | m_cfg->writeEntry("unscaled",how); | 123 | m_cfg->writeEntry("unscaled",how); |
124 | } | 124 | } |
125 | odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; | 125 | odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; |
126 | odebug << "How: " << how << oendl; | 126 | odebug << "How: " << how << oendl; |
127 | if (how) { | 127 | if (how) { |
128 | m_aAutoRotate->setOn(false); | 128 | m_aAutoRotate->setOn(false); |
129 | } | 129 | } |
130 | if (m_disp) { | 130 | if (m_disp) { |
131 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); | 131 | m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); |
132 | } | 132 | } |
133 | m_aAutoRotate->setEnabled(!how); | 133 | m_aAutoRotate->setEnabled(!how); |
134 | odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; | 134 | odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; |
135 | } | 135 | } |
136 | 136 | ||
137 | void PMainWindow::slotConfig() { | 137 | void PMainWindow::slotConfig() { |
138 | /* | 138 | /* |
139 | * have a tab with the possible views | 139 | * have a tab with the possible views |
140 | * a tab for globals image cache size.. scaled loading | 140 | * a tab for globals image cache size.. scaled loading |
141 | * and one tab for the KeyConfigs | 141 | * and one tab for the KeyConfigs |
142 | */ | 142 | */ |
143 | QDialog dlg(this, 0, true); | 143 | QDialog dlg(this, 0, true); |
144 | dlg.setCaption( tr("Opie Eye - Config" ) ); | 144 | dlg.setCaption( tr("Opie Eye - Config" ) ); |
145 | 145 | ||
146 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 146 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
147 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 147 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
148 | lay->addWidget( wid ); | 148 | lay->addWidget( wid ); |
149 | 149 | ||
150 | BaseSetup*bSetup = new BaseSetup(m_cfg,wid); | 150 | BaseSetup*bSetup = new BaseSetup(m_cfg,wid); |
151 | wid->addTab(bSetup,"SettingsIcon","Basics setup"); | 151 | wid->addTab(bSetup,"SettingsIcon","Basics setup"); |
152 | 152 | ||
153 | ViewMap *vM = viewMap(); | 153 | ViewMap *vM = viewMap(); |
154 | ViewMap::Iterator _it = vM->begin(); | 154 | ViewMap::Iterator _it = vM->begin(); |
155 | QMap<PDirView*, QWidget*> lst; | 155 | QMap<PDirView*, QWidget*> lst; |
156 | 156 | ||
157 | for( ; _it != vM->end(); ++_it ) { | 157 | for( ; _it != vM->end(); ++_it ) { |
158 | PDirView *view = (_it.data())(*m_cfg); | 158 | PDirView *view = (_it.data())(*m_cfg); |
159 | PInterfaceInfo *inf = view->interfaceInfo(); | 159 | PInterfaceInfo *inf = view->interfaceInfo(); |
160 | QWidget *_wid = inf->configWidget( *m_cfg ); | 160 | QWidget *_wid = inf->configWidget( *m_cfg ); |
161 | if (!_wid) continue; | 161 | if (!_wid) continue; |
162 | _wid->reparent(wid, QPoint() ); | 162 | _wid->reparent(wid, QPoint() ); |
163 | lst.insert( view, _wid ); | 163 | lst.insert( view, _wid ); |
164 | wid->addTab( _wid, "fileopen", inf->name() ); | 164 | wid->addTab( _wid, "fileopen", inf->name() ); |
165 | } | 165 | } |
166 | 166 | ||
167 | /* | 167 | /* |
168 | * Add the KeyConfigWidget | 168 | * Add the KeyConfigWidget |
169 | */ | 169 | */ |
170 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 170 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
171 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 171 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
172 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 172 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
173 | QWidget*w = m_stack->visibleWidget(); | 173 | QWidget*w = m_stack->visibleWidget(); |
174 | 174 | ||
175 | bool reminfo = false; | 175 | bool reminfo = false; |
176 | if ( !m_info ) { | 176 | if ( !m_info ) { |
177 | reminfo = true; | 177 | reminfo = true; |
178 | initInfo(); | 178 | initInfo(); |
179 | m_info->hide(); | 179 | m_info->hide(); |
180 | } | 180 | } |
181 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 181 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
182 | 182 | ||
183 | bool remdisp = false; | 183 | bool remdisp = false; |
184 | if ( !m_disp ) { | 184 | if ( !m_disp ) { |
185 | remdisp = true; | 185 | remdisp = true; |
186 | initDisp(); | 186 | initDisp(); |
187 | m_disp->hide(); | 187 | m_disp->hide(); |
188 | } | 188 | } |
189 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 189 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
190 | 190 | ||
191 | keyWid->load(); | 191 | keyWid->load(); |
192 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 192 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
193 | wid->setCurrentTab(0); | 193 | wid->setCurrentTab(0); |
194 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 194 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
195 | 195 | ||
196 | /* | 196 | /* |
197 | * clean up | 197 | * clean up |
198 | *apply changes | 198 | *apply changes |
199 | */ | 199 | */ |
200 | 200 | ||
201 | QMap<PDirView*, QWidget*>::Iterator it; | 201 | QMap<PDirView*, QWidget*>::Iterator it; |
202 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 202 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
203 | if ( act ) | 203 | if ( act ) |
204 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 204 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
205 | delete it.key(); | 205 | delete it.key(); |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | if ( act ) { | 209 | if ( act ) { |
210 | keyWid->save(); | 210 | keyWid->save(); |
211 | m_disp->manager()->save(); | 211 | m_disp->manager()->save(); |
212 | m_info->manager()->save(); | 212 | m_info->manager()->save(); |
213 | m_view->manager()->save(); | 213 | m_view->manager()->save(); |
214 | bSetup->save_values(); | 214 | bSetup->save_values(); |
215 | m_view->resetView(); | 215 | m_view->resetView(); |
216 | readConfig(); | 216 | readConfig(); |
217 | } | 217 | } |
218 | delete keyWid; | 218 | delete keyWid; |
219 | 219 | ||
220 | m_stack->raiseWidget(w); | 220 | m_stack->raiseWidget(w); |
221 | if (remdisp) { | 221 | if (remdisp) { |
222 | m_disp->hide(); | 222 | m_disp->hide(); |
223 | } | 223 | } |
224 | if (reminfo) { | 224 | if (reminfo) { |
225 | m_info->hide(); | 225 | m_info->hide(); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | /* | 229 | /* |
230 | * create a new image info component | 230 | * create a new image info component |
231 | * and detach the current one | 231 | * and detach the current one |
232 | * we will make the other delete on exit | 232 | * we will make the other delete on exit |
233 | */ | 233 | */ |
234 | template<class T> | 234 | template<class T> |
235 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 235 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
236 | if ( *ptr ) { | 236 | if ( *ptr ) { |
237 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 237 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
238 | (*ptr)->setDestructiveClose(); | 238 | (*ptr)->setDestructiveClose(); |
239 | m_stack->removeWidget( *ptr ); | 239 | m_stack->removeWidget( *ptr ); |
240 | } | 240 | } |
241 | *ptr = new T(m_cfg, m_stack, name ); | 241 | *ptr = new T(m_cfg, m_stack, name ); |
242 | m_stack->addWidget( *ptr, id ); | 242 | m_stack->addWidget( *ptr, id ); |
243 | 243 | ||
244 | connect(*ptr, SIGNAL(sig_return()), | 244 | connect(*ptr, SIGNAL(sig_return()), |
245 | this,SLOT(slotReturn())); | 245 | this,SLOT(slotReturn())); |
246 | 246 | ||
247 | } | 247 | } |
248 | 248 | ||
249 | void PMainWindow::initInfo() { | 249 | void PMainWindow::initInfo() { |
250 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 250 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
251 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 251 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
252 | } | 252 | } |
253 | 253 | ||
254 | void PMainWindow::initDisp() { | 254 | void PMainWindow::initDisp() { |
255 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 255 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
256 | if (m_disp) { | 256 | if (m_disp) { |
257 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 257 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
258 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 258 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
259 | } | 259 | } |
260 | m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); | 260 | m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); |
261 | m_disp->setAutoScale(!m_aUnscaled->isOn()); | 261 | m_disp->setAutoScale(!m_aUnscaled->isOn()); |
262 | m_disp->setAutoRotate(m_aAutoRotate->isOn()); | 262 | m_disp->setAutoRotate(m_aAutoRotate->isOn()); |
263 | m_disp->setShowZoomer(m_aZoomer->isOn()); | 263 | m_disp->setShowZoomer(m_aZoomer->isOn()); |
264 | m_disp->setBackgroundColor(white); | 264 | m_disp->setBackgroundColor(white); |
265 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 265 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
266 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 266 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
267 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 267 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
268 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); | 268 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); |
269 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 269 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
270 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 270 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
271 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | 271 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); |
272 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | 272 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); |
273 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); | 273 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); |
274 | slotFullScreenToggled(m_aFullScreen->isOn()); | 274 | slotFullScreenToggled(m_aFullScreen->isOn()); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void PMainWindow::slotToggleFullScreen() | 278 | void PMainWindow::slotToggleFullScreen() |
279 | { | 279 | { |
280 | bool current = !m_aFullScreen->isOn(); | 280 | bool current = !m_aFullScreen->isOn(); |
281 | m_aFullScreen->setOn(current); | 281 | m_aFullScreen->setOn(current); |
282 | } | 282 | } |
283 | 283 | ||
284 | void PMainWindow::slotFullScreenButton(bool current) | 284 | void PMainWindow::slotFullScreenButton(bool current) |
285 | { | 285 | { |
286 | if (autoSave) { | 286 | if (autoSave) { |
287 | m_cfg->writeEntry("fullscreen",current); | 287 | m_cfg->writeEntry("fullscreen",current); |
288 | } | 288 | } |
289 | if (!m_disp) return; | 289 | if (!m_disp) return; |
290 | if (m_disp->isVisible()) { | 290 | if (m_disp->isVisible()) { |
291 | setupViewWindow(current, true); | 291 | setupViewWindow(current, true); |
292 | } | 292 | } |
293 | } | 293 | } |
294 | 294 | ||
295 | void PMainWindow::setupViewWindow(bool current, bool forceDisplay) | 295 | void PMainWindow::setupViewWindow(bool current, bool forceDisplay) |
296 | { | 296 | { |
297 | if (!m_disp) return; | 297 | if (!m_disp) { |
298 | return; | ||
299 | } | ||
298 | if (current) { | 300 | if (current) { |
299 | m_disp->setBackgroundColor(black); | 301 | m_disp->setBackgroundColor(black); |
300 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); | 302 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); |
301 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); | 303 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); |
302 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); | 304 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); |
303 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 305 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
306 | m_disp->setFullScreen(current,forceDisplay); | ||
304 | } else { | 307 | } else { |
305 | setUpdatesEnabled(false); | 308 | setUpdatesEnabled(false); |
306 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 309 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
307 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 310 | |
311 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); | ||
308 | } else { | 312 | } else { |
309 | m_disp->setMinimumSize(10,10); | 313 | //m_disp->setMinimumSize(10,10); |
310 | } | 314 | } |
311 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 315 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
312 | m_disp->reparent(0,QPoint(50,50)); | 316 | m_disp->reparent(0,QPoint(10,10)); |
313 | } else { | 317 | } else { |
314 | m_disp->reparent(0,QPoint(0,0)); | 318 | m_disp->reparent(0,QPoint(0,0)); |
315 | } | 319 | } |
316 | m_disp->setBackgroundColor(white); | 320 | m_disp->setBackgroundColor(white); |
317 | m_stack->addWidget(m_disp,ImageDisplay); | 321 | m_stack->addWidget(m_disp,ImageDisplay); |
318 | m_disp->setVScrollBarMode(QScrollView::Auto); | 322 | m_disp->setVScrollBarMode(QScrollView::Auto); |
319 | m_disp->setHScrollBarMode(QScrollView::Auto); | 323 | m_disp->setHScrollBarMode(QScrollView::Auto); |
320 | if (forceDisplay || m_disp->isVisible()) | ||
321 | m_stack->raiseWidget(m_disp); | ||
322 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 324 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
323 | m_disp->resize(m_disp->minimumSize()); | 325 | m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); |
326 | } | ||
327 | if (forceDisplay || m_disp->isVisible()) { | ||
328 | m_stack->raiseWidget(m_disp); | ||
329 | m_disp->setFocus(); | ||
324 | } | 330 | } |
325 | setUpdatesEnabled(true); | 331 | setUpdatesEnabled(true); |
326 | } | 332 | } |
327 | m_disp->setFullScreen(current,forceDisplay); | 333 | m_disp->setFullScreen(current,forceDisplay); |
328 | } | 334 | } |
329 | 335 | ||
330 | void PMainWindow::slotFullScreenToggled(bool current) | 336 | void PMainWindow::slotFullScreenToggled(bool current) |
331 | { | 337 | { |
332 | setupViewWindow(current,true); | 338 | setupViewWindow(current,true); |
333 | } | 339 | } |
334 | 340 | ||
335 | /** | 341 | /** |
336 | * With big Screen the plan could be to 'detach' the image | 342 | * With big Screen the plan could be to 'detach' the image |
337 | * window if visible and to create a ne wone | 343 | * window if visible and to create a ne wone |
338 | * init* already supports it but I make no use of it for | 344 | * init* already supports it but I make no use of it for |
339 | * now. We set filename and raise | 345 | * now. We set filename and raise |
340 | * | 346 | * |
341 | * ### FIXME and talk to alwin | 347 | * ### FIXME and talk to alwin |
342 | */ | 348 | */ |
343 | void PMainWindow::slotShowInfo( const QString& inf ) { | 349 | void PMainWindow::slotShowInfo( const QString& inf ) { |
344 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 350 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
345 | return; | 351 | return; |
346 | } | 352 | } |
347 | if ( !m_info ) { | 353 | if ( !m_info ) { |
348 | initInfo(); | 354 | initInfo(); |
349 | } | 355 | } |
350 | m_info->setPath( inf ); | 356 | m_info->setPath( inf ); |
351 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 357 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
352 | m_aNext->removeFrom(toolBar); | 358 | m_aNext->removeFrom(toolBar); |
353 | m_aPrevious->removeFrom(toolBar); | 359 | m_aPrevious->removeFrom(toolBar); |
354 | m_aNext->setEnabled(false); | 360 | m_aNext->setEnabled(false); |
355 | m_aPrevious->setEnabled(false); | 361 | m_aPrevious->setEnabled(false); |
356 | m_aDirUp->setEnabled(false); | 362 | m_aDirUp->setEnabled(false); |
357 | m_aShowInfo->setEnabled(false); | 363 | m_aShowInfo->setEnabled(false); |
358 | m_aViewfile->setEnabled(true); | 364 | m_aViewfile->setEnabled(true); |
359 | m_aStartSlide->setEnabled(false); | 365 | m_aStartSlide->setEnabled(false); |
360 | fsButton->hide(); | 366 | fsButton->hide(); |
361 | } | 367 | } |
362 | m_stack->raiseWidget( ImageInfo ); | 368 | m_stack->raiseWidget( ImageInfo ); |
363 | } | 369 | } |
364 | 370 | ||
365 | void PMainWindow::slotDisplay( const QString& inf ) { | 371 | void PMainWindow::slotDisplay( const QString& inf ) { |
366 | bool nwindow = false; | 372 | bool nwindow = false; |
367 | if ( !m_disp ) { | 373 | if ( !m_disp ) { |
368 | nwindow = true; | 374 | nwindow = true; |
369 | initDisp(); | 375 | initDisp(); |
370 | } | 376 | } |
371 | m_disp->setImage( inf ); | 377 | m_disp->setImage( inf ); |
372 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 378 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
373 | if (m_gPrevNext->isEnabled()==false) { | 379 | if (m_gPrevNext->isEnabled()==false) { |
374 | m_gPrevNext->addTo(toolBar); | 380 | m_gPrevNext->addTo(toolBar); |
375 | m_gPrevNext->setEnabled(true); | 381 | m_gPrevNext->setEnabled(true); |
376 | 382 | ||
377 | m_aDirUp->setEnabled(false); | 383 | m_aDirUp->setEnabled(false); |
378 | m_aShowInfo->setEnabled(true); | 384 | m_aShowInfo->setEnabled(true); |
379 | m_aViewfile->setEnabled(false); | 385 | m_aViewfile->setEnabled(false); |
380 | m_aStartSlide->setEnabled(false); | 386 | m_aStartSlide->setEnabled(false); |
381 | fsButton->hide(); | 387 | fsButton->hide(); |
382 | } | 388 | } |
383 | } | 389 | } |
384 | if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { | 390 | if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { |
385 | slotFullScreenToggled(m_aFullScreen->isOn()); | 391 | slotFullScreenToggled(m_aFullScreen->isOn()); |
386 | } | 392 | } |
387 | if (m_disp->fullScreen()) { | 393 | if (m_disp->fullScreen()) { |
388 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 394 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
389 | } else { | 395 | } else { |
390 | m_stack->raiseWidget( ImageDisplay ); | 396 | m_stack->raiseWidget( ImageDisplay ); |
391 | } | 397 | } |
392 | } | 398 | } |
393 | 399 | ||
394 | void PMainWindow::raiseIconView() { | 400 | void PMainWindow::raiseIconView() { |
395 | setUpdatesEnabled(false); | 401 | setUpdatesEnabled(false); |
396 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 402 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
397 | m_gPrevNext->removeFrom(toolBar); | 403 | m_gPrevNext->removeFrom(toolBar); |
398 | m_gPrevNext->setEnabled(false); | 404 | m_gPrevNext->setEnabled(false); |
399 | m_aDirUp->setEnabled(true); | 405 | m_aDirUp->setEnabled(true); |
400 | m_aShowInfo->setEnabled(true); | 406 | m_aShowInfo->setEnabled(true); |
401 | m_aViewfile->setEnabled(true); | 407 | m_aViewfile->setEnabled(true); |
402 | m_aStartSlide->setEnabled(true); | 408 | m_aStartSlide->setEnabled(true); |
403 | fsButton->show(); | 409 | fsButton->show(); |
404 | } | 410 | } |
405 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 411 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
406 | m_disp->stopSlide(); | 412 | m_disp->stopSlide(); |
407 | m_disp->hide(); | 413 | m_disp->hide(); |
408 | } | 414 | } |
409 | m_stack->raiseWidget( IconView ); | 415 | m_stack->raiseWidget( IconView ); |
410 | setUpdatesEnabled(true); | 416 | setUpdatesEnabled(true); |
411 | repaint(); | 417 | repaint(); |
412 | } | 418 | } |
413 | 419 | ||
414 | void PMainWindow::slotReturn() { | 420 | void PMainWindow::slotReturn() { |
415 | raiseIconView(); | 421 | raiseIconView(); |
416 | } | 422 | } |
417 | 423 | ||
418 | 424 | ||
419 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 425 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
420 | /* | 426 | /* |
421 | * return from view | 427 | * return from view |
422 | * or properly quit | 428 | * or properly quit |
423 | */ | 429 | */ |
424 | if (!m_setDocCalled) { | 430 | if (!m_setDocCalled) { |
425 | if ( m_stack->visibleWidget() == m_info || | 431 | if ( m_stack->visibleWidget() == m_info || |
426 | m_stack->visibleWidget() == m_disp ) { | 432 | m_stack->visibleWidget() == m_disp ) { |
427 | ev->ignore(); | 433 | ev->ignore(); |
428 | raiseIconView(); | 434 | raiseIconView(); |
429 | return; | 435 | return; |
430 | } | 436 | } |
431 | } | 437 | } |
432 | if (m_disp && m_disp->fullScreen()) { | 438 | if (m_disp && m_disp->fullScreen()) { |
433 | /* otherwise opie-eye crashes in bigscreen mode! */ | 439 | /* otherwise opie-eye crashes in bigscreen mode! */ |
434 | m_disp->reparent(0,QPoint(0,0)); | 440 | m_disp->reparent(0,QPoint(0,0)); |
435 | m_stack->addWidget(m_disp,ImageDisplay); | 441 | m_stack->addWidget(m_disp,ImageDisplay); |
436 | } | 442 | } |
437 | ev->accept(); | 443 | ev->accept(); |
438 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 444 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
439 | } | 445 | } |
440 | 446 | ||
441 | void PMainWindow::setDocument( const QString& showImg ) | 447 | void PMainWindow::setDocument( const QString& showImg ) |
442 | { | 448 | { |
443 | QString file = showImg; | 449 | QString file = showImg; |
444 | DocLnk lnk(showImg); | 450 | DocLnk lnk(showImg); |
445 | if (lnk.isValid() ) | 451 | if (lnk.isValid() ) |
446 | file = lnk.file(); | 452 | file = lnk.file(); |
447 | slotDisplay( file ); | 453 | slotDisplay( file ); |
448 | #if 0 | 454 | #if 0 |
449 | if (!m_polishDone) { | 455 | if (!m_polishDone) { |
450 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | 456 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); |
451 | } | 457 | } |
452 | #endif | 458 | #endif |
453 | } | 459 | } |
454 | 460 | ||
455 | void PMainWindow::check_view_fullscreen() | 461 | void PMainWindow::check_view_fullscreen() |
456 | { | 462 | { |
457 | if (!m_view) return; | 463 | if (!m_view) return; |
458 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { | 464 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { |
459 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 465 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
460 | } | 466 | } |
461 | } | 467 | } |
462 | 468 | ||
463 | void PMainWindow::slotSelectDir(int id) | 469 | void PMainWindow::slotSelectDir(int id) |
464 | { | 470 | { |
465 | emit changeDir( m_dev[fsMenu->text(id )] ); | 471 | emit changeDir( m_dev[fsMenu->text(id )] ); |
466 | } | 472 | } |
467 | 473 | ||
468 | void PMainWindow::dirChanged() | 474 | void PMainWindow::dirChanged() |
469 | { | 475 | { |
470 | fsMenu->clear(); | 476 | fsMenu->clear(); |
471 | m_dev.clear(); | 477 | m_dev.clear(); |
472 | 478 | ||
473 | /* home dir, too */ | 479 | /* home dir, too */ |
474 | QString f = getenv( "HOME" ); | 480 | QString f = getenv( "HOME" ); |
475 | if (!f.isEmpty()) { | 481 | if (!f.isEmpty()) { |
476 | m_dev.insert("Home directory",f); | 482 | m_dev.insert("Home directory",f); |
477 | fsMenu->insertItem("Home directory"); | 483 | fsMenu->insertItem("Home directory"); |
478 | } | 484 | } |
479 | const QList<FileSystem> &fs = m_storage->fileSystems(); | 485 | const QList<FileSystem> &fs = m_storage->fileSystems(); |
480 | QListIterator<FileSystem> it(fs ); | 486 | QListIterator<FileSystem> it(fs ); |
481 | for ( ; it.current(); ++it ) { | 487 | for ( ; it.current(); ++it ) { |
482 | const QString disk = (*it)->name(); | 488 | const QString disk = (*it)->name(); |
483 | const QString path = (*it)->path(); | 489 | const QString path = (*it)->path(); |
484 | m_dev.insert( disk, path ); | 490 | m_dev.insert( disk, path ); |
485 | fsMenu->insertItem( disk ); | 491 | fsMenu->insertItem( disk ); |
486 | } | 492 | } |
487 | } | 493 | } |
488 | 494 | ||
489 | void PMainWindow::showToolbar(bool how) | 495 | void PMainWindow::showToolbar(bool how) |
490 | { | 496 | { |
491 | if (!how) toolBar->hide(); | 497 | if (!how) toolBar->hide(); |
492 | else toolBar->show(); | 498 | else toolBar->show(); |
493 | if (autoSave) { | 499 | if (autoSave) { |
494 | m_cfg->writeEntry("showtoolbar",how); | 500 | m_cfg->writeEntry("showtoolbar",how); |
495 | } | 501 | } |
496 | } | 502 | } |
497 | 503 | ||
498 | void PMainWindow::setupActions() | 504 | void PMainWindow::setupActions() |
499 | { | 505 | { |
500 | m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); | 506 | m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); |
501 | m_aDirUp->setToggleAction(false); | 507 | m_aDirUp->setToggleAction(false); |
502 | connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); | 508 | connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); |
503 | 509 | ||
504 | if ( Ir::supported() ) { | 510 | if ( Ir::supported() ) { |
505 | m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); | 511 | m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); |
506 | m_aBeam->setToggleAction(false); | 512 | m_aBeam->setToggleAction(false); |
507 | connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); | 513 | connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); |
508 | } else { | 514 | } else { |
509 | m_aBeam = 0; | 515 | m_aBeam = 0; |
510 | } | 516 | } |
511 | 517 | ||
512 | m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); | 518 | m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); |
513 | m_aShowInfo->setToggleAction(false); | 519 | m_aShowInfo->setToggleAction(false); |
514 | connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); | 520 | connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); |
515 | 521 | ||
516 | m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); | 522 | m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); |
517 | m_aTrash->setToggleAction(false); | 523 | m_aTrash->setToggleAction(false); |
518 | connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); | 524 | connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); |
519 | 525 | ||
520 | m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); | 526 | m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); |
521 | m_aViewfile->setToggleAction(false); | 527 | m_aViewfile->setToggleAction(false); |
522 | connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); | 528 | connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); |
523 | 529 | ||
524 | m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); | 530 | m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); |
525 | m_aStartSlide->setToggleAction(false); | 531 | m_aStartSlide->setToggleAction(false); |
526 | connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); | 532 | connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); |
527 | 533 | ||
528 | m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); | 534 | m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); |
529 | m_aHideToolbar->setOn (true); | 535 | m_aHideToolbar->setOn (true); |
530 | connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); | 536 | connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); |
531 | 537 | ||
532 | m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); | 538 | m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); |
533 | m_aSetup->setToggleAction(false); | 539 | m_aSetup->setToggleAction(false); |
534 | connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); | 540 | connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); |
535 | 541 | ||
536 | m_gListViewMode = new QActionGroup(this,"Select listmode",true); | 542 | m_gListViewMode = new QActionGroup(this,"Select listmode",true); |
537 | connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); | 543 | connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); |
538 | 544 | ||
539 | m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); | 545 | m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); |
540 | m_aDirLong->setToggleAction(true); | 546 | m_aDirLong->setToggleAction(true); |
541 | m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); | 547 | m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); |
542 | m_aDirShort->setToggleAction(true); | 548 | m_aDirShort->setToggleAction(true); |
543 | m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); | 549 | m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); |
544 | m_aDirName->setToggleAction(true); | 550 | m_aDirName->setToggleAction(true); |
545 | int mode = m_cfg->readNumEntry("ListViewMode", 1); | 551 | int mode = m_cfg->readNumEntry("ListViewMode", 1); |
546 | if (mode < 1 || mode>3) mode = 1; | 552 | if (mode < 1 || mode>3) mode = 1; |
547 | switch (mode) { | 553 | switch (mode) { |
548 | case 3: | 554 | case 3: |
549 | m_aDirName->setOn(true); | 555 | m_aDirName->setOn(true); |
550 | break; | 556 | break; |
551 | case 2: | 557 | case 2: |
552 | m_aDirShort->setOn(true); | 558 | m_aDirShort->setOn(true); |
553 | break; | 559 | break; |
554 | case 1: | 560 | case 1: |
555 | default: | 561 | default: |
556 | m_aDirLong->setOn(true); | 562 | m_aDirLong->setOn(true); |
557 | } | 563 | } |
558 | m_gListViewMode->insert(m_aDirLong); | 564 | m_gListViewMode->insert(m_aDirLong); |
559 | m_gListViewMode->insert(m_aDirShort); | 565 | m_gListViewMode->insert(m_aDirShort); |
560 | m_gListViewMode->insert(m_aDirName); | 566 | m_gListViewMode->insert(m_aDirName); |
561 | 567 | ||
562 | m_gPrevNext = new QActionGroup(this,"imageprevnext",false); | 568 | m_gPrevNext = new QActionGroup(this,"imageprevnext",false); |
563 | m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); | 569 | m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); |
564 | m_aNext->setToggleAction(false); | 570 | m_aNext->setToggleAction(false); |
565 | connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); | 571 | connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); |
566 | m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); | 572 | m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); |
567 | m_aPrevious->setToggleAction(false); | 573 | m_aPrevious->setToggleAction(false); |
568 | connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); | 574 | connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); |
569 | m_gPrevNext->insert(m_aPrevious); | 575 | m_gPrevNext->insert(m_aPrevious); |
570 | m_gPrevNext->insert(m_aNext); | 576 | m_gPrevNext->insert(m_aNext); |
571 | 577 | ||
572 | m_aFullScreen = new QAction( tr( "Show images fullscreen" ), | 578 | m_aFullScreen = new QAction( tr( "Show images fullscreen" ), |
573 | Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); | 579 | Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); |
574 | m_aFullScreen->setToggleAction(true); | 580 | m_aFullScreen->setToggleAction(true); |
575 | if (autoSave) { | 581 | if (autoSave) { |
576 | m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); | 582 | m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); |
577 | } else { | 583 | } else { |
578 | m_aFullScreen->setOn(false); | 584 | m_aFullScreen->setOn(false); |
579 | } | 585 | } |
580 | connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); | 586 | connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); |
581 | 587 | ||
582 | m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); | 588 | m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); |
583 | m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); | 589 | m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); |
584 | m_aAutoRotate->setToggleAction(true); | 590 | m_aAutoRotate->setToggleAction(true); |
585 | 591 | ||
586 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 592 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
587 | m_aAutoRotate->setOn(true); | 593 | m_aAutoRotate->setOn(true); |
588 | } else { | 594 | } else { |
589 | m_aAutoRotate->setOn(false); | 595 | m_aAutoRotate->setOn(false); |
590 | } | 596 | } |
591 | if (autoSave) { | 597 | if (autoSave) { |
592 | m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); | 598 | m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); |
593 | } | 599 | } |
594 | connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 600 | connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
595 | 601 | ||
596 | m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); | 602 | m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); |
597 | m_aUnscaled->setToggleAction(true); | 603 | m_aUnscaled->setToggleAction(true); |
598 | connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 604 | connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
599 | if (autoSave) { | 605 | if (autoSave) { |
600 | m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); | 606 | m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); |
601 | } else { | 607 | } else { |
602 | m_aUnscaled->setOn(false); | 608 | m_aUnscaled->setOn(false); |
603 | } | 609 | } |
604 | 610 | ||
605 | m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); | 611 | m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); |
606 | m_aZoomer->setToggleAction(true); | 612 | m_aZoomer->setToggleAction(true); |
607 | if (autoSave) { | 613 | if (autoSave) { |
608 | m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); | 614 | m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); |
609 | } else { | 615 | } else { |
610 | m_aZoomer->setOn (true); | 616 | m_aZoomer->setOn (true); |
611 | } | 617 | } |
612 | connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 618 | connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
613 | m_gDisplayType->insert(m_aAutoRotate); | 619 | m_gDisplayType->insert(m_aAutoRotate); |
614 | m_gDisplayType->insert(m_aUnscaled); | 620 | m_gDisplayType->insert(m_aUnscaled); |
615 | m_gDisplayType->insert(m_aZoomer); | 621 | m_gDisplayType->insert(m_aZoomer); |
616 | 622 | ||
617 | m_hGroup = new QActionGroup(this,"actioncollection",false); | 623 | m_hGroup = new QActionGroup(this,"actioncollection",false); |
618 | m_hGroup->insert(m_aFullScreen); | 624 | m_hGroup->insert(m_aFullScreen); |
619 | } | 625 | } |
620 | 626 | ||
621 | void PMainWindow::setupToolbar() | 627 | void PMainWindow::setupToolbar() |
622 | { | 628 | { |
623 | toolBar = new QToolBar( this ); | 629 | toolBar = new QToolBar( this ); |
624 | addToolBar(toolBar); | 630 | addToolBar(toolBar); |
625 | toolBar->setHorizontalStretchable( true ); | 631 | toolBar->setHorizontalStretchable( true ); |
626 | setToolBarsMovable( false ); | 632 | setToolBarsMovable( false ); |
627 | m_aDirUp->addTo( toolBar ); | 633 | m_aDirUp->addTo( toolBar ); |
628 | 634 | ||
629 | fsButton = new PFileSystem( toolBar ); | 635 | fsButton = new PFileSystem( toolBar ); |
630 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 636 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
631 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 637 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
632 | connect( this, SIGNAL( changeDir( const QString& ) ), | 638 | connect( this, SIGNAL( changeDir( const QString& ) ), |
633 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 639 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
634 | 640 | ||
635 | if (m_aBeam) { | 641 | if (m_aBeam) { |
636 | m_aBeam->addTo( toolBar ); | 642 | m_aBeam->addTo( toolBar ); |
637 | } | 643 | } |
638 | m_aShowInfo->addTo(toolBar); | 644 | m_aShowInfo->addTo(toolBar); |
639 | m_aTrash->addTo(toolBar); | 645 | m_aTrash->addTo(toolBar); |
640 | // m_aSetup->addTo(toolBar); | 646 | // m_aSetup->addTo(toolBar); |
641 | 647 | ||
642 | m_gDisplayType->addTo(toolBar); | 648 | m_gDisplayType->addTo(toolBar); |
643 | 649 | ||
644 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 650 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
645 | m_gPrevNext->addTo(toolBar); | 651 | m_gPrevNext->addTo(toolBar); |
646 | } else { | 652 | } else { |
647 | m_gPrevNext->setEnabled(false); | 653 | m_gPrevNext->setEnabled(false); |
648 | } | 654 | } |
649 | } | 655 | } |
650 | 656 | ||
651 | void PMainWindow::setupMenu() | 657 | void PMainWindow::setupMenu() |
652 | { | 658 | { |
653 | fileMenu = new QPopupMenu( menuBar() ); | 659 | fileMenu = new QPopupMenu( menuBar() ); |
654 | menuBar()->insertItem( tr( "File" ), fileMenu ); | 660 | menuBar()->insertItem( tr( "File" ), fileMenu ); |
655 | dispMenu = new QPopupMenu( menuBar() ); | 661 | dispMenu = new QPopupMenu( menuBar() ); |
656 | menuBar()->insertItem( tr( "Show" ), dispMenu ); | 662 | menuBar()->insertItem( tr( "Show" ), dispMenu ); |
657 | settingsMenu = new QPopupMenu( menuBar() ); | 663 | settingsMenu = new QPopupMenu( menuBar() ); |
658 | menuBar()->insertItem( tr( "Settings" ), settingsMenu ); | 664 | menuBar()->insertItem( tr( "Settings" ), settingsMenu ); |
659 | 665 | ||
660 | m_aViewfile->addTo(fileMenu); | 666 | m_aViewfile->addTo(fileMenu); |
661 | m_aShowInfo->addTo(fileMenu); | 667 | m_aShowInfo->addTo(fileMenu); |
662 | m_aStartSlide->addTo(fileMenu); | 668 | m_aStartSlide->addTo(fileMenu); |
663 | 669 | ||
664 | fileMenu->insertSeparator(); | 670 | fileMenu->insertSeparator(); |
665 | m_aDirUp->addTo( fileMenu ); | 671 | m_aDirUp->addTo( fileMenu ); |
666 | 672 | ||
667 | fsMenu = new QPopupMenu(fileMenu); | 673 | fsMenu = new QPopupMenu(fileMenu); |
668 | fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); | 674 | fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); |
669 | connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); | 675 | connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); |
670 | dirChanged(); | 676 | dirChanged(); |
671 | 677 | ||
672 | if ( m_aBeam ) { | 678 | if ( m_aBeam ) { |
673 | fileMenu->insertSeparator(); | 679 | fileMenu->insertSeparator(); |
674 | m_aBeam->addTo( fileMenu ); | 680 | m_aBeam->addTo( fileMenu ); |
675 | } | 681 | } |
676 | fileMenu->insertSeparator(); | 682 | fileMenu->insertSeparator(); |
677 | m_aTrash->addTo(fileMenu); | 683 | m_aTrash->addTo(fileMenu); |
678 | 684 | ||
679 | listviewMenu = new QPopupMenu(dispMenu); | 685 | listviewMenu = new QPopupMenu(dispMenu); |
680 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); | 686 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); |
681 | m_gListViewMode->addTo(listviewMenu); | 687 | m_gListViewMode->addTo(listviewMenu); |
682 | dispMenu->insertSeparator(); | 688 | dispMenu->insertSeparator(); |
683 | m_aFullScreen->addTo(dispMenu); | 689 | m_aFullScreen->addTo(dispMenu); |
684 | m_gDisplayType->addTo(dispMenu); | 690 | m_gDisplayType->addTo(dispMenu); |
685 | dispMenu->insertSeparator(); | 691 | dispMenu->insertSeparator(); |
686 | m_gPrevNext->addTo(dispMenu); | 692 | m_gPrevNext->addTo(dispMenu); |
687 | 693 | ||
688 | m_aSetup->addTo(settingsMenu); | 694 | m_aSetup->addTo(settingsMenu); |
689 | m_aHideToolbar->addTo(settingsMenu); | 695 | m_aHideToolbar->addTo(settingsMenu); |
690 | } | 696 | } |
691 | 697 | ||
692 | void PMainWindow::listviewselected(QAction*which) | 698 | void PMainWindow::listviewselected(QAction*which) |
693 | { | 699 | { |
694 | if (!which || which->isOn()==false) return; | 700 | if (!which || which->isOn()==false) return; |
695 | int val = 1; | 701 | int val = 1; |
696 | 702 | ||
697 | if (which==m_aDirName) { | 703 | if (which==m_aDirName) { |
698 | val = 3; | 704 | val = 3; |
699 | } else if (which==m_aDirShort) { | 705 | } else if (which==m_aDirShort) { |
700 | val = 2; | 706 | val = 2; |
701 | } else if (which==m_aDirLong) { | 707 | } else if (which==m_aDirLong) { |
702 | val = 1; | 708 | val = 1; |
703 | } | 709 | } |
704 | emit changeListMode(val); | 710 | emit changeListMode(val); |
705 | } | 711 | } |
706 | 712 | ||
707 | void PMainWindow::readConfig() | 713 | void PMainWindow::readConfig() |