summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-19 11:39:36 (UTC)
committer alwin <alwin>2004-04-19 11:39:36 (UTC)
commit2add0a39efab1af658ab3515090b31fba30df0d5 (patch) (unidiff)
tree50ba1101316b70d724b218dfc8f89ecfaa7f7149
parente3ca538f7ce2e7b7df2f29f263778acc342d51db (diff)
downloadopie-2add0a39efab1af658ab3515090b31fba30df0d5.zip
opie-2add0a39efab1af658ab3515090b31fba30df0d5.tar.gz
opie-2add0a39efab1af658ab3515090b31fba30df0d5.tar.bz2
last iconview mode will be saved and restored
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp45
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp4
-rw-r--r--noncore/graphics/opie-eye/gui/viewmodebutton.cpp4
-rw-r--r--noncore/graphics/opie-eye/gui/viewmodebutton.h2
4 files changed, 30 insertions, 25 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index d546b64..660c4fa 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -77,199 +77,200 @@ namespace {
77 ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); 77 ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
78 QPixmap *pixmap()const; 78 QPixmap *pixmap()const;
79 void setText( const QString& ); 79 void setText( const QString& );
80 }; 80 };
81 81
82 82
83/* 83/*
84 * If we request an Image or String 84 * If we request an Image or String
85 * we add it to the map 85 * we add it to the map
86 */ 86 */
87 static QMap<QString, IconViewItem*> g_stringInf; 87 static QMap<QString, IconViewItem*> g_stringInf;
88 static QMap<QString, IconViewItem*> g_stringPix; 88 static QMap<QString, IconViewItem*> g_stringPix;
89 89
90 IconViewItem::IconViewItem( QIconView* view,const QString& path, 90 IconViewItem::IconViewItem( QIconView* view,const QString& path,
91 const QString& name, bool isDir ) 91 const QString& name, bool isDir )
92 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 92 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
93 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 93 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
94 { 94 {
95 if ( isDir && !_dirPix ) 95 if ( isDir && !_dirPix )
96 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 96 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
97 else if ( !isDir && !_unkPix ) 97 else if ( !isDir && !_unkPix )
98 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 98 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
99 } 99 }
100 100
101 inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) 101 inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw)
102 { 102 {
103 m_Pixset = true; 103 m_Pixset = true;
104 calcRect(text()); 104 calcRect(text());
105 } 105 }
106 inline void IconViewItem::setPixmap( const QPixmap & icon) 106 inline void IconViewItem::setPixmap( const QPixmap & icon)
107 { 107 {
108 m_Pixset = true; 108 m_Pixset = true;
109 calcRect(text()); 109 calcRect(text());
110 } 110 }
111 111
112 inline QPixmap* IconViewItem::pixmap()const { 112 inline QPixmap* IconViewItem::pixmap()const {
113// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", 113// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
114// rect().x(),rect().y(),rect().width(),rect().height(), 114// rect().x(),rect().y(),rect().width(),rect().height(),
115// iconView()->contentsX(), iconView()->contentsY()); 115// iconView()->contentsX(), iconView()->contentsY());
116 116
117 if (textOnly()&&!m_isDir) { 117 if (textOnly()&&!m_isDir) {
118 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 118 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
119 return _emptyPix; 119 return _emptyPix;
120 } 120 }
121 if ( m_isDir ) 121 if ( m_isDir )
122 return _dirPix; 122 return _dirPix;
123 else{ 123 else{
124 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 124 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
125 currentView()->dirLister()->imageInfo( m_path ); 125 currentView()->dirLister()->imageInfo( m_path );
126 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 126 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
127 } 127 }
128 128
129 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 129 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
130 if (!m_pix && !g_stringPix.contains( m_path )) { 130 if (!m_pix && !g_stringPix.contains( m_path )) {
131 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 131 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
132 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 132 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
133 } 133 }
134 return m_pix ? m_pix : _unkPix; 134 return m_pix ? m_pix : _unkPix;
135 } 135 }
136 } 136 }
137 inline void IconViewItem::setText( const QString& str ) { 137 inline void IconViewItem::setText( const QString& str ) {
138 QString text = QIconViewItem::text()+"\n"+str; 138 QString text = QIconViewItem::text()+"\n"+str;
139 m_noInfo = true; 139 m_noInfo = true;
140 QIconViewItem::setText( text ); 140 QIconViewItem::setText( text );
141 } 141 }
142} 142}
143 143
144 144
145/* 145/*
146 * Set up the GUI.. initialize the slave set up gui 146 * Set up the GUI.. initialize the slave set up gui
147 * and also load a dir 147 * and also load a dir
148 */ 148 */
149PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 149PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
150 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 150 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
151{ 151{
152 { 152 {
153 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 153 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
154 } 154 }
155 m_path = QDir::homeDirPath(); 155 m_path = QDir::homeDirPath();
156 m_mode = 0; 156 m_mode = 0;
157 157
158 QHBox *hbox = new QHBox( this ); 158 QHBox *hbox = new QHBox( this );
159 QLabel* lbl = new QLabel( hbox ); 159 QLabel* lbl = new QLabel( hbox );
160 lbl->setText( tr("View as" ) ); 160 lbl->setText( tr("View as" ) );
161 161
162 m_views = new QComboBox( hbox, "View As" ); 162 m_views = new QComboBox( hbox, "View As" );
163 connect( m_views, SIGNAL(activated(int)), 163 connect( m_views, SIGNAL(activated(int)),
164 this, SLOT(slotViewChanged(int)) ); 164 this, SLOT(slotViewChanged(int)) );
165 165
166 m_view= new QIconView( this ); 166 m_view= new QIconView( this );
167 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 167 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
168 this, SLOT(slotClicked(QIconViewItem*)) ); 168 this, SLOT(slotClicked(QIconViewItem*)) );
169 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), 169 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
170 this, SLOT(slotClicked(QIconViewItem*)) ); 170 this, SLOT(slotClicked(QIconViewItem*)) );
171 171
172 m_view->setArrangement( QIconView::LeftToRight ); 172 m_view->setArrangement( QIconView::LeftToRight );
173 m_view->setItemTextPos( QIconView::Right );
174 173
175 int dw = QApplication::desktop()->width(); 174 m_mode = cfg->readNumEntry("ListViewMode", 1);
176 int viewerWidth = dw-style().scrollBarExtent().width();
177 m_view->setGridX( viewerWidth-3*m_view->spacing());
178 m_view->setGridY( fontMetrics().height()*2+40 );
179 175
176 if (m_mode < 1 || m_mode>3) m_mode = 1;
177
178 m_view->setItemTextPos( QIconView::Right );
179
180 calculateGrid();
180 181
181 initKeys(); 182 initKeys();
182 183
183 loadViews(); 184 loadViews();
184 slotViewChanged( m_views->currentItem() ); 185 slotViewChanged( m_views->currentItem() );
185} 186}
186 187
187/* 188/*
188 * Unref the slave and save the keyboard manager 189 * Unref the slave and save the keyboard manager
189 */ 190 */
190PIconView::~PIconView() { 191PIconView::~PIconView() {
191 { 192 {
192 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 193 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
193 } 194 }
194 m_viewManager->save(); 195 m_viewManager->save();
195 delete m_viewManager; 196 delete m_viewManager;
196} 197}
197 198
198Opie::Core::OKeyConfigManager* PIconView::manager() { 199Opie::Core::OKeyConfigManager* PIconView::manager() {
199 return m_viewManager; 200 return m_viewManager;
200} 201}
201 202
202 203
203/* 204/*
204 * init the KeyBoard Shortcuts 205 * init the KeyBoard Shortcuts
205 * called from the c'tor 206 * called from the c'tor
206 */ 207 */
207void PIconView::initKeys() { 208void PIconView::initKeys() {
208 Opie::Core::OKeyPair::List lst; 209 Opie::Core::OKeyPair::List lst;
209 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 210 lst.append( Opie::Core::OKeyPair::upArrowKey() );
210 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 211 lst.append( Opie::Core::OKeyPair::downArrowKey() );
211 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 212 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
212 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 213 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
213 lst.append( Opie::Core::OKeyPair::returnKey() ); 214 lst.append( Opie::Core::OKeyPair::returnKey() );
214 215
215 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 216 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
216 lst, false,this, "keyconfig name" ); 217 lst, false,this, "keyconfig name" );
217 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 218 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
218 Resource::loadPixmap("beam"), BeamItem, 219 Resource::loadPixmap("beam"), BeamItem,
219 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), 220 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
220 this, SLOT(slotBeam())) ); 221 this, SLOT(slotBeam())) );
221 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 222 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
222 Resource::loadPixmap("trash"), DeleteItem, 223 Resource::loadPixmap("trash"), DeleteItem,
223 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), 224 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
224 this, SLOT(slotTrash())) ); 225 this, SLOT(slotTrash())) );
225 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 226 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
226 Resource::loadPixmap("1to1"), ViewItem, 227 Resource::loadPixmap("1to1"), ViewItem,
227 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), 228 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
228 this, SLOT(slotShowImage()))); 229 this, SLOT(slotShowImage())));
229 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 230 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
230 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 231 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
231 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 232 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
232 this, SLOT(slotImageInfo()) ) ); 233 this, SLOT(slotImageInfo()) ) );
233 m_viewManager->load(); 234 m_viewManager->load();
234 m_viewManager->handleWidget( m_view ); 235 m_viewManager->handleWidget( m_view );
235} 236}
236 237
237 238
238/* 239/*
239 * change one dir up 240 * change one dir up
240 */ 241 */
241void PIconView::slotDirUp() { 242void PIconView::slotDirUp() {
242 QDir dir( m_path ); 243 QDir dir( m_path );
243 dir.cdUp(); 244 dir.cdUp();
244 slotChangeDir( dir.absPath() ); 245 slotChangeDir( dir.absPath() );
245} 246}
246 247
247/* 248/*
248 * change the dir 249 * change the dir
249 */ 250 */
250void PIconView::slotChangeDir(const QString& path) { 251void PIconView::slotChangeDir(const QString& path) {
251 if ( !currentView() ) 252 if ( !currentView() )
252 return; 253 return;
253 254
254 PDirLister *lister = currentView()->dirLister(); 255 PDirLister *lister = currentView()->dirLister();
255 if (!lister ) 256 if (!lister )
256 return; 257 return;
257 258
258 /* 259 /*
259 * Say what we want and take what we get 260 * Say what we want and take what we get
260 */ 261 */
261 lister->setStartPath( path ); 262 lister->setStartPath( path );
262 m_path = lister->currentPath(); 263 m_path = lister->currentPath();
263 264
264 m_view->viewport()->setUpdatesEnabled( false ); 265 m_view->viewport()->setUpdatesEnabled( false );
265 m_view->clear(); 266 m_view->clear();
266 267
267 /* 268 /*
268 * add files and folders 269 * add files and folders
269 */ 270 */
270 addFolders( lister->folders() ); 271 addFolders( lister->folders() );
271 addFiles( lister->files() ); 272 addFiles( lister->files() );
272 m_view->viewport()->setUpdatesEnabled( true ); 273 m_view->viewport()->setUpdatesEnabled( true );
273 274
274 // Also invalidate the cache. We can't cancel the operations anyway 275 // Also invalidate the cache. We can't cancel the operations anyway
275 g_stringPix.clear(); 276 g_stringPix.clear();
@@ -472,143 +473,145 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
472 } 473 }
473 g_stringPix.remove( _path ); 474 g_stringPix.remove( _path );
474} 475}
475 476
476 477
477/* 478/*
478 * FIXME rename 479 * FIXME rename
479 */ 480 */
480void PIconView::slotRename() { 481void PIconView::slotRename() {
481 482
482} 483}
483 484
484 485
485/* 486/*
486 * BEAM the current file 487 * BEAM the current file
487 */ 488 */
488void PIconView::slotBeam() { 489void PIconView::slotBeam() {
489 bool isDir; 490 bool isDir;
490 QString pa = currentFileName( isDir ); 491 QString pa = currentFileName( isDir );
491 if ( isDir && pa.isEmpty() ) 492 if ( isDir && pa.isEmpty() )
492 return; 493 return;
493 494
494 Ir* ir = new Ir( this ); 495 Ir* ir = new Ir( this );
495 connect( ir, SIGNAL(done(Ir*)), 496 connect( ir, SIGNAL(done(Ir*)),
496 this, SLOT(slotBeamDone(Ir*))); 497 this, SLOT(slotBeamDone(Ir*)));
497 ir->send(pa, tr( "Image" ) ); 498 ir->send(pa, tr( "Image" ) );
498} 499}
499 500
500/* 501/*
501 * BEAM done clean up 502 * BEAM done clean up
502 */ 503 */
503void PIconView::slotBeamDone( Ir* ir) { 504void PIconView::slotBeamDone( Ir* ir) {
504 delete ir; 505 delete ir;
505} 506}
506 507
507void PIconView::slotStart() { 508void PIconView::slotStart() {
508 m_view->viewport()->setUpdatesEnabled( false ); 509 m_view->viewport()->setUpdatesEnabled( false );
509} 510}
510 511
511void PIconView::slotEnd() { 512void PIconView::slotEnd() {
512 if ( m_updatet ) 513 if ( m_updatet )
513 m_view->arrangeItemsInGrid( ); 514 m_view->arrangeItemsInGrid( );
514 m_view->viewport()->setUpdatesEnabled( true ); 515 m_view->viewport()->setUpdatesEnabled( true );
515 m_updatet = false; 516 m_updatet = false;
516} 517}
517 518
518void PIconView::slotShowNext() 519void PIconView::slotShowNext()
519{ 520{
520 bool isDir = false; 521 bool isDir = false;
521 QString name = nextFileName(isDir); 522 QString name = nextFileName(isDir);
522 if (name.isEmpty()) return; 523 if (name.isEmpty()) return;
523 if (isDir) return; 524 if (isDir) return;
524 /* if we got a name we have a next item */ 525 /* if we got a name we have a next item */
525 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 526 m_view->setCurrentItem(m_view->currentItem()->nextItem());
526 slotShowImage(name); 527 slotShowImage(name);
527} 528}
528 529
529void PIconView::slotShowPrev() 530void PIconView::slotShowPrev()
530{ 531{
531 bool isDir = false; 532 bool isDir = false;
532 QString name = prevFileName(isDir); 533 QString name = prevFileName(isDir);
533 if (name.isEmpty()) return; 534 if (name.isEmpty()) return;
534 if (isDir) return; 535 if (isDir) return;
535 /* if we got a name we have a prev item */ 536 /* if we got a name we have a prev item */
536 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 537 m_view->setCurrentItem(m_view->currentItem()->prevItem());
537 slotShowImage(name); 538 slotShowImage(name);
538} 539}
539 540
540void PIconView::slotShowImage() 541void PIconView::slotShowImage()
541{ 542{
542 bool isDir = false; 543 bool isDir = false;
543 QString name = currentFileName(isDir); 544 QString name = currentFileName(isDir);
544 if (isDir) return; 545 if (isDir) return;
545 546
546 slotShowImage( name ); 547 slotShowImage( name );
547} 548}
548void PIconView::slotShowImage( const QString& name) { 549void PIconView::slotShowImage( const QString& name) {
549 emit sig_display( name ); 550 emit sig_display( name );
550} 551}
551void PIconView::slotImageInfo() { 552void PIconView::slotImageInfo() {
552 bool isDir = false; 553 bool isDir = false;
553 QString name = currentFileName(isDir); 554 QString name = currentFileName(isDir);
554 if (isDir) return; 555 if (isDir) return;
555 556
556 slotImageInfo( name ); 557 slotImageInfo( name );
557} 558}
558 559
559void PIconView::slotImageInfo( const QString& name) { 560void PIconView::slotImageInfo( const QString& name) {
560 emit sig_showInfo( name ); 561 emit sig_showInfo( name );
561} 562}
562 563
563 564
564void PIconView::slotChangeMode( int mode ) { 565void PIconView::slotChangeMode( int mode ) {
565 if ( mode >= 1 && mode <= 3 ) 566 if ( mode >= 1 && mode <= 3 )
566 m_mode = mode; 567 m_mode = mode;
567 568
568 QIconView::ItemTextPos pos; 569 m_cfg->writeEntry("ListViewMode", m_mode);
569 switch( m_mode ) {
570 case 2:
571 pos = QIconView::Bottom;
572 break;
573 case 3:
574 case 1:
575 default:
576 pos = QIconView::Right;
577 break;
578 }
579 m_view->setItemTextPos( pos );
580
581 calculateGrid(); 570 calculateGrid();
582 slotReloadDir(); 571 slotReloadDir();
583} 572}
584 573
585 574
586void PIconView::resizeEvent( QResizeEvent* re ) { 575void PIconView::resizeEvent( QResizeEvent* re ) {
587 QVBox::resizeEvent( re ); 576 QVBox::resizeEvent( re );
588 calculateGrid(); 577 calculateGrid();
589} 578}
590 579
591 580
592void PIconView::calculateGrid() { 581void PIconView::calculateGrid() {
593 odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl; 582 odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl;
594 odebug << "Size of view: " << m_view->size() << oendl; 583 odebug << "Size of view: " << m_view->size() << oendl;
584 int dw = QApplication::desktop()->width();
585 int viewerWidth = dw-style().scrollBarExtent().width();
595 586
587 QIconView::ItemTextPos pos;
588 switch( m_mode ) {
589 case 2:
590 pos = QIconView::Bottom;
591 break;
592 case 3:
593 case 1:
594 default:
595 pos = QIconView::Right;
596 break;
597 }
598 m_view->setItemTextPos( pos );
596 switch (m_mode) { 599 switch (m_mode) {
597 case 2: 600 case 2:
598 m_view->setGridX(50); 601 m_view->setGridX(50);
599 m_view->setGridY(20); 602 m_view->setGridY(20);
600 PPixmapCache::self()->setMaxImages(40); 603 PPixmapCache::self()->setMaxImages(40);
601 break; 604 break;
602 case 3: 605 case 3:
603 m_view->setGridX(m_view->width()); 606 m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
604 m_view->setGridY(8); 607 m_view->setGridY(8);
605 PPixmapCache::self()->setMaxImages(2); 608 PPixmapCache::self()->setMaxImages(2);
606 break; 609 break;
607 case 1: 610 case 1:
608 default: 611 default:
609 m_view->setGridX(m_view->width()); 612 m_view->setGridX( viewerWidth-3*m_view->spacing());
610 m_view->setGridY(80); 613 m_view->setGridY( fontMetrics().height()*2+40 );
611 PPixmapCache::self()->setMaxImages(20); 614 PPixmapCache::self()->setMaxImages(20);
612 break; 615 break;
613 } 616 }
614} 617}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index ef6e6df..a90231b 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,190 +1,192 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include "imageview.h" 6#include "imageview.h"
7 7
8#include "iconview.h" 8#include "iconview.h"
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12 12
13#include <iface/ifaceinfo.h> 13#include <iface/ifaceinfo.h>
14#include <iface/dirview.h> 14#include <iface/dirview.h>
15 15
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/owidgetstack.h> 17#include <opie2/owidgetstack.h>
18#include <opie2/oapplicationfactory.h> 18#include <opie2/oapplicationfactory.h>
19#include <opie2/otabwidget.h> 19#include <opie2/otabwidget.h>
20#include <opie2/okeyconfigwidget.h> 20#include <opie2/okeyconfigwidget.h>
21 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/ir.h> 24#include <qpe/ir.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qmap.h> 31#include <qmap.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34 34
35 35
36 36
37OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 37OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
38 38
39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 39PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
40 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 40 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
41{ 41{
42 setCaption( QObject::tr("Opie Eye Caramba" ) ); 42 setCaption( QObject::tr("Opie Eye Caramba" ) );
43 m_cfg = new Opie::Core::OConfig("phunkview"); 43 m_cfg = new Opie::Core::OConfig("phunkview");
44 m_cfg->setGroup("Zecke_view" ); 44 m_cfg->setGroup("Zecke_view" );
45// 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 int mode = m_cfg->readNumEntry("ListViewMode", 1);
95 if (mode < 1 || mode>3) mode = 1;
96 viewModeButton = new ViewModeButton( bar,mode );
95 connect( viewModeButton, SIGNAL(changeMode(int)), 97 connect( viewModeButton, SIGNAL(changeMode(int)),
96 m_view, SLOT(slotChangeMode(int))); 98 m_view, SLOT(slotChangeMode(int)));
97 99
98 btn = new QToolButton( bar ); 100 btn = new QToolButton( bar );
99 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); 101 btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
100 connect( btn, SIGNAL(clicked() ), 102 connect( btn, SIGNAL(clicked() ),
101 this, SLOT(slotConfig() ) ); 103 this, SLOT(slotConfig() ) );
102 104
103 105
104 106
105 prevButton = new QToolButton(bar); 107 prevButton = new QToolButton(bar);
106 prevButton->setIconSet( Resource::loadIconSet( "back" ) ); 108 prevButton->setIconSet( Resource::loadIconSet( "back" ) );
107 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); 109 connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev()));
108 110
109 nextButton = new QToolButton(bar); 111 nextButton = new QToolButton(bar);
110 nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); 112 nextButton->setIconSet( Resource::loadIconSet( "forward" ) );
111 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); 113 connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext()));
112 114
113 rotateButton = new QToolButton(bar); 115 rotateButton = new QToolButton(bar);
114 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); 116 rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
115 rotateButton->setToggleButton(true); 117 rotateButton->setToggleButton(true);
116 118
117 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 119 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
118 rotateButton->setOn(true); 120 rotateButton->setOn(true);
119 autoRotate = true; 121 autoRotate = true;
120 prevButton->hide(); 122 prevButton->hide();
121 nextButton->hide(); 123 nextButton->hide();
122 } else { 124 } else {
123 rotateButton->setOn(false); 125 rotateButton->setOn(false);
124 autoRotate = false; 126 autoRotate = false;
125 } 127 }
126 128
127 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 129 connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
128 130
129 btn = new QToolButton(bar); 131 btn = new QToolButton(bar);
130 btn->setIconSet( Resource::loadIconSet( "1to1" ) ); 132 btn->setIconSet( Resource::loadIconSet( "1to1" ) );
131 btn->setToggleButton(true); 133 btn->setToggleButton(true);
132 btn->setOn(false); 134 btn->setOn(false);
133 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 135 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
134 autoScale = true; 136 autoScale = true;
135 137
136 btn = new QToolButton(bar); 138 btn = new QToolButton(bar);
137 btn->setIconSet( Resource::loadIconSet( "mag" ) ); 139 btn->setIconSet( Resource::loadIconSet( "mag" ) );
138 btn->setToggleButton(true); 140 btn->setToggleButton(true);
139 btn->setOn(true); 141 btn->setOn(true);
140 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 142 connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
141 zoomerOn = true; 143 zoomerOn = true;
142} 144}
143 145
144PMainWindow::~PMainWindow() { 146PMainWindow::~PMainWindow() {
145 odebug << "Shutting down" << oendl; 147 odebug << "Shutting down" << oendl;
146} 148}
147 149
148void PMainWindow::slotZoomerToggled(bool how) 150void PMainWindow::slotZoomerToggled(bool how)
149{ 151{
150 zoomerOn = how; 152 zoomerOn = how;
151 if (m_disp) { 153 if (m_disp) {
152 m_disp->setShowZoomer(zoomerOn); 154 m_disp->setShowZoomer(zoomerOn);
153 } 155 }
154} 156}
155 157
156void PMainWindow::slotRotateToggled(bool how) 158void PMainWindow::slotRotateToggled(bool how)
157{ 159{
158 autoRotate = how; 160 autoRotate = how;
159 if (m_disp) { 161 if (m_disp) {
160 m_disp->setAutoRotate(how); 162 m_disp->setAutoRotate(how);
161 } 163 }
162} 164}
163 165
164void PMainWindow::slotScaleToggled(bool how) 166void PMainWindow::slotScaleToggled(bool how)
165{ 167{
166 autoScale = !how; 168 autoScale = !how;
167 if (!how) { 169 if (!how) {
168 autoRotate = how; 170 autoRotate = how;
169 } 171 }
170 if (m_disp) { 172 if (m_disp) {
171 m_disp->setAutoScaleRotate(autoScale,autoRotate); 173 m_disp->setAutoScaleRotate(autoScale,autoRotate);
172 } 174 }
173 if (!autoScale) { 175 if (!autoScale) {
174 rotateButton->setOn(false); 176 rotateButton->setOn(false);
175 } 177 }
176 rotateButton->setEnabled(!how); 178 rotateButton->setEnabled(!how);
177} 179}
178 180
179void PMainWindow::slotConfig() { 181void PMainWindow::slotConfig() {
180 /* 182 /*
181 * have a tab with the possible views 183 * have a tab with the possible views
182 * a tab for globals image cache size.. scaled loading 184 * a tab for globals image cache size.. scaled loading
183 * and one tab for the KeyConfigs 185 * and one tab for the KeyConfigs
184 */ 186 */
185 QDialog dlg(this, 0, true); 187 QDialog dlg(this, 0, true);
186 dlg.setCaption( tr("Phunk View - Config" ) ); 188 dlg.setCaption( tr("Phunk View - Config" ) );
187 189
188 QHBoxLayout *lay = new QHBoxLayout(&dlg); 190 QHBoxLayout *lay = new QHBoxLayout(&dlg);
189 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 191 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
190 lay->addWidget( wid ); 192 lay->addWidget( wid );
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp
index 0e4a7cb..36e5dcf 100644
--- a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp
+++ b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp
@@ -1,45 +1,45 @@
1#include "viewmodebutton.h" 1#include "viewmodebutton.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5#include <qtoolbar.h> 5#include <qtoolbar.h>
6#include <qpopupmenu.h> 6#include <qpopupmenu.h>
7 7
8ViewModeButton::ViewModeButton( QToolBar* bar ) 8ViewModeButton::ViewModeButton( QToolBar* bar,int def )
9 : QToolButton( bar ) 9 : QToolButton( bar )
10{ 10{
11 slotChange( 1 ); 11 slotChange( def );
12 QPopupMenu *pop= new QPopupMenu( this ); 12 QPopupMenu *pop= new QPopupMenu( this );
13 pop->setCheckable( true ); 13 pop->setCheckable( true );
14 pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); 14 pop->insertItem( tr("Thumbnail and Imageinfo"), 1 );
15 pop->insertItem( tr("Thumbnail and Name" ), 2 ); 15 pop->insertItem( tr("Thumbnail and Name" ), 2 );
16 pop->insertItem( tr("Name Only" ), 3 ); 16 pop->insertItem( tr("Name Only" ), 3 );
17 connect(pop, SIGNAL(activated(int)), 17 connect(pop, SIGNAL(activated(int)),
18 this, SIGNAL(changeMode(int)) ); 18 this, SIGNAL(changeMode(int)) );
19 connect(pop, SIGNAL(activated(int)), 19 connect(pop, SIGNAL(activated(int)),
20 this, SLOT(slotChange(int)) ); 20 this, SLOT(slotChange(int)) );
21 21
22 22
23 setPopup( pop ); 23 setPopup( pop );
24} 24}
25 25
26ViewModeButton::~ViewModeButton() { 26ViewModeButton::~ViewModeButton() {
27} 27}
28 28
29void ViewModeButton::slotChange( int i ) { 29void ViewModeButton::slotChange( int i ) {
30 QString name; 30 QString name;
31 switch( i ) { 31 switch( i ) {
32 case 1: 32 case 1:
33 name = "opie-eye/opie-eye-thumb"; 33 name = "opie-eye/opie-eye-thumb";
34 break; 34 break;
35 case 2: 35 case 2:
36 name = "opie-eye/opie-eye-thumbonly"; 36 name = "opie-eye/opie-eye-thumbonly";
37 break; 37 break;
38 case 3: 38 case 3:
39 name = "opie-eye/opie-eye-textview"; 39 name = "opie-eye/opie-eye-textview";
40 break; 40 break;
41 } 41 }
42 42
43 qWarning("foo %d" +name, i ); 43 qWarning("foo %d" +name, i );
44 setIconSet( Resource::loadIconSet( name ) ); 44 setIconSet( Resource::loadIconSet( name ) );
45} 45}
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.h b/noncore/graphics/opie-eye/gui/viewmodebutton.h
index 3247114..48f0e67 100644
--- a/noncore/graphics/opie-eye/gui/viewmodebutton.h
+++ b/noncore/graphics/opie-eye/gui/viewmodebutton.h
@@ -1,25 +1,25 @@
1/* 1/*
2 * GPLv2 only 2 * GPLv2 only
3 * zecke@handhelds.org 3 * zecke@handhelds.org
4 */ 4 */
5 5
6#ifndef PHUNK_VIEW_MODE_BUTTON_H 6#ifndef PHUNK_VIEW_MODE_BUTTON_H
7#define PHUNK_VIEW_MODE_BUTTON_H 7#define PHUNK_VIEW_MODE_BUTTON_H
8 8
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10 10
11#include <qtoolbutton.h> 11#include <qtoolbutton.h>
12 12
13class ViewModeButton : public QToolButton { 13class ViewModeButton : public QToolButton {
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 ViewModeButton( QToolBar* ); 16 ViewModeButton( QToolBar*,int def=1 );
17 ~ViewModeButton(); 17 ~ViewModeButton();
18 18
19signals: 19signals:
20 void changeMode( int ); 20 void changeMode( int );
21private slots: 21private slots:
22 void slotChange( int i ); 22 void slotChange( int i );
23}; 23};
24 24
25#endif 25#endif