summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/mainwindow.cpp
Unidiff
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.cpp63
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
@@ -9,60 +9,61 @@
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12 12
13#include <iface/ifaceinfo.h> 13#include <iface/ifaceinfo.h>
14#include <iface/dirview.h> 14#include <iface/dirview.h>
15 15
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/owidgetstack.h> 17#include <opie2/owidgetstack.h>
18#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
19#include <opie2/otabwidget.h> 19#include <opie2/otabwidget.h>
20#include <opie2/okeyconfigwidget.h> 20#include <opie2/okeyconfigwidget.h>
21 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qmap.h> 31#include <qmap.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33#include <qframe.h>
34 34
35 35
36 36
37OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 37OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
38 38
39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 39PMainWindow::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 );
51 bar->setHorizontalStretchable( true ); 52 bar->setHorizontalStretchable( true );
52 setToolBarsMovable( false ); 53 setToolBarsMovable( false );
53 54
54 m_stack = new Opie::Ui::OWidgetStack( this ); 55 m_stack = new Opie::Ui::OWidgetStack( this );
55 setCentralWidget( m_stack ); 56 setCentralWidget( m_stack );
56 57
57 m_view = new PIconView( m_stack, m_cfg ); 58 m_view = new PIconView( m_stack, m_cfg );
58 m_stack->addWidget( m_view, IconView ); 59 m_stack->addWidget( m_view, IconView );
59 m_stack->raiseWidget( IconView ); 60 m_stack->raiseWidget( IconView );
60 connect(m_view, SIGNAL(sig_display(const QString&)), 61 connect(m_view, SIGNAL(sig_display(const QString&)),
61 this, SLOT(slotDisplay(const QString&))); 62 this, SLOT(slotDisplay(const QString&)));
62 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 63 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
63 this, SLOT(slotShowInfo(const QString&)) ); 64 this, SLOT(slotShowInfo(const QString&)) );
64 65
65 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 66 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
66 67
67 upButton = new QToolButton( bar ); 68 upButton = new QToolButton( bar );
68 upButton->setIconSet( Resource::loadIconSet( "up" ) ); 69 upButton->setIconSet( Resource::loadIconSet( "up" ) );
@@ -107,82 +108,99 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
107 prevButton = new QToolButton(bar); 108 prevButton = new QToolButton(bar);
108 prevButton->setIconSet( Resource::loadIconSet( "back" ) ); 109 prevButton->setIconSet( Resource::loadIconSet( "back" ) );
109 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); 110 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev()));
110 111
111 nextButton = new QToolButton(bar); 112 nextButton = new QToolButton(bar);
112 nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); 113 nextButton->setIconSet( Resource::loadIconSet( "forward" ) );
113 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); 114 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext()));
114 115
115 rotateButton = new QToolButton(bar); 116 rotateButton = new QToolButton(bar);
116 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); 117 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
117 rotateButton->setToggleButton(true); 118 rotateButton->setToggleButton(true);
118 119
119 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 120 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
120 rotateButton->setOn(true); 121 rotateButton->setOn(true);
121 autoRotate = true; 122 autoRotate = true;
122 prevButton->hide(); 123 prevButton->hide();
123 nextButton->hide(); 124 nextButton->hide();
124 } else { 125 } else {
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
146PMainWindow::~PMainWindow() { 147PMainWindow::~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
150void PMainWindow::slotToggleZoomer() 153void PMainWindow::slotToggleZoomer()
151{ 154{
152 if (!m_disp) return; 155 if (!m_disp) return;
153 bool cur = zoomButton->isOn(); 156 bool cur = zoomButton->isOn();
154 zoomButton->setOn(!cur); 157 zoomButton->setOn(!cur);
155} 158}
156 159
157void PMainWindow::slotZoomerToggled(bool how) 160void PMainWindow::slotZoomerToggled(bool how)
158{ 161{
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
168void PMainWindow::slotToggleAutorotate()
169{
170 if (!m_disp) return;
171 if (!rotateButton->isEnabled()) return;
172 bool cur = rotateButton->isOn();
173 rotateButton->setOn(!cur);
174}
175
176void PMainWindow::slotToggleAutoscale()
177{
178 if (!m_disp) return;
179 bool cur = scaleButton->isOn();
180 scaleButton->setOn(!cur);
181}
182
165void PMainWindow::slotRotateToggled(bool how) 183void 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 }
171} 189}
172 190
173void PMainWindow::slotScaleToggled(bool how) 191void PMainWindow::slotScaleToggled(bool how)
174{ 192{
175 autoScale = !how; 193 autoScale = !how;
176 if (!how) { 194 if (!how) {
177 autoRotate = how; 195 autoRotate = how;
178 } 196 }
179 if (m_disp) { 197 if (m_disp) {
180 m_disp->setAutoScaleRotate(autoScale,autoRotate); 198 m_disp->setAutoScaleRotate(autoScale,autoRotate);
181 } 199 }
182 if (!autoScale) { 200 if (!autoScale) {
183 rotateButton->setOn(false); 201 rotateButton->setOn(false);
184 } 202 }
185 rotateButton->setEnabled(!how); 203 rotateButton->setEnabled(!how);
186} 204}
187 205
188void PMainWindow::slotConfig() { 206void PMainWindow::slotConfig() {
@@ -274,142 +292,159 @@ void PMainWindow::initT( const char* name, T** ptr, int id) {
274 connect(*ptr, SIGNAL(sig_return()), 292 connect(*ptr, SIGNAL(sig_return()),
275 this,SLOT(slotReturn())); 293 this,SLOT(slotReturn()));
276 294
277} 295}
278void PMainWindow::initInfo() { 296void PMainWindow::initInfo() {
279 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 297 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
280 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 298 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
281} 299}
282void PMainWindow::initDisp() { 300void PMainWindow::initDisp() {
283 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 301 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
284 if (m_disp) { 302 if (m_disp) {
285 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 303 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
286 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 304 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
287 } 305 }
288 m_disp->setAutoScale(autoScale); 306 m_disp->setAutoScale(autoScale);
289 m_disp->setAutoRotate(autoRotate); 307 m_disp->setAutoRotate(autoRotate);
290 m_disp->setShowZoomer(zoomerOn); 308 m_disp->setShowZoomer(zoomerOn);
291 m_disp->setBackgroundColor(white); 309 m_disp->setBackgroundColor(white);
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
301void PMainWindow::slotToggleFullScreen() 321void PMainWindow::slotToggleFullScreen()
302{ 322{
303 odebug << "Toggle full " << oendl; 323 odebug << "Toggle full " << oendl;
304 if (!m_disp) return; 324 if (!m_disp) return;
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) {
324 m_disp->resize(m_disp->minimumSize()); 353 m_disp->resize(m_disp->minimumSize());
325 } 354 }
326 } 355 }
327} 356}
328 357
329/** 358/**
330 * With big Screen the plan could be to 'detach' the image 359 * With big Screen the plan could be to 'detach' the image
331 * window if visible and to create a ne wone 360 * window if visible and to create a ne wone
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 */
337void PMainWindow::slotShowInfo( const QString& inf ) { 366void 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
355void PMainWindow::slotDisplay( const QString& inf ) { 384void PMainWindow::slotDisplay( const QString& inf ) {
356 if ( !m_disp ) { 385 if ( !m_disp ) {
357 initDisp(); 386 initDisp();
358 } 387 }
359 m_disp->setImage( inf ); 388 m_disp->setImage( inf );
360 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 389 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
361 prevButton->show(); 390 prevButton->show();
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
374void PMainWindow::slotReturn() { 404void PMainWindow::slotReturn() {
375 raiseIconView(); 405 raiseIconView();
376} 406}
377 407
378 408
379void PMainWindow::closeEvent( QCloseEvent* ev ) { 409void 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
394void PMainWindow::raiseIconView() { 429void PMainWindow::raiseIconView() {
395 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 430 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
396 prevButton->hide(); 431 prevButton->hide();
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
408void PMainWindow::setDocument( const QString& showImg ) { 443void PMainWindow::setDocument( const QString& showImg ) {
409 QString file = showImg; 444 QString file = showImg;
410 DocLnk lnk(showImg); 445 DocLnk lnk(showImg);
411 if (lnk.isValid() ) 446 if (lnk.isValid() )
412 file = lnk.file(); 447 file = lnk.file();
413 448
414 slotDisplay( file ); 449 slotDisplay( file );
415} 450}