summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp94
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp28
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp1
5 files changed, 131 insertions, 4 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 7196aba..0499af9 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,668 +1,758 @@
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 10
11#include <iface/dirview.h> 11#include <iface/dirview.h>
12#include <iface/dirlister.h> 12#include <iface/dirlister.h>
13 13
14#include <opie2/oconfig.h> 14#include <opie2/oconfig.h>
15#include <opie2/okeyconfigwidget.h> 15#include <opie2/okeyconfigwidget.h>
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/oimagescrollview.h> 17#include <opie2/oimagescrollview.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::Core::OKeyConfigItem; 36using Opie::Core::OKeyConfigItem;
37 37
38/* 38/*
39 * The Icons, Request Cache and IconViewItem for the IconView 39 * The Icons, Request Cache and IconViewItem for the IconView
40 */ 40 */
41namespace { 41namespace {
42 static QPixmap* _dirPix = 0; 42 static QPixmap* _dirPix = 0;
43 static QPixmap* _unkPix = 0; 43 static QPixmap* _unkPix = 0;
44 static QPixmap* _emptyPix = 0; 44 static QPixmap* _emptyPix = 0;
45 class IconViewItem : public QIconViewItem { 45 class IconViewItem : public QIconViewItem {
46 public: 46 public:
47 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); 47 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
48 QPixmap* pixmap()const; 48 QPixmap* pixmap()const;
49 QString path()const { return m_path; } 49 QString path()const { return m_path; }
50 bool isDir()const { return m_isDir; } 50 bool isDir()const { return m_isDir; }
51 void setText( const QString& ); 51 void setText( const QString& );
52 bool textOnly()const{return m_textOnly;} 52 bool textOnly()const{return m_textOnly;}
53 void setTextOnly(bool how){m_textOnly=how;} 53 void setTextOnly(bool how){m_textOnly=how;}
54 /* just for starting recalc of item rect! */ 54 /* just for starting recalc of item rect! */
55 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); 55 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
56 /* just for starting recalc of item rect! */ 56 /* just for starting recalc of item rect! */
57 virtual void setPixmap( const QPixmap & icon); 57 virtual void setPixmap( const QPixmap & icon);
58 58
59 protected: 59 protected:
60 mutable QPixmap* m_pix; 60 mutable QPixmap* m_pix;
61 61
62 private: 62 private:
63 QString m_path; 63 QString m_path;
64 bool m_isDir : 1; 64 bool m_isDir : 1;
65 bool m_noInfo :1; 65 bool m_noInfo :1;
66 bool m_textOnly:1; 66 bool m_textOnly:1;
67 bool m_NameOnly:1; 67 bool m_NameOnly:1;
68 bool m_Pixset:1; 68 bool m_Pixset:1;
69 }; 69 };
70 class TextViewItem : public IconViewItem { 70 class TextViewItem : public IconViewItem {
71 TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); 71 TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
72 QPixmap *pixmap()const; 72 QPixmap *pixmap()const;
73 void setText( const QString& ); 73 void setText( const QString& );
74 }; 74 };
75 class ThumbViewItem : public IconViewItem { 75 class ThumbViewItem : public IconViewItem {
76 ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); 76 ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
77 QPixmap *pixmap()const; 77 QPixmap *pixmap()const;
78 void setText( const QString& ); 78 void setText( const QString& );
79 }; 79 };
80 80
81 81
82/* 82/*
83 * If we request an Image or String 83 * If we request an Image or String
84 * we add it to the map 84 * we add it to the map
85 */ 85 */
86 static QMap<QString, IconViewItem*> g_stringInf; 86 static QMap<QString, IconViewItem*> g_stringInf;
87 static QMap<QString, IconViewItem*> g_stringPix; 87 static QMap<QString, IconViewItem*> g_stringPix;
88 88
89 IconViewItem::IconViewItem( QIconView* view,const QString& path, 89 IconViewItem::IconViewItem( QIconView* view,const QString& path,
90 const QString& name, bool isDir ) 90 const QString& name, bool isDir )
91 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 91 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
92 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 92 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
93 { 93 {
94 if ( isDir && !_dirPix ) 94 if ( isDir && !_dirPix )
95 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 95 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
96 else if ( !isDir && !_unkPix ) 96 else if ( !isDir && !_unkPix )
97 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 97 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
98 } 98 }
99 99
100 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) 100 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
101 { 101 {
102 m_Pixset = true; 102 m_Pixset = true;
103 calcRect(text()); 103 calcRect(text());
104 } 104 }
105 inline void IconViewItem::setPixmap( const QPixmap & ) 105 inline void IconViewItem::setPixmap( const QPixmap & )
106 { 106 {
107 m_Pixset = true; 107 m_Pixset = true;
108 calcRect(text()); 108 calcRect(text());
109 } 109 }
110 110
111 inline QPixmap* IconViewItem::pixmap()const { 111 inline QPixmap* IconViewItem::pixmap()const {
112// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() 112// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
113// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() 113// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
114// << " " << iconView()->contentsY() << oendl; 114// << " " << iconView()->contentsY() << oendl;
115 115
116 if (textOnly()&&!m_isDir) { 116 if (textOnly()&&!m_isDir) {
117 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 117 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
118 return _emptyPix; 118 return _emptyPix;
119 } 119 }
120 if ( m_isDir ) 120 if ( m_isDir )
121 return _dirPix; 121 return _dirPix;
122 else{ 122 else{
123 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 123 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
124 currentView()->dirLister()->imageInfo( m_path ); 124 currentView()->dirLister()->imageInfo( m_path );
125 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 125 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
126 } 126 }
127 127
128 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 128 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
129 if (!m_pix && !g_stringPix.contains( m_path )) { 129 if (!m_pix && !g_stringPix.contains( m_path )) {
130 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 130 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
131 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 131 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
132 } 132 }
133 return m_pix ? m_pix : _unkPix; 133 return m_pix ? m_pix : _unkPix;
134 } 134 }
135 } 135 }
136 inline void IconViewItem::setText( const QString& str ) { 136 inline void IconViewItem::setText( const QString& str ) {
137 QString text = QIconViewItem::text()+"\n"+str; 137 QString text = QIconViewItem::text()+"\n"+str;
138 m_noInfo = true; 138 m_noInfo = true;
139 QIconViewItem::setText( text ); 139 QIconViewItem::setText( text );
140 } 140 }
141} 141}
142 142
143 143
144/* 144/*
145 * Set up the GUI.. initialize the slave set up gui 145 * Set up the GUI.. initialize the slave set up gui
146 * and also load a dir 146 * and also load a dir
147 */ 147 */
148PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 148PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
149 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 149 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
150{ 150{
151 { 151 {
152 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 152 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
153 } 153 }
154 m_path = QDir::homeDirPath(); 154 m_path = QDir::homeDirPath();
155 m_mode = 0; 155 m_mode = 0;
156 156
157 QHBox *hbox = new QHBox( this ); 157 QHBox *hbox = new QHBox( this );
158 QLabel* lbl = new QLabel( hbox ); 158 QLabel* lbl = new QLabel( hbox );
159 lbl->setText( tr("View as" ) ); 159 lbl->setText( tr("View as" ) );
160 160
161 m_views = new QComboBox( hbox, "View As" ); 161 m_views = new QComboBox( hbox, "View As" );
162 162
163 m_view= new QIconView( this ); 163 m_view= new QIconView( this );
164 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 164 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
165 this, SLOT(slotClicked(QIconViewItem*)) ); 165 this, SLOT(slotClicked(QIconViewItem*)) );
166 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), 166 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
167 this, SLOT(slotClicked(QIconViewItem*)) ); 167 this, SLOT(slotClicked(QIconViewItem*)) );
168 168
169 m_view->setArrangement( QIconView::LeftToRight ); 169 m_view->setArrangement( QIconView::LeftToRight );
170 170
171 m_mode = m_cfg->readNumEntry("ListViewMode", 1); 171 m_mode = m_cfg->readNumEntry("ListViewMode", 1);
172 QString lastView = m_cfg->readEntry("LastView",""); 172 QString lastView = m_cfg->readEntry("LastView","");
173 173
174 if (m_mode < 1 || m_mode>3) m_mode = 1; 174 if (m_mode < 1 || m_mode>3) m_mode = 1;
175 175
176 m_view->setItemTextPos( QIconView::Right ); 176 m_view->setItemTextPos( QIconView::Right );
177 177
178 calculateGrid(); 178 calculateGrid();
179 179
180 initKeys(); 180 initKeys();
181 181
182 loadViews(); 182 loadViews();
183 int cc=0; 183 int cc=0;
184 for (; cc<m_views->count();++cc) { 184 for (; cc<m_views->count();++cc) {
185 if (m_views->text(cc)==lastView) { 185 if (m_views->text(cc)==lastView) {
186 break; 186 break;
187 } 187 }
188 } 188 }
189 if (cc<m_views->count()) { 189 if (cc<m_views->count()) {
190 m_views->setCurrentItem(cc); 190 m_views->setCurrentItem(cc);
191 slotViewChanged(cc); 191 slotViewChanged(cc);
192 } else { 192 } else {
193 slotViewChanged(m_views->currentItem()); 193 slotViewChanged(m_views->currentItem());
194 } 194 }
195 connect( m_views, SIGNAL(activated(int)), 195 connect( m_views, SIGNAL(activated(int)),
196 this, SLOT(slotViewChanged(int)) ); 196 this, SLOT(slotViewChanged(int)) );
197} 197}
198 198
199/* 199/*
200 * Unref the slave and save the keyboard manager 200 * Unref the slave and save the keyboard manager
201 */ 201 */
202PIconView::~PIconView() { 202PIconView::~PIconView() {
203 { 203 {
204 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 204 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
205 } 205 }
206 m_viewManager->save(); 206 m_viewManager->save();
207 delete m_viewManager; 207 delete m_viewManager;
208} 208}
209 209
210Opie::Core::OKeyConfigManager* PIconView::manager() { 210Opie::Core::OKeyConfigManager* PIconView::manager() {
211 return m_viewManager; 211 return m_viewManager;
212} 212}
213 213
214 214
215/* 215/*
216 * init the KeyBoard Shortcuts 216 * init the KeyBoard Shortcuts
217 * called from the c'tor 217 * called from the c'tor
218 */ 218 */
219void PIconView::initKeys() { 219void PIconView::initKeys() {
220 Opie::Core::OKeyPair::List lst; 220 Opie::Core::OKeyPair::List lst;
221 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 221 lst.append( Opie::Core::OKeyPair::upArrowKey() );
222 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 222 lst.append( Opie::Core::OKeyPair::downArrowKey() );
223 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 223 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
224 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 224 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
225 lst.append( Opie::Core::OKeyPair::returnKey() ); 225 lst.append( Opie::Core::OKeyPair::returnKey() );
226 226
227 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 227 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
228 lst, false,this, "keyconfig name" ); 228 lst, false,this, "keyconfig name" );
229 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 229 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
230 Resource::loadPixmap("beam"), BeamItem, 230 Resource::loadPixmap("beam"), BeamItem,
231 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), 231 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
232 this, SLOT(slotBeam())) ); 232 this, SLOT(slotBeam())) );
233 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 233 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
234 Resource::loadPixmap("trash"), DeleteItem, 234 Resource::loadPixmap("trash"), DeleteItem,
235 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), 235 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
236 this, SLOT(slotTrash())) ); 236 this, SLOT(slotTrash())) );
237 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 237 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
238 Resource::loadPixmap("1to1"), ViewItem, 238 Resource::loadPixmap("1to1"), ViewItem,
239 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), 239 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
240 this, SLOT(slotShowImage()))); 240 this, SLOT(slotShowImage())));
241 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 241 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
242 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 242 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
243 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 243 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
244 this, SLOT(slotImageInfo()) ) ); 244 this, SLOT(slotImageInfo()) ) );
245 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
246 Resource::loadPixmap("1to1"), SlideItem,
247 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
248 this, SLOT(slotStartSlide())));
245 m_viewManager->load(); 249 m_viewManager->load();
246 m_viewManager->handleWidget( m_view ); 250 m_viewManager->handleWidget( m_view );
247} 251}
248 252
249 253
250/* 254/*
251 * change one dir up 255 * change one dir up
252 */ 256 */
253void PIconView::slotDirUp() 257void PIconView::slotDirUp()
254{ 258{
255 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); 259 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
256} 260}
257 261
258/* 262/*
259 * change the dir 263 * change the dir
260 */ 264 */
261void PIconView::slotChangeDir(const QString& path) { 265void PIconView::slotChangeDir(const QString& path) {
262 if ( !currentView() ) 266 if ( !currentView() )
263 return; 267 return;
264 268
265 PDirLister *lister = currentView()->dirLister(); 269 PDirLister *lister = currentView()->dirLister();
266 if (!lister ) 270 if (!lister )
267 return; 271 return;
268 272
269 /* 273 /*
270 * Say what we want and take what we get 274 * Say what we want and take what we get
271 */ 275 */
272 lister->setStartPath( path ); 276 lister->setStartPath( path );
273 m_path = lister->currentPath(); 277 m_path = lister->currentPath();
274 278
275 m_view->viewport()->setUpdatesEnabled( false ); 279 m_view->viewport()->setUpdatesEnabled( false );
276 m_view->clear(); 280 m_view->clear();
277 281
278 /* 282 /*
279 * add files and folders 283 * add files and folders
280 */ 284 */
281 addFolders( lister->folders() ); 285 addFolders( lister->folders() );
282 addFiles( lister->files() ); 286 addFiles( lister->files() );
283 m_view->viewport()->setUpdatesEnabled( true ); 287 m_view->viewport()->setUpdatesEnabled( true );
284 288
285 // Also invalidate the cache. We can't cancel the operations anyway 289 // Also invalidate the cache. We can't cancel the operations anyway
286 g_stringPix.clear(); 290 g_stringPix.clear();
287 g_stringInf.clear(); 291 g_stringInf.clear();
288 292
289 // looks ugly 293 // looks ugly
290 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 294 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
291} 295}
292 296
293/** 297/**
294 * get the current file name 298 * get the current file name
295 * @param isDir see if this is a dir or real file 299 * @param isDir see if this is a dir or real file
296 */ 300 */
297QString PIconView::currentFileName(bool &isDir)const { 301QString PIconView::currentFileName(bool &isDir)const {
298 isDir = false; 302 isDir = false;
299 QIconViewItem* _it = m_view->currentItem(); 303 QIconViewItem* _it = m_view->currentItem();
300 if ( !_it ) 304 if ( !_it )
301 return QString::null; 305 return QString::null;
302 306
303 IconViewItem* it = static_cast<IconViewItem*>( _it ); 307 IconViewItem* it = static_cast<IconViewItem*>( _it );
304 isDir = it->isDir(); 308 isDir = it->isDir();
305 return it->path(); 309 return it->path();
306} 310}
307 311
308QString PIconView::nextFileName(bool &isDir)const 312QString PIconView::nextFileName(bool &isDir)const
309{ 313{
310 isDir = false; 314 isDir = false;
311 QIconViewItem* _it1 = m_view->currentItem(); 315 QIconViewItem* _it1 = m_view->currentItem();
312 if ( !_it1 ) 316 if ( !_it1 )
313 return QString::null; 317 return QString::null;
314 QIconViewItem* _it = _it1->nextItem(); 318 QIconViewItem* _it = _it1->nextItem();
315 if ( !_it ) 319 if ( !_it )
316 return QString::null; 320 return QString::null;
317 IconViewItem* it = static_cast<IconViewItem*>( _it ); 321 IconViewItem* it = static_cast<IconViewItem*>( _it );
318 isDir = it->isDir(); 322 isDir = it->isDir();
319 return it->path(); 323 return it->path();
320} 324}
321 325
322QString PIconView::prevFileName(bool &isDir)const{ 326QString PIconView::prevFileName(bool &isDir)const{
323 isDir = false; 327 isDir = false;
324 QIconViewItem* _it = m_view->currentItem(); 328 QIconViewItem* _it = m_view->currentItem();
325 if ( !_it ) 329 if ( !_it )
326 return QString::null; 330 return QString::null;
327 _it = _it->prevItem(); 331 _it = _it->prevItem();
328 if ( !_it ) 332 if ( !_it )
329 return QString::null; 333 return QString::null;
330 IconViewItem* it = static_cast<IconViewItem*>( _it ); 334 IconViewItem* it = static_cast<IconViewItem*>( _it );
331 isDir = it->isDir(); 335 isDir = it->isDir();
332 return it->path(); 336 return it->path();
333} 337}
334 338
335void PIconView::slotTrash() { 339void PIconView::slotTrash() {
336 bool isDir; 340 bool isDir;
337 QString pa = currentFileName( isDir ); 341 QString pa = currentFileName( isDir );
338 if ( isDir && pa.isEmpty() ) 342 if ( isDir && pa.isEmpty() )
339 return; 343 return;
340 344
341 if (!QPEMessageBox::confirmDelete( this, 345 if (!QPEMessageBox::confirmDelete( this,
342 tr("Delete Image" ), 346 tr("Delete Image" ),
343 tr("the Image %1" ).arg(pa))) 347 tr("the Image %1" ).arg(pa)))
344 return 348 return
345 349
346 350
347 currentView()->dirLister()->deleteImage( pa ); 351 currentView()->dirLister()->deleteImage( pa );
348 delete m_view->currentItem(); 352 delete m_view->currentItem();
349} 353}
350 354
351/* 355/*
352 * see what views are available 356 * see what views are available
353 */ 357 */
354void PIconView::loadViews() { 358void PIconView::loadViews() {
355 ViewMap::Iterator it; 359 ViewMap::Iterator it;
356 ViewMap* map = viewMap(); 360 ViewMap* map = viewMap();
357 for ( it = map->begin(); it != map->end(); ++it ) 361 for ( it = map->begin(); it != map->end(); ++it )
358 m_views->insertItem( it.key() ); 362 m_views->insertItem( it.key() );
359} 363}
360 364
361void PIconView::resetView() { 365void PIconView::resetView() {
362 slotViewChanged(m_views->currentItem()); 366 slotViewChanged(m_views->currentItem());
363} 367}
364 368
365/* 369/*
366 *swicth view reloadDir and connect signals 370 *swicth view reloadDir and connect signals
367 */ 371 */
368void PIconView::slotViewChanged( int i) { 372void PIconView::slotViewChanged( int i) {
369 if (!m_views->count() ) { 373 if (!m_views->count() ) {
370 setCurrentView( 0l); 374 setCurrentView( 0l);
371 return; 375 return;
372 } 376 }
373 377
374 PDirView* cur = currentView(); 378 PDirView* cur = currentView();
375 if (cur) delete cur; 379 if (cur) delete cur;
376 QString str = m_views->text(i); 380 QString str = m_views->text(i);
377 ViewMap* map = viewMap(); 381 ViewMap* map = viewMap();
378 if (!map) { 382 if (!map) {
379 setCurrentView(0l); 383 setCurrentView(0l);
380 return; 384 return;
381 } 385 }
382 386
383 if (map->find(str) == map->end()) { 387 if (map->find(str) == map->end()) {
384 owarn << "Key not found" << oendl; 388 owarn << "Key not found" << oendl;
385 setCurrentView(0l); 389 setCurrentView(0l);
386 return; 390 return;
387 } 391 }
388 392
389 m_cfg->writeEntry("LastView",str); 393 m_cfg->writeEntry("LastView",str);
390 m_cfg->write(); 394 m_cfg->write();
391 cur = (*(*map)[str])(*m_cfg); 395 cur = (*(*map)[str])(*m_cfg);
392 setCurrentView( cur ); 396 setCurrentView( cur );
393 397
394 /* connect to the signals of the lister */ 398 /* connect to the signals of the lister */
395 PDirLister* lis = cur->dirLister(); 399 PDirLister* lis = cur->dirLister();
396 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 400 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
397 this, SLOT( slotThumbInfo(const QString&, const QString&))); 401 this, SLOT( slotThumbInfo(const QString&, const QString&)));
398 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 402 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
399 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 403 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
400 connect(lis, SIGNAL(sig_start()), 404 connect(lis, SIGNAL(sig_start()),
401 this, SLOT(slotStart())); 405 this, SLOT(slotStart()));
402 connect(lis, SIGNAL(sig_end()) , 406 connect(lis, SIGNAL(sig_end()) ,
403 this, SLOT(slotEnd()) ); 407 this, SLOT(slotEnd()) );
404 408
405 409
406 /* reload now with default Path*/ 410 /* reload now with default Path*/
407 m_path = lis->defaultPath(); 411 m_path = lis->defaultPath();
408 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 412 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
409} 413}
410 414
411 415
412void PIconView::slotReloadDir() { 416void PIconView::slotReloadDir() {
413 slotChangeDir( m_path ); 417 slotChangeDir( m_path );
414} 418}
415 419
416 420
417/* 421/*
418 * add files and folders 422 * add files and folders
419 */ 423 */
420void PIconView::addFolders( const QStringList& lst) { 424void PIconView::addFolders( const QStringList& lst) {
421 QStringList::ConstIterator it; 425 QStringList::ConstIterator it;
422 IconViewItem * _iv; 426 IconViewItem * _iv;
423 427
424 for(it=lst.begin(); it != lst.end(); ++it ) { 428 for(it=lst.begin(); it != lst.end(); ++it ) {
425 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 429 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
426 if (m_mode==3) _iv->setTextOnly(true); 430 if (m_mode==3) _iv->setTextOnly(true);
427 } 431 }
428} 432}
429 433
430void PIconView::addFiles( const QStringList& lst) { 434void PIconView::addFiles( const QStringList& lst) {
431 QStringList::ConstIterator it; 435 QStringList::ConstIterator it;
432 IconViewItem * _iv; 436 IconViewItem * _iv;
433 QPixmap*m_pix = 0; 437 QPixmap*m_pix = 0;
434 QString pre = ""; 438 QString pre = "";
435 if (!m_path.isEmpty()) { 439 if (!m_path.isEmpty()) {
436 pre = m_path+"/"; 440 pre = m_path+"/";
437 } 441 }
438 for (it=lst.begin(); it!= lst.end(); ++it ) { 442 for (it=lst.begin(); it!= lst.end(); ++it ) {
439 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); 443 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 );
440 _iv = new IconViewItem( m_view, pre+(*it), (*it) ); 444 _iv = new IconViewItem( m_view, pre+(*it), (*it) );
441 if (m_mode==3) { 445 if (m_mode==3) {
442 _iv->setTextOnly(true); 446 _iv->setTextOnly(true);
443 _iv->setPixmap(QPixmap()); 447 _iv->setPixmap(QPixmap());
444 448
445 449
446 450
447 } else { 451 } else {
448 if (m_pix) _iv->setPixmap(*m_pix); 452 if (m_pix) _iv->setPixmap(*m_pix);
449 } 453 }
450 } 454 }
451 455
452} 456}
453 457
454/* 458/*
455 * user clicked on the item. Change dir or view 459 * user clicked on the item. Change dir or view
456 */ 460 */
457void PIconView::slotClicked(QIconViewItem* _it) { 461void PIconView::slotClicked(QIconViewItem* _it) {
458 if(!_it ) 462 if(!_it )
459 return; 463 return;
460 464
461 IconViewItem* it = static_cast<IconViewItem*>(_it); 465 IconViewItem* it = static_cast<IconViewItem*>(_it);
462 if( it->isDir() ) 466 if( it->isDir() )
463 slotChangeDir( it->path() ); 467 slotChangeDir( it->path() );
464 else // view image 468 else // view image
465 slotShowImage(); 469 slotShowImage();
466} 470}
467 471
468/* 472/*
469 * Return was pressed. which is triggered by the keydown 473 * Return was pressed. which is triggered by the keydown
470 * handler. The problem is that the key up will be handled 474 * handler. The problem is that the key up will be handled
471 * by the ImageDisplayer and goes to the next image 475 * by the ImageDisplayer and goes to the next image
472 */ 476 */
473void PIconView::slotRetrun( QIconViewItem *_it ) { 477void PIconView::slotRetrun( QIconViewItem *_it ) {
474 if(!_it ) 478 if(!_it )
475 return; 479 return;
476 480
477 IconViewItem* it = static_cast<IconViewItem*>(_it); 481 IconViewItem* it = static_cast<IconViewItem*>(_it);
478 if( it->isDir() ) 482 if( it->isDir() )
479 slotChangeDir( it->path() ); 483 slotChangeDir( it->path() );
480 else 484 else
481 QTimer::singleShot(0, this, SLOT(slotShowImage()) ); 485 QTimer::singleShot(0, this, SLOT(slotShowImage()) );
482} 486}
483 487
484/* 488/*
485 * got thumb info add to the cache if items is visible 489 * got thumb info add to the cache if items is visible
486 * we later need update after processing of slave is done 490 * we later need update after processing of slave is done
487 */ 491 */
488void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 492void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
489 IconViewItem* item = g_stringInf[_path]; 493 IconViewItem* item = g_stringInf[_path];
490 if (!item ) 494 if (!item )
491 return; 495 return;
492 496
493 if (m_mode == 2) { 497 if (m_mode == 2) {
494 return; 498 return;
495 } 499 }
496 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 500 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
497 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 501 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
498 m_updatet = true; 502 m_updatet = true;
499 503
500 item->setText( str ); 504 item->setText( str );
501 g_stringInf.remove( _path ); 505 g_stringInf.remove( _path );
502} 506}
503 507
504/* 508/*
505 * got thumbnail and see if it is visible so we need to update later 509 * got thumbnail and see if it is visible so we need to update later
506 */ 510 */
507void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 511void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
508 IconViewItem* item = g_stringPix[_path]; 512 IconViewItem* item = g_stringPix[_path];
509 if (!item ) 513 if (!item )
510 return; 514 return;
511 515
512 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 516 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
513 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 517 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
514 m_updatet = true; 518 m_updatet = true;
515 519
516 if (pix.width()>0) { 520 if (pix.width()>0) {
517 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 521 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
518 item->setPixmap(pix,true); 522 item->setPixmap(pix,true);
519 } else { 523 } else {
520 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); 524 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 );
521 } 525 }
522 g_stringPix.remove( _path ); 526 g_stringPix.remove( _path );
523} 527}
524 528
525 529
526/* 530/*
527 * FIXME rename 531 * FIXME rename
528 */ 532 */
529void PIconView::slotRename() { 533void PIconView::slotRename() {
530 534
531} 535}
532 536
533 537
534/* 538/*
535 * BEAM the current file 539 * BEAM the current file
536 */ 540 */
537void PIconView::slotBeam() { 541void PIconView::slotBeam() {
538 bool isDir; 542 bool isDir;
539 QString pa = currentFileName( isDir ); 543 QString pa = currentFileName( isDir );
540 if ( isDir && pa.isEmpty() ) 544 if ( isDir && pa.isEmpty() )
541 return; 545 return;
542 546
543 Ir* ir = new Ir( this ); 547 Ir* ir = new Ir( this );
544 connect( ir, SIGNAL(done(Ir*)), 548 connect( ir, SIGNAL(done(Ir*)),
545 this, SLOT(slotBeamDone(Ir*))); 549 this, SLOT(slotBeamDone(Ir*)));
546 ir->send(pa, tr( "Image" ) ); 550 ir->send(pa, tr( "Image" ) );
547} 551}
548 552
549/* 553/*
550 * BEAM done clean up 554 * BEAM done clean up
551 */ 555 */
552void PIconView::slotBeamDone( Ir* ir) { 556void PIconView::slotBeamDone( Ir* ir) {
553 delete ir; 557 delete ir;
554} 558}
555 559
556void PIconView::slotStart() { 560void PIconView::slotStart() {
557 m_view->viewport()->setUpdatesEnabled( false ); 561 m_view->viewport()->setUpdatesEnabled( false );
558} 562}
559 563
560void PIconView::slotEnd() { 564void PIconView::slotEnd() {
561 if ( m_updatet ) 565 if ( m_updatet )
562 m_view->arrangeItemsInGrid( ); 566 m_view->arrangeItemsInGrid( );
563 m_view->viewport()->setUpdatesEnabled( true ); 567 m_view->viewport()->setUpdatesEnabled( true );
564 m_updatet = false; 568 m_updatet = false;
565} 569}
566 570
571void PIconView::slotShowLast()
572{
573 QIconViewItem* last_it = m_view->lastItem();
574 if (!last_it) return;
575 m_view->setCurrentItem(last_it);
576 IconViewItem* it = static_cast<IconViewItem*>( last_it );
577 bool isDir = it->isDir();
578 QString name = it->path();
579 if (!isDir && !name.isEmpty()) {
580 slotShowImage(name);
581 return;
582 }
583 bool first_loop = true;
584 while(isDir==true) {
585 if (!first_loop) {
586 m_view->setCurrentItem(m_view->currentItem()->prevItem());
587 } else {
588 first_loop = false;
589 }
590 name = prevFileName(isDir);
591 }
592
593 if (name.isEmpty()) return;
594 /* if we got a name we have a prev item */
595 m_view->setCurrentItem(m_view->currentItem()->prevItem());
596 slotShowImage(name);
597}
598
599bool PIconView::slotShowFirst()
600{
601 /* stop when reached - otherwise we may get an endless loop */
602 QIconViewItem* first_it = m_view->firstItem();
603 if (!first_it) return false;
604 m_view->setCurrentItem(first_it);
605 IconViewItem* it = static_cast<IconViewItem*>( first_it );
606 bool isDir = it->isDir();
607 QString name = it->path();
608 if (!isDir && !name.isEmpty()) {
609 slotShowImage(name);
610 return false;
611 }
612 bool first_loop = true;
613 while(isDir==true) {
614 /* if name is empty isDir is false, too. */
615 if (!first_loop) {
616 m_view->setCurrentItem(m_view->currentItem()->nextItem());
617 } else {
618 first_loop = false;
619 }
620 name = nextFileName(isDir);
621 }
622 if (name.isEmpty()) return false;
623 /* if we got a name we have a next item */
624 m_view->setCurrentItem(m_view->currentItem()->nextItem());
625 slotShowImage(name);
626 return true;
627}
628
567void PIconView::slotShowNext() 629void PIconView::slotShowNext()
568{ 630{
569 bool isDir = false; 631 bool isDir = false;
570 QString name = nextFileName(isDir); 632 QString name = nextFileName(isDir);
571 if (name.isEmpty()) return; 633 while (isDir==true) {
634 m_view->setCurrentItem(m_view->currentItem()->nextItem());
635 name = nextFileName(isDir);
636 }
637 if (name.isEmpty()) {
638 slotShowFirst();
639 return;
640 }
572 if (isDir) return; 641 if (isDir) return;
573 /* if we got a name we have a next item */ 642 /* if we got a name we have a next item */
574 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 643 m_view->setCurrentItem(m_view->currentItem()->nextItem());
575 slotShowImage(name); 644 slotShowImage(name);
576} 645}
577 646
578void PIconView::slotShowPrev() 647void PIconView::slotShowPrev()
579{ 648{
580 bool isDir = false; 649 bool isDir = false;
581 QString name = prevFileName(isDir); 650 QString name = prevFileName(isDir);
582 if (name.isEmpty()) return; 651 while (isDir==true) {
652 /* if name is empty isDir is false, too. */
653 m_view->setCurrentItem(m_view->currentItem()->prevItem());
654 name = prevFileName(isDir);
655 }
656 if (name.isEmpty()) {
657 slotShowLast();
658 return;
659 }
583 if (isDir) return; 660 if (isDir) return;
584 /* if we got a name we have a prev item */ 661 /* if we got a name we have a prev item */
585 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 662 m_view->setCurrentItem(m_view->currentItem()->prevItem());
586 slotShowImage(name); 663 slotShowImage(name);
587} 664}
588 665
589void PIconView::slotShowImage() 666void PIconView::slotShowImage()
590{ 667{
591 bool isDir = false; 668 bool isDir = false;
592 QString name = currentFileName(isDir); 669 QString name = currentFileName(isDir);
593 if (isDir) return; 670 if (isDir) return;
594 slotShowImage( name ); 671 slotShowImage( name );
595} 672}
596void PIconView::slotShowImage( const QString& name) { 673void PIconView::slotShowImage( const QString& name) {
597 PDirLister *lister = currentView()->dirLister(); 674 PDirLister *lister = currentView()->dirLister();
598 QString r_name = lister->nameToFname(name); 675 QString r_name = lister->nameToFname(name);
599 emit sig_display( r_name ); 676 emit sig_display( r_name );
600} 677}
678
679void PIconView::slotStartSlide() {
680 bool isDir = false;
681 QString name = currentFileName(isDir);
682 if (isDir) {
683 if (!slotShowFirst())
684 return;
685 } else {
686 slotShowImage( name );
687 }
688 emit sig_startslide(2);
689}
690
601void PIconView::slotImageInfo() { 691void PIconView::slotImageInfo() {
602 bool isDir = false; 692 bool isDir = false;
603 QString name = currentFileName(isDir); 693 QString name = currentFileName(isDir);
604 if (isDir) return; 694 if (isDir) return;
605 695
606 slotImageInfo( name ); 696 slotImageInfo( name );
607} 697}
608 698
609void PIconView::slotImageInfo( const QString& name) { 699void PIconView::slotImageInfo( const QString& name) {
610 PDirLister *lister = currentView()->dirLister(); 700 PDirLister *lister = currentView()->dirLister();
611 QString r_name = lister->nameToFname(name); 701 QString r_name = lister->nameToFname(name);
612 emit sig_showInfo(r_name ); 702 emit sig_showInfo(r_name );
613} 703}
614 704
615 705
616void PIconView::slotChangeMode( int mode ) { 706void PIconView::slotChangeMode( int mode ) {
617 if ( mode >= 1 && mode <= 3 ) 707 if ( mode >= 1 && mode <= 3 )
618 m_mode = mode; 708 m_mode = mode;
619 709
620 m_cfg->writeEntry("ListViewMode", m_mode); 710 m_cfg->writeEntry("ListViewMode", m_mode);
621 /* performance! */ 711 /* performance! */
622 m_view->clear(); 712 m_view->clear();
623 calculateGrid(); 713 calculateGrid();
624 slotReloadDir(); 714 slotReloadDir();
625} 715}
626 716
627 717
628void PIconView::resizeEvent( QResizeEvent* re ) { 718void PIconView::resizeEvent( QResizeEvent* re ) {
629 QVBox::resizeEvent( re ); 719 QVBox::resizeEvent( re );
630 calculateGrid(); 720 calculateGrid();
631} 721}
632 722
633 723
634void PIconView::calculateGrid() { 724void PIconView::calculateGrid() {
635 int dw = QApplication::desktop()->width(); 725 int dw = QApplication::desktop()->width();
636 int viewerWidth = dw-style().scrollBarExtent().width(); 726 int viewerWidth = dw-style().scrollBarExtent().width();
637 727
638 QIconView::ItemTextPos pos; 728 QIconView::ItemTextPos pos;
639 switch( m_mode ) { 729 switch( m_mode ) {
640 case 2: 730 case 2:
641 pos = QIconView::Bottom; 731 pos = QIconView::Bottom;
642 break; 732 break;
643 case 3: 733 case 3:
644 case 1: 734 case 1:
645 default: 735 default:
646 pos = QIconView::Right; 736 pos = QIconView::Right;
647 break; 737 break;
648 } 738 }
649 m_view->setItemTextPos( pos ); 739 m_view->setItemTextPos( pos );
650 switch (m_mode) { 740 switch (m_mode) {
651 case 2: 741 case 2:
652 m_view->setGridX(50); 742 m_view->setGridX(50);
653 m_view->setGridY(20); 743 m_view->setGridY(20);
654 PPixmapCache::self()->setMaxImages(40); 744 PPixmapCache::self()->setMaxImages(40);
655 break; 745 break;
656 case 3: 746 case 3:
657 m_view->setGridX( fontMetrics().width("testimage.jpg")+20); 747 m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
658 m_view->setGridY(8); 748 m_view->setGridY(8);
659 PPixmapCache::self()->setMaxImages(2); 749 PPixmapCache::self()->setMaxImages(2);
660 break; 750 break;
661 case 1: 751 case 1:
662 default: 752 default:
663 m_view->setGridX( viewerWidth-3*m_view->spacing()); 753 m_view->setGridX( viewerWidth-3*m_view->spacing());
664 m_view->setGridY( fontMetrics().height()*2+40 ); 754 m_view->setGridY( fontMetrics().height()*2+40 );
665 PPixmapCache::self()->setMaxImages(20); 755 PPixmapCache::self()->setMaxImages(20);
666 break; 756 break;
667 } 757 }
668} 758}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index a424c5c..bccbb0e 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,96 +1,100 @@
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 class OKeyConfigManager; 22 class OKeyConfigManager;
23} 23}
24} 24}
25 25
26class PIconView : public QVBox { 26class PIconView : public QVBox {
27 Q_OBJECT 27 Q_OBJECT
28 friend class PIconViewItem; 28 friend class PIconViewItem;
29 enum ActionIds { 29 enum ActionIds {
30 BeamItem, DeleteItem, ViewItem, InfoItem 30 BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem
31 }; 31 };
32public: 32public:
33 PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); 33 PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
34 ~PIconView(); 34 ~PIconView();
35 void resetView(); 35 void resetView();
36 Opie::Core::OKeyConfigManager* manager(); 36 Opie::Core::OKeyConfigManager* manager();
37 37
38signals: 38signals:
39 void sig_showInfo( const QString& ); 39 void sig_showInfo( const QString& );
40 void sig_display( const QString& ); 40 void sig_display( const QString& );
41 void sig_startslide(int timeout);
41 42
42public slots: 43public slots:
43 virtual void slotShowNext(); 44 virtual void slotShowNext();
44 virtual void slotShowPrev(); 45 virtual void slotShowPrev();
46 virtual void slotShowLast();
47 virtual bool slotShowFirst();
45 48
46protected: 49protected:
47 void resizeEvent( QResizeEvent* ); 50 void resizeEvent( QResizeEvent* );
48 51
49private: 52private:
50 void initKeys(); 53 void initKeys();
51 QString currentFileName(bool &isDir)const; 54 QString currentFileName(bool &isDir)const;
52 QString nextFileName(bool &isDir)const; 55 QString nextFileName(bool &isDir)const;
53 QString prevFileName(bool &isDir)const; 56 QString prevFileName(bool &isDir)const;
54 void loadViews(); 57 void loadViews();
55 void calculateGrid(); 58 void calculateGrid();
56 59
57private slots: 60private slots:
58 void slotDirUp(); 61 void slotDirUp();
59 void slotChangeDir(const QString&); 62 void slotChangeDir(const QString&);
60 void slotTrash(); 63 void slotTrash();
61 void slotViewChanged( int ); 64 void slotViewChanged( int );
62 void slotReloadDir(); 65 void slotReloadDir();
63 void slotRename(); 66 void slotRename();
64 void slotBeam(); 67 void slotBeam();
65 void slotBeamDone( Ir* ); 68 void slotBeamDone( Ir* );
66 69
67 void slotShowImage(); 70 void slotShowImage();
68 void slotShowImage( const QString& ); 71 void slotShowImage( const QString& );
69 void slotImageInfo(); 72 void slotImageInfo();
70 void slotImageInfo( const QString& ); 73 void slotImageInfo( const QString& );
74 void slotStartSlide();
71 75
72 void slotStart(); 76 void slotStart();
73 void slotEnd(); 77 void slotEnd();
74 78
75/* for performance reasons make it inline in the future */ 79/* for performance reasons make it inline in the future */
76 void addFolders( const QStringList& ); 80 void addFolders( const QStringList& );
77 void addFiles( const QStringList& ); 81 void addFiles( const QStringList& );
78 void slotClicked(QIconViewItem* ); 82 void slotClicked(QIconViewItem* );
79 void slotRetrun(QIconViewItem* ); 83 void slotRetrun(QIconViewItem* );
80 84
81/**/ 85/**/
82 void slotThumbInfo(const QString&, const QString&); 86 void slotThumbInfo(const QString&, const QString&);
83 void slotThumbNail(const QString&, const QPixmap&); 87 void slotThumbNail(const QString&, const QPixmap&);
84 88
85 void slotChangeMode( int ); 89 void slotChangeMode( int );
86private: 90private:
87 Opie::Core::OKeyConfigManager *m_viewManager; 91 Opie::Core::OKeyConfigManager *m_viewManager;
88 Opie::Core::OConfig *m_cfg; 92 Opie::Core::OConfig *m_cfg;
89 QComboBox* m_views; 93 QComboBox* m_views;
90 QIconView* m_view; 94 QIconView* m_view;
91 QString m_path; 95 QString m_path;
92 bool m_updatet : 1; 96 bool m_updatet : 1;
93 int m_mode; 97 int m_mode;
94}; 98};
95 99
96#endif 100#endif
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index 5522131..b699aa1 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,180 +1,206 @@
1#include "imageview.h" 1#include "imageview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4#include <opie2/oconfig.h> 4#include <opie2/oconfig.h>
5#include <opie2/okeyconfigwidget.h> 5#include <opie2/okeyconfigwidget.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpopupmenu.h> 9#include <qpopupmenu.h>
10#include <qtimer.h>
10 11
11using namespace Opie::Core; 12using namespace Opie::Core;
12 13
13ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) 14ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
14 : Opie::MM::OImageScrollView(parent,name,fl) 15 : Opie::MM::OImageScrollView(parent,name,fl)
15{ 16{
16 m_viewManager = 0; 17 m_viewManager = 0;
17 focus_in_count = 0; 18 focus_in_count = 0;
18 m_cfg = cfg; 19 m_cfg = cfg;
19 m_isFullScreen = false; 20 m_isFullScreen = false;
20 m_ignore_next_in = false; 21 m_ignore_next_in = false;
22 m_slideTimer = 0;
21 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); 23 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
22 initKeys(); 24 initKeys();
25 m_slideValue = 5;
23} 26}
24 27
25ImageView::~ImageView() 28ImageView::~ImageView()
26{ 29{
27 odebug << "Delete Imageview" << oendl; 30 odebug << "Delete Imageview" << oendl;
28 delete m_viewManager; 31 delete m_viewManager;
29} 32}
30 33
31Opie::Core::OKeyConfigManager* ImageView::manager() 34Opie::Core::OKeyConfigManager* ImageView::manager()
32{ 35{
33 if (!m_viewManager) { 36 if (!m_viewManager) {
34 initKeys(); 37 initKeys();
35 } 38 }
36 return m_viewManager; 39 return m_viewManager;
37} 40}
38 41
42void ImageView::startSlide(int value)
43{
44 if (!m_slideTimer) {
45 m_slideTimer = new QTimer(this);
46 }
47 m_slideValue=value;
48 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide()));
49 m_slideTimer->start(m_slideValue*1000,true);
50}
51
52void ImageView::nextSlide()
53{
54 if (!m_slideTimer) {
55 return;
56 }
57 if (isHidden()) {
58 delete m_slideTimer;
59 m_slideTimer = 0;
60 return;
61 }
62 emit dispNext();
63 m_slideTimer->start(m_slideValue*1000,true);
64}
39void ImageView::initKeys() 65void ImageView::initKeys()
40{ 66{
41 odebug << "init imageview keys" << oendl; 67 odebug << "init imageview keys" << oendl;
42 if (!m_cfg) { 68 if (!m_cfg) {
43 m_cfg = new Opie::Core::OConfig("phunkview"); 69 m_cfg = new Opie::Core::OConfig("phunkview");
44 m_cfg->setGroup("image_view_keys" ); 70 m_cfg->setGroup("image_view_keys" );
45 } 71 }
46 Opie::Core::OKeyPair::List lst; 72 Opie::Core::OKeyPair::List lst;
47 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 73 lst.append( Opie::Core::OKeyPair::upArrowKey() );
48 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 74 lst.append( Opie::Core::OKeyPair::downArrowKey() );
49 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 75 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
50 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 76 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
51 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); 77 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0));
52 78
53 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 79 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
54 lst, false,this, "image_view_keys" ); 80 lst, false,this, "image_view_keys" );
55 81
56 /** 82 /**
57 * Handle KeyEvents when they're pressed. This avoids problems 83 * Handle KeyEvents when they're pressed. This avoids problems
58 * with 'double next' on Return. 84 * with 'double next' on Return.
59 * The Return press would switch to this view and the return 85 * The Return press would switch to this view and the return
60 * release would emit the dispNext Signal. 86 * release would emit the dispNext Signal.
61 */ 87 */
62 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); 88 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed );
63 89
64 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 90 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
65 Resource::loadPixmap("1to1"), ViewInfo, 91 Resource::loadPixmap("1to1"), ViewInfo,
66 Opie::Core::OKeyPair(Qt::Key_I,0), 92 Opie::Core::OKeyPair(Qt::Key_I,0),
67 this, SLOT(slotShowImageInfo()))); 93 this, SLOT(slotShowImageInfo())));
68 94
69 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", 95 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
70 Resource::loadPixmap("rotate"), Autorotate, 96 Resource::loadPixmap("rotate"), Autorotate,
71 Opie::Core::OKeyPair(Qt::Key_R,0), 97 Opie::Core::OKeyPair(Qt::Key_R,0),
72 this, SIGNAL(toggleAutorotate()))); 98 this, SIGNAL(toggleAutorotate())));
73 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", 99 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale",
74 Resource::loadPixmap("1to1"), Autoscale, 100 Resource::loadPixmap("1to1"), Autoscale,
75 Opie::Core::OKeyPair(Qt::Key_S,0), 101 Opie::Core::OKeyPair(Qt::Key_S,0),
76 this, SIGNAL(toggleAutoscale()))); 102 this, SIGNAL(toggleAutoscale())));
77 103
78 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", 104 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext",
79 Resource::loadPixmap("forward"), ShowNext, 105 Resource::loadPixmap("forward"), ShowNext,
80 Opie::Core::OKeyPair(Qt::Key_Return,0), 106 Opie::Core::OKeyPair(Qt::Key_Return,0),
81 this, SIGNAL(dispNext()))); 107 this, SIGNAL(dispNext())));
82 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", 108 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev",
83 Resource::loadPixmap("back"), ShowPrevious, 109 Resource::loadPixmap("back"), ShowPrevious,
84 Opie::Core::OKeyPair(Qt::Key_P,0), 110 Opie::Core::OKeyPair(Qt::Key_P,0),
85 this, SIGNAL(dispPrev()))); 111 this, SIGNAL(dispPrev())));
86 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", 112 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen",
87 Resource::loadPixmap("fullscreen"), FullScreen, 113 Resource::loadPixmap("fullscreen"), FullScreen,
88 Opie::Core::OKeyPair(Qt::Key_F,0), 114 Opie::Core::OKeyPair(Qt::Key_F,0),
89 this, SIGNAL(toggleFullScreen()))); 115 this, SIGNAL(toggleFullScreen())));
90 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", 116 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer",
91 Resource::loadPixmap("mag"), Zoomer, 117 Resource::loadPixmap("mag"), Zoomer,
92 Opie::Core::OKeyPair(Qt::Key_T,0), 118 Opie::Core::OKeyPair(Qt::Key_T,0),
93 this, SIGNAL(toggleZoomer()))); 119 this, SIGNAL(toggleZoomer())));
94 m_viewManager->handleWidget( this ); 120 m_viewManager->handleWidget( this );
95 m_viewManager->load(); 121 m_viewManager->load();
96} 122}
97 123
98void ImageView::keyReleaseEvent(QKeyEvent * e) 124void ImageView::keyReleaseEvent(QKeyEvent * e)
99{ 125{
100 if (!e || e->state()!=0) { 126 if (!e || e->state()!=0) {
101 return; 127 return;
102 } 128 }
103 if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); 129 if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe();
104} 130}
105 131
106void ImageView::slotShowImageInfo() 132void ImageView::slotShowImageInfo()
107{ 133{
108 emit dispImageInfo(m_lastName); 134 emit dispImageInfo(m_lastName);
109} 135}
110 136
111void ImageView::contentsMousePressEvent ( QMouseEvent * e) 137void ImageView::contentsMousePressEvent ( QMouseEvent * e)
112{ 138{
113 if (e->button()==1) { 139 if (e->button()==1) {
114 return OImageScrollView::contentsMousePressEvent(e); 140 return OImageScrollView::contentsMousePressEvent(e);
115 } 141 }
116 odebug << "Popup " << oendl; 142 odebug << "Popup " << oendl;
117 QPopupMenu *m = new QPopupMenu(0); 143 QPopupMenu *m = new QPopupMenu(0);
118 if (!m) return; 144 if (!m) return;
119 m->insertItem(tr("Toggle fullscreen"),this, SIGNAL(toggleFullScreen())); 145 m->insertItem(tr("Toggle fullscreen"),this, SIGNAL(toggleFullScreen()));
120 if (fullScreen()) { 146 if (fullScreen()) {
121 m->insertSeparator(); 147 m->insertSeparator();
122 m->insertItem(tr("Previous image"),this,SIGNAL(dispPrev())); 148 m->insertItem(tr("Previous image"),this,SIGNAL(dispPrev()));
123 m->insertItem(tr("Next image"),this,SIGNAL(dispNext())); 149 m->insertItem(tr("Next image"),this,SIGNAL(dispNext()));
124 m->insertSeparator(); 150 m->insertSeparator();
125 m->insertItem(tr("Toggle autoscale"),this, SIGNAL(toggleAutoscale())); 151 m->insertItem(tr("Toggle autoscale"),this, SIGNAL(toggleAutoscale()));
126 m->insertItem(tr("Toggle autorotate"),this, SIGNAL(toggleAutorotate())); 152 m->insertItem(tr("Toggle autorotate"),this, SIGNAL(toggleAutorotate()));
127 m->insertItem(tr("Toggle thumbnail"),this, SIGNAL(toggleZoomer())); 153 m->insertItem(tr("Toggle thumbnail"),this, SIGNAL(toggleZoomer()));
128 } 154 }
129 m->setFocus(); 155 m->setFocus();
130 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 156 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
131 delete m; 157 delete m;
132} 158}
133 159
134void ImageView::setFullScreen(bool how) 160void ImageView::setFullScreen(bool how)
135{ 161{
136 m_isFullScreen = how; 162 m_isFullScreen = how;
137 if (how) { 163 if (how) {
138 m_ignore_next_in = true; 164 m_ignore_next_in = true;
139 setFixedSize(qApp->desktop()->size()); 165 setFixedSize(qApp->desktop()->size());
140 showFullScreen(); 166 showFullScreen();
141 } else { 167 } else {
142 setMinimumSize(10,10); 168 setMinimumSize(10,10);
143 } 169 }
144} 170}
145 171
146void ImageView::focusInEvent(QFocusEvent *) 172void ImageView::focusInEvent(QFocusEvent *)
147{ 173{
148 // Always do it here, no matter the size. 174 // Always do it here, no matter the size.
149 odebug << "Focus in (view)" << oendl; 175 odebug << "Focus in (view)" << oendl;
150 //if (fullScreen()) parentWidget()->showNormal(); 176 //if (fullScreen()) parentWidget()->showNormal();
151 if (m_ignore_next_in){m_ignore_next_in=false;return;} 177 if (m_ignore_next_in){m_ignore_next_in=false;return;}
152 if (fullScreen()) enableFullscreen(); 178 if (fullScreen()) enableFullscreen();
153} 179}
154 180
155void ImageView::hide() 181void ImageView::hide()
156{ 182{
157 if (fullScreen()) { 183 if (fullScreen()) {
158 m_ignore_next_in = true; 184 m_ignore_next_in = true;
159 showNormal(); 185 showNormal();
160 } 186 }
161 QWidget::hide(); 187 QWidget::hide();
162} 188}
163void ImageView::enableFullscreen() 189void ImageView::enableFullscreen()
164{ 190{
165 if (!fullScreen()) return; 191 if (!fullScreen()) return;
166 if (m_ignore_next_in) {m_ignore_next_in = false;return;} 192 if (m_ignore_next_in) {m_ignore_next_in = false;return;}
167 193
168 setUpdatesEnabled(false); 194 setUpdatesEnabled(false);
169 // This is needed because showNormal() forcefully changes the window 195 // This is needed because showNormal() forcefully changes the window
170 // style to WSTyle_TopLevel. 196 // style to WSTyle_TopLevel.
171 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 197 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
172 // Enable fullscreen. 198 // Enable fullscreen.
173 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus 199 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus
174 * so we must block it here! */ 200 * so we must block it here! */
175 m_ignore_next_in = true; 201 m_ignore_next_in = true;
176 showFullScreen(); 202 showFullScreen();
177 setUpdatesEnabled(true); 203 setUpdatesEnabled(true);
178 204
179} 205}
180 206
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h
index 18697e0..f0e6541 100644
--- a/noncore/graphics/opie-eye/gui/imageview.h
+++ b/noncore/graphics/opie-eye/gui/imageview.h
@@ -1,65 +1,71 @@
1#ifndef _IMAGE_VIEW_H 1#ifndef _IMAGE_VIEW_H
2#define _IMAGE_VIEW_H 2#define _IMAGE_VIEW_H
3 3
4#include <opie2/oimagescrollview.h> 4#include <opie2/oimagescrollview.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7 7
8class QTimer;
9
8namespace Opie { 10namespace Opie {
9 namespace Core { 11 namespace Core {
10 class OConfig; 12 class OConfig;
11 class OKeyConfigManager; 13 class OKeyConfigManager;
12 } 14 }
13} 15}
14 16
15class ImageView:public Opie::MM::OImageScrollView 17class ImageView:public Opie::MM::OImageScrollView
16{ 18{
17 Q_OBJECT 19 Q_OBJECT
18 20
19 enum ActionIds { 21 enum ActionIds {
20 ViewInfo, 22 ViewInfo,
21 FullScreen, 23 FullScreen,
22 ShowNext, 24 ShowNext,
23 ShowPrevious, 25 ShowPrevious,
24 Zoomer, 26 Zoomer,
25 Autorotate, 27 Autorotate,
26 Autoscale 28 Autoscale
27 }; 29 };
28 30
29public: 31public:
30 ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); 32 ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 );
31 virtual ~ImageView(); 33 virtual ~ImageView();
32 Opie::Core::OKeyConfigManager* manager(); 34 Opie::Core::OKeyConfigManager* manager();
33 void setFullScreen(bool how); 35 void setFullScreen(bool how);
34 bool fullScreen(){return m_isFullScreen;} 36 bool fullScreen(){return m_isFullScreen;}
35 virtual void enableFullscreen(); 37 virtual void enableFullscreen();
36 38
37signals: 39signals:
38 void dispImageInfo(const QString&); 40 void dispImageInfo(const QString&);
39 void dispNext(); 41 void dispNext();
40 void dispPrev(); 42 void dispPrev();
41 void toggleFullScreen(); 43 void toggleFullScreen();
42 void hideMe(); 44 void hideMe();
43 void toggleZoomer(); 45 void toggleZoomer();
44 void toggleAutoscale(); 46 void toggleAutoscale();
45 void toggleAutorotate(); 47 void toggleAutorotate();
46 48
47protected: 49protected:
48 Opie::Core::OConfig * m_cfg; 50 Opie::Core::OConfig * m_cfg;
49 Opie::Core::OKeyConfigManager*m_viewManager; 51 Opie::Core::OKeyConfigManager*m_viewManager;
50 void initKeys(); 52 void initKeys();
51 bool m_isFullScreen:1; 53 bool m_isFullScreen:1;
52 bool m_ignore_next_in:1; 54 bool m_ignore_next_in:1;
53 int focus_in_count; 55 int focus_in_count;
56 QTimer*m_slideTimer;
57 int m_slideValue;
54 virtual void focusInEvent ( QFocusEvent * ); 58 virtual void focusInEvent ( QFocusEvent * );
55 59
56public slots: 60public slots:
57 virtual void hide(); 61 virtual void hide();
62 virtual void startSlide(int);
63 virtual void nextSlide();
58 64
59protected slots: 65protected slots:
60 virtual void slotShowImageInfo(); 66 virtual void slotShowImageInfo();
61 virtual void keyReleaseEvent(QKeyEvent * e); 67 virtual void keyReleaseEvent(QKeyEvent * e);
62 virtual void contentsMousePressEvent ( QMouseEvent * e); 68 virtual void contentsMousePressEvent ( QMouseEvent * e);
63}; 69};
64 70
65#endif 71#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 438fbf2..3c946b6 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,445 +1,446 @@
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#include "imageview.h" 6#include "imageview.h"
7 7
8#include "iconview.h" 8#include "iconview.h"
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12 12
13#include <iface/ifaceinfo.h> 13#include <iface/ifaceinfo.h>
14#include <iface/dirview.h> 14#include <iface/dirview.h>
15 15
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/owidgetstack.h> 17#include <opie2/owidgetstack.h>
18#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
19#include <opie2/otabwidget.h> 19#include <opie2/otabwidget.h>
20#include <opie2/okeyconfigwidget.h> 20#include <opie2/okeyconfigwidget.h>
21 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qmap.h> 31#include <qmap.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qframe.h> 33#include <qframe.h>
34 34
35 35
36//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 36//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
37OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 37OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
38 38
39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
40 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 40 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
41{ 41{
42 setCaption( QObject::tr("Opie Eye Caramba" ) ); 42 setCaption( QObject::tr("Opie Eye Caramba" ) );
43 m_cfg = new Opie::Core::OConfig("phunkview"); 43 m_cfg = new Opie::Core::OConfig("phunkview");
44 m_cfg->setGroup("Zecke_view" ); 44 m_cfg->setGroup("Zecke_view" );
45 /* 45 /*
46 * Initialize ToolBar and IconView 46 * Initialize ToolBar and IconView
47 * And Connect Them 47 * And Connect Them
48 */ 48 */
49 QToolBar *bar = new QToolBar( this ); 49 QToolBar *bar = new QToolBar( this );
50 bar->setHorizontalStretchable( true ); 50 bar->setHorizontalStretchable( true );
51 setToolBarsMovable( false ); 51 setToolBarsMovable( false );
52 52
53 m_stack = new Opie::Ui::OWidgetStack( this ); 53 m_stack = new Opie::Ui::OWidgetStack( this );
54 setCentralWidget( m_stack ); 54 setCentralWidget( m_stack );
55 55
56 m_view = new PIconView( m_stack, m_cfg ); 56 m_view = new PIconView( m_stack, m_cfg );
57 m_stack->addWidget( m_view, IconView ); 57 m_stack->addWidget( m_view, IconView );
58 m_stack->raiseWidget( IconView ); 58 m_stack->raiseWidget( IconView );
59 connect(m_view, SIGNAL(sig_display(const QString&)), 59 connect(m_view, SIGNAL(sig_display(const QString&)),
60 this, SLOT(slotDisplay(const QString&))); 60 this, SLOT(slotDisplay(const QString&)));
61 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 61 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
62 this, SLOT(slotShowInfo(const QString&)) ); 62 this, SLOT(slotShowInfo(const QString&)) );
63 63
64 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 64 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
65 65
66 upButton = new QToolButton( bar ); 66 upButton = new QToolButton( bar );
67 upButton->setIconSet( Resource::loadIconSet( "up" ) ); 67 upButton->setIconSet( Resource::loadIconSet( "up" ) );
68 connect( upButton, SIGNAL(clicked()), 68 connect( upButton, SIGNAL(clicked()),
69 m_view, SLOT(slotDirUp()) ); 69 m_view, SLOT(slotDirUp()) );
70 70
71 fsButton = new PFileSystem( bar ); 71 fsButton = new PFileSystem( bar );
72 connect( fsButton, SIGNAL( changeDir( const QString& ) ), 72 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
73 m_view, SLOT(slotChangeDir( const QString& ) ) ); 73 m_view, SLOT(slotChangeDir( const QString& ) ) );
74 74
75 QToolButton*btn = new QToolButton( bar ); 75 QToolButton*btn = new QToolButton( bar );
76 btn->setIconSet( Resource::loadIconSet( "edit" ) ); 76 btn->setIconSet( Resource::loadIconSet( "edit" ) );
77 connect( btn, SIGNAL(clicked()), 77 connect( btn, SIGNAL(clicked()),
78 m_view, SLOT(slotImageInfo()) ); 78 m_view, SLOT(slotImageInfo()) );
79 79
80 if ( Ir::supported() ) { 80 if ( Ir::supported() ) {
81 btn = new QToolButton( bar ); 81 btn = new QToolButton( bar );
82 btn->setIconSet( Resource::loadIconSet( "beam" ) ); 82 btn->setIconSet( Resource::loadIconSet( "beam" ) );
83 connect( btn, SIGNAL(clicked()), 83 connect( btn, SIGNAL(clicked()),
84 m_view, SLOT(slotBeam()) ); 84 m_view, SLOT(slotBeam()) );
85 } 85 }
86 86
87 btn = new QToolButton( bar ); 87 btn = new QToolButton( bar );
88 btn->setIconSet( Resource::loadIconSet( "trash" ) ); 88 btn->setIconSet( Resource::loadIconSet( "trash" ) );
89 connect( btn, SIGNAL(clicked() ), 89 connect( btn, SIGNAL(clicked() ),
90 m_view, SLOT(slotTrash() ) ); 90 m_view, SLOT(slotTrash() ) );
91 91
92 92
93 int mode = m_cfg->readNumEntry("ListViewMode", 1); 93 int mode = m_cfg->readNumEntry("ListViewMode", 1);
94 if (mode < 1 || mode>3) mode = 1; 94 if (mode < 1 || mode>3) mode = 1;
95 viewModeButton = new ViewModeButton( bar,mode ); 95 viewModeButton = new ViewModeButton( bar,mode );
96 connect( viewModeButton, SIGNAL(changeMode(int)), 96 connect( viewModeButton, SIGNAL(changeMode(int)),
97 m_view, SLOT(slotChangeMode(int))); 97 m_view, SLOT(slotChangeMode(int)));
98 98
99 btn = new QToolButton( bar ); 99 btn = new QToolButton( bar );
100 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); 100 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
101 connect( btn, SIGNAL(clicked() ), 101 connect( btn, SIGNAL(clicked() ),
102 this, SLOT(slotConfig() ) ); 102 this, SLOT(slotConfig() ) );
103 103
104 104
105 105
106 prevButton = new QToolButton(bar); 106 prevButton = new QToolButton(bar);
107 prevButton->setIconSet( Resource::loadIconSet( "back" ) ); 107 prevButton->setIconSet( Resource::loadIconSet( "back" ) );
108 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); 108 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev()));
109 109
110 nextButton = new QToolButton(bar); 110 nextButton = new QToolButton(bar);
111 nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); 111 nextButton->setIconSet( Resource::loadIconSet( "forward" ) );
112 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); 112 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext()));
113 113
114 rotateButton = new QToolButton(bar); 114 rotateButton = new QToolButton(bar);
115 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); 115 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
116 rotateButton->setToggleButton(true); 116 rotateButton->setToggleButton(true);
117 117
118 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 118 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
119 rotateButton->setOn(true); 119 rotateButton->setOn(true);
120 autoRotate = true; 120 autoRotate = true;
121 prevButton->hide(); 121 prevButton->hide();
122 nextButton->hide(); 122 nextButton->hide();
123 } else { 123 } else {
124 rotateButton->setOn(false); 124 rotateButton->setOn(false);
125 autoRotate = false; 125 autoRotate = false;
126 } 126 }
127 127
128 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 128 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
129 129
130 scaleButton = new QToolButton(bar); 130 scaleButton = new QToolButton(bar);
131 scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); 131 scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) );
132 scaleButton->setToggleButton(true); 132 scaleButton->setToggleButton(true);
133 scaleButton->setOn(false); 133 scaleButton->setOn(false);
134 connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 134 connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
135 autoScale = true; 135 autoScale = true;
136 136
137 zoomButton = new QToolButton(bar); 137 zoomButton = new QToolButton(bar);
138 zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); 138 zoomButton->setIconSet( Resource::loadIconSet( "mag" ) );
139 zoomButton->setToggleButton(true); 139 zoomButton->setToggleButton(true);
140 zoomButton->setOn(true); 140 zoomButton->setOn(true);
141 connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 141 connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
142 zoomerOn = true; 142 zoomerOn = true;
143} 143}
144 144
145PMainWindow::~PMainWindow() { 145PMainWindow::~PMainWindow() {
146} 146}
147 147
148void PMainWindow::slotToggleZoomer() 148void PMainWindow::slotToggleZoomer()
149{ 149{
150 if (!m_disp) return; 150 if (!m_disp) return;
151 bool cur = zoomButton->isOn(); 151 bool cur = zoomButton->isOn();
152 zoomButton->setOn(!cur); 152 zoomButton->setOn(!cur);
153} 153}
154 154
155void PMainWindow::slotZoomerToggled(bool how) 155void PMainWindow::slotZoomerToggled(bool how)
156{ 156{
157 zoomerOn = how; 157 zoomerOn = how;
158 if (m_disp) { 158 if (m_disp) {
159 m_disp->setShowZoomer(zoomerOn); 159 m_disp->setShowZoomer(zoomerOn);
160 } 160 }
161} 161}
162 162
163void PMainWindow::slotToggleAutorotate() 163void PMainWindow::slotToggleAutorotate()
164{ 164{
165 if (!m_disp) return; 165 if (!m_disp) return;
166 if (!rotateButton->isEnabled()) return; 166 if (!rotateButton->isEnabled()) return;
167 bool cur = rotateButton->isOn(); 167 bool cur = rotateButton->isOn();
168 rotateButton->setOn(!cur); 168 rotateButton->setOn(!cur);
169} 169}
170 170
171void PMainWindow::slotToggleAutoscale() 171void PMainWindow::slotToggleAutoscale()
172{ 172{
173 if (!m_disp) return; 173 if (!m_disp) return;
174 bool cur = scaleButton->isOn(); 174 bool cur = scaleButton->isOn();
175 scaleButton->setOn(!cur); 175 scaleButton->setOn(!cur);
176} 176}
177 177
178void PMainWindow::slotRotateToggled(bool how) 178void PMainWindow::slotRotateToggled(bool how)
179{ 179{
180 autoRotate = how; 180 autoRotate = how;
181 if (m_disp) { 181 if (m_disp) {
182 m_disp->setAutoRotate(how); 182 m_disp->setAutoRotate(how);
183 } 183 }
184} 184}
185 185
186void PMainWindow::slotScaleToggled(bool how) 186void PMainWindow::slotScaleToggled(bool how)
187{ 187{
188 autoScale = !how; 188 autoScale = !how;
189 if (!how) { 189 if (!how) {
190 autoRotate = how; 190 autoRotate = how;
191 } 191 }
192 if (m_disp) { 192 if (m_disp) {
193 m_disp->setAutoScaleRotate(autoScale,autoRotate); 193 m_disp->setAutoScaleRotate(autoScale,autoRotate);
194 } 194 }
195 if (!autoScale) { 195 if (!autoScale) {
196 rotateButton->setOn(false); 196 rotateButton->setOn(false);
197 } 197 }
198 rotateButton->setEnabled(!how); 198 rotateButton->setEnabled(!how);
199} 199}
200 200
201void PMainWindow::slotConfig() { 201void PMainWindow::slotConfig() {
202 /* 202 /*
203 * have a tab with the possible views 203 * have a tab with the possible views
204 * a tab for globals image cache size.. scaled loading 204 * a tab for globals image cache size.. scaled loading
205 * and one tab for the KeyConfigs 205 * and one tab for the KeyConfigs
206 */ 206 */
207 QDialog dlg(this, 0, true); 207 QDialog dlg(this, 0, true);
208 dlg.setCaption( tr("Phunk View - Config" ) ); 208 dlg.setCaption( tr("Phunk View - Config" ) );
209 209
210 QHBoxLayout *lay = new QHBoxLayout(&dlg); 210 QHBoxLayout *lay = new QHBoxLayout(&dlg);
211 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 211 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
212 lay->addWidget( wid ); 212 lay->addWidget( wid );
213 ViewMap *vM = viewMap(); 213 ViewMap *vM = viewMap();
214 ViewMap::Iterator _it = vM->begin(); 214 ViewMap::Iterator _it = vM->begin();
215 QMap<PDirView*, QWidget*> lst; 215 QMap<PDirView*, QWidget*> lst;
216 216
217 for( ; _it != vM->end(); ++_it ) { 217 for( ; _it != vM->end(); ++_it ) {
218 PDirView *view = (_it.data())(*m_cfg); 218 PDirView *view = (_it.data())(*m_cfg);
219 PInterfaceInfo *inf = view->interfaceInfo(); 219 PInterfaceInfo *inf = view->interfaceInfo();
220 QWidget *_wid = inf->configWidget( *m_cfg ); 220 QWidget *_wid = inf->configWidget( *m_cfg );
221 if (!_wid) continue; 221 if (!_wid) continue;
222 _wid->reparent(wid, QPoint() ); 222 _wid->reparent(wid, QPoint() );
223 lst.insert( view, _wid ); 223 lst.insert( view, _wid );
224 wid->addTab( _wid, "fileopen", inf->name() ); 224 wid->addTab( _wid, "fileopen", inf->name() );
225 } 225 }
226 226
227/* 227/*
228 * Add the KeyConfigWidget 228 * Add the KeyConfigWidget
229 */ 229 */
230 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 230 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
231 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 231 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
232 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 232 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
233 233
234 if ( !m_info ) { 234 if ( !m_info ) {
235 initInfo(); 235 initInfo();
236 } 236 }
237 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 237 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
238 238
239 if ( !m_disp ) { 239 if ( !m_disp ) {
240 initDisp(); 240 initDisp();
241 } 241 }
242 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); 242 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
243 243
244 keyWid->load(); 244 keyWid->load();
245 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 245 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
246 246
247 247
248 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 248 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
249 249
250/* 250/*
251 * clean up 251 * clean up
252 *apply changes 252 *apply changes
253 */ 253 */
254 254
255 QMap<PDirView*, QWidget*>::Iterator it; 255 QMap<PDirView*, QWidget*>::Iterator it;
256 for ( it = lst.begin(); it != lst.end(); ++it ) { 256 for ( it = lst.begin(); it != lst.end(); ++it ) {
257 if ( act ) 257 if ( act )
258 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 258 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
259 delete it.key(); 259 delete it.key();
260 } 260 }
261 261
262 262
263 if ( act ) { 263 if ( act ) {
264 m_view->resetView(); 264 m_view->resetView();
265 keyWid->save(); 265 keyWid->save();
266 m_disp->manager()->save(); 266 m_disp->manager()->save();
267 m_info->manager()->save(); 267 m_info->manager()->save();
268 m_view->manager()->save(); 268 m_view->manager()->save();
269 } 269 }
270 delete keyWid; 270 delete keyWid;
271} 271}
272 272
273/* 273/*
274 * create a new image info component 274 * create a new image info component
275 * and detach the current one 275 * and detach the current one
276 * we will make the other delete on exit 276 * we will make the other delete on exit
277 */ 277 */
278template<class T> 278template<class T>
279void PMainWindow::initT( const char* name, T** ptr, int id) { 279void PMainWindow::initT( const char* name, T** ptr, int id) {
280 if ( *ptr ) { 280 if ( *ptr ) {
281 (*ptr)->disconnect(this, SLOT(slotReturn())); 281 (*ptr)->disconnect(this, SLOT(slotReturn()));
282 (*ptr)->setDestructiveClose(); 282 (*ptr)->setDestructiveClose();
283 m_stack->removeWidget( *ptr ); 283 m_stack->removeWidget( *ptr );
284 } 284 }
285 *ptr = new T(m_cfg, m_stack, name ); 285 *ptr = new T(m_cfg, m_stack, name );
286 m_stack->addWidget( *ptr, id ); 286 m_stack->addWidget( *ptr, id );
287 287
288 connect(*ptr, SIGNAL(sig_return()), 288 connect(*ptr, SIGNAL(sig_return()),
289 this,SLOT(slotReturn())); 289 this,SLOT(slotReturn()));
290 290
291} 291}
292void PMainWindow::initInfo() { 292void PMainWindow::initInfo() {
293 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 293 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
294 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 294 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
295} 295}
296void PMainWindow::initDisp() { 296void PMainWindow::initDisp() {
297 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 297 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
298 if (m_disp) { 298 if (m_disp) {
299 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 299 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
300 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 300 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
301 } 301 }
302 m_disp->setAutoScale(autoScale); 302 m_disp->setAutoScale(autoScale);
303 m_disp->setAutoRotate(autoRotate); 303 m_disp->setAutoRotate(autoRotate);
304 m_disp->setShowZoomer(zoomerOn); 304 m_disp->setShowZoomer(zoomerOn);
305 m_disp->setBackgroundColor(white); 305 m_disp->setBackgroundColor(white);
306 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 306 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
307 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 307 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
308 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 308 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
309 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); 309 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
310 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); 310 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
311 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); 311 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
312 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); 312 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
313 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); 313 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
314 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
314 } 315 }
315} 316}
316 317
317void PMainWindow::slotToggleFullScreen() 318void PMainWindow::slotToggleFullScreen()
318{ 319{
319 odebug << "Toggle full " << oendl; 320 odebug << "Toggle full " << oendl;
320 if (!m_disp) return; 321 if (!m_disp) return;
321 bool current = !m_disp->fullScreen(); 322 bool current = !m_disp->fullScreen();
322 odebug << "Current = " << current << oendl; 323 odebug << "Current = " << current << oendl;
323 if (current) { 324 if (current) {
324 odebug << "full" << oendl; 325 odebug << "full" << oendl;
325 m_disp->setBackgroundColor(black); 326 m_disp->setBackgroundColor(black);
326 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 327 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
327 m_disp->setVScrollBarMode(QScrollView::AlwaysOff); 328 m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
328 m_disp->setHScrollBarMode(QScrollView::AlwaysOff); 329 m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
329 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); 330 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
330 //m_disp->showFullScreen(); 331 //m_disp->showFullScreen();
331 //qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 332 //qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
332 } else { 333 } else {
333 setUpdatesEnabled(false); 334 setUpdatesEnabled(false);
334 odebug << "window" << oendl; 335 odebug << "window" << oendl;
335 m_disp->reparent(0,QPoint(0,0)); 336 m_disp->reparent(0,QPoint(0,0));
336 m_disp->showNormal(); 337 m_disp->showNormal();
337 m_disp->setBackgroundColor(white); 338 m_disp->setBackgroundColor(white);
338 m_stack->addWidget(m_disp,ImageDisplay); 339 m_stack->addWidget(m_disp,ImageDisplay);
339 m_disp->setVScrollBarMode(QScrollView::Auto); 340 m_disp->setVScrollBarMode(QScrollView::Auto);
340 m_disp->setHScrollBarMode(QScrollView::Auto); 341 m_disp->setHScrollBarMode(QScrollView::Auto);
341 m_stack->raiseWidget(m_disp); 342 m_stack->raiseWidget(m_disp);
342 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 343 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
343 m_disp->resize(m_disp->minimumSize()); 344 m_disp->resize(m_disp->minimumSize());
344 } 345 }
345 setUpdatesEnabled(true); 346 setUpdatesEnabled(true);
346 } 347 }
347 m_disp->setFullScreen(current); 348 m_disp->setFullScreen(current);
348} 349}
349 350
350/** 351/**
351 * With big Screen the plan could be to 'detach' the image 352 * With big Screen the plan could be to 'detach' the image
352 * window if visible and to create a ne wone 353 * window if visible and to create a ne wone
353 * init* already supports it but I make no use of it for 354 * init* already supports it but I make no use of it for
354 * now. We set filename and raise 355 * now. We set filename and raise
355 * 356 *
356 * ### FIXME and talk to alwin 357 * ### FIXME and talk to alwin
357 */ 358 */
358void PMainWindow::slotShowInfo( const QString& inf ) { 359void PMainWindow::slotShowInfo( const QString& inf ) {
359 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 360 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
360 return; 361 return;
361 } 362 }
362 if ( !m_info ) { 363 if ( !m_info ) {
363 initInfo(); 364 initInfo();
364 } 365 }
365 m_info->setPath( inf ); 366 m_info->setPath( inf );
366 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 367 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
367 prevButton->hide(); 368 prevButton->hide();
368 nextButton->hide(); 369 nextButton->hide();
369 upButton->hide(); 370 upButton->hide();
370 fsButton->hide(); 371 fsButton->hide();
371 viewModeButton->hide(); 372 viewModeButton->hide();
372 } 373 }
373 m_stack->raiseWidget( ImageInfo ); 374 m_stack->raiseWidget( ImageInfo );
374} 375}
375 376
376void PMainWindow::slotDisplay( const QString& inf ) { 377void PMainWindow::slotDisplay( const QString& inf ) {
377 if ( !m_disp ) { 378 if ( !m_disp ) {
378 initDisp(); 379 initDisp();
379 } 380 }
380 m_disp->setImage( inf ); 381 m_disp->setImage( inf );
381 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 382 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
382 prevButton->show(); 383 prevButton->show();
383 nextButton->show(); 384 nextButton->show();
384 upButton->hide(); 385 upButton->hide();
385 fsButton->hide(); 386 fsButton->hide();
386 viewModeButton->hide(); 387 viewModeButton->hide();
387 } 388 }
388 if (m_disp->fullScreen()) { 389 if (m_disp->fullScreen()) {
389 //m_disp->showFullScreen(); 390 //m_disp->showFullScreen();
390 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 391 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
391 } else { 392 } else {
392 m_stack->raiseWidget( ImageDisplay ); 393 m_stack->raiseWidget( ImageDisplay );
393 } 394 }
394} 395}
395 396
396void PMainWindow::slotReturn() { 397void PMainWindow::slotReturn() {
397 raiseIconView(); 398 raiseIconView();
398} 399}
399 400
400 401
401void PMainWindow::closeEvent( QCloseEvent* ev ) { 402void PMainWindow::closeEvent( QCloseEvent* ev ) {
402 /* 403 /*
403 * return from view 404 * return from view
404 * or properly quit 405 * or properly quit
405 */ 406 */
406 if ( m_stack->visibleWidget() == m_info || 407 if ( m_stack->visibleWidget() == m_info ||
407 m_stack->visibleWidget() == m_disp ) { 408 m_stack->visibleWidget() == m_disp ) {
408 ev->ignore(); 409 ev->ignore();
409 raiseIconView(); 410 raiseIconView();
410 return; 411 return;
411 } 412 }
412 if (m_disp && m_disp->fullScreen()) { 413 if (m_disp && m_disp->fullScreen()) {
413 /* otherwise opie-eye crashes in bigscreen mode! */ 414 /* otherwise opie-eye crashes in bigscreen mode! */
414 m_disp->reparent(0,QPoint(0,0)); 415 m_disp->reparent(0,QPoint(0,0));
415 m_stack->addWidget(m_disp,ImageDisplay); 416 m_stack->addWidget(m_disp,ImageDisplay);
416 } 417 }
417 ev->accept(); 418 ev->accept();
418 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 419 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
419} 420}
420 421
421void PMainWindow::raiseIconView() { 422void PMainWindow::raiseIconView() {
422 setUpdatesEnabled(false); 423 setUpdatesEnabled(false);
423 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 424 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
424 prevButton->hide(); 425 prevButton->hide();
425 nextButton->hide(); 426 nextButton->hide();
426 upButton->show(); 427 upButton->show();
427 fsButton->show(); 428 fsButton->show();
428 viewModeButton->show(); 429 viewModeButton->show();
429 } 430 }
430 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 431 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
431 m_disp->hide(); 432 m_disp->hide();
432 } 433 }
433 m_stack->raiseWidget( IconView ); 434 m_stack->raiseWidget( IconView );
434 setUpdatesEnabled(true); 435 setUpdatesEnabled(true);
435 repaint(); 436 repaint();
436} 437}
437 438
438void PMainWindow::setDocument( const QString& showImg ) { 439void PMainWindow::setDocument( const QString& showImg ) {
439 QString file = showImg; 440 QString file = showImg;
440 DocLnk lnk(showImg); 441 DocLnk lnk(showImg);
441 if (lnk.isValid() ) 442 if (lnk.isValid() )
442 file = lnk.file(); 443 file = lnk.file();
443 444
444 slotDisplay( file ); 445 slotDisplay( file );
445} 446}