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 | |
parent | cb3097d5249b6bd576d0212394ab57e885f9e9da (diff) | |
download | opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.zip opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.tar.gz opie-ecdd2845abeb5f3d00f58540e9b222799d6610e8.tar.bz2 |
Make use of OWidgetStack
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 61 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.h | 20 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 20 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 109 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 24 |
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 | |||
@@ -32,15 +32,18 @@ | |||
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | 34 | ||
35 | 35 | ||
36 | using Opie::Ui::OKeyConfigItem; | 36 | using Opie::Ui::OKeyConfigItem; |
37 | 37 | ||
38 | /* | ||
39 | * The Icons, Request Cache and IconViewItem for the IconView | ||
40 | */ | ||
38 | namespace { | 41 | namespace { |
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 { |
42 | public: | 45 | public: |
43 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 46 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
44 | QPixmap* pixmap()const; | 47 | QPixmap* pixmap()const; |
45 | QString path()const { return m_path; } | 48 | QString path()const { return m_path; } |
46 | bool isDir()const { return m_isDir; } | 49 | bool isDir()const { return m_isDir; } |
@@ -56,14 +59,14 @@ namespace { | |||
56 | 59 | ||
57 | 60 | ||
58 | /* | 61 | /* |
59 | * If we request an Image or String | 62 | * If we request an Image or String |
60 | * we add it to the map | 63 | * we add it to the map |
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 | ||
65 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 68 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
66 | const QString& name, bool isDir ) | 69 | const QString& name, bool isDir ) |
67 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 70 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
68 | m_noInfo( false ) | 71 | m_noInfo( false ) |
69 | { | 72 | { |
@@ -98,12 +101,16 @@ namespace { | |||
98 | m_noInfo = true; | 101 | m_noInfo = true; |
99 | QIconViewItem::setText( text ); | 102 | QIconViewItem::setText( text ); |
100 | } | 103 | } |
101 | } | 104 | } |
102 | 105 | ||
103 | 106 | ||
107 | /* | ||
108 | * Set up the GUI.. initialize the slave set up gui | ||
109 | * and also load a dir | ||
110 | */ | ||
104 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 111 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
105 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 112 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
106 | { | 113 | { |
107 | { | 114 | { |
108 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 115 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
109 | } | 116 | } |
@@ -133,24 +140,32 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | |||
133 | initKeys(); | 140 | initKeys(); |
134 | 141 | ||
135 | loadViews(); | 142 | loadViews(); |
136 | slotViewChanged( m_views->currentItem() ); | 143 | slotViewChanged( m_views->currentItem() ); |
137 | } | 144 | } |
138 | 145 | ||
146 | /* | ||
147 | * Unref the slave and save the keyboard manager | ||
148 | */ | ||
139 | PIconView::~PIconView() { | 149 | PIconView::~PIconView() { |
140 | { | 150 | { |
141 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 151 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
142 | } | 152 | } |
143 | m_viewManager->save(); | 153 | m_viewManager->save(); |
144 | delete m_viewManager; | 154 | delete m_viewManager; |
145 | } | 155 | } |
146 | 156 | ||
147 | Opie::Ui::OKeyConfigManager* PIconView::manager() { | 157 | Opie::Ui::OKeyConfigManager* PIconView::manager() { |
148 | return m_viewManager; | 158 | return m_viewManager; |
149 | } | 159 | } |
150 | 160 | ||
161 | |||
162 | /* | ||
163 | * init the KeyBoard Shortcuts | ||
164 | * called from the c'tor | ||
165 | */ | ||
151 | void PIconView::initKeys() { | 166 | void PIconView::initKeys() { |
152 | Opie::Ui::OKeyPair::List lst; | 167 | Opie::Ui::OKeyPair::List lst; |
153 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); | 168 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); |
154 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); | 169 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); |
155 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); | 170 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); |
156 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); | 171 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); |
@@ -175,19 +190,26 @@ void PIconView::initKeys() { | |||
175 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 190 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
176 | this, SLOT(slotImageInfo()) ) ); | 191 | this, SLOT(slotImageInfo()) ) ); |
177 | m_viewManager->load(); | 192 | m_viewManager->load(); |
178 | m_viewManager->handleWidget( m_view ); | 193 | m_viewManager->handleWidget( m_view ); |
179 | } | 194 | } |
180 | 195 | ||
196 | |||
197 | /* | ||
198 | * change one dir up | ||
199 | */ | ||
181 | void PIconView::slotDirUp() { | 200 | void PIconView::slotDirUp() { |
182 | QDir dir( m_path ); | 201 | QDir dir( m_path ); |
183 | dir.cdUp(); | 202 | dir.cdUp(); |
184 | slotChangeDir( dir.absPath() ); | 203 | slotChangeDir( dir.absPath() ); |
185 | 204 | ||
186 | } | 205 | } |
187 | 206 | ||
207 | /* | ||
208 | * change the dir | ||
209 | */ | ||
188 | void PIconView::slotChangeDir(const QString& path) { | 210 | void PIconView::slotChangeDir(const QString& path) { |
189 | if ( !currentView() ) | 211 | if ( !currentView() ) |
190 | return; | 212 | return; |
191 | 213 | ||
192 | PDirLister *lister = currentView()->dirLister(); | 214 | PDirLister *lister = currentView()->dirLister(); |
193 | if (!lister ) | 215 | if (!lister ) |
@@ -281,15 +303,15 @@ void PIconView::slotReloadDir() { | |||
281 | } | 303 | } |
282 | 304 | ||
283 | 305 | ||
284 | void PIconView::addFolders( const QStringList& lst) { | 306 | void PIconView::addFolders( const QStringList& lst) { |
285 | QStringList::ConstIterator it; | 307 | QStringList::ConstIterator it; |
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 | ||
291 | } | 313 | } |
292 | 314 | ||
293 | void PIconView::addFiles( const QStringList& lst) { | 315 | void PIconView::addFiles( const QStringList& lst) { |
294 | QStringList::ConstIterator it; | 316 | QStringList::ConstIterator it; |
295 | for (it=lst.begin(); it!= lst.end(); ++it ) | 317 | for (it=lst.begin(); it!= lst.end(); ++it ) |
@@ -302,13 +324,13 @@ void PIconView::slotClicked(QIconViewItem* _it) { | |||
302 | return; | 324 | return; |
303 | 325 | ||
304 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 326 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
305 | if( it->isDir() ) | 327 | if( it->isDir() ) |
306 | slotChangeDir( it->path() ); | 328 | slotChangeDir( it->path() ); |
307 | else // view image | 329 | else // view image |
308 | ; | 330 | slotShowImage(); |
309 | } | 331 | } |
310 | 332 | ||
311 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 333 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
312 | IconViewItem* item = g_stringInf[_path]; | 334 | IconViewItem* item = g_stringInf[_path]; |
313 | if (!item ) | 335 | if (!item ) |
314 | return; | 336 | return; |
@@ -357,40 +379,39 @@ void PIconView::slotBeam() { | |||
357 | void PIconView::slotBeamDone( Ir* ir) { | 379 | void PIconView::slotBeamDone( Ir* ir) { |
358 | delete ir; | 380 | delete ir; |
359 | } | 381 | } |
360 | 382 | ||
361 | void PIconView::slotStart() { | 383 | void PIconView::slotStart() { |
362 | m_view->viewport()->setUpdatesEnabled( false ); | 384 | m_view->viewport()->setUpdatesEnabled( false ); |
363 | qWarning( "Sig Start" ); | ||
364 | } | 385 | } |
365 | 386 | ||
366 | void PIconView::slotEnd() { | 387 | void PIconView::slotEnd() { |
367 | qWarning( "SLot End" ); | ||
368 | if ( m_updatet ) | 388 | if ( m_updatet ) |
369 | m_view->arrangeItemsInGrid( ); | 389 | m_view->arrangeItemsInGrid( ); |
370 | m_view->viewport()->setUpdatesEnabled( true ); | 390 | m_view->viewport()->setUpdatesEnabled( true ); |
371 | m_updatet = false; | 391 | m_updatet = false; |
372 | } | 392 | } |
373 | 393 | ||
374 | void PIconView::slotShowImage() { | 394 | void PIconView::slotShowImage() |
375 | qDebug("image show"); | 395 | { |
396 | qWarning( "SLotShowImage" ); | ||
376 | bool isDir = false; | 397 | bool isDir = false; |
377 | QString name = currentFileName(isDir); | 398 | QString name = currentFileName(isDir); |
378 | if (isDir) return; | 399 | if (isDir) return; |
379 | ImageDlg dlg(name); | ||
380 | QPEApplication::execDialog(&dlg); | ||
381 | } | ||
382 | void PIconView::slotShowImage( const QString& ) { | ||
383 | 400 | ||
401 | slotShowImage( name ); | ||
402 | } | ||
403 | void PIconView::slotShowImage( const QString& name) { | ||
404 | emit sig_display( name ); | ||
384 | } | 405 | } |
385 | void PIconView::slotImageInfo() { | 406 | void PIconView::slotImageInfo() { |
386 | qDebug("image info"); | 407 | qWarning( "SlotImageInfo" ); |
387 | bool isDir = false; | 408 | bool isDir = false; |
388 | QString name = currentFileName(isDir); | 409 | QString name = currentFileName(isDir); |
389 | if (isDir) return; | 410 | if (isDir) return; |
390 | infoDlg dlg(name); | 411 | |
391 | QPEApplication::execDialog(&dlg); | 412 | slotImageInfo( name ); |
392 | } | 413 | } |
393 | 414 | ||
394 | void PIconView::slotImageInfo( const QString& ) { | 415 | void 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 | |||
@@ -34,12 +34,16 @@ class PIconView : public QVBox { | |||
34 | public: | 34 | public: |
35 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); | 35 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
36 | ~PIconView(); | 36 | ~PIconView(); |
37 | void resetView(); | 37 | void resetView(); |
38 | Opie::Ui::OKeyConfigManager* manager(); | 38 | Opie::Ui::OKeyConfigManager* manager(); |
39 | 39 | ||
40 | signals: | ||
41 | void sig_showInfo( const QString& ); | ||
42 | void sig_display( const QString& ); | ||
43 | |||
40 | private: | 44 | private: |
41 | void initKeys(); | 45 | void initKeys(); |
42 | QString currentFileName(bool &isDir)const; | 46 | QString currentFileName(bool &isDir)const; |
43 | void loadViews(); | 47 | void loadViews(); |
44 | 48 | ||
45 | private slots: | 49 | private slots: |
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 | |||
@@ -16,17 +16,28 @@ | |||
16 | #include <lib/slavemaster.h> | 16 | #include <lib/slavemaster.h> |
17 | #include <lib/imagecache.h> | 17 | #include <lib/imagecache.h> |
18 | 18 | ||
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | 21 | ||
22 | #define THUMBSIZE 128 | 22 | static const int THUMBSIZE = 128; |
23 | |||
24 | |||
25 | imageinfo::imageinfo(QWidget* parent, const char* name, WFlags fl ) | ||
26 | : QWidget( parent, name, fl ) | ||
27 | { | ||
28 | init(name); | ||
29 | } | ||
23 | 30 | ||
24 | imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) | 31 | imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) |
25 | : QWidget( parent, name, fl ),currentFile(_path) | 32 | : QWidget( parent, name, fl ),currentFile(_path) |
26 | { | 33 | { |
34 | init(name); | ||
35 | slotChangeName(_path); | ||
36 | } | ||
37 | void imageinfo::init(const char* name) { | ||
27 | { | 38 | { |
28 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 39 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
29 | } | 40 | } |
30 | if ( !name ) | 41 | if ( !name ) |
31 | setName( "imageinfo" ); | 42 | setName( "imageinfo" ); |
32 | resize( 289, 335 ); | 43 | resize( 289, 335 ); |
@@ -59,13 +70,12 @@ imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WF | |||
59 | 70 | ||
60 | SlaveMaster* master = SlaveMaster::self(); | 71 | SlaveMaster* master = SlaveMaster::self(); |
61 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 72 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
62 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); | 73 | this, SLOT(slot_fullInfo(const QString&, const QString&)) ); |
63 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 74 | connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
64 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 75 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
65 | slotChangeName(_path); | ||
66 | } | 76 | } |
67 | 77 | ||
68 | void imageinfo::slotChangeName(const QString&_path) | 78 | void imageinfo::slotChangeName(const QString&_path) |
69 | { | 79 | { |
70 | currentFile=_path; | 80 | currentFile=_path; |
71 | QFileInfo fi(_path); | 81 | QFileInfo fi(_path); |
@@ -108,12 +118,25 @@ void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) | |||
108 | PixmapLabel1->setPixmap( _pix ); | 118 | PixmapLabel1->setPixmap( _pix ); |
109 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); | 119 | PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); |
110 | } | 120 | } |
111 | } | 121 | } |
112 | } | 122 | } |
113 | 123 | ||
124 | void imageinfo::setPath( const QString& str ) { | ||
125 | slotChangeName( str ); | ||
126 | } | ||
127 | |||
128 | void 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 */ |
115 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) | 138 | infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) |
116 | :QDialog(parent,name,true,WStyle_ContextHelp) | 139 | :QDialog(parent,name,true,WStyle_ContextHelp) |
117 | { | 140 | { |
118 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 141 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
119 | dlglayout->setSpacing(2); | 142 | dlglayout->setSpacing(2); |
@@ -122,6 +145,8 @@ infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) | |||
122 | dlglayout->addWidget(inf); | 145 | dlglayout->addWidget(inf); |
123 | } | 146 | } |
124 | 147 | ||
125 | infoDlg::~infoDlg() | 148 | infoDlg::~infoDlg() |
126 | { | 149 | { |
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 | |||
@@ -2,40 +2,50 @@ | |||
2 | #define IMAGEINFO_H | 2 | #define IMAGEINFO_H |
3 | 3 | ||
4 | #include <qvariant.h> | 4 | #include <qvariant.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qdialog.h> | 6 | #include <qdialog.h> |
7 | 7 | ||
8 | class QVBoxLayout; | 8 | class QVBoxLayout; |
9 | class QHBoxLayout; | 9 | class QHBoxLayout; |
10 | class QGridLayout; | 10 | class QGridLayout; |
11 | class QFrame; | 11 | class QFrame; |
12 | class QLabel; | 12 | class QLabel; |
13 | class QTextView; | 13 | class QTextView; |
14 | 14 | ||
15 | class imageinfo : public QWidget | 15 | class imageinfo : public QWidget |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
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 ); |
21 | ~imageinfo(); | 22 | ~imageinfo(); |
22 | 23 | ||
24 | void setDestructiveClose(); | ||
25 | |||
26 | public slots: | ||
27 | void setPath( const QString& path ); | ||
28 | |||
29 | private: | ||
30 | void init(const char* name); | ||
31 | |||
32 | protected: | ||
23 | QLabel* PixmapLabel1; | 33 | QLabel* PixmapLabel1; |
24 | QLabel* fnameLabel; | 34 | QLabel* fnameLabel; |
25 | QFrame* Line1; | 35 | QFrame* Line1; |
26 | QTextView* TextView1; | 36 | QTextView* TextView1; |
27 | 37 | ||
28 | protected: | 38 | protected: |
29 | QVBoxLayout* imageinfoLayout; | 39 | QVBoxLayout* imageinfoLayout; |
30 | QString currentFile; | 40 | QString currentFile; |
31 | 41 | ||
32 | protected slots: | 42 | protected slots: |
33 | virtual void slot_fullInfo(const QString&, const QString&); | 43 | virtual void slot_fullInfo(const QString&, const QString&); |
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&); |
37 | }; | 47 | }; |
38 | 48 | ||
39 | /* for testing purpose */ | 49 | /* for testing purpose */ |
40 | class infoDlg:public QDialog | 50 | class infoDlg:public QDialog |
41 | { | 51 | { |
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 | |||
@@ -4,12 +4,19 @@ | |||
4 | 4 | ||
5 | using namespace Opie::Core; | 5 | using namespace Opie::Core; |
6 | 6 | ||
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | 9 | ||
10 | ImageScrollView::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 | |||
10 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 17 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 18 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), |
12 | rotate_to_fit(rfit),first_resize_done(false) | 19 | rotate_to_fit(rfit),first_resize_done(false) |
13 | { | 20 | { |
14 | init(); | 21 | init(); |
15 | } | 22 | } |
@@ -26,12 +33,16 @@ void ImageScrollView::setImage(const QImage&img) | |||
26 | _image_data = QImage(); | 33 | _image_data = QImage(); |
27 | _original_data=img; | 34 | _original_data=img; |
28 | first_resize_done = false; | 35 | first_resize_done = false; |
29 | init(); | 36 | init(); |
30 | } | 37 | } |
31 | 38 | ||
39 | void 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 */ |
33 | void ImageScrollView::init() | 44 | void ImageScrollView::init() |
34 | { | 45 | { |
35 | viewport()->setBackgroundColor(white); | 46 | viewport()->setBackgroundColor(white); |
36 | if (_original_data.size().isValid()) { | 47 | if (_original_data.size().isValid()) { |
37 | resizeContents(_original_data.width(),_original_data.height()); | 48 | resizeContents(_original_data.width(),_original_data.height()); |
@@ -256,12 +267,21 @@ void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) | |||
256 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | 267 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) |
257 | { | 268 | { |
258 | _mouseStartPosX = e->x(); | 269 | _mouseStartPosX = e->x(); |
259 | _mouseStartPosY = e->y(); | 270 | _mouseStartPosY = e->y(); |
260 | } | 271 | } |
261 | 272 | ||
273 | void 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 */ |
263 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) | 283 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) |
264 | :QDialog(parent,name,true,WStyle_ContextHelp) | 284 | :QDialog(parent,name,true,WStyle_ContextHelp) |
265 | { | 285 | { |
266 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 286 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
267 | dlglayout->setSpacing(2); | 287 | dlglayout->setSpacing(2); |
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 | |||
@@ -9,25 +9,31 @@ | |||
9 | class QPainter; | 9 | class QPainter; |
10 | 10 | ||
11 | class ImageScrollView:public QScrollView | 11 | class ImageScrollView:public QScrollView |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | public: | 14 | public: |
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 ); |
16 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 17 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); |
17 | virtual ~ImageScrollView(); | 18 | virtual ~ImageScrollView(); |
18 | 19 | ||
19 | void setImage(const QImage&); | 20 | void setImage(const QImage&); |
21 | void setImage( const QString& path ); | ||
22 | void setDestructiveClose(); | ||
20 | 23 | ||
21 | enum Rotation { | 24 | enum Rotation { |
22 | Rotate0, | 25 | Rotate0, |
23 | Rotate90, | 26 | Rotate90, |
24 | Rotate180, | 27 | Rotate180, |
25 | Rotate270 | 28 | Rotate270 |
26 | }; | 29 | }; |
27 | 30 | ||
31 | signals: | ||
32 | void sig_return(); | ||
33 | |||
28 | protected: | 34 | protected: |
29 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); | 35 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); |
30 | void init(); | 36 | void init(); |
31 | 37 | ||
32 | QImage _image_data; | 38 | QImage _image_data; |
33 | QImage _original_data; | 39 | QImage _original_data; |
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 | ||
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"); |
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,21 +93,22 @@ 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 | ||
86 | PMainWindow::~PMainWindow() { | 98 | PMainWindow::~PMainWindow() { |
99 | odebug << "Shutting down" << oendl; | ||
87 | } | 100 | } |
88 | 101 | ||
89 | 102 | ||
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); |
97 | dlg.setCaption( tr("Phunk View - Config" ) ); | 110 | dlg.setCaption( tr("Phunk View - Config" ) ); |
98 | 111 | ||
99 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 112 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
100 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 113 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
101 | lay->addWidget( wid ); | 114 | lay->addWidget( wid ); |
@@ -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 | */ | ||
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 | } | ||
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 | |||
@@ -12,26 +12,50 @@ | |||
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | namespace Opie { | 15 | namespace Opie { |
16 | namespace Ui{ | 16 | namespace Ui{ |
17 | class OKeyConfigManager; | 17 | class OKeyConfigManager; |
18 | class OWidgetStack; | ||
18 | } | 19 | } |
19 | } | 20 | } |
20 | 21 | ||
21 | class PIconView; | 22 | class PIconView; |
23 | class imageinfo; | ||
24 | class ImageScrollView; | ||
22 | class PMainWindow : public QMainWindow { | 25 | class PMainWindow : public QMainWindow { |
23 | Q_OBJECT | 26 | Q_OBJECT |
27 | enum Views { IconView, ImageInfo, ImageDisplay }; | ||
24 | public: | 28 | public: |
25 | static QString appName() { return QString::fromLatin1("opie-eye" ); } | 29 | static QString appName() { return QString::fromLatin1("opie-eye" ); } |
26 | PMainWindow(QWidget*, const char*, WFlags ); | 30 | PMainWindow(QWidget*, const char*, WFlags ); |
27 | ~PMainWindow(); | 31 | ~PMainWindow(); |
28 | 32 | ||
33 | signals: | ||
34 | void configChanged(); | ||
35 | |||
36 | public slots: | ||
37 | void slotShowInfo( const QString& inf ); | ||
38 | void slotDisplay( const QString& inf ); | ||
39 | void slotReturn(); | ||
40 | |||
41 | protected: | ||
42 | void raiseIconView(); | ||
43 | void closeEvent( QCloseEvent* ); | ||
44 | |||
45 | private: | ||
46 | template<class T> void initT( const char* name, T**, int ); | ||
47 | void initInfo(); | ||
48 | void initDisp(); | ||
49 | |||
29 | private: | 50 | private: |
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 | ||
33 | 57 | ||
34 | private slots: | 58 | private slots: |
35 | void slotConfig(); | 59 | void slotConfig(); |
36 | }; | 60 | }; |
37 | 61 | ||