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
@@ -8,2 +8,4 @@
#include "filesystem.h"
+#include "imageinfoui.h"
+#include "imagescrollview.h"
@@ -12,2 +14,4 @@
+#include <opie2/odebug.h>
+#include <opie2/owidgetstack.h>
#include <opie2/oapplicationfactory.h>
@@ -26,3 +30,3 @@
#include <qmap.h>
-
+#include <qtimer.h>
@@ -34,3 +38,3 @@ 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 )
{
@@ -49,4 +53,12 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
- 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&)) );
@@ -86,2 +98,3 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
PMainWindow::~PMainWindow() {
+ odebug << "Shutting down" << oendl;
}
@@ -90,7 +103,7 @@ PMainWindow::~PMainWindow() {
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);
@@ -126,2 +139,7 @@ void PMainWindow::slotConfig() {
+/*
+ * clean up
+ *apply changes
+ */
+
QMap<PDirView*, QWidget*>::Iterator it;
@@ -133,2 +151,3 @@ void PMainWindow::slotConfig() {
+
if ( act ) {
@@ -138 +157,73 @@ void PMainWindow::slotConfig() {
}
+
+/*
+ * 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 );
+}