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) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp109
1 files changed, 100 insertions, 9 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
@@ -6,10 +6,14 @@
#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>
@@ -24,7 +28,7 @@
#include <qlayout.h>
#include <qdialog.h>
#include <qmap.h>
-
+#include <qtimer.h>
@@ -32,7 +36,7 @@
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");
@@ -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<PDirView*, QWidget*>::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<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 );
+}