Diffstat (limited to 'noncore/graphics/opie-eye/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 0484f73..a784f5b 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -27,24 +27,25 @@ | |||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qdialog.h> | 30 | #include <qdialog.h> |
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | #include <qframe.h> | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 37 | OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
38 | 38 | ||
39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
41 | { | 41 | { |
42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
43 | m_cfg = new Opie::Core::OConfig("phunkview"); | 43 | m_cfg = new Opie::Core::OConfig("phunkview"); |
44 | m_cfg->setGroup("Zecke_view" ); | 44 | m_cfg->setGroup("Zecke_view" ); |
45 | tFrame = 0; | ||
45 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); | 46 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); |
46 | /* | 47 | /* |
47 | * Initialize ToolBar and IconView | 48 | * Initialize ToolBar and IconView |
48 | * And Connect Them | 49 | * And Connect Them |
49 | */ | 50 | */ |
50 | QToolBar *bar = new QToolBar( this ); | 51 | QToolBar *bar = new QToolBar( this ); |
@@ -125,29 +126,31 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
125 | rotateButton->setOn(false); | 126 | rotateButton->setOn(false); |
126 | autoRotate = false; | 127 | autoRotate = false; |
127 | } | 128 | } |
128 | 129 | ||
129 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 130 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
130 | 131 | ||
131 | btn = new QToolButton(bar); | 132 | scaleButton = new QToolButton(bar); |
132 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); | 133 | scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); |
133 | btn->setToggleButton(true); | 134 | scaleButton->setToggleButton(true); |
134 | btn->setOn(false); | 135 | scaleButton->setOn(false); |
135 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 136 | connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
136 | autoScale = true; | 137 | autoScale = true; |
137 | 138 | ||
138 | zoomButton = new QToolButton(bar); | 139 | zoomButton = new QToolButton(bar); |
139 | zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); | 140 | zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); |
140 | zoomButton->setToggleButton(true); | 141 | zoomButton->setToggleButton(true); |
141 | zoomButton->setOn(true); | 142 | zoomButton->setOn(true); |
142 | connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 143 | connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
143 | zoomerOn = true; | 144 | zoomerOn = true; |
144 | } | 145 | } |
145 | 146 | ||
146 | PMainWindow::~PMainWindow() { | 147 | PMainWindow::~PMainWindow() { |
147 | odebug << "Shutting down" << oendl; | 148 | odebug << "Shutting down" << oendl; |
149 | if (tFrame) delete tFrame; | ||
150 | odebug << "Shutting down done" << oendl; | ||
148 | } | 151 | } |
149 | 152 | ||
150 | void PMainWindow::slotToggleZoomer() | 153 | void PMainWindow::slotToggleZoomer() |
151 | { | 154 | { |
152 | if (!m_disp) return; | 155 | if (!m_disp) return; |
153 | bool cur = zoomButton->isOn(); | 156 | bool cur = zoomButton->isOn(); |
@@ -159,12 +162,27 @@ void PMainWindow::slotZoomerToggled(bool how) | |||
159 | zoomerOn = how; | 162 | zoomerOn = how; |
160 | if (m_disp) { | 163 | if (m_disp) { |
161 | m_disp->setShowZoomer(zoomerOn); | 164 | m_disp->setShowZoomer(zoomerOn); |
162 | } | 165 | } |
163 | } | 166 | } |
164 | 167 | ||
168 | void PMainWindow::slotToggleAutorotate() | ||
169 | { | ||
170 | if (!m_disp) return; | ||
171 | if (!rotateButton->isEnabled()) return; | ||
172 | bool cur = rotateButton->isOn(); | ||
173 | rotateButton->setOn(!cur); | ||
174 | } | ||
175 | |||
176 | void PMainWindow::slotToggleAutoscale() | ||
177 | { | ||
178 | if (!m_disp) return; | ||
179 | bool cur = scaleButton->isOn(); | ||
180 | scaleButton->setOn(!cur); | ||
181 | } | ||
182 | |||
165 | void PMainWindow::slotRotateToggled(bool how) | 183 | void PMainWindow::slotRotateToggled(bool how) |
166 | { | 184 | { |
167 | autoRotate = how; | 185 | autoRotate = how; |
168 | if (m_disp) { | 186 | if (m_disp) { |
169 | m_disp->setAutoRotate(how); | 187 | m_disp->setAutoRotate(how); |
170 | } | 188 | } |
@@ -292,12 +310,14 @@ void PMainWindow::initDisp() { | |||
292 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 310 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
293 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 311 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
294 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 312 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
295 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); | 313 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); |
296 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 314 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
297 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 315 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
316 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | ||
317 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | ||
298 | } | 318 | } |
299 | } | 319 | } |
300 | 320 | ||
301 | void PMainWindow::slotToggleFullScreen() | 321 | void PMainWindow::slotToggleFullScreen() |
302 | { | 322 | { |
303 | odebug << "Toggle full " << oendl; | 323 | odebug << "Toggle full " << oendl; |
@@ -305,19 +325,28 @@ void PMainWindow::slotToggleFullScreen() | |||
305 | bool current = !m_disp->fullScreen(); | 325 | bool current = !m_disp->fullScreen(); |
306 | m_disp->setFullScreen(current); | 326 | m_disp->setFullScreen(current); |
307 | odebug << "Current = " << current << oendl; | 327 | odebug << "Current = " << current << oendl; |
308 | if (current) { | 328 | if (current) { |
309 | odebug << "full" << oendl; | 329 | odebug << "full" << oendl; |
310 | m_disp->setBackgroundColor(black); | 330 | m_disp->setBackgroundColor(black); |
311 | m_disp->reparent(0,QPoint(0,0)); | 331 | if (!tFrame) { |
332 | tFrame = new QWidget(0,0,WType_TopLevel|WStyle_NoBorder|WStyle_StaysOnTop); | ||
333 | tFrame->resize(qApp->desktop()->width(), qApp->desktop()->height()); | ||
334 | tFrame->setMinimumSize(qApp->desktop()->width(), qApp->desktop()->height()); | ||
335 | } | ||
336 | m_disp->reparent(tFrame,QPoint(0,0)); | ||
312 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); | 337 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); |
313 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); | 338 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); |
314 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 339 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
315 | m_disp->showFullScreen(); | 340 | tFrame->showFullScreen(); |
316 | } else { | 341 | } else { |
317 | odebug << "window" << oendl; | 342 | odebug << "window" << oendl; |
343 | m_disp->reparent(0,QPoint(0,0)); | ||
344 | m_disp->showNormal(); | ||
345 | /* don't forget it! */ | ||
346 | tFrame->hide(); | ||
318 | m_disp->setBackgroundColor(white); | 347 | m_disp->setBackgroundColor(white); |
319 | m_stack->addWidget(m_disp,ImageDisplay); | 348 | m_stack->addWidget(m_disp,ImageDisplay); |
320 | m_disp->setVScrollBarMode(QScrollView::Auto); | 349 | m_disp->setVScrollBarMode(QScrollView::Auto); |
321 | m_disp->setHScrollBarMode(QScrollView::Auto); | 350 | m_disp->setHScrollBarMode(QScrollView::Auto); |
322 | m_stack->raiseWidget(m_disp); | 351 | m_stack->raiseWidget(m_disp); |
323 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 352 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
@@ -332,26 +361,26 @@ void PMainWindow::slotToggleFullScreen() | |||
332 | * init* already supports it but I make no use of it for | 361 | * init* already supports it but I make no use of it for |
333 | * now. We set filename and raise | 362 | * now. We set filename and raise |
334 | * | 363 | * |
335 | * ### FIXME and talk to alwin | 364 | * ### FIXME and talk to alwin |
336 | */ | 365 | */ |
337 | void PMainWindow::slotShowInfo( const QString& inf ) { | 366 | void PMainWindow::slotShowInfo( const QString& inf ) { |
367 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | ||
368 | return; | ||
369 | } | ||
338 | if ( !m_info ) { | 370 | if ( !m_info ) { |
339 | initInfo(); | 371 | initInfo(); |
340 | } | 372 | } |
341 | m_info->setPath( inf ); | 373 | m_info->setPath( inf ); |
342 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 374 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
343 | prevButton->hide(); | 375 | prevButton->hide(); |
344 | nextButton->hide(); | 376 | nextButton->hide(); |
345 | upButton->hide(); | 377 | upButton->hide(); |
346 | fsButton->hide(); | 378 | fsButton->hide(); |
347 | viewModeButton->hide(); | 379 | viewModeButton->hide(); |
348 | } | 380 | } |
349 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | ||
350 | m_disp->hide(); | ||
351 | } | ||
352 | m_stack->raiseWidget( ImageInfo ); | 381 | m_stack->raiseWidget( ImageInfo ); |
353 | } | 382 | } |
354 | 383 | ||
355 | void PMainWindow::slotDisplay( const QString& inf ) { | 384 | void PMainWindow::slotDisplay( const QString& inf ) { |
356 | if ( !m_disp ) { | 385 | if ( !m_disp ) { |
357 | initDisp(); | 386 | initDisp(); |
@@ -362,13 +391,14 @@ void PMainWindow::slotDisplay( const QString& inf ) { | |||
362 | nextButton->show(); | 391 | nextButton->show(); |
363 | upButton->hide(); | 392 | upButton->hide(); |
364 | fsButton->hide(); | 393 | fsButton->hide(); |
365 | viewModeButton->hide(); | 394 | viewModeButton->hide(); |
366 | } | 395 | } |
367 | if (m_disp->fullScreen()) { | 396 | if (m_disp->fullScreen()) { |
368 | m_disp->show(); | 397 | tFrame->setActiveWindow(); |
398 | tFrame->showFullScreen(); | ||
369 | } else { | 399 | } else { |
370 | m_stack->raiseWidget( ImageDisplay ); | 400 | m_stack->raiseWidget( ImageDisplay ); |
371 | } | 401 | } |
372 | } | 402 | } |
373 | 403 | ||
374 | void PMainWindow::slotReturn() { | 404 | void PMainWindow::slotReturn() { |
@@ -380,16 +410,21 @@ void PMainWindow::closeEvent( QCloseEvent* ev ) { | |||
380 | /* | 410 | /* |
381 | * return from view | 411 | * return from view |
382 | * or properly quit | 412 | * or properly quit |
383 | */ | 413 | */ |
384 | if ( m_stack->visibleWidget() == m_info || | 414 | if ( m_stack->visibleWidget() == m_info || |
385 | m_stack->visibleWidget() == m_disp ) { | 415 | m_stack->visibleWidget() == m_disp ) { |
386 | raiseIconView(); | ||
387 | ev->ignore(); | 416 | ev->ignore(); |
417 | raiseIconView(); | ||
388 | return; | 418 | return; |
389 | } | 419 | } |
420 | if (m_disp && m_disp->fullScreen()) { | ||
421 | /* otherwise opie-eye crashes in bigscreen mode! */ | ||
422 | m_disp->reparent(0,QPoint(0,0)); | ||
423 | m_stack->addWidget(m_disp,ImageDisplay); | ||
424 | } | ||
390 | ev->accept(); | 425 | ev->accept(); |
391 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 426 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
392 | } | 427 | } |
393 | 428 | ||
394 | void PMainWindow::raiseIconView() { | 429 | void PMainWindow::raiseIconView() { |
395 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 430 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
@@ -397,13 +432,13 @@ void PMainWindow::raiseIconView() { | |||
397 | nextButton->hide(); | 432 | nextButton->hide(); |
398 | upButton->show(); | 433 | upButton->show(); |
399 | fsButton->show(); | 434 | fsButton->show(); |
400 | viewModeButton->show(); | 435 | viewModeButton->show(); |
401 | } | 436 | } |
402 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 437 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
403 | m_disp->hide(); | 438 | tFrame->hide(); |
404 | } | 439 | } |
405 | m_stack->raiseWidget( IconView ); | 440 | m_stack->raiseWidget( IconView ); |
406 | } | 441 | } |
407 | 442 | ||
408 | void PMainWindow::setDocument( const QString& showImg ) { | 443 | void PMainWindow::setDocument( const QString& showImg ) { |
409 | QString file = showImg; | 444 | QString file = showImg; |