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