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.cpp | 109 |
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 @@ | |||
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 | } |
@@ -90,7 +103,7 @@ PMainWindow::~PMainWindow() { | |||
90 | void PMainWindow::slotConfig() { | 103 | void PMainWindow::slotConfig() { |
91 | /* | 104 | /* |
92 | * have a tab with the possible views | 105 | * have a tab with the possible views |
93 | * a tab for globals image cache size.. scaled loading | 106 | * a tab for globals image cache size.. scaled loading |
94 | * and one tab for the KeyConfigs | 107 | * and one tab for the KeyConfigs |
95 | */ | 108 | */ |
96 | QDialog dlg(this, 0, true); | 109 | QDialog dlg(this, 0, true); |
@@ -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 | } | ||