From ecdd2845abeb5f3d00f58540e9b222799d6610e8 Mon Sep 17 00:00:00 2001 From: zecke Date: Mon, 05 Apr 2004 20:01:22 +0000 Subject: Make use of OWidgetStack --- (limited to 'noncore/graphics/opie-eye/gui/mainwindow.cpp') diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 83ff4f1..7f384bd 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -6,10 +6,14 @@ #include "iconview.h" #include "filesystem.h" +#include "imageinfoui.h" +#include "imagescrollview.h" #include #include +#include +#include #include #include #include @@ -24,7 +28,7 @@ #include #include #include - +#include @@ -32,7 +36,7 @@ OPIE_EXPORT_APP( Opie::Core::OApplicationFactory ) PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) - : QMainWindow( wid, name, style ) + : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) { setCaption( QObject::tr("Opie Eye Caramba" ) ); m_cfg = new Opie::Core::OConfig("phunkview"); @@ -47,8 +51,16 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) bar->setHorizontalStretchable( true ); setToolBarsMovable( false ); - m_view = new PIconView( this, m_cfg ); - setCentralWidget( m_view ); + m_stack = new Opie::Ui::OWidgetStack( this ); + setCentralWidget( m_stack ); + + m_view = new PIconView( m_stack, m_cfg ); + m_stack->addWidget( m_view, IconView ); + m_stack->raiseWidget( IconView ); + connect(m_view, SIGNAL(sig_display(const QString&)), + this, SLOT(slotDisplay(const QString&))); + connect(m_view, SIGNAL(sig_showInfo(const QString&)), + this, SLOT(slotShowInfo(const QString&)) ); QToolButton *btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "up" ) ); @@ -84,15 +96,16 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) } PMainWindow::~PMainWindow() { + odebug << "Shutting down" << oendl; } void PMainWindow::slotConfig() { -/* - * have a tab with the possible views - * a tab for globals image cache size.. scaled loading - * and one tab for the KeyConfigs - */ + /* + * have a tab with the possible views + * a tab for globals image cache size.. scaled loading + * and one tab for the KeyConfigs + */ QDialog dlg(this, 0, true); dlg.setCaption( tr("Phunk View - Config" ) ); @@ -124,6 +137,11 @@ void PMainWindow::slotConfig() { bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); +/* + * clean up + *apply changes + */ + QMap::Iterator it; for ( it = lst.begin(); it != lst.end(); ++it ) { if ( act ) @@ -131,8 +149,81 @@ void PMainWindow::slotConfig() { delete it.key(); } + if ( act ) { m_view->resetView(); keyWid->save(); } } + +/* + * create a new image info component + * and detach the current one + * we will make the other delete on exit + */ +template +void PMainWindow::initT( const char* name, T** ptr, int id) { + if ( *ptr ) { + (*ptr)->disconnect(this, SLOT(slotReturn())); + (*ptr)->setDestructiveClose(); + m_stack->removeWidget( *ptr ); + } + *ptr = new T( m_stack, name ); + m_stack->addWidget( *ptr, id ); + + connect(*ptr, SIGNAL(sig_return()), + this,SLOT(slotReturn())); + +} +void PMainWindow::initInfo() { + initT( "Image Info", &m_info, ImageInfo ); +} +void PMainWindow::initDisp() { + initT( "Image ScrollView", &m_disp, ImageDisplay ); +} + +/** + * With big Screen the plan could be to 'detach' the image + * window if visible and to create a ne wone + * init* already supports it but I make no use of it for + * now. We set filename and raise + * + * ### FIXME and talk to alwin + */ +void PMainWindow::slotShowInfo( const QString& inf ) { + if ( !m_info ) + initInfo(); + m_info->setPath( inf ); + m_stack->raiseWidget( ImageInfo ); +} + +void PMainWindow::slotDisplay( const QString& inf ) { + if ( !m_disp ) + initDisp(); + m_disp->setImage( inf ); + m_stack->raiseWidget( ImageDisplay ); +} + +void PMainWindow::slotReturn() { + raiseIconView(); +} + + +void PMainWindow::closeEvent( QCloseEvent* ev ) { + /* + * return from view + * or properly quit + */ + if ( m_stack->visibleWidget() == m_info || + m_stack->visibleWidget() == m_disp ) { + raiseIconView(); + ev->ignore(); + return; + } + ev->accept(); + QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); +} + +void PMainWindow::raiseIconView() { + m_stack->raiseWidget( IconView ); +} -- cgit v0.9.0.2