summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-05 20:01:22 (UTC)
committer zecke <zecke>2004-04-05 20:01:22 (UTC)
commitecdd2845abeb5f3d00f58540e9b222799d6610e8 (patch) (unidiff)
tree7199007b1dc296bb4572f2c96178d47d2f36bc02
parentcb3097d5249b6bd576d0212394ab57e885f9e9da (diff)
downloadopie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.zip
opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.tar.gz
opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.tar.bz2
Make use of OWidgetStack
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp61
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h4
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.cpp29
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.h20
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.cpp20
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp109
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h24
8 files changed, 237 insertions, 36 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index de2cdf0..4ced52d 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -37,5 +37,8 @@ using Opie::Ui::OKeyConfigItem;
37 37
38/*
39 * The Icons, Request Cache and IconViewItem for the IconView
40 */
38namespace { 41namespace {
39 QPixmap* _dirPix = 0; 42 static QPixmap* _dirPix = 0;
40 QPixmap* _unkPix = 0; 43 static QPixmap* _unkPix = 0;
41 class IconViewItem : public QIconViewItem { 44 class IconViewItem : public QIconViewItem {
@@ -61,4 +64,4 @@ namespace {
61 */ 64 */
62 QMap<QString, IconViewItem*> g_stringInf; 65 static QMap<QString, IconViewItem*> g_stringInf;
63 QMap<QString, IconViewItem*> g_stringPix; 66 static QMap<QString, IconViewItem*> g_stringPix;
64 67
@@ -103,2 +106,6 @@ namespace {
103 106
107/*
108 * Set up the GUI.. initialize the slave set up gui
109 * and also load a dir
110 */
104PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 111PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
@@ -138,2 +145,5 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
138 145
146/*
147 * Unref the slave and save the keyboard manager
148 */
139PIconView::~PIconView() { 149PIconView::~PIconView() {
@@ -150,2 +160,7 @@ Opie::Ui::OKeyConfigManager* PIconView::manager() {
150 160
161
162/*
163 * init the KeyBoard Shortcuts
164 * called from the c'tor
165 */
151void PIconView::initKeys() { 166void PIconView::initKeys() {
@@ -180,2 +195,6 @@ void PIconView::initKeys() {
180 195
196
197/*
198 * change one dir up
199 */
181void PIconView::slotDirUp() { 200void PIconView::slotDirUp() {
@@ -187,2 +206,5 @@ void PIconView::slotDirUp() {
187 206
207/*
208 * change the dir
209 */
188void PIconView::slotChangeDir(const QString& path) { 210void PIconView::slotChangeDir(const QString& path) {
@@ -286,5 +308,5 @@ void PIconView::addFolders( const QStringList& lst) {
286 308
287 for(it=lst.begin(); it != lst.end(); ++it ) { 309 for(it=lst.begin(); it != lst.end(); ++it )
288 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 310 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
289 } 311
290 312
@@ -307,3 +329,3 @@ void PIconView::slotClicked(QIconViewItem* _it) {
307 else // view image 329 else // view image
308 ; 330 slotShowImage();
309} 331}
@@ -362,3 +384,2 @@ void PIconView::slotStart() {
362 m_view->viewport()->setUpdatesEnabled( false ); 384 m_view->viewport()->setUpdatesEnabled( false );
363 qWarning( "Sig Start" );
364} 385}
@@ -366,3 +387,2 @@ void PIconView::slotStart() {
366void PIconView::slotEnd() { 387void PIconView::slotEnd() {
367 qWarning( "SLot End" );
368 if ( m_updatet ) 388 if ( m_updatet )
@@ -373,4 +393,5 @@ void PIconView::slotEnd() {
373 393
374void PIconView::slotShowImage() { 394void PIconView::slotShowImage()
375 qDebug("image show"); 395{
396 qWarning( "SLotShowImage" );
376 bool isDir = false; 397 bool isDir = false;
@@ -378,10 +399,10 @@ void PIconView::slotShowImage() {
378 if (isDir) return; 399 if (isDir) return;
379 ImageDlg dlg(name);
380 QPEApplication::execDialog(&dlg);
381}
382void PIconView::slotShowImage( const QString& ) {
383 400
401 slotShowImage( name );
402}
403void PIconView::slotShowImage( const QString& name) {
404 emit sig_display( name );
384} 405}
385void PIconView::slotImageInfo() { 406void PIconView::slotImageInfo() {
386 qDebug("image info"); 407 qWarning( "SlotImageInfo" );
387 bool isDir = false; 408 bool isDir = false;
@@ -389,8 +410,8 @@ void PIconView::slotImageInfo() {
389 if (isDir) return; 410 if (isDir) return;
390 infoDlg dlg(name); 411
391 QPEApplication::execDialog(&dlg); 412 slotImageInfo( name );
392} 413}
393 414
394void PIconView::slotImageInfo( const QString& ) { 415void PIconView::slotImageInfo( const QString& name) {
395 416 emit sig_showInfo( name );
396} 417}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index 7ddb023..a4ca0bc 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -39,2 +39,6 @@ public:
39 39
40signals:
41 void sig_showInfo( const QString& );
42 void sig_display( const QString& );
43
40private: 44private:
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
index 3463ba6..74a9ea4 100644
--- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
@@ -21,3 +21,10 @@
21 21
22#define THUMBSIZE 128 22static const int THUMBSIZE = 128;
23
24
25imageinfo::imageinfo(QWidget* parent, const char* name, WFlags fl )
26 : QWidget( parent, name, fl )
27{
28 init(name);
29}
23 30
@@ -26,2 +33,6 @@ imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WF
26{ 33{
34 init(name);
35 slotChangeName(_path);
36}
37void imageinfo::init(const char* name) {
27 { 38 {
@@ -64,3 +75,2 @@ imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WF
64 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 75 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
65 slotChangeName(_path);
66} 76}
@@ -113,2 +123,15 @@ void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix)
113 123
124void imageinfo::setPath( const QString& str ) {
125 slotChangeName( str );
126}
127
128void imageinfo::setDestructiveClose() {
129 WFlags fl = getWFlags();
130 /* clear it just in case */
131 fl &= ~WDestructiveClose;
132 fl |= WDestructiveClose;
133 setWFlags( fl );
134}
135
136
114/* for testing */ 137/* for testing */
@@ -127 +150,3 @@ infoDlg::~infoDlg()
127} 150}
151
152
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.h b/noncore/graphics/opie-eye/gui/imageinfoui.h
index 34ec937..300c92a 100644
--- a/noncore/graphics/opie-eye/gui/imageinfoui.h
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.h
@@ -7,5 +7,5 @@
7 7
8class QVBoxLayout; 8class QVBoxLayout;
9class QHBoxLayout; 9class QHBoxLayout;
10class QGridLayout; 10class QGridLayout;
11class QFrame; 11class QFrame;
@@ -15,3 +15,3 @@ class QTextView;
15class imageinfo : public QWidget 15class imageinfo : public QWidget
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
@@ -19,2 +19,3 @@ class imageinfo : public QWidget
19public: 19public:
20 imageinfo( QWidget* parent = 0, const char* name = 0, WFlags fl =0);
20 imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 21 imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
@@ -22,2 +23,11 @@ public:
22 23
24 void setDestructiveClose();
25
26public slots:
27 void setPath( const QString& path );
28
29private:
30 void init(const char* name);
31
32protected:
23 QLabel* PixmapLabel1; 33 QLabel* PixmapLabel1;
@@ -34,3 +44,3 @@ protected slots:
34 virtual void slotThumbNail(const QString&, const QPixmap&); 44 virtual void slotThumbNail(const QString&, const QPixmap&);
35 45
36 virtual void slotChangeName(const QString&); 46 virtual void slotChangeName(const QString&);
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
index 0d35354..7d83e29 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
@@ -9,2 +9,9 @@ using namespace Opie::Core;
9 9
10ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f )
11 :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true),
12 rotate_to_fit(true),first_resize_done(false)
13{
14 init();
15}
16
10ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 17ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit)
@@ -31,2 +38,6 @@ void ImageScrollView::setImage(const QImage&img)
31 38
39void ImageScrollView::setImage( const QString& path ) {
40
41}
42
32/* should be called every time the QImage changed it content */ 43/* should be called every time the QImage changed it content */
@@ -261,2 +272,11 @@ void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e)
261 272
273void ImageScrollView::setDestructiveClose() {
274 WFlags fl = getWFlags();
275 /* clear it just in case */
276 fl &= ~WDestructiveClose;
277 fl |= WDestructiveClose;
278 setWFlags( fl );
279}
280
281
262/* for testing */ 282/* for testing */
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h
index e25f955..864a015 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.h
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.h
@@ -14,2 +14,3 @@ class ImageScrollView:public QScrollView
14public: 14public:
15 ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 );
15 ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); 16 ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false );
@@ -19,2 +20,4 @@ public:
19 void setImage(const QImage&); 20 void setImage(const QImage&);
21 void setImage( const QString& path );
22 void setDestructiveClose();
20 23
@@ -27,2 +30,5 @@ public:
27 30
31signals:
32 void sig_return();
33
28protected: 34protected:
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> )
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{
@@ -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)
86PMainWindow::~PMainWindow() { 98PMainWindow::~PMainWindow() {
99 odebug << "Shutting down" << oendl;
87} 100}
@@ -90,7 +103,7 @@ PMainWindow::~PMainWindow() {
90void PMainWindow::slotConfig() { 103void 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 */
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}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 317a51e..35116ae 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -17,2 +17,3 @@ namespace Ui{
17 class OKeyConfigManager; 17 class OKeyConfigManager;
18 class OWidgetStack;
18} 19}
@@ -21,4 +22,7 @@ namespace Ui{
21class PIconView; 22class PIconView;
23class imageinfo;
24class ImageScrollView;
22class PMainWindow : public QMainWindow { 25class PMainWindow : public QMainWindow {
23 Q_OBJECT 26 Q_OBJECT
27 enum Views { IconView, ImageInfo, ImageDisplay };
24public: 28public:
@@ -28,5 +32,25 @@ public:
28 32
33signals:
34 void configChanged();
35
36public slots:
37 void slotShowInfo( const QString& inf );
38 void slotDisplay( const QString& inf );
39 void slotReturn();
40
41protected:
42 void raiseIconView();
43 void closeEvent( QCloseEvent* );
44
45private:
46 template<class T> void initT( const char* name, T**, int );
47 void initInfo();
48 void initDisp();
49
29private: 50private:
30 Opie::Core::OConfig *m_cfg; 51 Opie::Core::OConfig *m_cfg;
52 Opie::Ui::OWidgetStack *m_stack;
31 PIconView* m_view; 53 PIconView* m_view;
54 imageinfo *m_info;
55 ImageScrollView *m_disp;
32 56