summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp85
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h6
2 files changed, 61 insertions, 30 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 90e2e99..a96bfbd 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -3,123 +3,127 @@
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" )
40OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 40OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
41 41
42PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 42PMainWindow::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 m_SmallWindow = QApplication::desktop()->size().width()<330;
51 52
52 m_storage = new StorageInfo(); 53 m_storage = new StorageInfo();
53 connect(m_storage, SIGNAL(disksChanged() ), 54 connect(m_storage, SIGNAL(disksChanged() ),
54 this, SLOT( dirChanged() ) ); 55 this, SLOT( dirChanged() ) );
55 56
56 m_stack = new Opie::Ui::OWidgetStack( this ); 57 m_stack = new Opie::Ui::OWidgetStack( this );
57 setCentralWidget( m_stack ); 58 setCentralWidget( m_stack );
58 59
59 m_view = new PIconView( m_stack, m_cfg ); 60 m_view = new PIconView( m_stack, m_cfg );
60 m_stack->addWidget( m_view, IconView ); 61 m_stack->addWidget( m_view, IconView );
61 m_stack->raiseWidget( IconView ); 62 m_stack->raiseWidget( IconView );
62 63
63 connect(m_view, SIGNAL(sig_display(const QString&)), 64 connect(m_view, SIGNAL(sig_display(const QString&)),
64 this, SLOT(slotDisplay(const QString&))); 65 this, SLOT(slotDisplay(const QString&)));
65 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 66 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
66 this, SLOT(slotShowInfo(const QString&)) ); 67 this, SLOT(slotShowInfo(const QString&)) );
67 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); 68 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
68 69
69 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 70 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
70 71
71 listviewMenu = 0; 72 listviewMenu = 0;
72 /* setup menu and toolbar */ 73 /* setup menu and toolbar */
73 setupActions(); 74 setupActions();
74 setupToolbar(); 75 setupToolbar();
75 setupMenu(); 76 setupMenu();
76 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); 77 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
77 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); 78 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
79 if (m_aForceSmall) {
80 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true));
81 }
78 odebug << "mainwindow constructor done" << oendl; 82 odebug << "mainwindow constructor done" << oendl;
79} 83}
80 84
81PMainWindow::~PMainWindow() { 85PMainWindow::~PMainWindow() {
82} 86}
83 87
84void PMainWindow::slotToggleZoomer() 88void PMainWindow::slotToggleZoomer()
85{ 89{
86 m_aZoomer->setOn(!m_aZoomer->isOn()); 90 m_aZoomer->setOn(!m_aZoomer->isOn());
87} 91}
88 92
89void PMainWindow::slotZoomerToggled(bool how) 93void PMainWindow::slotZoomerToggled(bool how)
90{ 94{
91 if (m_disp) { 95 if (m_disp) {
92 m_disp->setShowZoomer(how); 96 m_disp->setShowZoomer(how);
93 } 97 }
94 if (autoSave) { 98 if (autoSave) {
95 m_cfg->writeEntry("zoomeron",how); 99 m_cfg->writeEntry("zoomeron",how);
96 } 100 }
97} 101}
98 102
99void PMainWindow::slotToggleAutorotate() 103void PMainWindow::slotToggleAutorotate()
100{ 104{
101 if (!m_aAutoRotate->isEnabled()) return; 105 if (!m_aAutoRotate->isEnabled()) return;
102 m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); 106 m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
103} 107}
104 108
105void PMainWindow::slotToggleAutoscale() 109void PMainWindow::slotToggleAutoscale()
106{ 110{
107 m_aUnscaled->setOn(!m_aUnscaled->isOn()); 111 m_aUnscaled->setOn(!m_aUnscaled->isOn());
108} 112}
109 113
110void PMainWindow::slotRotateToggled(bool how) 114void PMainWindow::slotRotateToggled(bool how)
111{ 115{
112 if (autoSave) { 116 if (autoSave) {
113 m_cfg->writeEntry("autorotate",how); 117 m_cfg->writeEntry("autorotate",how);
114 } 118 }
115 if (m_disp) { 119 if (m_disp) {
116 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); 120 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
117 } 121 }
118} 122}
119 123
120void PMainWindow::slotScaleToggled(bool how) 124void PMainWindow::slotScaleToggled(bool how)
121{ 125{
122 if (autoSave) { 126 if (autoSave) {
123 m_cfg->writeEntry("unscaled",how); 127 m_cfg->writeEntry("unscaled",how);
124 } 128 }
125 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; 129 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
@@ -209,250 +213,248 @@ void PMainWindow::slotConfig() {
209 if ( act ) { 213 if ( act ) {
210 keyWid->save(); 214 keyWid->save();
211 m_disp->manager()->save(); 215 m_disp->manager()->save();
212 m_info->manager()->save(); 216 m_info->manager()->save();
213 m_view->manager()->save(); 217 m_view->manager()->save();
214 bSetup->save_values(); 218 bSetup->save_values();
215 m_view->resetView(); 219 m_view->resetView();
216 readConfig(); 220 readConfig();
217 } 221 }
218 delete keyWid; 222 delete keyWid;
219 223
220 m_stack->raiseWidget(w); 224 m_stack->raiseWidget(w);
221 if (remdisp) { 225 if (remdisp) {
222 m_disp->hide(); 226 m_disp->hide();
223 } 227 }
224 if (reminfo) { 228 if (reminfo) {
225 m_info->hide(); 229 m_info->hide();
226 } 230 }
227} 231}
228 232
229/* 233/*
230 * create a new image info component 234 * create a new image info component
231 * and detach the current one 235 * and detach the current one
232 * we will make the other delete on exit 236 * we will make the other delete on exit
233 */ 237 */
234template<class T> 238template<class T>
235void PMainWindow::initT( const char* name, T** ptr, int id) { 239void PMainWindow::initT( const char* name, T** ptr, int id) {
236 if ( *ptr ) { 240 if ( *ptr ) {
237 (*ptr)->disconnect(this, SLOT(slotReturn())); 241 (*ptr)->disconnect(this, SLOT(slotReturn()));
238 (*ptr)->setDestructiveClose(); 242 (*ptr)->setDestructiveClose();
239 m_stack->removeWidget( *ptr ); 243 m_stack->removeWidget( *ptr );
240 } 244 }
241 *ptr = new T(m_cfg, m_stack, name ); 245 *ptr = new T(m_cfg, m_stack, name );
242 m_stack->addWidget( *ptr, id ); 246 m_stack->addWidget( *ptr, id );
243 247
244 connect(*ptr, SIGNAL(sig_return()), 248 connect(*ptr, SIGNAL(sig_return()),
245 this,SLOT(slotReturn())); 249 this,SLOT(slotReturn()));
246 250
247} 251}
248 252
249void PMainWindow::initInfo() { 253void PMainWindow::initInfo() {
250 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 254 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
251 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 255 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
252} 256}
253 257
254void PMainWindow::initDisp() { 258void PMainWindow::initDisp() {
255 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 259 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
256 if (m_disp) { 260 if (m_disp) {
257 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 261// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
258 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 262 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
259 } 263// }
260 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); 264 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
261 m_disp->setAutoScale(!m_aUnscaled->isOn()); 265 m_disp->setAutoScale(!m_aUnscaled->isOn());
262 m_disp->setAutoRotate(m_aAutoRotate->isOn()); 266 m_disp->setAutoRotate(m_aAutoRotate->isOn());
263 m_disp->setShowZoomer(m_aZoomer->isOn()); 267 m_disp->setShowZoomer(m_aZoomer->isOn());
264 m_disp->setBackgroundColor(white); 268 m_disp->setBackgroundColor(white);
265 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 269 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
266 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 270 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
267 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 271 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
268 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); 272 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
269 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); 273 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
270 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); 274 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
271 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); 275 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
272 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); 276 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
273 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); 277 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
274 slotFullScreenToggled(m_aFullScreen->isOn()); 278 slotFullScreenToggled(m_aFullScreen->isOn());
275 } 279 }
276} 280}
277 281
278void PMainWindow::slotToggleFullScreen() 282void PMainWindow::slotToggleFullScreen()
279{ 283{
280 bool current = !m_aFullScreen->isOn(); 284 bool current = !m_aFullScreen->isOn();
281 m_aFullScreen->setOn(current); 285 m_aFullScreen->setOn(current);
282} 286}
283 287
284void PMainWindow::slotFullScreenButton(bool current) 288void PMainWindow::slotFullScreenButton(bool current)
285{ 289{
286 if (autoSave) { 290 if (autoSave) {
287 m_cfg->writeEntry("fullscreen",current); 291 m_cfg->writeEntry("fullscreen",current);
288 } 292 }
289 if (!m_disp) return; 293 if (!m_disp) return;
290 if (m_disp->isVisible()) { 294 if (m_disp->isVisible()) {
291 setupViewWindow(current, true); 295 setupViewWindow(current, true);
292 } 296 }
293} 297}
294 298
295void PMainWindow::setupViewWindow(bool current, bool forceDisplay) 299void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
296{ 300{
297 if (!m_disp) { 301 if (!m_disp) {
298 return; 302 return;
299 } 303 }
300 if (current) { 304 if (current) {
301 m_disp->setBackgroundColor(black); 305 m_disp->setBackgroundColor(black);
302 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 306 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
303 m_disp->setVScrollBarMode(QScrollView::AlwaysOff); 307 m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
304 m_disp->setHScrollBarMode(QScrollView::AlwaysOff); 308 m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
305 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); 309 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
306 m_disp->setFullScreen(current,forceDisplay); 310 m_disp->setFullScreen(current,forceDisplay);
307 } else { 311 } else {
308 setUpdatesEnabled(false); 312 setUpdatesEnabled(false);
313#if 0
309 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 314 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
310 315
311 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 316 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
312 } else { 317 } else {
313 //m_disp->setMinimumSize(10,10); 318 //m_disp->setMinimumSize(10,10);
314 } 319 }
315 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 320#endif
316 m_disp->reparent(0,QPoint(10,10));
317 } else {
318 m_disp->reparent(0,QPoint(0,0));
319 }
320 m_disp->setBackgroundColor(white); 321 m_disp->setBackgroundColor(white);
321 m_stack->addWidget(m_disp,ImageDisplay); 322 m_stack->addWidget(m_disp,ImageDisplay);
322 m_disp->setVScrollBarMode(QScrollView::Auto); 323 m_disp->setVScrollBarMode(QScrollView::Auto);
323 m_disp->setHScrollBarMode(QScrollView::Auto); 324 m_disp->setHScrollBarMode(QScrollView::Auto);
324 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 325 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
325 m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); 326 m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60);
326 } 327 }
327 if (forceDisplay || m_disp->isVisible()) { 328 if (forceDisplay || m_disp->isVisible()) {
328 m_stack->raiseWidget(m_disp); 329 m_stack->raiseWidget(m_disp);
329 m_disp->setFocus(); 330 m_disp->setFocus();
330 } 331 }
331 setUpdatesEnabled(true); 332 setUpdatesEnabled(true);
332 } 333 }
333 m_disp->setFullScreen(current,forceDisplay); 334 m_disp->setFullScreen(current,forceDisplay);
334} 335}
335 336
336void PMainWindow::slotFullScreenToggled(bool current) 337void PMainWindow::slotFullScreenToggled(bool current)
337{ 338{
338 setupViewWindow(current,true); 339 setupViewWindow(current,true);
339} 340}
340 341
341/** 342/**
342 * With big Screen the plan could be to 'detach' the image 343 * With big Screen the plan could be to 'detach' the image
343 * window if visible and to create a ne wone 344 * window if visible and to create a ne wone
344 * init* already supports it but I make no use of it for 345 * init* already supports it but I make no use of it for
345 * now. We set filename and raise 346 * now. We set filename and raise
346 * 347 *
347 * ### FIXME and talk to alwin 348 * ### FIXME and talk to alwin
348 */ 349 */
349void PMainWindow::slotShowInfo( const QString& inf ) { 350void PMainWindow::slotShowInfo( const QString& inf ) {
350 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 351 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
351 return; 352 return;
352 } 353 }
353 if ( !m_info ) { 354 if ( !m_info ) {
354 initInfo(); 355 initInfo();
355 } 356 }
356 m_info->setPath( inf ); 357 m_info->setPath( inf );
357 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 358 if (m_SmallWindow) {
358 m_aNext->removeFrom(toolBar); 359 m_aNext->removeFrom(toolBar);
359 m_aPrevious->removeFrom(toolBar); 360 m_aPrevious->removeFrom(toolBar);
360 m_aNext->setEnabled(false);
361 m_aPrevious->setEnabled(false);
362 m_aDirUp->setEnabled(false);
363 m_aShowInfo->setEnabled(false);
364 m_aViewfile->setEnabled(true);
365 m_aStartSlide->setEnabled(false);
366 fsButton->hide(); 361 fsButton->hide();
367 } 362 }
363 m_aNext->setEnabled(false);
364 m_aPrevious->setEnabled(false);
365 m_aDirUp->setEnabled(false);
366 m_aShowInfo->setEnabled(false);
367 m_aViewfile->setEnabled(true);
368 m_aStartSlide->setEnabled(false);
368 m_stack->raiseWidget( ImageInfo ); 369 m_stack->raiseWidget( ImageInfo );
369} 370}
370 371
371void PMainWindow::slotDisplay( const QString& inf ) { 372void PMainWindow::slotDisplay( const QString& inf ) {
372 bool nwindow = false; 373 bool nwindow = false;
373 if ( !m_disp ) { 374 if ( !m_disp ) {
374 nwindow = true; 375 nwindow = true;
375 initDisp(); 376 initDisp();
376 } 377 }
377 m_disp->setImage( inf ); 378 m_disp->setImage( inf );
378 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 379 if (m_SmallWindow) {
379 if (m_gPrevNext->isEnabled()==false) { 380 if (m_gPrevNext->isEnabled()==false) {
380 m_gPrevNext->addTo(toolBar); 381 m_gPrevNext->addTo(toolBar);
381 m_gPrevNext->setEnabled(true);
382
383 m_aDirUp->setEnabled(false);
384 m_aShowInfo->setEnabled(true);
385 m_aViewfile->setEnabled(false);
386 m_aStartSlide->setEnabled(false);
387 fsButton->hide(); 382 fsButton->hide();
388 } 383 }
389 } 384 }
385 m_gPrevNext->setEnabled(true);
386 m_aDirUp->setEnabled(false);
387 m_aShowInfo->setEnabled(true);
388 m_aViewfile->setEnabled(false);
389 m_aStartSlide->setEnabled(false);
390
390 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { 391 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
391 slotFullScreenToggled(m_aFullScreen->isOn()); 392 slotFullScreenToggled(m_aFullScreen->isOn());
392 } 393 }
393 if (m_disp->fullScreen()) { 394 if (m_disp->fullScreen()) {
394 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 395 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
395 } else { 396 } else {
396 m_stack->raiseWidget( ImageDisplay ); 397 m_stack->raiseWidget( ImageDisplay );
397 } 398 }
398} 399}
399 400
400void PMainWindow::raiseIconView() { 401void PMainWindow::raiseIconView() {
401 setUpdatesEnabled(false); 402 setUpdatesEnabled(false);
402 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 403 if (m_SmallWindow) {
403 m_gPrevNext->removeFrom(toolBar); 404 m_gPrevNext->removeFrom(toolBar);
404 m_gPrevNext->setEnabled(false);
405 m_aDirUp->setEnabled(true);
406 m_aShowInfo->setEnabled(true);
407 m_aViewfile->setEnabled(true);
408 m_aStartSlide->setEnabled(true);
409 fsButton->show(); 405 fsButton->show();
410 } 406 }
407 m_gPrevNext->setEnabled(false);
408 m_aDirUp->setEnabled(true);
409 m_aShowInfo->setEnabled(true);
410 m_aViewfile->setEnabled(true);
411 m_aStartSlide->setEnabled(true);
412
411 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 413 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
412 m_disp->stopSlide(); 414 m_disp->stopSlide();
413 m_disp->hide(); 415 m_disp->hide();
414 } 416 }
415 m_stack->raiseWidget( IconView ); 417 m_stack->raiseWidget( IconView );
416 setUpdatesEnabled(true); 418 setUpdatesEnabled(true);
417 repaint(); 419 repaint();
418} 420}
419 421
420void PMainWindow::slotReturn() { 422void PMainWindow::slotReturn() {
421 raiseIconView(); 423 raiseIconView();
422} 424}
423 425
424 426
425void PMainWindow::closeEvent( QCloseEvent* ev ) { 427void PMainWindow::closeEvent( QCloseEvent* ev ) {
426 /* 428 /*
427 * return from view 429 * return from view
428 * or properly quit 430 * or properly quit
429 */ 431 */
430 if (!m_setDocCalled) { 432 if (!m_setDocCalled) {
431 if ( m_stack->visibleWidget() == m_info || 433 if ( m_stack->visibleWidget() == m_info ||
432 m_stack->visibleWidget() == m_disp ) { 434 m_stack->visibleWidget() == m_disp ) {
433 ev->ignore(); 435 ev->ignore();
434 raiseIconView(); 436 raiseIconView();
435 return; 437 return;
436 } 438 }
437 } 439 }
438 if (m_disp && m_disp->fullScreen()) { 440 if (m_disp && m_disp->fullScreen()) {
439 /* otherwise opie-eye crashes in bigscreen mode! */ 441 /* otherwise opie-eye crashes in bigscreen mode! */
440 m_disp->reparent(0,QPoint(0,0)); 442 m_disp->reparent(0,QPoint(0,0));
441 m_stack->addWidget(m_disp,ImageDisplay); 443 m_stack->addWidget(m_disp,ImageDisplay);
442 } 444 }
443 ev->accept(); 445 ev->accept();
444 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 446 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
445} 447}
446 448
447void PMainWindow::setDocument( const QString& showImg ) 449void PMainWindow::setDocument( const QString& showImg )
448{ 450{
449 QString file = showImg; 451 QString file = showImg;
450 DocLnk lnk(showImg); 452 DocLnk lnk(showImg);
451 if (lnk.isValid() ) 453 if (lnk.isValid() )
452 file = lnk.file(); 454 file = lnk.file();
453 slotDisplay( file ); 455 slotDisplay( file );
454#if 0 456#if 0
455 if (!m_polishDone) { 457 if (!m_polishDone) {
456 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 458 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
457 } 459 }
458#endif 460#endif
@@ -577,163 +579,190 @@ void PMainWindow::setupActions()
577 579
578 m_aFullScreen = new QAction( tr( "Show images fullscreen" ), 580 m_aFullScreen = new QAction( tr( "Show images fullscreen" ),
579 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); 581 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true );
580 m_aFullScreen->setToggleAction(true); 582 m_aFullScreen->setToggleAction(true);
581 if (autoSave) { 583 if (autoSave) {
582 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); 584 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false));
583 } else { 585 } else {
584 m_aFullScreen->setOn(false); 586 m_aFullScreen->setOn(false);
585 } 587 }
586 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); 588 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool)));
587 589
588 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); 590 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false);
589 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); 591 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true );
590 m_aAutoRotate->setToggleAction(true); 592 m_aAutoRotate->setToggleAction(true);
591 593
592 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 594 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
593 m_aAutoRotate->setOn(true); 595 m_aAutoRotate->setOn(true);
594 } else { 596 } else {
595 m_aAutoRotate->setOn(false); 597 m_aAutoRotate->setOn(false);
596 } 598 }
597 if (autoSave) { 599 if (autoSave) {
598 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); 600 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn()));
599 } 601 }
600 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 602 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
601 603
602 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); 604 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true );
603 m_aUnscaled->setToggleAction(true); 605 m_aUnscaled->setToggleAction(true);
604 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 606 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
605 if (autoSave) { 607 if (autoSave) {
606 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); 608 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false));
607 } else { 609 } else {
608 m_aUnscaled->setOn(false); 610 m_aUnscaled->setOn(false);
609 } 611 }
610 612
611 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); 613 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true );
612 m_aZoomer->setToggleAction(true); 614 m_aZoomer->setToggleAction(true);
613 if (autoSave) { 615 if (autoSave) {
614 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); 616 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true));
615 } else { 617 } else {
616 m_aZoomer->setOn (true); 618 m_aZoomer->setOn (true);
617 } 619 }
618 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 620 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
619 m_gDisplayType->insert(m_aAutoRotate); 621 m_gDisplayType->insert(m_aAutoRotate);
620 m_gDisplayType->insert(m_aUnscaled); 622 m_gDisplayType->insert(m_aUnscaled);
621 m_gDisplayType->insert(m_aZoomer); 623 m_gDisplayType->insert(m_aZoomer);
622 624
623 m_hGroup = new QActionGroup(this,"actioncollection",false); 625 m_hGroup = new QActionGroup(this,"actioncollection",false);
624 m_hGroup->insert(m_aFullScreen); 626 m_hGroup->insert(m_aFullScreen);
627
628 if (!m_SmallWindow) {
629 m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true);
630 m_aForceSmall->setToggleAction(true);
631 connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool)));
632 } else {
633 m_aForceSmall = 0;
634 }
625} 635}
626 636
627void PMainWindow::setupToolbar() 637void PMainWindow::setupToolbar()
628{ 638{
629 toolBar = new QToolBar( this ); 639 toolBar = new QToolBar( this );
630 addToolBar(toolBar); 640 addToolBar(toolBar);
631 toolBar->setHorizontalStretchable( true ); 641 toolBar->setHorizontalStretchable( true );
632 setToolBarsMovable( false ); 642 setToolBarsMovable( false );
633 m_aDirUp->addTo( toolBar ); 643 m_aDirUp->addTo( toolBar );
634 644
635 fsButton = new PFileSystem( toolBar ); 645 fsButton = new PFileSystem( toolBar );
636 connect( fsButton, SIGNAL( changeDir( const QString& ) ), 646 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
637 m_view, SLOT(slotChangeDir( const QString& ) ) ); 647 m_view, SLOT(slotChangeDir( const QString& ) ) );
638 connect( this, SIGNAL( changeDir( const QString& ) ), 648 connect( this, SIGNAL( changeDir( const QString& ) ),
639 m_view, SLOT(slotChangeDir( const QString& ) ) ); 649 m_view, SLOT(slotChangeDir( const QString& ) ) );
640 650
641 if (m_aBeam) { 651 if (m_aBeam) {
642 m_aBeam->addTo( toolBar ); 652 m_aBeam->addTo( toolBar );
643 } 653 }
644 m_aShowInfo->addTo(toolBar); 654 m_aShowInfo->addTo(toolBar);
645 m_aTrash->addTo(toolBar); 655 m_aTrash->addTo(toolBar);
646// m_aSetup->addTo(toolBar); 656// m_aSetup->addTo(toolBar);
647 657
648 m_gDisplayType->addTo(toolBar); 658 m_gDisplayType->addTo(toolBar);
649 659
650 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 660 if (!m_SmallWindow) {
651 m_gPrevNext->addTo(toolBar); 661 m_gPrevNext->addTo(toolBar);
652 } else { 662 } else {
653 m_gPrevNext->setEnabled(false); 663 m_gPrevNext->setEnabled(false);
654 } 664 }
655} 665}
656 666
657void PMainWindow::setupMenu() 667void PMainWindow::setupMenu()
658{ 668{
659 fileMenu = new QPopupMenu( menuBar() ); 669 fileMenu = new QPopupMenu( menuBar() );
660 menuBar()->insertItem( tr( "File" ), fileMenu ); 670 menuBar()->insertItem( tr( "File" ), fileMenu );
661 dispMenu = new QPopupMenu( menuBar() ); 671 dispMenu = new QPopupMenu( menuBar() );
662 menuBar()->insertItem( tr( "Show" ), dispMenu ); 672 menuBar()->insertItem( tr( "Show" ), dispMenu );
663 settingsMenu = new QPopupMenu( menuBar() ); 673 settingsMenu = new QPopupMenu( menuBar() );
664 menuBar()->insertItem( tr( "Settings" ), settingsMenu ); 674 menuBar()->insertItem( tr( "Settings" ), settingsMenu );
665 675
666 m_aViewfile->addTo(fileMenu); 676 m_aViewfile->addTo(fileMenu);
667 m_aShowInfo->addTo(fileMenu); 677 m_aShowInfo->addTo(fileMenu);
668 m_aStartSlide->addTo(fileMenu); 678 m_aStartSlide->addTo(fileMenu);
669 679
670 fileMenu->insertSeparator(); 680 fileMenu->insertSeparator();
671 m_aDirUp->addTo( fileMenu ); 681 m_aDirUp->addTo( fileMenu );
672 682
673 fsMenu = new QPopupMenu(fileMenu); 683 fsMenu = new QPopupMenu(fileMenu);
674 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); 684 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu);
675 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); 685 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) );
676 dirChanged(); 686 dirChanged();
677 687
678 if ( m_aBeam ) { 688 if ( m_aBeam ) {
679 fileMenu->insertSeparator(); 689 fileMenu->insertSeparator();
680 m_aBeam->addTo( fileMenu ); 690 m_aBeam->addTo( fileMenu );
681 } 691 }
682 fileMenu->insertSeparator(); 692 fileMenu->insertSeparator();
683 m_aTrash->addTo(fileMenu); 693 m_aTrash->addTo(fileMenu);
684 694
685 listviewMenu = new QPopupMenu(dispMenu); 695 listviewMenu = new QPopupMenu(dispMenu);
686 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); 696 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
687 m_gListViewMode->addTo(listviewMenu); 697 m_gListViewMode->addTo(listviewMenu);
688 dispMenu->insertSeparator(); 698 dispMenu->insertSeparator();
689 m_aFullScreen->addTo(dispMenu); 699 m_aFullScreen->addTo(dispMenu);
690 m_gDisplayType->addTo(dispMenu); 700 m_gDisplayType->addTo(dispMenu);
691 dispMenu->insertSeparator(); 701 dispMenu->insertSeparator();
692 m_gPrevNext->addTo(dispMenu); 702 m_gPrevNext->addTo(dispMenu);
703 if (m_aForceSmall) {
704 dispMenu->insertSeparator();
705 m_aForceSmall->addTo(dispMenu);
706 }
693 707
694 m_aSetup->addTo(settingsMenu); 708 m_aSetup->addTo(settingsMenu);
695 m_aHideToolbar->addTo(settingsMenu); 709 m_aHideToolbar->addTo(settingsMenu);
696} 710}
697 711
698void PMainWindow::listviewselected(QAction*which) 712void PMainWindow::listviewselected(QAction*which)
699{ 713{
700 if (!which || which->isOn()==false) return; 714 if (!which || which->isOn()==false) return;
701 int val = 1; 715 int val = 1;
702 716
703 if (which==m_aDirName) { 717 if (which==m_aDirName) {
704 val = 3; 718 val = 3;
705 } else if (which==m_aDirShort) { 719 } else if (which==m_aDirShort) {
706 val = 2; 720 val = 2;
707 } else if (which==m_aDirLong) { 721 } else if (which==m_aDirLong) {
708 val = 1; 722 val = 1;
709 } 723 }
710 emit changeListMode(val); 724 emit changeListMode(val);
711} 725}
712 726
713void PMainWindow::readConfig() 727void PMainWindow::readConfig()
714{ 728{
715 autoSave =m_cfg->readBoolEntry("savestatus",true); 729 autoSave =m_cfg->readBoolEntry("savestatus",true);
716} 730}
717 731
718void PMainWindow::polish() 732void PMainWindow::polish()
719{ 733{
720 if (m_disp) { 734 if (m_disp) {
721 odebug << "======================\n" 735 odebug << "======================\n"
722 << "Called via setdocument\n" 736 << "Called via setdocument\n"
723 << "======================" << oendl; 737 << "======================" << oendl;
724 m_setDocCalled = true; 738 m_setDocCalled = true;
725 m_view->setDoccalled(true); 739 m_view->setDoccalled(true);
726 m_disp->setCloseIfHide(true); 740 m_disp->setCloseIfHide(true);
727 } else { 741 } else {
728 m_setDocCalled = false; 742 m_setDocCalled = false;
729 m_view->setDoccalled(false); 743 m_view->setDoccalled(false);
730 } 744 }
731 m_polishDone = true; 745 m_polishDone = true;
732 QMainWindow::polish(); 746 QMainWindow::polish();
733 if (m_setDocCalled) { 747 if (m_setDocCalled) {
734 if (m_aFullScreen->isOn()) { 748 if (m_aFullScreen->isOn()) {
735 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 749 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
736 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 750 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
737 } 751 }
738 } 752 }
739} 753}
754
755void PMainWindow::slotForceSmall(bool how)
756{
757 odebug << "Disable separate windows: " << how << oendl;
758 if (m_stack) {
759 if (how) {
760 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
761 } else {
762 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
763 }
764 }
765 if (autoSave) {
766 m_cfg->writeEntry("dontshowseperate",how);
767 }
768}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 2f54090..a49a9d3 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -35,76 +35,78 @@ class StorageInfo;
35class PMainWindow : public QMainWindow { 35class PMainWindow : public QMainWindow {
36 Q_OBJECT 36 Q_OBJECT
37 enum Views { IconView, ImageInfo, ImageDisplay }; 37 enum Views { IconView, ImageInfo, ImageDisplay };
38public: 38public:
39 static QString appName() { return QString::fromLatin1("opie-eye" ); } 39 static QString appName() { return QString::fromLatin1("opie-eye" ); }
40 PMainWindow(QWidget*, const char*, WFlags ); 40 PMainWindow(QWidget*, const char*, WFlags );
41 ~PMainWindow(); 41 ~PMainWindow();
42 42
43signals: 43signals:
44 void configChanged(); 44 void configChanged();
45 void changeDir( const QString& ); 45 void changeDir( const QString& );
46 void changeListMode(int); 46 void changeListMode(int);
47 47
48public slots: 48public slots:
49 void slotShowInfo( const QString& inf ); 49 void slotShowInfo( const QString& inf );
50 void slotDisplay( const QString& inf ); 50 void slotDisplay( const QString& inf );
51 void slotReturn(); 51 void slotReturn();
52 void slotRotateToggled(bool); 52 void slotRotateToggled(bool);
53 void slotScaleToggled(bool); 53 void slotScaleToggled(bool);
54 void slotZoomerToggled(bool); 54 void slotZoomerToggled(bool);
55 void slotToggleZoomer(); 55 void slotToggleZoomer();
56 void slotToggleAutorotate(); 56 void slotToggleAutorotate();
57 void slotToggleAutoscale(); 57 void slotToggleAutoscale();
58 void setDocument( const QString& ); 58 void setDocument( const QString& );
59 virtual void slotToggleFullScreen(); 59 virtual void slotToggleFullScreen();
60 virtual void slotFullScreenToggled(bool); 60 virtual void slotFullScreenToggled(bool);
61 virtual void polish(); 61 virtual void polish();
62 62
63protected slots: 63protected slots:
64 void raiseIconView(); 64 void raiseIconView();
65 void closeEvent( QCloseEvent* ); 65 void closeEvent( QCloseEvent* );
66 void showToolbar(bool); 66 void showToolbar(bool);
67 void listviewselected(QAction*); 67 void listviewselected(QAction*);
68 void slotFullScreenButton(bool); 68 void slotFullScreenButton(bool);
69 void check_view_fullscreen(); 69 void check_view_fullscreen();
70 70
71private: 71private:
72 template<class T> void initT( const char* name, T**, int ); 72 template<class T> void initT( const char* name, T**, int );
73 void initInfo(); 73 void initInfo();
74 void initDisp(); 74 void initDisp();
75 void setupViewWindow(bool full, bool forceDisplay); 75 void setupViewWindow(bool full, bool forceDisplay);
76 76
77private: 77private:
78 Opie::Core::OConfig *m_cfg; 78 Opie::Core::OConfig *m_cfg;
79 Opie::Ui::OWidgetStack *m_stack; 79 Opie::Ui::OWidgetStack *m_stack;
80 PIconView* m_view; 80 PIconView* m_view;
81 imageinfo *m_info; 81 imageinfo *m_info;
82 ImageView *m_disp; 82 ImageView *m_disp;
83 bool autoSave; 83 bool autoSave:1;
84 bool m_setDocCalled:1; 84 bool m_setDocCalled:1;
85 bool m_polishDone:1; 85 bool m_polishDone:1;
86 bool m_SmallWindow:1;
86 QToolButton*fsButton; 87 QToolButton*fsButton;
87 QToolBar *toolBar; 88 QToolBar *toolBar;
88 QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu,*settingsMenu; 89 QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu,*settingsMenu;
89 QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide; 90 QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide;
90 QAction*m_aHideToolbar,*m_aSetup,*m_aDirName,*m_aDirShort,*m_aDirLong; 91 QAction*m_aHideToolbar,*m_aSetup,*m_aDirName,*m_aDirShort,*m_aDirLong;
91 QActionGroup *m_gListViewMode,*m_gDisplayType,*m_gPrevNext,*m_hGroup; 92 QActionGroup *m_gListViewMode,*m_gDisplayType,*m_gPrevNext,*m_hGroup;
92 QAction *m_aNext,*m_aPrevious,*m_aFullScreen; 93 QAction *m_aNext,*m_aPrevious,*m_aFullScreen;
93 QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer; 94 QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer,*m_aForceSmall;
94 95
95 /* init funs */ 96 /* init funs */
96 void readConfig(); 97 void readConfig();
97 void setupActions(); 98 void setupActions();
98 void setupToolbar(); 99 void setupToolbar();
99 void setupMenu(); 100 void setupMenu();
100 /* for the device submenu - ToDo: Merge with the special button */ 101 /* for the device submenu - ToDo: Merge with the special button */
101 StorageInfo *m_storage; 102 StorageInfo *m_storage;
102 QMap<QString, QString> m_dev; 103 QMap<QString, QString> m_dev;
103 104
104private slots: 105private slots:
105 void slotConfig(); 106 void slotConfig();
106 void slotSelectDir(int); 107 void slotSelectDir(int);
107 void dirChanged(); 108 void dirChanged();
109 void slotForceSmall(bool);
108}; 110};
109 111
110#endif 112#endif