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.cpp | 99 |
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 | |||
@@ -6,10 +6,14 @@ | |||
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> |
@@ -24,7 +28,7 @@ | |||
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 | ||
@@ -32,7 +36,7 @@ | |||
32 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) | 36 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) |
33 | 37 | ||
34 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 38 | PMainWindow::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"); |
@@ -47,8 +51,16 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
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" ) ); |
@@ -84,6 +96,7 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
84 | } | 96 | } |
85 | 97 | ||
86 | PMainWindow::~PMainWindow() { | 98 | PMainWindow::~PMainWindow() { |
99 | odebug << "Shutting down" << oendl; | ||
87 | } | 100 | } |
88 | 101 | ||
89 | 102 | ||
@@ -124,6 +137,11 @@ void PMainWindow::slotConfig() { | |||
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 ) |
@@ -131,8 +149,81 @@ void PMainWindow::slotConfig() { | |||
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 | */ | ||
164 | template<class T> | ||
165 | void 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 | } | ||
178 | void PMainWindow::initInfo() { | ||
179 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | ||
180 | } | ||
181 | void 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 | */ | ||
193 | void PMainWindow::slotShowInfo( const QString& inf ) { | ||
194 | if ( !m_info ) | ||
195 | initInfo(); | ||
196 | m_info->setPath( inf ); | ||
197 | m_stack->raiseWidget( ImageInfo ); | ||
198 | } | ||
199 | |||
200 | void PMainWindow::slotDisplay( const QString& inf ) { | ||
201 | if ( !m_disp ) | ||
202 | initDisp(); | ||
203 | m_disp->setImage( inf ); | ||
204 | m_stack->raiseWidget( ImageDisplay ); | ||
205 | } | ||
206 | |||
207 | void PMainWindow::slotReturn() { | ||
208 | raiseIconView(); | ||
209 | } | ||
210 | |||
211 | |||
212 | void 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 | |||
227 | void PMainWindow::raiseIconView() { | ||
228 | m_stack->raiseWidget( IconView ); | ||
229 | } | ||