-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 80 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 41 |
2 files changed, 91 insertions, 30 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 7231bfb..039f53f 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,203 +1,230 @@ | |||
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 | ||
36 | using Opie::Core::OKeyConfigItem; | 36 | using 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 | */ |
41 | namespace { | 41 | namespace { |
42 | static QPixmap* _dirPix = 0; | 42 | static QPixmap* _dirPix = 0; |
43 | static QPixmap* _unkPix = 0; | 43 | static QPixmap* _unkPix = 0; |
44 | static QPixmap* _picPix = 0; | 44 | static QPixmap* _picPix = 0; |
45 | static QPixmap* _emptyPix = 0; | ||
45 | class IconViewItem : public QIconViewItem { | 46 | class IconViewItem : public QIconViewItem { |
46 | public: | 47 | public: |
47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 48 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
48 | QPixmap* pixmap()const; | 49 | QPixmap* pixmap()const; |
49 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
50 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
51 | void setText( const QString& ); | 52 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | ||
54 | void setTextOnly(bool how){m_textOnly=how;} | ||
55 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | ||
56 | virtual void setPixmap( const QPixmap & icon); | ||
52 | 57 | ||
53 | protected: | 58 | protected: |
54 | mutable QPixmap* m_pix; | 59 | mutable QPixmap* m_pix; |
55 | 60 | ||
56 | private: | 61 | private: |
57 | QString m_path; | 62 | QString m_path; |
58 | bool m_isDir : 1; | 63 | bool m_isDir : 1; |
59 | bool m_noInfo :1; | 64 | bool m_noInfo :1; |
65 | bool m_textOnly:1; | ||
66 | bool m_NameOnly:1; | ||
67 | bool m_Pixset:1; | ||
60 | }; | 68 | }; |
61 | class TextViewItem : public IconViewItem { | 69 | class TextViewItem : public IconViewItem { |
62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 70 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
63 | QPixmap *pixmap()const; | 71 | QPixmap *pixmap()const; |
64 | void setText( const QString& ); | 72 | void setText( const QString& ); |
65 | }; | 73 | }; |
66 | class ThumbViewItem : public IconViewItem { | 74 | class ThumbViewItem : public IconViewItem { |
67 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 75 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
68 | QPixmap *pixmap()const; | 76 | QPixmap *pixmap()const; |
69 | void setText( const QString& ); | 77 | void setText( const QString& ); |
70 | }; | 78 | }; |
71 | 79 | ||
72 | 80 | ||
73 | /* | 81 | /* |
74 | * If we request an Image or String | 82 | * If we request an Image or String |
75 | * we add it to the map | 83 | * we add it to the map |
76 | */ | 84 | */ |
77 | static QMap<QString, IconViewItem*> g_stringInf; | 85 | static QMap<QString, IconViewItem*> g_stringInf; |
78 | static QMap<QString, IconViewItem*> g_stringPix; | 86 | static QMap<QString, IconViewItem*> g_stringPix; |
79 | 87 | ||
80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 88 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
81 | const QString& name, bool isDir ) | 89 | const QString& name, bool isDir ) |
82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 90 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
83 | m_noInfo( false ) | 91 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
84 | { | 92 | { |
85 | if ( isDir && !_dirPix ) | 93 | if ( isDir && !_dirPix ) |
86 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 94 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
87 | else if ( !isDir && !_unkPix ) | 95 | else if ( !isDir && !_unkPix ) |
88 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 96 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
89 | } | 97 | } |
98 | |||
99 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) | ||
100 | { | ||
101 | m_Pixset = true; | ||
102 | QIconViewItem::setPixmap(icon,recalc,redraw); | ||
103 | } | ||
104 | inline void IconViewItem::setPixmap( const QPixmap & icon) | ||
105 | { | ||
106 | m_Pixset = true; | ||
107 | QIconViewItem::setPixmap(icon); | ||
108 | } | ||
109 | |||
90 | inline QPixmap* IconViewItem::pixmap()const { | 110 | inline QPixmap* IconViewItem::pixmap()const { |
91 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 111 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
92 | // rect().x(),rect().y(),rect().width(),rect().height(), | 112 | // rect().x(),rect().y(),rect().width(),rect().height(), |
93 | // iconView()->contentsX(), iconView()->contentsY()); | 113 | // iconView()->contentsX(), iconView()->contentsY()); |
94 | 114 | ||
115 | if (textOnly()&&!m_isDir) { | ||
116 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | ||
117 | return _emptyPix; | ||
118 | } | ||
95 | if ( m_isDir ) | 119 | if ( m_isDir ) |
96 | return _dirPix; | 120 | return _dirPix; |
97 | else{ | 121 | else{ |
98 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 122 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
99 | currentView()->dirLister()->imageInfo( m_path ); | 123 | currentView()->dirLister()->imageInfo( m_path ); |
100 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 124 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
101 | } | 125 | } |
102 | 126 | ||
103 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 127 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
104 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 128 | if (!m_pix && !g_stringPix.contains( m_path )&&!m_Pixset) { |
105 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 129 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
106 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 130 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
107 | } | 131 | } |
132 | if (m_Pixset) { | ||
133 | return QIconViewItem::pixmap(); | ||
134 | } | ||
108 | return m_pix ? m_pix : _unkPix; | 135 | return m_pix ? m_pix : _unkPix; |
109 | } | 136 | } |
110 | } | 137 | } |
111 | inline void IconViewItem::setText( const QString& str ) { | 138 | inline void IconViewItem::setText( const QString& str ) { |
112 | QString text = QIconViewItem::text()+"\n"+str; | 139 | QString text = QIconViewItem::text()+"\n"+str; |
113 | m_noInfo = true; | 140 | m_noInfo = true; |
114 | QIconViewItem::setText( text ); | 141 | QIconViewItem::setText( text ); |
115 | } | 142 | } |
116 | } | 143 | } |
117 | 144 | ||
118 | 145 | ||
119 | /* | 146 | /* |
120 | * Set up the GUI.. initialize the slave set up gui | 147 | * Set up the GUI.. initialize the slave set up gui |
121 | * and also load a dir | 148 | * and also load a dir |
122 | */ | 149 | */ |
123 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 150 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
124 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 151 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
125 | { | 152 | { |
126 | { | 153 | { |
127 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 154 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
128 | } | 155 | } |
129 | m_path = QDir::homeDirPath(); | 156 | m_path = QDir::homeDirPath(); |
130 | m_mode = 0; | 157 | m_mode = 0; |
131 | 158 | ||
132 | QHBox *hbox = new QHBox( this ); | 159 | QHBox *hbox = new QHBox( this ); |
133 | QLabel* lbl = new QLabel( hbox ); | 160 | QLabel* lbl = new QLabel( hbox ); |
134 | lbl->setText( tr("View as" ) ); | 161 | lbl->setText( tr("View as" ) ); |
135 | 162 | ||
136 | m_views = new QComboBox( hbox, "View As" ); | 163 | m_views = new QComboBox( hbox, "View As" ); |
137 | connect( m_views, SIGNAL(activated(int)), | 164 | connect( m_views, SIGNAL(activated(int)), |
138 | this, SLOT(slotViewChanged(int)) ); | 165 | this, SLOT(slotViewChanged(int)) ); |
139 | 166 | ||
140 | m_view= new QIconView( this ); | 167 | m_view= new QIconView( this ); |
141 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 168 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
142 | this, SLOT(slotClicked(QIconViewItem*)) ); | 169 | this, SLOT(slotClicked(QIconViewItem*)) ); |
143 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 170 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
144 | this, SLOT(slotClicked(QIconViewItem*)) ); | 171 | this, SLOT(slotClicked(QIconViewItem*)) ); |
145 | 172 | ||
146 | m_view->setArrangement( QIconView::LeftToRight ); | 173 | m_view->setArrangement( QIconView::LeftToRight ); |
147 | m_view->setItemTextPos( QIconView::Right ); | 174 | m_view->setItemTextPos( QIconView::Right ); |
148 | 175 | ||
149 | int dw = QApplication::desktop()->width(); | 176 | int dw = QApplication::desktop()->width(); |
150 | int viewerWidth = dw-style().scrollBarExtent().width(); | 177 | int viewerWidth = dw-style().scrollBarExtent().width(); |
151 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 178 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
152 | m_view->setGridY( fontMetrics().height()*2+40 ); | 179 | m_view->setGridY( fontMetrics().height()*2+40 ); |
153 | 180 | ||
154 | 181 | ||
155 | initKeys(); | 182 | initKeys(); |
156 | 183 | ||
157 | loadViews(); | 184 | loadViews(); |
158 | slotViewChanged( m_views->currentItem() ); | 185 | slotViewChanged( m_views->currentItem() ); |
159 | } | 186 | } |
160 | 187 | ||
161 | /* | 188 | /* |
162 | * Unref the slave and save the keyboard manager | 189 | * Unref the slave and save the keyboard manager |
163 | */ | 190 | */ |
164 | PIconView::~PIconView() { | 191 | PIconView::~PIconView() { |
165 | { | 192 | { |
166 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 193 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
167 | } | 194 | } |
168 | m_viewManager->save(); | 195 | m_viewManager->save(); |
169 | delete m_viewManager; | 196 | delete m_viewManager; |
170 | } | 197 | } |
171 | 198 | ||
172 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 199 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
173 | return m_viewManager; | 200 | return m_viewManager; |
174 | } | 201 | } |
175 | 202 | ||
176 | 203 | ||
177 | /* | 204 | /* |
178 | * init the KeyBoard Shortcuts | 205 | * init the KeyBoard Shortcuts |
179 | * called from the c'tor | 206 | * called from the c'tor |
180 | */ | 207 | */ |
181 | void PIconView::initKeys() { | 208 | void PIconView::initKeys() { |
182 | Opie::Core::OKeyPair::List lst; | 209 | Opie::Core::OKeyPair::List lst; |
183 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 210 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
184 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 211 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
185 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 212 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
186 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 213 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
187 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 214 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
188 | 215 | ||
189 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 216 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
190 | lst, false,this, "keyconfig name" ); | 217 | lst, false,this, "keyconfig name" ); |
191 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 218 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
192 | Resource::loadPixmap("beam"), BeamItem, | 219 | Resource::loadPixmap("beam"), BeamItem, |
193 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 220 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
194 | this, SLOT(slotBeam())) ); | 221 | this, SLOT(slotBeam())) ); |
195 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 222 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
196 | Resource::loadPixmap("trash"), DeleteItem, | 223 | Resource::loadPixmap("trash"), DeleteItem, |
197 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 224 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
198 | this, SLOT(slotTrash())) ); | 225 | this, SLOT(slotTrash())) ); |
199 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 226 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
200 | Resource::loadPixmap("1to1"), ViewItem, | 227 | Resource::loadPixmap("1to1"), ViewItem, |
201 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 228 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
202 | this, SLOT(slotShowImage()))); | 229 | this, SLOT(slotShowImage()))); |
203 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
@@ -274,279 +301,308 @@ QString PIconView::nextFileName(bool &isDir)const | |||
274 | QIconViewItem* _it1 = m_view->currentItem(); | 301 | QIconViewItem* _it1 = m_view->currentItem(); |
275 | if ( !_it1 ) | 302 | if ( !_it1 ) |
276 | return QString::null; | 303 | return QString::null; |
277 | QIconViewItem* _it = _it1->nextItem(); | 304 | QIconViewItem* _it = _it1->nextItem(); |
278 | if ( !_it ) | 305 | if ( !_it ) |
279 | return QString::null; | 306 | return QString::null; |
280 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 307 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
281 | isDir = it->isDir(); | 308 | isDir = it->isDir(); |
282 | return it->path(); | 309 | return it->path(); |
283 | } | 310 | } |
284 | 311 | ||
285 | QString PIconView::prevFileName(bool &isDir)const{ | 312 | QString PIconView::prevFileName(bool &isDir)const{ |
286 | isDir = false; | 313 | isDir = false; |
287 | QIconViewItem* _it = m_view->currentItem(); | 314 | QIconViewItem* _it = m_view->currentItem(); |
288 | if ( !_it ) | 315 | if ( !_it ) |
289 | return QString::null; | 316 | return QString::null; |
290 | _it = _it->prevItem(); | 317 | _it = _it->prevItem(); |
291 | if ( !_it ) | 318 | if ( !_it ) |
292 | return QString::null; | 319 | return QString::null; |
293 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 320 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
294 | isDir = it->isDir(); | 321 | isDir = it->isDir(); |
295 | return it->path(); | 322 | return it->path(); |
296 | } | 323 | } |
297 | 324 | ||
298 | void PIconView::slotTrash() { | 325 | void PIconView::slotTrash() { |
299 | bool isDir; | 326 | bool isDir; |
300 | QString pa = currentFileName( isDir ); | 327 | QString pa = currentFileName( isDir ); |
301 | if ( isDir && pa.isEmpty() ) | 328 | if ( isDir && pa.isEmpty() ) |
302 | return; | 329 | return; |
303 | 330 | ||
304 | if (!QPEMessageBox::confirmDelete( this, | 331 | if (!QPEMessageBox::confirmDelete( this, |
305 | tr("Delete Image" ), | 332 | tr("Delete Image" ), |
306 | tr("the Image %1" ).arg(pa))) | 333 | tr("the Image %1" ).arg(pa))) |
307 | return | 334 | return |
308 | 335 | ||
309 | 336 | ||
310 | currentView()->dirLister()->deleteImage( pa ); | 337 | currentView()->dirLister()->deleteImage( pa ); |
311 | delete m_view->currentItem(); | 338 | delete m_view->currentItem(); |
312 | } | 339 | } |
313 | 340 | ||
314 | /* | 341 | /* |
315 | * see what views are available | 342 | * see what views are available |
316 | */ | 343 | */ |
317 | void PIconView::loadViews() { | 344 | void PIconView::loadViews() { |
318 | ViewMap::Iterator it; | 345 | ViewMap::Iterator it; |
319 | ViewMap* map = viewMap(); | 346 | ViewMap* map = viewMap(); |
320 | for ( it = map->begin(); it != map->end(); ++it ) | 347 | for ( it = map->begin(); it != map->end(); ++it ) |
321 | m_views->insertItem( QObject::tr(it.key() ) ); | 348 | m_views->insertItem( QObject::tr(it.key() ) ); |
322 | } | 349 | } |
323 | 350 | ||
324 | void PIconView::resetView() { | 351 | void PIconView::resetView() { |
325 | slotViewChanged(m_views->currentItem()); | 352 | slotViewChanged(m_views->currentItem()); |
326 | } | 353 | } |
327 | 354 | ||
328 | /* | 355 | /* |
329 | *swicth view reloadDir and connect signals | 356 | *swicth view reloadDir and connect signals |
330 | */ | 357 | */ |
331 | void PIconView::slotViewChanged( int i) { | 358 | void PIconView::slotViewChanged( int i) { |
332 | if (!m_views->count() ) { | 359 | if (!m_views->count() ) { |
333 | setCurrentView( 0l); | 360 | setCurrentView( 0l); |
334 | return; | 361 | return; |
335 | } | 362 | } |
336 | 363 | ||
337 | PDirView* cur = currentView(); | 364 | PDirView* cur = currentView(); |
338 | delete cur; | 365 | delete cur; |
339 | QString str = m_views->text(i); | 366 | QString str = m_views->text(i); |
340 | cur = (*(*viewMap())[str])(*m_cfg); | 367 | cur = (*(*viewMap())[str])(*m_cfg); |
341 | setCurrentView( cur ); | 368 | setCurrentView( cur ); |
342 | 369 | ||
343 | /* connect to the signals of the lister */ | 370 | /* connect to the signals of the lister */ |
344 | PDirLister* lis = cur->dirLister(); | 371 | PDirLister* lis = cur->dirLister(); |
345 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 372 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
346 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 373 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
347 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 374 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
348 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 375 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
349 | connect(lis, SIGNAL(sig_start()), | 376 | connect(lis, SIGNAL(sig_start()), |
350 | this, SLOT(slotStart())); | 377 | this, SLOT(slotStart())); |
351 | connect(lis, SIGNAL(sig_end()) , | 378 | connect(lis, SIGNAL(sig_end()) , |
352 | this, SLOT(slotEnd()) ); | 379 | this, SLOT(slotEnd()) ); |
353 | 380 | ||
354 | 381 | ||
355 | /* reload now */ | 382 | /* reload now */ |
356 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 383 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
357 | } | 384 | } |
358 | 385 | ||
359 | 386 | ||
360 | void PIconView::slotReloadDir() { | 387 | void PIconView::slotReloadDir() { |
361 | slotChangeDir( m_path ); | 388 | slotChangeDir( m_path ); |
362 | } | 389 | } |
363 | 390 | ||
364 | 391 | ||
365 | /* | 392 | /* |
366 | * add files and folders | 393 | * add files and folders |
367 | */ | 394 | */ |
368 | void PIconView::addFolders( const QStringList& lst) { | 395 | void PIconView::addFolders( const QStringList& lst) { |
369 | QStringList::ConstIterator it; | 396 | QStringList::ConstIterator it; |
397 | IconViewItem * _iv; | ||
370 | 398 | ||
371 | for(it=lst.begin(); it != lst.end(); ++it ) | 399 | for(it=lst.begin(); it != lst.end(); ++it ) { |
372 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 400 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
373 | 401 | if (m_mode==3) _iv->setTextOnly(true); | |
374 | 402 | } | |
375 | } | 403 | } |
376 | 404 | ||
377 | void PIconView::addFiles( const QStringList& lst) { | 405 | void PIconView::addFiles( const QStringList& lst) { |
378 | QStringList::ConstIterator it; | 406 | QStringList::ConstIterator it; |
379 | for (it=lst.begin(); it!= lst.end(); ++it ) | 407 | IconViewItem * _iv; |
380 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 408 | QPixmap*m_pix = 0; |
409 | for (it=lst.begin(); it!= lst.end(); ++it ) { | ||
410 | m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 ); | ||
411 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | ||
412 | if (m_mode==3) _iv->setTextOnly(true); | ||
413 | if (m_pix) _iv->setPixmap(*m_pix); | ||
414 | } | ||
381 | 415 | ||
382 | } | 416 | } |
383 | 417 | ||
384 | /* | 418 | /* |
385 | * user clicked on the item. Change dir or view | 419 | * user clicked on the item. Change dir or view |
386 | */ | 420 | */ |
387 | void PIconView::slotClicked(QIconViewItem* _it) { | 421 | void PIconView::slotClicked(QIconViewItem* _it) { |
388 | if(!_it ) | 422 | if(!_it ) |
389 | return; | 423 | return; |
390 | 424 | ||
391 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 425 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
392 | if( it->isDir() ) | 426 | if( it->isDir() ) |
393 | slotChangeDir( it->path() ); | 427 | slotChangeDir( it->path() ); |
394 | else // view image | 428 | else // view image |
395 | slotShowImage(); | 429 | slotShowImage(); |
396 | } | 430 | } |
397 | 431 | ||
398 | /* | 432 | /* |
399 | * got thumb info add to the cache if items is visible | 433 | * got thumb info add to the cache if items is visible |
400 | * we later need update after processing of slave is done | 434 | * we later need update after processing of slave is done |
401 | */ | 435 | */ |
402 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 436 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
403 | IconViewItem* item = g_stringInf[_path]; | 437 | IconViewItem* item = g_stringInf[_path]; |
404 | if (!item ) | 438 | if (!item ) |
405 | return; | 439 | return; |
406 | 440 | ||
441 | if (m_mode == 2) { | ||
442 | return; | ||
443 | } | ||
407 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 444 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
408 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 445 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
409 | m_updatet = true; | 446 | m_updatet = true; |
410 | 447 | ||
411 | item->setText( str ); | 448 | item->setText( str ); |
412 | g_stringInf.remove( _path ); | 449 | g_stringInf.remove( _path ); |
413 | } | 450 | } |
414 | 451 | ||
415 | /* | 452 | /* |
416 | * got thumbnail and see if it is visible so we need to update later | 453 | * got thumbnail and see if it is visible so we need to update later |
417 | */ | 454 | */ |
418 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 455 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
419 | IconViewItem* item = g_stringPix[_path]; | 456 | IconViewItem* item = g_stringPix[_path]; |
420 | if (!item ) | 457 | if (!item ) |
421 | return; | 458 | return; |
422 | 459 | ||
423 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 460 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
424 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 461 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
425 | m_updatet = true; | 462 | m_updatet = true; |
426 | 463 | ||
427 | if (pix.width()>0) | 464 | if (pix.width()>0) { |
428 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 465 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
429 | 466 | item->setPixmap(pix,true); | |
430 | 467 | } else { | |
468 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); | ||
469 | } | ||
431 | g_stringPix.remove( _path ); | 470 | g_stringPix.remove( _path ); |
432 | } | 471 | } |
433 | 472 | ||
434 | 473 | ||
435 | /* | 474 | /* |
436 | * FIXME rename | 475 | * FIXME rename |
437 | */ | 476 | */ |
438 | void PIconView::slotRename() { | 477 | void PIconView::slotRename() { |
439 | 478 | ||
440 | } | 479 | } |
441 | 480 | ||
442 | 481 | ||
443 | /* | 482 | /* |
444 | * BEAM the current file | 483 | * BEAM the current file |
445 | */ | 484 | */ |
446 | void PIconView::slotBeam() { | 485 | void PIconView::slotBeam() { |
447 | bool isDir; | 486 | bool isDir; |
448 | QString pa = currentFileName( isDir ); | 487 | QString pa = currentFileName( isDir ); |
449 | if ( isDir && pa.isEmpty() ) | 488 | if ( isDir && pa.isEmpty() ) |
450 | return; | 489 | return; |
451 | 490 | ||
452 | Ir* ir = new Ir( this ); | 491 | Ir* ir = new Ir( this ); |
453 | connect( ir, SIGNAL(done(Ir*)), | 492 | connect( ir, SIGNAL(done(Ir*)), |
454 | this, SLOT(slotBeamDone(Ir*))); | 493 | this, SLOT(slotBeamDone(Ir*))); |
455 | ir->send(pa, tr( "Image" ) ); | 494 | ir->send(pa, tr( "Image" ) ); |
456 | } | 495 | } |
457 | 496 | ||
458 | /* | 497 | /* |
459 | * BEAM done clean up | 498 | * BEAM done clean up |
460 | */ | 499 | */ |
461 | void PIconView::slotBeamDone( Ir* ir) { | 500 | void PIconView::slotBeamDone( Ir* ir) { |
462 | delete ir; | 501 | delete ir; |
463 | } | 502 | } |
464 | 503 | ||
465 | void PIconView::slotStart() { | 504 | void PIconView::slotStart() { |
466 | m_view->viewport()->setUpdatesEnabled( false ); | 505 | m_view->viewport()->setUpdatesEnabled( false ); |
467 | } | 506 | } |
468 | 507 | ||
469 | void PIconView::slotEnd() { | 508 | void PIconView::slotEnd() { |
470 | if ( m_updatet ) | 509 | if ( m_updatet ) |
471 | m_view->arrangeItemsInGrid( ); | 510 | m_view->arrangeItemsInGrid( ); |
472 | m_view->viewport()->setUpdatesEnabled( true ); | 511 | m_view->viewport()->setUpdatesEnabled( true ); |
473 | m_updatet = false; | 512 | m_updatet = false; |
474 | } | 513 | } |
475 | 514 | ||
476 | void PIconView::slotShowNext() | 515 | void PIconView::slotShowNext() |
477 | { | 516 | { |
478 | bool isDir = false; | 517 | bool isDir = false; |
479 | QString name = nextFileName(isDir); | 518 | QString name = nextFileName(isDir); |
480 | if (name.isEmpty()) return; | 519 | if (name.isEmpty()) return; |
481 | if (isDir) return; | 520 | if (isDir) return; |
482 | /* if we got a name we have a next item */ | 521 | /* if we got a name we have a next item */ |
483 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 522 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
484 | slotShowImage(name); | 523 | slotShowImage(name); |
485 | } | 524 | } |
486 | 525 | ||
487 | void PIconView::slotShowPrev() | 526 | void PIconView::slotShowPrev() |
488 | { | 527 | { |
489 | bool isDir = false; | 528 | bool isDir = false; |
490 | QString name = prevFileName(isDir); | 529 | QString name = prevFileName(isDir); |
491 | if (name.isEmpty()) return; | 530 | if (name.isEmpty()) return; |
492 | if (isDir) return; | 531 | if (isDir) return; |
493 | /* if we got a name we have a prev item */ | 532 | /* if we got a name we have a prev item */ |
494 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 533 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
495 | slotShowImage(name); | 534 | slotShowImage(name); |
496 | } | 535 | } |
497 | 536 | ||
498 | void PIconView::slotShowImage() | 537 | void PIconView::slotShowImage() |
499 | { | 538 | { |
500 | bool isDir = false; | 539 | bool isDir = false; |
501 | QString name = currentFileName(isDir); | 540 | QString name = currentFileName(isDir); |
502 | if (isDir) return; | 541 | if (isDir) return; |
503 | 542 | ||
504 | slotShowImage( name ); | 543 | slotShowImage( name ); |
505 | } | 544 | } |
506 | void PIconView::slotShowImage( const QString& name) { | 545 | void PIconView::slotShowImage( const QString& name) { |
507 | emit sig_display( name ); | 546 | emit sig_display( name ); |
508 | } | 547 | } |
509 | void PIconView::slotImageInfo() { | 548 | void PIconView::slotImageInfo() { |
510 | bool isDir = false; | 549 | bool isDir = false; |
511 | QString name = currentFileName(isDir); | 550 | QString name = currentFileName(isDir); |
512 | if (isDir) return; | 551 | if (isDir) return; |
513 | 552 | ||
514 | slotImageInfo( name ); | 553 | slotImageInfo( name ); |
515 | } | 554 | } |
516 | 555 | ||
517 | void PIconView::slotImageInfo( const QString& name) { | 556 | void PIconView::slotImageInfo( const QString& name) { |
518 | emit sig_showInfo( name ); | 557 | emit sig_showInfo( name ); |
519 | } | 558 | } |
520 | 559 | ||
521 | 560 | ||
522 | void PIconView::slotChangeMode( int mode ) { | 561 | void PIconView::slotChangeMode( int mode ) { |
523 | if ( mode >= 1 && mode <= 3 ) | 562 | if ( mode >= 1 && mode <= 3 ) |
524 | m_mode = mode; | 563 | m_mode = mode; |
525 | 564 | ||
526 | QIconView::ItemTextPos pos; | 565 | QIconView::ItemTextPos pos; |
527 | switch( m_mode ) { | 566 | switch( m_mode ) { |
528 | case 2: | 567 | case 2: |
529 | pos = QIconView::Bottom; | 568 | pos = QIconView::Bottom; |
530 | break; | 569 | break; |
531 | case 3: | 570 | case 3: |
532 | case 1: | 571 | case 1: |
533 | default: | 572 | default: |
534 | pos = QIconView::Right; | 573 | pos = QIconView::Right; |
535 | break; | 574 | break; |
536 | } | 575 | } |
537 | m_view->setItemTextPos( pos ); | 576 | m_view->setItemTextPos( pos ); |
538 | 577 | ||
539 | calculateGrid(); | 578 | calculateGrid(); |
540 | slotReloadDir(); | 579 | slotReloadDir(); |
541 | } | 580 | } |
542 | 581 | ||
543 | 582 | ||
544 | void PIconView::resizeEvent( QResizeEvent* re ) { | 583 | void PIconView::resizeEvent( QResizeEvent* re ) { |
545 | QVBox::resizeEvent( re ); | 584 | QVBox::resizeEvent( re ); |
546 | calculateGrid(); | 585 | calculateGrid(); |
547 | } | 586 | } |
548 | 587 | ||
549 | 588 | ||
550 | void PIconView::calculateGrid() { | 589 | void PIconView::calculateGrid() { |
551 | 590 | odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; | |
591 | odebug << "Size of view: " << m_view->size() << oendl; | ||
592 | |||
593 | switch (m_mode) { | ||
594 | case 2: | ||
595 | m_view->setGridX(80); | ||
596 | m_view->setGridY(80); | ||
597 | break; | ||
598 | case 3: | ||
599 | m_view->setGridX(m_view->width()); | ||
600 | m_view->setGridY(8); | ||
601 | break; | ||
602 | case 1: | ||
603 | default: | ||
604 | m_view->setGridX(m_view->width()); | ||
605 | m_view->setGridY(80); | ||
606 | break; | ||
607 | } | ||
552 | } | 608 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 5ba4c8e..4852bf6 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -12,348 +12,353 @@ | |||
12 | 12 | ||
13 | #include <iface/ifaceinfo.h> | 13 | #include <iface/ifaceinfo.h> |
14 | #include <iface/dirview.h> | 14 | #include <iface/dirview.h> |
15 | 15 | ||
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <opie2/owidgetstack.h> | 17 | #include <opie2/owidgetstack.h> |
18 | #include <opie2/oapplicationfactory.h> | 18 | #include <opie2/oapplicationfactory.h> |
19 | #include <opie2/otabwidget.h> | 19 | #include <opie2/otabwidget.h> |
20 | #include <opie2/okeyconfigwidget.h> | 20 | #include <opie2/okeyconfigwidget.h> |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qdialog.h> | 30 | #include <qdialog.h> |
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 37 | OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
38 | 38 | ||
39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
41 | { | 41 | { |
42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
43 | m_cfg = new Opie::Core::OConfig("phunkview"); | 43 | m_cfg = new Opie::Core::OConfig("phunkview"); |
44 | m_cfg->setGroup("Zecke_view" ); | 44 | m_cfg->setGroup("Zecke_view" ); |
45 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); | 45 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); |
46 | /* | 46 | /* |
47 | * Initialize ToolBar and IconView | 47 | * Initialize ToolBar and IconView |
48 | * And Connect Them | 48 | * And Connect Them |
49 | */ | 49 | */ |
50 | QToolBar *bar = new QToolBar( this ); | 50 | QToolBar *bar = new QToolBar( this ); |
51 | bar->setHorizontalStretchable( true ); | 51 | bar->setHorizontalStretchable( true ); |
52 | setToolBarsMovable( false ); | 52 | setToolBarsMovable( false ); |
53 | 53 | ||
54 | m_stack = new Opie::Ui::OWidgetStack( this ); | 54 | m_stack = new Opie::Ui::OWidgetStack( this ); |
55 | setCentralWidget( m_stack ); | 55 | setCentralWidget( m_stack ); |
56 | 56 | ||
57 | m_view = new PIconView( m_stack, m_cfg ); | 57 | m_view = new PIconView( m_stack, m_cfg ); |
58 | m_stack->addWidget( m_view, IconView ); | 58 | m_stack->addWidget( m_view, IconView ); |
59 | m_stack->raiseWidget( IconView ); | 59 | m_stack->raiseWidget( IconView ); |
60 | connect(m_view, SIGNAL(sig_display(const QString&)), | 60 | connect(m_view, SIGNAL(sig_display(const QString&)), |
61 | this, SLOT(slotDisplay(const QString&))); | 61 | this, SLOT(slotDisplay(const QString&))); |
62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
63 | this, SLOT(slotShowInfo(const QString&)) ); | 63 | this, SLOT(slotShowInfo(const QString&)) ); |
64 | 64 | ||
65 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 65 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
66 | 66 | ||
67 | upButton = new QToolButton( bar ); | 67 | upButton = new QToolButton( bar ); |
68 | upButton->setIconSet( Resource::loadIconSet( "up" ) ); | 68 | upButton->setIconSet( Resource::loadIconSet( "up" ) ); |
69 | connect( upButton, SIGNAL(clicked()), | 69 | connect( upButton, SIGNAL(clicked()), |
70 | m_view, SLOT(slotDirUp()) ); | 70 | m_view, SLOT(slotDirUp()) ); |
71 | 71 | ||
72 | fsButton = new PFileSystem( bar ); | 72 | fsButton = new PFileSystem( bar ); |
73 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 73 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
74 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 74 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
75 | 75 | ||
76 | QToolButton*btn = new QToolButton( bar ); | 76 | QToolButton*btn = new QToolButton( bar ); |
77 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); | 77 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); |
78 | connect( btn, SIGNAL(clicked()), | 78 | connect( btn, SIGNAL(clicked()), |
79 | m_view, SLOT(slotRename()) ); | 79 | m_view, SLOT(slotRename()) ); |
80 | 80 | ||
81 | if ( Ir::supported() ) { | 81 | if ( Ir::supported() ) { |
82 | btn = new QToolButton( bar ); | 82 | btn = new QToolButton( bar ); |
83 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); | 83 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); |
84 | connect( btn, SIGNAL(clicked()), | 84 | connect( btn, SIGNAL(clicked()), |
85 | m_view, SLOT(slotBeam()) ); | 85 | m_view, SLOT(slotBeam()) ); |
86 | } | 86 | } |
87 | 87 | ||
88 | btn = new QToolButton( bar ); | 88 | btn = new QToolButton( bar ); |
89 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 89 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
90 | connect( btn, SIGNAL(clicked() ), | 90 | connect( btn, SIGNAL(clicked() ), |
91 | m_view, SLOT(slotTrash() ) ); | 91 | m_view, SLOT(slotTrash() ) ); |
92 | 92 | ||
93 | 93 | ||
94 | viewModeButton = new ViewModeButton( bar ); | 94 | viewModeButton = new ViewModeButton( bar ); |
95 | connect( viewModeButton, SIGNAL(changeMode(int)), | 95 | connect( viewModeButton, SIGNAL(changeMode(int)), |
96 | m_view, SLOT(slotChangeMode(int))); | 96 | m_view, SLOT(slotChangeMode(int))); |
97 | 97 | ||
98 | btn = new QToolButton( bar ); | 98 | btn = new QToolButton( bar ); |
99 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 99 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
100 | connect( btn, SIGNAL(clicked() ), | 100 | connect( btn, SIGNAL(clicked() ), |
101 | this, SLOT(slotConfig() ) ); | 101 | this, SLOT(slotConfig() ) ); |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | prevButton = new QToolButton(bar); | 105 | prevButton = new QToolButton(bar); |
106 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); | 106 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); |
107 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); | 107 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); |
108 | prevButton->hide(); | ||
109 | 108 | ||
110 | nextButton = new QToolButton(bar); | 109 | nextButton = new QToolButton(bar); |
111 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); | 110 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); |
112 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); | 111 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); |
113 | nextButton->hide(); | ||
114 | 112 | ||
115 | rotateButton = new QToolButton(bar); | 113 | rotateButton = new QToolButton(bar); |
116 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | 114 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); |
117 | rotateButton->setToggleButton(true); | 115 | rotateButton->setToggleButton(true); |
118 | 116 | ||
119 | odebug << "Mode = " << m_stack->mode() << oendl; | ||
120 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 117 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
121 | rotateButton->setOn(true); | 118 | rotateButton->setOn(true); |
122 | autoRotate = true; | 119 | autoRotate = true; |
120 | prevButton->hide(); | ||
121 | nextButton->hide(); | ||
123 | } else { | 122 | } else { |
124 | rotateButton->setOn(false); | 123 | rotateButton->setOn(false); |
125 | autoRotate = false; | 124 | autoRotate = false; |
126 | } | 125 | } |
127 | 126 | ||
128 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 127 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
129 | 128 | ||
130 | btn = new QToolButton(bar); | 129 | btn = new QToolButton(bar); |
131 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); | 130 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); |
132 | btn->setToggleButton(true); | 131 | btn->setToggleButton(true); |
133 | btn->setOn(false); | 132 | btn->setOn(false); |
134 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 133 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
135 | autoScale = true; | 134 | autoScale = true; |
136 | 135 | ||
137 | btn = new QToolButton(bar); | 136 | btn = new QToolButton(bar); |
138 | btn->setIconSet( Resource::loadIconSet( "mag" ) ); | 137 | btn->setIconSet( Resource::loadIconSet( "mag" ) ); |
139 | btn->setToggleButton(true); | 138 | btn->setToggleButton(true); |
140 | btn->setOn(true); | 139 | btn->setOn(true); |
141 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 140 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
142 | zoomerOn = true; | 141 | zoomerOn = true; |
143 | } | 142 | } |
144 | 143 | ||
145 | PMainWindow::~PMainWindow() { | 144 | PMainWindow::~PMainWindow() { |
146 | odebug << "Shutting down" << oendl; | 145 | odebug << "Shutting down" << oendl; |
147 | } | 146 | } |
148 | 147 | ||
149 | void PMainWindow::slotZoomerToggled(bool how) | 148 | void PMainWindow::slotZoomerToggled(bool how) |
150 | { | 149 | { |
151 | zoomerOn = how; | 150 | zoomerOn = how; |
152 | if (m_disp) { | 151 | if (m_disp) { |
153 | m_disp->setShowZoomer(zoomerOn); | 152 | m_disp->setShowZoomer(zoomerOn); |
154 | } | 153 | } |
155 | } | 154 | } |
156 | 155 | ||
157 | void PMainWindow::slotRotateToggled(bool how) | 156 | void PMainWindow::slotRotateToggled(bool how) |
158 | { | 157 | { |
159 | autoRotate = how; | 158 | autoRotate = how; |
160 | if (m_disp) { | 159 | if (m_disp) { |
161 | m_disp->setAutoRotate(how); | 160 | m_disp->setAutoRotate(how); |
162 | } | 161 | } |
163 | } | 162 | } |
164 | 163 | ||
165 | void PMainWindow::slotScaleToggled(bool how) | 164 | void PMainWindow::slotScaleToggled(bool how) |
166 | { | 165 | { |
167 | autoScale = !how; | 166 | autoScale = !how; |
168 | if (!how) { | 167 | if (!how) { |
169 | autoRotate = how; | 168 | autoRotate = how; |
170 | } | 169 | } |
171 | if (m_disp) { | 170 | if (m_disp) { |
172 | m_disp->setAutoScaleRotate(autoScale,autoRotate); | 171 | m_disp->setAutoScaleRotate(autoScale,autoRotate); |
173 | } | 172 | } |
174 | if (!autoScale) { | 173 | if (!autoScale) { |
175 | rotateButton->setOn(false); | 174 | rotateButton->setOn(false); |
176 | } | 175 | } |
177 | rotateButton->setEnabled(!how); | 176 | rotateButton->setEnabled(!how); |
178 | } | 177 | } |
179 | 178 | ||
180 | void PMainWindow::slotConfig() { | 179 | void PMainWindow::slotConfig() { |
181 | /* | 180 | /* |
182 | * have a tab with the possible views | 181 | * have a tab with the possible views |
183 | * a tab for globals image cache size.. scaled loading | 182 | * a tab for globals image cache size.. scaled loading |
184 | * and one tab for the KeyConfigs | 183 | * and one tab for the KeyConfigs |
185 | */ | 184 | */ |
186 | QDialog dlg(this, 0, true); | 185 | QDialog dlg(this, 0, true); |
187 | dlg.setCaption( tr("Phunk View - Config" ) ); | 186 | dlg.setCaption( tr("Phunk View - Config" ) ); |
188 | 187 | ||
189 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 188 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
190 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 189 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
191 | lay->addWidget( wid ); | 190 | lay->addWidget( wid ); |
192 | ViewMap *vM = viewMap(); | 191 | ViewMap *vM = viewMap(); |
193 | ViewMap::Iterator _it = vM->begin(); | 192 | ViewMap::Iterator _it = vM->begin(); |
194 | QMap<PDirView*, QWidget*> lst; | 193 | QMap<PDirView*, QWidget*> lst; |
195 | 194 | ||
196 | for( ; _it != vM->end(); ++_it ) { | 195 | for( ; _it != vM->end(); ++_it ) { |
197 | PDirView *view = (_it.data())(*m_cfg); | 196 | PDirView *view = (_it.data())(*m_cfg); |
198 | PInterfaceInfo *inf = view->interfaceInfo(); | 197 | PInterfaceInfo *inf = view->interfaceInfo(); |
199 | QWidget *_wid = inf->configWidget( *m_cfg ); | 198 | QWidget *_wid = inf->configWidget( *m_cfg ); |
200 | _wid->reparent(wid, QPoint() ); | 199 | _wid->reparent(wid, QPoint() ); |
201 | lst.insert( view, _wid ); | 200 | lst.insert( view, _wid ); |
202 | wid->addTab( _wid, "fileopen", inf->name() ); | 201 | wid->addTab( _wid, "fileopen", inf->name() ); |
203 | } | 202 | } |
204 | 203 | ||
205 | /* | 204 | /* |
206 | * Add the KeyConfigWidget | 205 | * Add the KeyConfigWidget |
207 | */ | 206 | */ |
208 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 207 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
209 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 208 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
210 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 209 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
211 | 210 | ||
212 | if ( !m_info ) { | 211 | if ( !m_info ) { |
213 | initInfo(); | 212 | initInfo(); |
214 | } | 213 | } |
215 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 214 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
216 | 215 | ||
217 | if ( !m_disp ) { | 216 | if ( !m_disp ) { |
218 | initDisp(); | 217 | initDisp(); |
219 | } | 218 | } |
220 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 219 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
221 | 220 | ||
222 | keyWid->load(); | 221 | keyWid->load(); |
223 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 222 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
224 | 223 | ||
225 | 224 | ||
226 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 225 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
227 | 226 | ||
228 | /* | 227 | /* |
229 | * clean up | 228 | * clean up |
230 | *apply changes | 229 | *apply changes |
231 | */ | 230 | */ |
232 | 231 | ||
233 | QMap<PDirView*, QWidget*>::Iterator it; | 232 | QMap<PDirView*, QWidget*>::Iterator it; |
234 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 233 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
235 | if ( act ) | 234 | if ( act ) |
236 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 235 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
237 | delete it.key(); | 236 | delete it.key(); |
238 | } | 237 | } |
239 | 238 | ||
240 | 239 | ||
241 | if ( act ) { | 240 | if ( act ) { |
242 | m_view->resetView(); | 241 | m_view->resetView(); |
243 | keyWid->save(); | 242 | keyWid->save(); |
244 | m_disp->manager()->save(); | 243 | m_disp->manager()->save(); |
245 | m_info->manager()->save(); | 244 | m_info->manager()->save(); |
246 | m_view->manager()->save(); | 245 | m_view->manager()->save(); |
247 | } | 246 | } |
248 | delete keyWid; | 247 | delete keyWid; |
249 | } | 248 | } |
250 | 249 | ||
251 | /* | 250 | /* |
252 | * create a new image info component | 251 | * create a new image info component |
253 | * and detach the current one | 252 | * and detach the current one |
254 | * we will make the other delete on exit | 253 | * we will make the other delete on exit |
255 | */ | 254 | */ |
256 | template<class T> | 255 | template<class T> |
257 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 256 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
258 | if ( *ptr ) { | 257 | if ( *ptr ) { |
259 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 258 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
260 | (*ptr)->setDestructiveClose(); | 259 | (*ptr)->setDestructiveClose(); |
261 | m_stack->removeWidget( *ptr ); | 260 | m_stack->removeWidget( *ptr ); |
262 | } | 261 | } |
263 | *ptr = new T(m_cfg, m_stack, name ); | 262 | *ptr = new T(m_cfg, m_stack, name ); |
264 | m_stack->addWidget( *ptr, id ); | 263 | m_stack->addWidget( *ptr, id ); |
265 | 264 | ||
266 | connect(*ptr, SIGNAL(sig_return()), | 265 | connect(*ptr, SIGNAL(sig_return()), |
267 | this,SLOT(slotReturn())); | 266 | this,SLOT(slotReturn())); |
268 | 267 | ||
269 | } | 268 | } |
270 | void PMainWindow::initInfo() { | 269 | void PMainWindow::initInfo() { |
271 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 270 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
272 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 271 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
273 | } | 272 | } |
274 | void PMainWindow::initDisp() { | 273 | void PMainWindow::initDisp() { |
275 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 274 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
276 | if (m_disp) { | 275 | if (m_disp) { |
277 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 276 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
278 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 277 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
279 | } | 278 | } |
280 | m_disp->setAutoScale(autoScale); | 279 | m_disp->setAutoScale(autoScale); |
281 | m_disp->setAutoRotate(autoRotate); | 280 | m_disp->setAutoRotate(autoRotate); |
282 | m_disp->setShowZoomer(zoomerOn); | 281 | m_disp->setShowZoomer(zoomerOn); |
283 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 282 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
284 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 283 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
285 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 284 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
286 | } | 285 | } |
287 | } | 286 | } |
288 | 287 | ||
289 | /** | 288 | /** |
290 | * With big Screen the plan could be to 'detach' the image | 289 | * With big Screen the plan could be to 'detach' the image |
291 | * window if visible and to create a ne wone | 290 | * window if visible and to create a ne wone |
292 | * init* already supports it but I make no use of it for | 291 | * init* already supports it but I make no use of it for |
293 | * now. We set filename and raise | 292 | * now. We set filename and raise |
294 | * | 293 | * |
295 | * ### FIXME and talk to alwin | 294 | * ### FIXME and talk to alwin |
296 | */ | 295 | */ |
297 | void PMainWindow::slotShowInfo( const QString& inf ) { | 296 | void PMainWindow::slotShowInfo( const QString& inf ) { |
298 | if ( !m_info ) { | 297 | if ( !m_info ) { |
299 | initInfo(); | 298 | initInfo(); |
300 | } | 299 | } |
301 | m_info->setPath( inf ); | 300 | m_info->setPath( inf ); |
302 | prevButton->hide(); | 301 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
303 | nextButton->hide(); | 302 | prevButton->hide(); |
304 | upButton->hide(); | 303 | nextButton->hide(); |
305 | fsButton->hide(); | 304 | upButton->hide(); |
306 | viewModeButton->hide(); | 305 | fsButton->hide(); |
306 | viewModeButton->hide(); | ||
307 | } | ||
307 | m_stack->raiseWidget( ImageInfo ); | 308 | m_stack->raiseWidget( ImageInfo ); |
308 | } | 309 | } |
309 | 310 | ||
310 | void PMainWindow::slotDisplay( const QString& inf ) { | 311 | void PMainWindow::slotDisplay( const QString& inf ) { |
311 | if ( !m_disp ) { | 312 | if ( !m_disp ) { |
312 | initDisp(); | 313 | initDisp(); |
313 | } | 314 | } |
314 | m_disp->setImage( inf ); | 315 | m_disp->setImage( inf ); |
315 | prevButton->show(); | 316 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
316 | nextButton->show(); | 317 | prevButton->show(); |
317 | upButton->hide(); | 318 | nextButton->show(); |
318 | fsButton->hide(); | 319 | upButton->hide(); |
319 | viewModeButton->hide(); | 320 | fsButton->hide(); |
321 | viewModeButton->hide(); | ||
322 | } | ||
320 | m_stack->raiseWidget( ImageDisplay ); | 323 | m_stack->raiseWidget( ImageDisplay ); |
321 | } | 324 | } |
322 | 325 | ||
323 | void PMainWindow::slotReturn() { | 326 | void PMainWindow::slotReturn() { |
324 | raiseIconView(); | 327 | raiseIconView(); |
325 | } | 328 | } |
326 | 329 | ||
327 | 330 | ||
328 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 331 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
329 | /* | 332 | /* |
330 | * return from view | 333 | * return from view |
331 | * or properly quit | 334 | * or properly quit |
332 | */ | 335 | */ |
333 | if ( m_stack->visibleWidget() == m_info || | 336 | if ( m_stack->visibleWidget() == m_info || |
334 | m_stack->visibleWidget() == m_disp ) { | 337 | m_stack->visibleWidget() == m_disp ) { |
335 | raiseIconView(); | 338 | raiseIconView(); |
336 | ev->ignore(); | 339 | ev->ignore(); |
337 | return; | 340 | return; |
338 | } | 341 | } |
339 | ev->accept(); | 342 | ev->accept(); |
340 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 343 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
341 | } | 344 | } |
342 | 345 | ||
343 | void PMainWindow::raiseIconView() { | 346 | void PMainWindow::raiseIconView() { |
344 | prevButton->hide(); | 347 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
345 | nextButton->hide(); | 348 | prevButton->hide(); |
346 | upButton->show(); | 349 | nextButton->hide(); |
347 | fsButton->show(); | 350 | upButton->show(); |
348 | viewModeButton->show(); | 351 | fsButton->show(); |
352 | viewModeButton->show(); | ||
353 | } | ||
349 | m_stack->raiseWidget( IconView ); | 354 | m_stack->raiseWidget( IconView ); |
350 | } | 355 | } |
351 | 356 | ||
352 | void PMainWindow::setDocument( const QString& showImg ) { | 357 | void PMainWindow::setDocument( const QString& showImg ) { |
353 | QString file = showImg; | 358 | QString file = showImg; |
354 | DocLnk lnk(showImg); | 359 | DocLnk lnk(showImg); |
355 | if (lnk.isValid() ) | 360 | if (lnk.isValid() ) |
356 | file = lnk.file(); | 361 | file = lnk.file(); |
357 | 362 | ||
358 | slotDisplay( file ); | 363 | slotDisplay( file ); |
359 | } | 364 | } |