summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'noncore/graphics/opie-eye/gui/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp99
1 files changed, 95 insertions, 4 deletions
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
@@ -3,16 +3,20 @@
* No WArranty...
*/
#include "mainwindow.h"
#include "iconview.h"
#include "filesystem.h"
+#include "imageinfoui.h"
+#include "imagescrollview.h"
#include <iface/ifaceinfo.h>
#include <iface/dirview.h>
+#include <opie2/odebug.h>
+#include <opie2/owidgetstack.h>
#include <opie2/oapplicationfactory.h>
#include <opie2/otabwidget.h>
#include <opie2/okeyconfigwidget.h>
#include <qpe/resource.h>
@@ -21,21 +25,21 @@
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qlayout.h>
#include <qdialog.h>
#include <qmap.h>
-
+#include <qtimer.h>
OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> )
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");
m_cfg->setGroup("Zecke_view" );
@@ -44,14 +48,22 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
* And Connect Them
*/
QToolBar *bar = new QToolBar( this );
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" ) );
connect( btn, SIGNAL(clicked()),
m_view, SLOT(slotDirUp()) );
@@ -81,12 +93,13 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
connect( btn, SIGNAL(clicked() ),
this, SLOT(slotConfig() ) );
}
PMainWindow::~PMainWindow() {
+ odebug << "Shutting down" << oendl;
}
void PMainWindow::slotConfig() {
/*
* have a tab with the possible views
@@ -121,18 +134,96 @@ void PMainWindow::slotConfig() {
keyWid->load();
wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
+/*
+ * clean up
+ *apply changes
+ */
+
QMap<PDirView*, QWidget*>::Iterator it;
for ( it = lst.begin(); it != lst.end(); ++it ) {
if ( act )
it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
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<class T>
+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<imageinfo>( "Image Info", &m_info, ImageInfo );
+}
+void PMainWindow::initDisp() {
+ initT<ImageScrollView>( "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 );
+}