summaryrefslogtreecommitdiff
Unidiff
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
@@ -1,396 +1,417 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#include "iconview.h" 6#include "iconview.h"
7 7
8#include <lib/imagecache.h> 8#include <lib/imagecache.h>
9#include <gui/imageinfoui.h> 9#include <gui/imageinfoui.h>
10#include <gui/imagescrollview.h> 10#include <gui/imagescrollview.h>
11 11
12#include <iface/dirview.h> 12#include <iface/dirview.h>
13#include <iface/dirlister.h> 13#include <iface/dirlister.h>
14 14
15#include <opie2/oconfig.h> 15#include <opie2/oconfig.h>
16#include <opie2/okeyconfigwidget.h> 16#include <opie2/okeyconfigwidget.h>
17#include <opie2/odebug.h> 17#include <opie2/odebug.h>
18 18
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20#include <qpe/qpemessagebox.h> 20#include <qpe/qpemessagebox.h>
21#include <qpe/ir.h> 21#include <qpe/ir.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qiconview.h> 25#include <qiconview.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qhbox.h> 27#include <qhbox.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qmainwindow.h> 31#include <qmainwindow.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qstyle.h> 33#include <qstyle.h>
34 34
35 35
36using Opie::Ui::OKeyConfigItem; 36using 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 {
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; }
47 void setText( const QString& ); 50 void setText( const QString& );
48 51
49 52
50 private: 53 private:
51 mutable QPixmap* m_pix; 54 mutable QPixmap* m_pix;
52 QString m_path; 55 QString m_path;
53 bool m_isDir : 1; 56 bool m_isDir : 1;
54 bool m_noInfo :1; 57 bool m_noInfo :1;
55 }; 58 };
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 {
70 if ( isDir && !_dirPix ) 73 if ( isDir && !_dirPix )
71 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 74 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
72 else if ( !isDir && !_unkPix ) 75 else if ( !isDir && !_unkPix )
73 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 76 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
74 } 77 }
75 inline QPixmap* IconViewItem::pixmap()const { 78 inline QPixmap* IconViewItem::pixmap()const {
76// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", 79// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
77// rect().x(),rect().y(),rect().width(),rect().height(), 80// rect().x(),rect().y(),rect().width(),rect().height(),
78// iconView()->contentsX(), iconView()->contentsY()); 81// iconView()->contentsX(), iconView()->contentsY());
79 82
80 if ( m_isDir ) 83 if ( m_isDir )
81 return _dirPix; 84 return _dirPix;
82 else{ 85 else{
83 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 86 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
84 currentView()->dirLister()->imageInfo( m_path ); 87 currentView()->dirLister()->imageInfo( m_path );
85 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 88 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
86 } 89 }
87 90
88 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 91 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
89 if ( !m_pix && !g_stringPix.contains( m_path )) { 92 if ( !m_pix && !g_stringPix.contains( m_path )) {
90 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 93 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
91 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 94 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
92 } 95 }
93 return m_pix ? m_pix : _unkPix; 96 return m_pix ? m_pix : _unkPix;
94 } 97 }
95 } 98 }
96 inline void IconViewItem::setText( const QString& str ) { 99 inline void IconViewItem::setText( const QString& str ) {
97 QString text = QIconViewItem::text()+"\n"+str; 100 QString text = QIconViewItem::text()+"\n"+str;
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 */
104PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 111PIconView::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 }
110 m_path = QDir::homeDirPath(); 117 m_path = QDir::homeDirPath();
111 118
112 QHBox *hbox = new QHBox( this ); 119 QHBox *hbox = new QHBox( this );
113 QLabel* lbl = new QLabel( hbox ); 120 QLabel* lbl = new QLabel( hbox );
114 lbl->setText( tr("View as" ) ); 121 lbl->setText( tr("View as" ) );
115 122
116 m_views = new QComboBox( hbox, "View As" ); 123 m_views = new QComboBox( hbox, "View As" );
117 connect( m_views, SIGNAL(activated(int)), 124 connect( m_views, SIGNAL(activated(int)),
118 this, SLOT(slotViewChanged(int)) ); 125 this, SLOT(slotViewChanged(int)) );
119 126
120 m_view= new QIconView( this ); 127 m_view= new QIconView( this );
121 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 128 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
122 this, SLOT(slotClicked(QIconViewItem*)) ); 129 this, SLOT(slotClicked(QIconViewItem*)) );
123 130
124 m_view->setArrangement( QIconView::LeftToRight ); 131 m_view->setArrangement( QIconView::LeftToRight );
125 m_view->setItemTextPos( QIconView::Right ); 132 m_view->setItemTextPos( QIconView::Right );
126 133
127 int dw = QApplication::desktop()->width(); 134 int dw = QApplication::desktop()->width();
128 int viewerWidth = dw-style().scrollBarExtent().width(); 135 int viewerWidth = dw-style().scrollBarExtent().width();
129 m_view->setGridX( viewerWidth-3*m_view->spacing()); 136 m_view->setGridX( viewerWidth-3*m_view->spacing());
130 m_view->setGridY( fontMetrics().height()*2+40 ); 137 m_view->setGridY( fontMetrics().height()*2+40 );
131 138
132 139
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 */
139PIconView::~PIconView() { 149PIconView::~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
147Opie::Ui::OKeyConfigManager* PIconView::manager() { 157Opie::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 */
151void PIconView::initKeys() { 166void 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() );
157 lst.append( Opie::Ui::OKeyPair::returnKey() ); 172 lst.append( Opie::Ui::OKeyPair::returnKey() );
158 173
159 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 174 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
160 lst, false,this, "keyconfig name" ); 175 lst, false,this, "keyconfig name" );
161 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 176 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
162 Resource::loadPixmap("beam"), BeamItem, 177 Resource::loadPixmap("beam"), BeamItem,
163 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), 178 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
164 this, SLOT(slotBeam())) ); 179 this, SLOT(slotBeam())) );
165 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 180 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
166 Resource::loadPixmap("trash"), DeleteItem, 181 Resource::loadPixmap("trash"), DeleteItem,
167 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), 182 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
168 this, SLOT(slotTrash())) ); 183 this, SLOT(slotTrash())) );
169 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 184 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
170 Resource::loadPixmap("1to1"), ViewItem, 185 Resource::loadPixmap("1to1"), ViewItem,
171 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), 186 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
172 this, SLOT(slotShowImage()))); 187 this, SLOT(slotShowImage())));
173 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 188 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
174 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 189 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
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 */
181void PIconView::slotDirUp() { 200void 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 */
188void PIconView::slotChangeDir(const QString& path) { 210void 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 )
194 return; 216 return;
195 217
196 lister->setStartPath( path ); 218 lister->setStartPath( path );
197 m_path = lister->currentPath(); 219 m_path = lister->currentPath();
198 220
199 m_view->viewport()->setUpdatesEnabled( false ); 221 m_view->viewport()->setUpdatesEnabled( false );
200 m_view->clear(); 222 m_view->clear();
201 addFolders( lister->folders() ); 223 addFolders( lister->folders() );
202 addFiles( lister->files() ); 224 addFiles( lister->files() );
203 m_view->viewport()->setUpdatesEnabled( true ); 225 m_view->viewport()->setUpdatesEnabled( true );
204 226
205 // Also invalidate the cache. We can't cancel the operations anyway 227 // Also invalidate the cache. We can't cancel the operations anyway
206 g_stringPix.clear(); 228 g_stringPix.clear();
207 g_stringInf.clear(); 229 g_stringInf.clear();
208 230
209 // looks ugly 231 // looks ugly
210 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 232 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
211} 233}
212 234
213QString PIconView::currentFileName(bool &isDir)const { 235QString PIconView::currentFileName(bool &isDir)const {
214 isDir = false; 236 isDir = false;
215 QIconViewItem* _it = m_view->currentItem(); 237 QIconViewItem* _it = m_view->currentItem();
216 if ( !_it ) 238 if ( !_it )
217 return QString::null; 239 return QString::null;
218 240
219 IconViewItem* it = static_cast<IconViewItem*>( _it ); 241 IconViewItem* it = static_cast<IconViewItem*>( _it );
220 isDir = it->isDir(); 242 isDir = it->isDir();
221 return it->path(); 243 return it->path();
222} 244}
223 245
224void PIconView::slotTrash() { 246void PIconView::slotTrash() {
225 bool isDir; 247 bool isDir;
226 QString pa = currentFileName( isDir ); 248 QString pa = currentFileName( isDir );
227 if ( isDir && pa.isEmpty() ) 249 if ( isDir && pa.isEmpty() )
228 return; 250 return;
229 251
230 if (!QPEMessageBox::confirmDelete( this, 252 if (!QPEMessageBox::confirmDelete( this,
231 tr("Delete Image" ), 253 tr("Delete Image" ),
232 tr("the Image %1" ).arg(pa))) 254 tr("the Image %1" ).arg(pa)))
233 return 255 return
234 256
235 257
236 currentView()->dirLister()->deleteImage( pa ); 258 currentView()->dirLister()->deleteImage( pa );
237 delete m_view->currentItem(); 259 delete m_view->currentItem();
238} 260}
239void PIconView::loadViews() { 261void PIconView::loadViews() {
240 ViewMap::Iterator it; 262 ViewMap::Iterator it;
241 ViewMap* map = viewMap(); 263 ViewMap* map = viewMap();
242 for ( it = map->begin(); it != map->end(); ++it ) 264 for ( it = map->begin(); it != map->end(); ++it )
243 m_views->insertItem( QObject::tr(it.key() ) ); 265 m_views->insertItem( QObject::tr(it.key() ) );
244} 266}
245 267
246void PIconView::resetView() { 268void PIconView::resetView() {
247 slotViewChanged(m_views->currentItem()); 269 slotViewChanged(m_views->currentItem());
248} 270}
249 271
250void PIconView::slotViewChanged( int i) { 272void PIconView::slotViewChanged( int i) {
251 if (!m_views->count() ) { 273 if (!m_views->count() ) {
252 setCurrentView( 0l); 274 setCurrentView( 0l);
253 return; 275 return;
254 } 276 }
255 277
256 PDirView* cur = currentView(); 278 PDirView* cur = currentView();
257 delete cur; 279 delete cur;
258 QString str = m_views->text(i); 280 QString str = m_views->text(i);
259 cur = (*(*viewMap())[str])(*m_cfg); 281 cur = (*(*viewMap())[str])(*m_cfg);
260 setCurrentView( cur ); 282 setCurrentView( cur );
261 283
262 /* connect to the signals of the lister */ 284 /* connect to the signals of the lister */
263 PDirLister* lis = cur->dirLister(); 285 PDirLister* lis = cur->dirLister();
264 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 286 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
265 this, SLOT( slotThumbInfo(const QString&, const QString&))); 287 this, SLOT( slotThumbInfo(const QString&, const QString&)));
266 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 288 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
267 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 289 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
268 connect(lis, SIGNAL(sig_start()), 290 connect(lis, SIGNAL(sig_start()),
269 this, SLOT(slotStart())); 291 this, SLOT(slotStart()));
270 connect(lis, SIGNAL(sig_end()) , 292 connect(lis, SIGNAL(sig_end()) ,
271 this, SLOT(slotEnd()) ); 293 this, SLOT(slotEnd()) );
272 294
273 295
274 /* reload now */ 296 /* reload now */
275 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 297 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
276} 298}
277 299
278 300
279void PIconView::slotReloadDir() { 301void PIconView::slotReloadDir() {
280 slotChangeDir( m_path ); 302 slotChangeDir( m_path );
281} 303}
282 304
283 305
284void PIconView::addFolders( const QStringList& lst) { 306void 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
293void PIconView::addFiles( const QStringList& lst) { 315void 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 )
296 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); 318 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
297 319
298} 320}
299 321
300void PIconView::slotClicked(QIconViewItem* _it) { 322void PIconView::slotClicked(QIconViewItem* _it) {
301 if(!_it ) 323 if(!_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
311void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 333void 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;
315 337
316 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 338 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
317 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 339 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
318 m_updatet = true; 340 m_updatet = true;
319 341
320 item->setText( str ); 342 item->setText( str );
321 g_stringInf.remove( _path ); 343 g_stringInf.remove( _path );
322} 344}
323void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 345void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
324 IconViewItem* item = g_stringPix[_path]; 346 IconViewItem* item = g_stringPix[_path];
325 if (!item ) 347 if (!item )
326 return; 348 return;
327 349
328 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 350 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
329 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 351 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
330 m_updatet = true; 352 m_updatet = true;
331 353
332 if (pix.width()>0) 354 if (pix.width()>0)
333 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 355 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
334 356
335 357
336 g_stringPix.remove( _path ); 358 g_stringPix.remove( _path );
337} 359}
338 360
339 361
340void PIconView::slotRename() { 362void PIconView::slotRename() {
341 363
342} 364}
343 365
344void PIconView::slotBeam() { 366void PIconView::slotBeam() {
345 bool isDir; 367 bool isDir;
346 QString pa = currentFileName( isDir ); 368 QString pa = currentFileName( isDir );
347 if ( isDir && pa.isEmpty() ) 369 if ( isDir && pa.isEmpty() )
348 return; 370 return;
349 371
350 Ir* ir = new Ir( this ); 372 Ir* ir = new Ir( this );
351 connect( ir, SIGNAL(done(Ir*)), 373 connect( ir, SIGNAL(done(Ir*)),
352 this, SLOT(slotBeamDone(Ir*))); 374 this, SLOT(slotBeamDone(Ir*)));
353 ir->send(pa, tr( "Image" ) ); 375 ir->send(pa, tr( "Image" ) );
354 376
355} 377}
356 378
357void PIconView::slotBeamDone( Ir* ir) { 379void PIconView::slotBeamDone( Ir* ir) {
358 delete ir; 380 delete ir;
359} 381}
360 382
361void PIconView::slotStart() { 383void PIconView::slotStart() {
362 m_view->viewport()->setUpdatesEnabled( false ); 384 m_view->viewport()->setUpdatesEnabled( false );
363 qWarning( "Sig Start" );
364} 385}
365 386
366void PIconView::slotEnd() { 387void 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
374void PIconView::slotShowImage() { 394void 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}
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;
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
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
@@ -1,80 +1,84 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#ifndef PHUNK_ICON_VIEW_H 6#ifndef PHUNK_ICON_VIEW_H
7#define PHUNK_ICON_VIEW_H 7#define PHUNK_ICON_VIEW_H
8 8
9#include <qvbox.h> 9#include <qvbox.h>
10 10
11 11
12class QIconView; 12class QIconView;
13class QIconViewItem; 13class QIconViewItem;
14class QComboBox; 14class QComboBox;
15class PIconViewItem; 15class PIconViewItem;
16class PDirLister; 16class PDirLister;
17class Ir; 17class Ir;
18 18
19namespace Opie { 19namespace Opie {
20namespace Core{ 20namespace Core{
21 class OConfig; 21 class OConfig;
22} 22}
23namespace Ui { 23namespace Ui {
24 class OKeyConfigManager; 24 class OKeyConfigManager;
25} 25}
26} 26}
27 27
28class PIconView : public QVBox { 28class PIconView : public QVBox {
29 Q_OBJECT 29 Q_OBJECT
30 friend class PIconViewItem; 30 friend class PIconViewItem;
31 enum ActionIds { 31 enum ActionIds {
32 BeamItem, DeleteItem, ViewItem, InfoItem 32 BeamItem, DeleteItem, ViewItem, InfoItem
33 }; 33 };
34public: 34public:
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
40signals:
41 void sig_showInfo( const QString& );
42 void sig_display( const QString& );
43
40private: 44private:
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
45private slots: 49private slots:
46 void slotDirUp(); 50 void slotDirUp();
47 void slotChangeDir(const QString&); 51 void slotChangeDir(const QString&);
48 void slotTrash(); 52 void slotTrash();
49 void slotViewChanged( int ); 53 void slotViewChanged( int );
50 void slotReloadDir(); 54 void slotReloadDir();
51 void slotRename(); 55 void slotRename();
52 void slotBeam(); 56 void slotBeam();
53 void slotBeamDone( Ir* ); 57 void slotBeamDone( Ir* );
54 58
55 void slotShowImage(); 59 void slotShowImage();
56 void slotShowImage( const QString& ); 60 void slotShowImage( const QString& );
57 void slotImageInfo(); 61 void slotImageInfo();
58 void slotImageInfo( const QString& ); 62 void slotImageInfo( const QString& );
59 63
60 void slotStart(); 64 void slotStart();
61 void slotEnd(); 65 void slotEnd();
62 66
63/* for performance reasons make it inline in the future */ 67/* for performance reasons make it inline in the future */
64 void addFolders( const QStringList& ); 68 void addFolders( const QStringList& );
65 void addFiles( const QStringList& ); 69 void addFiles( const QStringList& );
66 void slotClicked(QIconViewItem* ); 70 void slotClicked(QIconViewItem* );
67 71
68/**/ 72/**/
69 void slotThumbInfo(const QString&, const QString&); 73 void slotThumbInfo(const QString&, const QString&);
70 void slotThumbNail(const QString&, const QPixmap&); 74 void slotThumbNail(const QString&, const QPixmap&);
71private: 75private:
72 Opie::Ui::OKeyConfigManager *m_viewManager; 76 Opie::Ui::OKeyConfigManager *m_viewManager;
73 Opie::Core::OConfig *m_cfg; 77 Opie::Core::OConfig *m_cfg;
74 QComboBox* m_views; 78 QComboBox* m_views;
75 QIconView* m_view; 79 QIconView* m_view;
76 QString m_path; 80 QString m_path;
77 bool m_updatet : 1; 81 bool m_updatet : 1;
78}; 82};
79 83
80#endif 84#endif
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
@@ -1,127 +1,152 @@
1#include "imageinfoui.h" 1#include "imageinfoui.h"
2 2
3#include <qframe.h> 3#include <qframe.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qtextview.h> 6#include <qtextview.h>
7#include <qlayout.h> 7#include <qlayout.h>
8#include <qvariant.h> 8#include <qvariant.h>
9#include <qtooltip.h> 9#include <qtooltip.h>
10#include <qwhatsthis.h> 10#include <qwhatsthis.h>
11#include <qimage.h> 11#include <qimage.h>
12#include <qpixmap.h> 12#include <qpixmap.h>
13#include <qstring.h> 13#include <qstring.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15 15
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 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
24imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) 31imageinfo::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}
37void 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 );
33 setCaption( tr( "Image info" ) ); 44 setCaption( tr( "Image info" ) );
34 imageinfoLayout = new QVBoxLayout( this ); 45 imageinfoLayout = new QVBoxLayout( this );
35 imageinfoLayout->setSpacing(2); 46 imageinfoLayout->setSpacing(2);
36 imageinfoLayout->setMargin(4); 47 imageinfoLayout->setMargin(4);
37 48
38 PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); 49 PixmapLabel1 = new QLabel( this, "PixmapLabel1" );
39 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); 50 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) );
40 QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); 51 QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") );
41 52
42 imageinfoLayout->addWidget( PixmapLabel1 ); 53 imageinfoLayout->addWidget( PixmapLabel1 );
43 54
44 Line1 = new QFrame( this, "Line1" ); 55 Line1 = new QFrame( this, "Line1" );
45 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 56 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
46 imageinfoLayout->addWidget( Line1 ); 57 imageinfoLayout->addWidget( Line1 );
47 58
48 fnameLabel = new QLabel( this, "FnameLabel" ); 59 fnameLabel = new QLabel( this, "FnameLabel" );
49 imageinfoLayout->addWidget( fnameLabel); 60 imageinfoLayout->addWidget( fnameLabel);
50 61
51 TextView1 = new QTextView( this, "TextView1" ); 62 TextView1 = new QTextView( this, "TextView1" );
52 TextView1->setFrameShadow( QTextView::Sunken ); 63 TextView1->setFrameShadow( QTextView::Sunken );
53 TextView1->setResizePolicy( QTextView::AutoOneFit ); 64 TextView1->setResizePolicy( QTextView::AutoOneFit );
54 TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); 65 TextView1->setBackgroundOrigin( QTextView::ParentOrigin );
55 TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); 66 TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) );
56// TextView1->setVScrollBarMode(QScrollView::AlwaysOn); 67// TextView1->setVScrollBarMode(QScrollView::AlwaysOn);
57 QWhatsThis::add( TextView1, tr("Displays info of selected image") ); 68 QWhatsThis::add( TextView1, tr("Displays info of selected image") );
58 imageinfoLayout->addWidget( TextView1 ); 69 imageinfoLayout->addWidget( TextView1 );
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
68void imageinfo::slotChangeName(const QString&_path) 78void imageinfo::slotChangeName(const QString&_path)
69{ 79{
70 currentFile=_path; 80 currentFile=_path;
71 QFileInfo fi(_path); 81 QFileInfo fi(_path);
72 fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); 82 fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>");
73 SlaveMaster::self()->imageInfo( currentFile ); 83 SlaveMaster::self()->imageInfo( currentFile );
74 84
75 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); 85 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE );
76 if (!m_pix) { 86 if (!m_pix) {
77 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); 87 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" )));
78 SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); 88 SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE);
79 } else { 89 } else {
80 PixmapLabel1->setPixmap(*m_pix); 90 PixmapLabel1->setPixmap(*m_pix);
81 } 91 }
82} 92}
83 93
84imageinfo::~imageinfo() 94imageinfo::~imageinfo()
85{ 95{
86 { 96 {
87 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 97 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
88 } 98 }
89} 99}
90 100
91void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) 101void imageinfo::slot_fullInfo(const QString&_path, const QString&_t)
92{ 102{
93 if (_path == currentFile) { 103 if (_path == currentFile) {
94 qDebug(_t); 104 qDebug(_t);
95 QString t = _t; 105 QString t = _t;
96 t.replace(QRegExp("\n"),"<br>"); 106 t.replace(QRegExp("\n"),"<br>");
97/* t.replace(QRegeExp("<qt>",""); 107/* t.replace(QRegeExp("<qt>","");
98 t.replace(QRegeExp("</qt>","");*/ 108 t.replace(QRegeExp("</qt>","");*/
99 TextView1->setText(t); 109 TextView1->setText(t);
100 } 110 }
101} 111}
102 112
103void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) 113void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix)
104{ 114{
105 if (_path == currentFile) { 115 if (_path == currentFile) {
106 if (_pix.width()>0) { 116 if (_pix.width()>0) {
107 PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); 117 PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE );
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
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 */
115infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) 138infoDlg::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);
120 dlglayout->setMargin(1); 143 dlglayout->setMargin(1);
121 imageinfo*inf = new imageinfo(fname,this); 144 imageinfo*inf = new imageinfo(fname,this);
122 dlglayout->addWidget(inf); 145 dlglayout->addWidget(inf);
123} 146}
124 147
125infoDlg::~infoDlg() 148infoDlg::~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
@@ -1,48 +1,58 @@
1#ifndef IMAGEINFO_H 1#ifndef IMAGEINFO_H
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
8class QVBoxLayout; 8class QVBoxLayout;
9class QHBoxLayout; 9class QHBoxLayout;
10class QGridLayout; 10class QGridLayout;
11class QFrame; 11class QFrame;
12class QLabel; 12class QLabel;
13class QTextView; 13class QTextView;
14 14
15class imageinfo : public QWidget 15class imageinfo : public QWidget
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
18 18
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 );
21 ~imageinfo(); 22 ~imageinfo();
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;
24 QLabel* fnameLabel; 34 QLabel* fnameLabel;
25 QFrame* Line1; 35 QFrame* Line1;
26 QTextView* TextView1; 36 QTextView* TextView1;
27 37
28protected: 38protected:
29 QVBoxLayout* imageinfoLayout; 39 QVBoxLayout* imageinfoLayout;
30 QString currentFile; 40 QString currentFile;
31 41
32protected slots: 42protected 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 */
40class infoDlg:public QDialog 50class infoDlg:public QDialog
41{ 51{
42 Q_OBJECT 52 Q_OBJECT
43public: 53public:
44 infoDlg(const QString&,QWidget * parent=0, const char * name=0); 54 infoDlg(const QString&,QWidget * parent=0, const char * name=0);
45 virtual ~infoDlg(); 55 virtual ~infoDlg();
46}; 56};
47 57
48#endif // IMAGEINFO_H 58#endif // IMAGEINFO_H
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
@@ -1,127 +1,138 @@
1#include "imagescrollview.h" 1#include "imagescrollview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5using namespace Opie::Core; 5using namespace Opie::Core;
6 6
7#include <qimage.h> 7#include <qimage.h>
8#include <qlayout.h> 8#include <qlayout.h>
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)
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}
16 23
17ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 24ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit)
18 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), 25 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale),
19 rotate_to_fit(rfit),first_resize_done(false) 26 rotate_to_fit(rfit),first_resize_done(false)
20{ 27{
21 init(); 28 init();
22} 29}
23 30
24void ImageScrollView::setImage(const QImage&img) 31void ImageScrollView::setImage(const QImage&img)
25{ 32{
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
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 */
33void ImageScrollView::init() 44void 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());
38 } 49 }
39 last_rot = Rotate0; 50 last_rot = Rotate0;
40} 51}
41 52
42ImageScrollView::~ImageScrollView() 53ImageScrollView::~ImageScrollView()
43{ 54{
44} 55}
45 56
46void ImageScrollView::rescaleImage(int w, int h) 57void ImageScrollView::rescaleImage(int w, int h)
47{ 58{
48 if (_image_data.width()==w && _image_data.height()==h) { 59 if (_image_data.width()==w && _image_data.height()==h) {
49 return; 60 return;
50 } 61 }
51 double hs = (double)h / (double)_image_data.height() ; 62 double hs = (double)h / (double)_image_data.height() ;
52 double ws = (double)w / (double)_image_data.width() ; 63 double ws = (double)w / (double)_image_data.width() ;
53 double scaleFactor = (hs > ws) ? ws : hs; 64 double scaleFactor = (hs > ws) ? ws : hs;
54 int smoothW = (int)(scaleFactor * _image_data.width()); 65 int smoothW = (int)(scaleFactor * _image_data.width());
55 int smoothH = (int)(scaleFactor * _image_data.height()); 66 int smoothH = (int)(scaleFactor * _image_data.height());
56 _image_data = _image_data.smoothScale(smoothW,smoothH); 67 _image_data = _image_data.smoothScale(smoothW,smoothH);
57} 68}
58 69
59void ImageScrollView::rotate_into_data(Rotation r) 70void ImageScrollView::rotate_into_data(Rotation r)
60{ 71{
61 /* realy - we must do this that way, 'cause when acting direct on _image_data the app will 72 /* realy - we must do this that way, 'cause when acting direct on _image_data the app will
62 segfault :( */ 73 segfault :( */
63 QImage dest; 74 QImage dest;
64 int x, y; 75 int x, y;
65 if ( _original_data.depth() > 8 ) 76 if ( _original_data.depth() > 8 )
66 { 77 {
67 unsigned int *srcData, *destData; 78 unsigned int *srcData, *destData;
68 switch ( r ) 79 switch ( r )
69 { 80 {
70 case Rotate90: 81 case Rotate90:
71 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 82 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
72 for ( y=0; y < _original_data.height(); ++y ) 83 for ( y=0; y < _original_data.height(); ++y )
73 { 84 {
74 srcData = (unsigned int *)_original_data.scanLine(y); 85 srcData = (unsigned int *)_original_data.scanLine(y);
75 for ( x=0; x < _original_data.width(); ++x ) 86 for ( x=0; x < _original_data.width(); ++x )
76 { 87 {
77 destData = (unsigned int *)dest.scanLine(x); 88 destData = (unsigned int *)dest.scanLine(x);
78 destData[_original_data.height()-y-1] = srcData[x]; 89 destData[_original_data.height()-y-1] = srcData[x];
79 } 90 }
80 } 91 }
81 break; 92 break;
82 case Rotate180: 93 case Rotate180:
83 dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); 94 dest.create(_original_data.width(), _original_data.height(), _original_data.depth());
84 for ( y=0; y < _original_data.height(); ++y ) 95 for ( y=0; y < _original_data.height(); ++y )
85 { 96 {
86 srcData = (unsigned int *)_original_data.scanLine(y); 97 srcData = (unsigned int *)_original_data.scanLine(y);
87 destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); 98 destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1);
88 for ( x=0; x < _original_data.width(); ++x ) 99 for ( x=0; x < _original_data.width(); ++x )
89 destData[_original_data.width()-x-1] = srcData[x]; 100 destData[_original_data.width()-x-1] = srcData[x];
90 } 101 }
91 break; 102 break;
92 case Rotate270: 103 case Rotate270:
93 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 104 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
94 for ( y=0; y < _original_data.height(); ++y ) 105 for ( y=0; y < _original_data.height(); ++y )
95 { 106 {
96 srcData = (unsigned int *)_original_data.scanLine(y); 107 srcData = (unsigned int *)_original_data.scanLine(y);
97 for ( x=0; x < _original_data.width(); ++x ) 108 for ( x=0; x < _original_data.width(); ++x )
98 { 109 {
99 destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); 110 destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1);
100 destData[y] = srcData[x]; 111 destData[y] = srcData[x];
101 } 112 }
102 } 113 }
103 break; 114 break;
104 default: 115 default:
105 dest = _original_data; 116 dest = _original_data;
106 break; 117 break;
107 } 118 }
108 } 119 }
109 else 120 else
110 { 121 {
111 unsigned char *srcData, *destData; 122 unsigned char *srcData, *destData;
112 unsigned int *srcTable, *destTable; 123 unsigned int *srcTable, *destTable;
113 switch ( r ) 124 switch ( r )
114 { 125 {
115 case Rotate90: 126 case Rotate90:
116 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 127 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
117 dest.setNumColors(_original_data.numColors()); 128 dest.setNumColors(_original_data.numColors());
118 srcTable = (unsigned int *)_original_data.colorTable(); 129 srcTable = (unsigned int *)_original_data.colorTable();
119 destTable = (unsigned int *)dest.colorTable(); 130 destTable = (unsigned int *)dest.colorTable();
120 for ( x=0; x < _original_data.numColors(); ++x ) 131 for ( x=0; x < _original_data.numColors(); ++x )
121 destTable[x] = srcTable[x]; 132 destTable[x] = srcTable[x];
122 for ( y=0; y < _original_data.height(); ++y ) 133 for ( y=0; y < _original_data.height(); ++y )
123 { 134 {
124 srcData = (unsigned char *)_original_data.scanLine(y); 135 srcData = (unsigned char *)_original_data.scanLine(y);
125 for ( x=0; x < _original_data.width(); ++x ) 136 for ( x=0; x < _original_data.width(); ++x )
126 { 137 {
127 destData = (unsigned char *)dest.scanLine(x); 138 destData = (unsigned char *)dest.scanLine(x);
@@ -166,111 +177,120 @@ void ImageScrollView::rotate_into_data(Rotation r)
166 break; 177 break;
167 } 178 }
168 179
169 } 180 }
170 _image_data = dest; 181 _image_data = dest;
171} 182}
172 183
173void ImageScrollView::resizeEvent(QResizeEvent * e) 184void ImageScrollView::resizeEvent(QResizeEvent * e)
174{ 185{
175 odebug << "ImageScrollView resizeEvent" << oendl; 186 odebug << "ImageScrollView resizeEvent" << oendl;
176 QScrollView::resizeEvent(e); 187 QScrollView::resizeEvent(e);
177 Rotation r = Rotate0; 188 Rotation r = Rotate0;
178 if (width()>height()&&_original_data.width()<_original_data.height() || 189 if (width()>height()&&_original_data.width()<_original_data.height() ||
179 width()<height()&&_original_data.width()>_original_data.height()) { 190 width()<height()&&_original_data.width()>_original_data.height()) {
180 if (rotate_to_fit) r = Rotate90; 191 if (rotate_to_fit) r = Rotate90;
181 } 192 }
182 odebug << " r = " << r << oendl; 193 odebug << " r = " << r << oendl;
183 if (scale_to_fit) { 194 if (scale_to_fit) {
184 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { 195 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
185 if (r==Rotate0) { 196 if (r==Rotate0) {
186 _image_data = _original_data; 197 _image_data = _original_data;
187 } else { 198 } else {
188 rotate_into_data(r); 199 rotate_into_data(r);
189 } 200 }
190 } 201 }
191 rescaleImage(width(),height()); 202 rescaleImage(width(),height());
192 resizeContents(width()-10,height()-10); 203 resizeContents(width()-10,height()-10);
193 } else if (!first_resize_done||r!=last_rot) { 204 } else if (!first_resize_done||r!=last_rot) {
194 if (r==Rotate0) { 205 if (r==Rotate0) {
195 _image_data = _original_data; 206 _image_data = _original_data;
196 } else { 207 } else {
197 rotate_into_data(r); 208 rotate_into_data(r);
198 } 209 }
199 last_rot = r; 210 last_rot = r;
200 resizeContents(_image_data.width(),_image_data.height()); 211 resizeContents(_image_data.width(),_image_data.height());
201 } 212 }
202 first_resize_done = true; 213 first_resize_done = true;
203} 214}
204 215
205void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) 216void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph)
206{ 217{
207 int w = clipw; 218 int w = clipw;
208 int h = cliph; 219 int h = cliph;
209 int x = clipx; 220 int x = clipx;
210 int y = clipy; 221 int y = clipy;
211 bool erase = false; 222 bool erase = false;
212 223
213 if (!_image_data.size().isValid()) { 224 if (!_image_data.size().isValid()) {
214 p->fillRect(clipx,clipy,clipw,cliph,white); 225 p->fillRect(clipx,clipy,clipw,cliph,white);
215 return; 226 return;
216 } 227 }
217 if (w>_image_data.width()) { 228 if (w>_image_data.width()) {
218 w=_image_data.width(); 229 w=_image_data.width();
219 x = 0; 230 x = 0;
220 erase = true; 231 erase = true;
221 } else if (x+w>_image_data.width()){ 232 } else if (x+w>_image_data.width()){
222 x = _image_data.width()-w; 233 x = _image_data.width()-w;
223 } 234 }
224 if (h>_image_data.height()) { 235 if (h>_image_data.height()) {
225 h=_image_data.height(); 236 h=_image_data.height();
226 y = 0; 237 y = 0;
227 erase = true; 238 erase = true;
228 } else if (y+h>_image_data.height()){ 239 } else if (y+h>_image_data.height()){
229 y = _image_data.height()-h; 240 y = _image_data.height()-h;
230 } 241 }
231 if (erase||_image_data.hasAlphaBuffer()) { 242 if (erase||_image_data.hasAlphaBuffer()) {
232 p->fillRect(clipx,clipy,clipw,cliph,white); 243 p->fillRect(clipx,clipy,clipw,cliph,white);
233 } 244 }
234 p->drawImage(clipx,clipy,_image_data,x,y,w,h); 245 p->drawImage(clipx,clipy,_image_data,x,y,w,h);
235} 246}
236 247
237/* using the real geometry points and not the translated points is wanted! */ 248/* using the real geometry points and not the translated points is wanted! */
238void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) 249void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
239{ 250{
240 int mx, my; 251 int mx, my;
241 mx = e->x(); 252 mx = e->x();
242 my = e->y(); 253 my = e->y();
243 int diffx = _mouseStartPosX-mx; 254 int diffx = _mouseStartPosX-mx;
244 int diffy = _mouseStartPosY-my; 255 int diffy = _mouseStartPosY-my;
245 scrollBy(diffx,diffy); 256 scrollBy(diffx,diffy);
246 _mouseStartPosX=mx; 257 _mouseStartPosX=mx;
247 _mouseStartPosY=my; 258 _mouseStartPosY=my;
248} 259}
249 260
250void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) 261void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e)
251{ 262{
252 _mouseStartPosX = e->x(); 263 _mouseStartPosX = e->x();
253 _mouseStartPosY = e->y(); 264 _mouseStartPosY = e->y();
254} 265}
255 266
256void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) 267void 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
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 */
263ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) 283ImageDlg::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);
268 dlglayout->setMargin(1); 288 dlglayout->setMargin(1);
269 ImageScrollView*inf = new ImageScrollView(fname,this); 289 ImageScrollView*inf = new ImageScrollView(fname,this);
270 dlglayout->addWidget(inf); 290 dlglayout->addWidget(inf);
271 odebug << "Imagedlg constructor end" << oendl; 291 odebug << "Imagedlg constructor end" << oendl;
272} 292}
273 293
274ImageDlg::~ImageDlg() 294ImageDlg::~ImageDlg()
275{ 295{
276} 296}
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
@@ -1,62 +1,68 @@
1#ifndef _IMAGE_SCROLL_VIEW_H 1#ifndef _IMAGE_SCROLL_VIEW_H
2#define _IMAGE_SCROLL_VIEW_H 2#define _IMAGE_SCROLL_VIEW_H
3 3
4#include <qscrollview.h> 4#include <qscrollview.h>
5#include <qimage.h> 5#include <qimage.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qdialog.h> 7#include <qdialog.h>
8 8
9class QPainter; 9class QPainter;
10 10
11class ImageScrollView:public QScrollView 11class ImageScrollView:public QScrollView
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
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 );
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
31signals:
32 void sig_return();
33
28protected: 34protected:
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;
34 40
35 int _mouseStartPosX,_mouseStartPosY; 41 int _mouseStartPosX,_mouseStartPosY;
36 42
37 bool scale_to_fit; 43 bool scale_to_fit;
38 bool rotate_to_fit; 44 bool rotate_to_fit;
39 bool first_resize_done; 45 bool first_resize_done;
40 Rotation last_rot; 46 Rotation last_rot;
41 47
42 void rescaleImage(int w, int h); 48 void rescaleImage(int w, int h);
43 49
44 void rotate_into_data(Rotation r); 50 void rotate_into_data(Rotation r);
45 51
46protected slots: 52protected slots:
47 virtual void viewportMouseMoveEvent(QMouseEvent* e); 53 virtual void viewportMouseMoveEvent(QMouseEvent* e);
48 virtual void contentsMousePressEvent ( QMouseEvent * e); 54 virtual void contentsMousePressEvent ( QMouseEvent * e);
49 virtual void contentsMouseReleaseEvent ( QMouseEvent * e); 55 virtual void contentsMouseReleaseEvent ( QMouseEvent * e);
50 virtual void resizeEvent(QResizeEvent * e); 56 virtual void resizeEvent(QResizeEvent * e);
51}; 57};
52 58
53/* for testing */ 59/* for testing */
54class ImageDlg:public QDialog 60class ImageDlg:public QDialog
55{ 61{
56 Q_OBJECT 62 Q_OBJECT
57public: 63public:
58 ImageDlg(const QString&,QWidget * parent=0, const char * name=0); 64 ImageDlg(const QString&,QWidget * parent=0, const char * name=0);
59 virtual ~ImageDlg(); 65 virtual ~ImageDlg();
60}; 66};
61 67
62#endif 68#endif
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
@@ -1,138 +1,229 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
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>
19#include <qpe/config.h> 23#include <qpe/config.h>
20#include <qpe/ir.h> 24#include <qpe/ir.h>
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
32OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) 36OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> )
33 37
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{
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
42 /* 46 /*
43 * Initialize ToolBar and IconView 47 * Initialize ToolBar and IconView
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
58 btn = new PFileSystem( bar ); 70 btn = new PFileSystem( bar );
59 connect( btn, SIGNAL( changeDir( const QString& ) ), 71 connect( btn, SIGNAL( changeDir( const QString& ) ),
60 m_view, SLOT(slotChangeDir( const QString& ) ) ); 72 m_view, SLOT(slotChangeDir( const QString& ) ) );
61 73
62 btn = new QToolButton( bar ); 74 btn = new QToolButton( bar );
63 btn->setIconSet( Resource::loadIconSet( "edit" ) ); 75 btn->setIconSet( Resource::loadIconSet( "edit" ) );
64 connect( btn, SIGNAL(clicked()), 76 connect( btn, SIGNAL(clicked()),
65 m_view, SLOT(slotRename()) ); 77 m_view, SLOT(slotRename()) );
66 78
67 if ( Ir::supported() ) { 79 if ( Ir::supported() ) {
68 btn = new QToolButton( bar ); 80 btn = new QToolButton( bar );
69 btn->setIconSet( Resource::loadIconSet( "beam" ) ); 81 btn->setIconSet( Resource::loadIconSet( "beam" ) );
70 connect( btn, SIGNAL(clicked()), 82 connect( btn, SIGNAL(clicked()),
71 m_view, SLOT(slotBeam()) ); 83 m_view, SLOT(slotBeam()) );
72 } 84 }
73 85
74 btn = new QToolButton( bar ); 86 btn = new QToolButton( bar );
75 btn->setIconSet( Resource::loadIconSet( "trash" ) ); 87 btn->setIconSet( Resource::loadIconSet( "trash" ) );
76 connect( btn, SIGNAL(clicked() ), 88 connect( btn, SIGNAL(clicked() ),
77 m_view, SLOT(slotTrash() ) ); 89 m_view, SLOT(slotTrash() ) );
78 90
79 btn = new QToolButton( bar ); 91 btn = new QToolButton( bar );
80 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); 92 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
81 connect( btn, SIGNAL(clicked() ), 93 connect( btn, SIGNAL(clicked() ),
82 this, SLOT(slotConfig() ) ); 94 this, SLOT(slotConfig() ) );
83 95
84} 96}
85 97
86PMainWindow::~PMainWindow() { 98PMainWindow::~PMainWindow() {
99 odebug << "Shutting down" << oendl;
87} 100}
88 101
89 102
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);
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 );
102 ViewMap *vM = viewMap(); 115 ViewMap *vM = viewMap();
103 ViewMap::Iterator _it = vM->begin(); 116 ViewMap::Iterator _it = vM->begin();
104 QMap<PDirView*, QWidget*> lst; 117 QMap<PDirView*, QWidget*> lst;
105 118
106 for( ; _it != vM->end(); ++_it ) { 119 for( ; _it != vM->end(); ++_it ) {
107 PDirView *view = (_it.data())(*m_cfg); 120 PDirView *view = (_it.data())(*m_cfg);
108 PInterfaceInfo *inf = view->interfaceInfo(); 121 PInterfaceInfo *inf = view->interfaceInfo();
109 QWidget *_wid = inf->configWidget( *m_cfg ); 122 QWidget *_wid = inf->configWidget( *m_cfg );
110 _wid->reparent(wid, QPoint() ); 123 _wid->reparent(wid, QPoint() );
111 lst.insert( view, _wid ); 124 lst.insert( view, _wid );
112 wid->addTab( _wid, "fileopen", inf->name() ); 125 wid->addTab( _wid, "fileopen", inf->name() );
113 } 126 }
114 127
115/* 128/*
116 * Add the KeyConfigWidget 129 * Add the KeyConfigWidget
117 */ 130 */
118 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 131 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
119 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 132 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
120 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 133 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
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 */
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
@@ -1,38 +1,62 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#ifndef PHUNK_MAIN_WINDOW_H 6#ifndef PHUNK_MAIN_WINDOW_H
7#define PHUNK_MAIN_WINDOW_H 7#define PHUNK_MAIN_WINDOW_H
8 8
9#include <opie2/oconfig.h> 9#include <opie2/oconfig.h>
10 10
11#include <qmainwindow.h> 11#include <qmainwindow.h>
12 12
13 13
14 14
15namespace Opie { 15namespace Opie {
16namespace Ui{ 16namespace Ui{
17 class OKeyConfigManager; 17 class OKeyConfigManager;
18 class OWidgetStack;
18} 19}
19} 20}
20 21
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:
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
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
33 57
34private slots: 58private slots:
35 void slotConfig(); 59 void slotConfig();
36}; 60};
37 61
38#endif 62#endif