summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/mainwindow.cpp
Unidiff
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 @@
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5#include "mainwindow.h" 5#include "mainwindow.h"
6 6
7#include "iconview.h" 7#include "iconview.h"
8#include "filesystem.h" 8#include "filesystem.h"
9#include "imageinfoui.h"
10#include "imagescrollview.h"
9 11
10#include <iface/ifaceinfo.h> 12#include <iface/ifaceinfo.h>
11#include <iface/dirview.h> 13#include <iface/dirview.h>
12 14
15#include <opie2/odebug.h>
16#include <opie2/owidgetstack.h>
13#include <opie2/oapplicationfactory.h> 17#include <opie2/oapplicationfactory.h>
14#include <opie2/otabwidget.h> 18#include <opie2/otabwidget.h>
15#include <opie2/okeyconfigwidget.h> 19#include <opie2/okeyconfigwidget.h>
16 20
17 21
18#include <qpe/resource.h> 22#include <qpe/resource.h>
@@ -21,21 +25,21 @@
21 25
22#include <qtoolbar.h> 26#include <qtoolbar.h>
23#include <qtoolbutton.h> 27#include <qtoolbutton.h>
24#include <qlayout.h> 28#include <qlayout.h>
25#include <qdialog.h> 29#include <qdialog.h>
26#include <qmap.h> 30#include <qmap.h>
27 31#include <qtimer.h>
28 32
29 33
30 34
31 35
32OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) 36OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> )
33 37
34PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 38PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
35 : QMainWindow( wid, name, style ) 39 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
36{ 40{
37 setCaption( QObject::tr("Opie Eye Caramba" ) ); 41 setCaption( QObject::tr("Opie Eye Caramba" ) );
38 m_cfg = new Opie::Core::OConfig("phunkview"); 42 m_cfg = new Opie::Core::OConfig("phunkview");
39 m_cfg->setGroup("Zecke_view" ); 43 m_cfg->setGroup("Zecke_view" );
40 44
41 45
@@ -44,14 +48,22 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
44 * And Connect Them 48 * And Connect Them
45 */ 49 */
46 QToolBar *bar = new QToolBar( this ); 50 QToolBar *bar = new QToolBar( this );
47 bar->setHorizontalStretchable( true ); 51 bar->setHorizontalStretchable( true );
48 setToolBarsMovable( false ); 52 setToolBarsMovable( false );
49 53
50 m_view = new PIconView( this, m_cfg ); 54 m_stack = new Opie::Ui::OWidgetStack( this );
51 setCentralWidget( m_view ); 55 setCentralWidget( m_stack );
56
57 m_view = new PIconView( m_stack, m_cfg );
58 m_stack->addWidget( m_view, IconView );
59 m_stack->raiseWidget( IconView );
60 connect(m_view, SIGNAL(sig_display(const QString&)),
61 this, SLOT(slotDisplay(const QString&)));
62 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
63 this, SLOT(slotShowInfo(const QString&)) );
52 64
53 QToolButton *btn = new QToolButton( bar ); 65 QToolButton *btn = new QToolButton( bar );
54 btn->setIconSet( Resource::loadIconSet( "up" ) ); 66 btn->setIconSet( Resource::loadIconSet( "up" ) );
55 connect( btn, SIGNAL(clicked()), 67 connect( btn, SIGNAL(clicked()),
56 m_view, SLOT(slotDirUp()) ); 68 m_view, SLOT(slotDirUp()) );
57 69
@@ -81,12 +93,13 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
81 connect( btn, SIGNAL(clicked() ), 93 connect( btn, SIGNAL(clicked() ),
82 this, SLOT(slotConfig() ) ); 94 this, SLOT(slotConfig() ) );
83 95
84} 96}
85 97
86PMainWindow::~PMainWindow() { 98PMainWindow::~PMainWindow() {
99 odebug << "Shutting down" << oendl;
87} 100}
88 101
89 102
90void PMainWindow::slotConfig() { 103void PMainWindow::slotConfig() {
91/* 104/*
92 * have a tab with the possible views 105 * have a tab with the possible views
@@ -121,18 +134,96 @@ void PMainWindow::slotConfig() {
121 keyWid->load(); 134 keyWid->load();
122 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 135 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
123 136
124 137
125 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 138 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
126 139
140/*
141 * clean up
142 *apply changes
143 */
144
127 QMap<PDirView*, QWidget*>::Iterator it; 145 QMap<PDirView*, QWidget*>::Iterator it;
128 for ( it = lst.begin(); it != lst.end(); ++it ) { 146 for ( it = lst.begin(); it != lst.end(); ++it ) {
129 if ( act ) 147 if ( act )
130 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 148 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
131 delete it.key(); 149 delete it.key();
132 } 150 }
133 151
152
134 if ( act ) { 153 if ( act ) {
135 m_view->resetView(); 154 m_view->resetView();
136 keyWid->save(); 155 keyWid->save();
137 } 156 }
138} 157}
158
159/*
160 * create a new image info component
161 * and detach the current one
162 * we will make the other delete on exit
163 */
164template<class T>
165void PMainWindow::initT( const char* name, T** ptr, int id) {
166 if ( *ptr ) {
167 (*ptr)->disconnect(this, SLOT(slotReturn()));
168 (*ptr)->setDestructiveClose();
169 m_stack->removeWidget( *ptr );
170 }
171 *ptr = new T( m_stack, name );
172 m_stack->addWidget( *ptr, id );
173
174 connect(*ptr, SIGNAL(sig_return()),
175 this,SLOT(slotReturn()));
176
177}
178void PMainWindow::initInfo() {
179 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
180}
181void PMainWindow::initDisp() {
182 initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay );
183}
184
185/**
186 * With big Screen the plan could be to 'detach' the image
187 * window if visible and to create a ne wone
188 * init* already supports it but I make no use of it for
189 * now. We set filename and raise
190 *
191 * ### FIXME and talk to alwin
192 */
193void PMainWindow::slotShowInfo( const QString& inf ) {
194 if ( !m_info )
195 initInfo();
196 m_info->setPath( inf );
197 m_stack->raiseWidget( ImageInfo );
198}
199
200void PMainWindow::slotDisplay( const QString& inf ) {
201 if ( !m_disp )
202 initDisp();
203 m_disp->setImage( inf );
204 m_stack->raiseWidget( ImageDisplay );
205}
206
207void PMainWindow::slotReturn() {
208 raiseIconView();
209}
210
211
212void PMainWindow::closeEvent( QCloseEvent* ev ) {
213 /*
214 * return from view
215 * or properly quit
216 */
217 if ( m_stack->visibleWidget() == m_info ||
218 m_stack->visibleWidget() == m_disp ) {
219 raiseIconView();
220 ev->ignore();
221 return;
222 }
223 ev->accept();
224 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
225}
226
227void PMainWindow::raiseIconView() {
228 m_stack->raiseWidget( IconView );
229}