author | zecke <zecke> | 2004-04-05 20:01:22 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-05 20:01:22 (UTC) |
commit | ecdd2845abeb5f3d00f58540e9b222799d6610e8 (patch) (unidiff) | |
tree | 7199007b1dc296bb4572f2c96178d47d2f36bc02 /noncore/graphics/opie-eye/gui/mainwindow.cpp | |
parent | cb3097d5249b6bd576d0212394ab57e885f9e9da (diff) | |
download | opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.zip opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.tar.gz opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.tar.bz2 |
Make use of OWidgetStack
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 | |||
@@ -8,2 +8,4 @@ | |||
8 | #include "filesystem.h" | 8 | #include "filesystem.h" |
9 | #include "imageinfoui.h" | ||
10 | #include "imagescrollview.h" | ||
9 | 11 | ||
@@ -12,2 +14,4 @@ | |||
12 | 14 | ||
15 | #include <opie2/odebug.h> | ||
16 | #include <opie2/owidgetstack.h> | ||
13 | #include <opie2/oapplicationfactory.h> | 17 | #include <opie2/oapplicationfactory.h> |
@@ -26,3 +30,3 @@ | |||
26 | #include <qmap.h> | 30 | #include <qmap.h> |
27 | 31 | #include <qtimer.h> | |
28 | 32 | ||
@@ -34,3 +38,3 @@ OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) | |||
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 | { |
@@ -49,4 +53,12 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
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 | ||
@@ -86,2 +98,3 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
86 | PMainWindow::~PMainWindow() { | 98 | PMainWindow::~PMainWindow() { |
99 | odebug << "Shutting down" << oendl; | ||
87 | } | 100 | } |
@@ -126,2 +139,7 @@ void PMainWindow::slotConfig() { | |||
126 | 139 | ||
140 | /* | ||
141 | * clean up | ||
142 | *apply changes | ||
143 | */ | ||
144 | |||
127 | QMap<PDirView*, QWidget*>::Iterator it; | 145 | QMap<PDirView*, QWidget*>::Iterator it; |
@@ -133,2 +151,3 @@ void PMainWindow::slotConfig() { | |||
133 | 151 | ||
152 | |||
134 | if ( act ) { | 153 | if ( act ) { |
@@ -138 +157,73 @@ void PMainWindow::slotConfig() { | |||
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 | } | ||