summaryrefslogtreecommitdiff
authordrw <drw>2005-04-03 17:21:58 (UTC)
committer drw <drw>2005-04-03 17:21:58 (UTC)
commitbe7d04d2b402e5515cfac3a2b32ed5831e15340b (patch) (unidiff)
treeed5829eb8cd46c222fc9e201c5a08a28fca23c87
parent5929a5467aacf1b95a570bdb560d03b28d9ae679 (diff)
downloadopie-be7d04d2b402e5515cfac3a2b32ed5831e15340b.zip
opie-be7d04d2b402e5515cfac3a2b32ed5831e15340b.tar.gz
opie-be7d04d2b402e5515cfac3a2b32ed5831e15340b.tar.bz2
Fix buttons so images scale correctly
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 069b625..8b53038 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -243,223 +243,229 @@ QWidget* ODocumentFileView::widget( QWidget* parent )
243 243
244 return m_selector; 244 return m_selector;
245} 245}
246 246
247/* 247/*
248 * This is the file system view used 248 * This is the file system view used
249 * we use a QListView + QListViewItems for it 249 * we use a QListView + QListViewItems for it
250 */ 250 */
251 251
252OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 252OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
253 const QString& path, const QString& date, 253 const QString& path, const QString& date,
254 const QString& size, const QString& dir, 254 const QString& size, const QString& dir,
255 bool isLocked, bool isDir ) 255 bool isLocked, bool isDir )
256 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) 256 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked)
257{ 257{
258 setPixmap(0, pixmap ); 258 setPixmap(0, pixmap );
259 setText(1, path ); 259 setText(1, path );
260 setText(2, size ); 260 setText(2, size );
261 setText(3, date ); 261 setText(3, date );
262} 262}
263 263
264OFileSelectorItem::~OFileSelectorItem() 264OFileSelectorItem::~OFileSelectorItem()
265{ 265{
266} 266}
267 267
268bool OFileSelectorItem::isLocked()const 268bool OFileSelectorItem::isLocked()const
269{ 269{
270 return m_locked; 270 return m_locked;
271} 271}
272 272
273QString OFileSelectorItem::directory()const 273QString OFileSelectorItem::directory()const
274{ 274{
275 return m_dir; 275 return m_dir;
276} 276}
277 277
278bool OFileSelectorItem::isDir()const 278bool OFileSelectorItem::isDir()const
279{ 279{
280 return m_isDir; 280 return m_isDir;
281} 281}
282 282
283QString OFileSelectorItem::path()const 283QString OFileSelectorItem::path()const
284{ 284{
285 return text( 1 ); 285 return text( 1 );
286} 286}
287 287
288QString OFileSelectorItem::key( int id, bool )const 288QString OFileSelectorItem::key( int id, bool )const
289{ 289{
290 QString ke; 290 QString ke;
291 291
292 /* 292 /*
293 * id = 0 ||id == 1 : Sort By Name but Directories at Top 293 * id = 0 ||id == 1 : Sort By Name but Directories at Top
294 * id = 2 : Sort By Size: Prepend '0' to the key 294 * id = 2 : Sort By Size: Prepend '0' to the key
295 */ 295 */
296 if( id == 0 || id == 1 ) 296 if( id == 0 || id == 1 )
297 { // name 297 { // name
298 if( m_isDir ) 298 if( m_isDir )
299 { 299 {
300 ke.append("0" ); 300 ke.append("0" );
301 ke.append( text(1) ); 301 ke.append( text(1) );
302 } 302 }
303 else 303 else
304 { 304 {
305 ke.append("1" ); 305 ke.append("1" );
306 ke.append( text(1) ); 306 ke.append( text(1) );
307 } 307 }
308 return ke; 308 return ke;
309 }else if(id == 2) { 309 }else if(id == 2) {
310 return text(2).rightJustify(20, '0'); 310 return text(2).rightJustify(20, '0');
311 }else 311 }else
312 return text( id ); 312 return text( id );
313 313
314} 314}
315 315
316OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 316OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
317 :QWidget( parent ), m_sel( sel ) 317 :QWidget( parent ), m_sel( sel )
318{ 318{
319 m_all = false; 319 m_all = false;
320 QVBoxLayout* lay = new QVBoxLayout( this ); 320 QVBoxLayout* lay = new QVBoxLayout( this );
321 m_currentDir = startDir; 321 m_currentDir = startDir;
322 322
323 /* 323 /*
324 * now we add a special bar 324 * now we add a special bar
325 * One Button For Up 325 * One Button For Up
326 * Home 326 * Home
327 * Doc 327 * Doc
328 * And a dropdown menu with FileSystems 328 * And a dropdown menu with FileSystems
329 * FUTURE: one to change dir with lineedit 329 * FUTURE: one to change dir with lineedit
330 * Bookmarks 330 * Bookmarks
331 * Create Dir 331 * Create Dir
332 */ 332 */
333 QHBox* box = new QHBox(this ); 333 QHBox* box = new QHBox(this );
334 box->setBackgroundMode( PaletteButton ); 334 box->setBackgroundMode( PaletteButton );
335 box->setSpacing( 0 ); 335 box->setSpacing( 0 );
336 336
337 QPixmap pic; 337 QPixmap pic;
338 QToolButton *btn = new QToolButton( box ); 338 QToolButton *btn = new QToolButton( box );
339 btn->setUsesBigPixmap( true );
339 pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 340 pic.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
340 btn->setPixmap( pic ); 341 btn->setPixmap( pic );
341 connect(btn, SIGNAL(clicked() ), 342 connect(btn, SIGNAL(clicked() ),
342 this, SLOT( cdUP() ) ); 343 this, SLOT( cdUP() ) );
343 344
344 btn = new QToolButton( box ); 345 btn = new QToolButton( box );
346 btn->setUsesBigPixmap( true );
345 pic.convertFromImage( Resource::loadImage( "home" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 347 pic.convertFromImage( Resource::loadImage( "home" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
346 btn->setPixmap( pic ); 348 btn->setPixmap( pic );
347 connect(btn, SIGNAL(clicked() ), 349 connect(btn, SIGNAL(clicked() ),
348 this, SLOT( cdHome() ) ); 350 this, SLOT( cdHome() ) );
349 351
350 btn = new QToolButton( box ); 352 btn = new QToolButton( box );
353 btn->setUsesBigPixmap( true );
351 pic.convertFromImage( Resource::loadImage( "DocsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 354 pic.convertFromImage( Resource::loadImage( "DocsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
352 btn->setPixmap( pic ); 355 btn->setPixmap( pic );
353 connect(btn, SIGNAL(clicked() ), 356 connect(btn, SIGNAL(clicked() ),
354 this, SLOT(cdDoc() ) ); 357 this, SLOT(cdDoc() ) );
355 358
356 m_btnNew = new QToolButton( box ); 359 m_btnNew = new QToolButton( box );
360 m_btnNew->setUsesBigPixmap( true );
357 pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 361 pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
358 m_btnNew->setPixmap( pic ); 362 m_btnNew->setPixmap( pic );
359 connect(m_btnNew, SIGNAL(clicked() ), 363 connect(m_btnNew, SIGNAL(clicked() ),
360 this, SLOT(slotNew() ) ); 364 this, SLOT(slotNew() ) );
361 365
362 366
363 m_btnClose = new QToolButton( box ); 367 m_btnClose = new QToolButton( box );
368 m_btnClose->setUsesBigPixmap( true );
364 pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 369 pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
365 m_btnClose->setPixmap( pic ); 370 m_btnClose->setPixmap( pic );
366 connect(m_btnClose, SIGNAL(clicked() ), 371 connect(m_btnClose, SIGNAL(clicked() ),
367 selector(), SIGNAL(closeMe() ) ); 372 selector(), SIGNAL(closeMe() ) );
368 373
369 btn = new QToolButton( box ); 374 btn = new QToolButton( box );
375 btn->setUsesBigPixmap( true );
370 pic.convertFromImage( Resource::loadImage( "cardmon/pcmcia" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 376 pic.convertFromImage( Resource::loadImage( "cardmon/pcmcia" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
371 btn->setPixmap( pic ); 377 btn->setPixmap( pic );
372 378
373 m_fsButton = btn; 379 m_fsButton = btn;
374 /* let's fill device parts */ 380 /* let's fill device parts */
375 QPopupMenu* pop = new QPopupMenu(this); 381 QPopupMenu* pop = new QPopupMenu(this);
376 connect(pop, SIGNAL( activated(int) ), 382 connect(pop, SIGNAL( activated(int) ),
377 this, SLOT(slotFSActivated(int) ) ); 383 this, SLOT(slotFSActivated(int) ) );
378 384
379 StorageInfo storage; 385 StorageInfo storage;
380 const QList<FileSystem> &fs = storage.fileSystems(); 386 const QList<FileSystem> &fs = storage.fileSystems();
381 QListIterator<FileSystem> it(fs); 387 QListIterator<FileSystem> it(fs);
382 for ( ; it.current(); ++it ) 388 for ( ; it.current(); ++it )
383 { 389 {
384 const QString disk = (*it)->name(); 390 const QString disk = (*it)->name();
385 const QString path = (*it)->path(); 391 const QString path = (*it)->path();
386 m_dev.insert( disk, path ); 392 m_dev.insert( disk, path );
387 pop->insertItem( disk ); 393 pop->insertItem( disk );
388 } 394 }
389 m_fsPop = pop; 395 m_fsPop = pop;
390 396
391 connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed())); 397 connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed()));
392 398
393 lay->addWidget( box ); 399 lay->addWidget( box );
394 400
395 m_view = new QListView( this ); 401 m_view = new QListView( this );
396 402
397 m_view->installEventFilter(this); 403 m_view->installEventFilter(this);
398 404
399 QPEApplication::setStylusOperation( m_view->viewport(), 405 QPEApplication::setStylusOperation( m_view->viewport(),
400 QPEApplication::RightOnHold); 406 QPEApplication::RightOnHold);
401 m_view->addColumn(" " ); 407 m_view->addColumn(" " );
402 m_view->addColumn(tr("Name"), 135 ); 408 m_view->addColumn(tr("Name"), 135 );
403 m_view->addColumn(tr("Size"), -1 ); 409 m_view->addColumn(tr("Size"), -1 );
404 m_view->addColumn(tr("Date"), 60 ); 410 m_view->addColumn(tr("Date"), 60 );
405 m_view->addColumn(tr("Mime Type"), -1 ); 411 m_view->addColumn(tr("Mime Type"), -1 );
406 412
407 413
408 m_view->setSorting( 1 ); 414 m_view->setSorting( 1 );
409 m_view->setAllColumnsShowFocus( TRUE ); 415 m_view->setAllColumnsShowFocus( TRUE );
410 416
411 lay->addWidget( m_view, 1000 ); 417 lay->addWidget( m_view, 1000 );
412 connectSlots(); 418 connectSlots();
413} 419}
414 420
415void OFileViewFileListView::slotFSpressed() 421void OFileViewFileListView::slotFSpressed()
416{ 422{
417 m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y())); 423 m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y()));
418 m_fsButton->setDown(false); 424 m_fsButton->setDown(false);
419} 425}
420 426
421OFileViewFileListView::~OFileViewFileListView() 427OFileViewFileListView::~OFileViewFileListView()
422{ 428{
423} 429}
424 430
425void OFileViewFileListView::slotNew() 431void OFileViewFileListView::slotNew()
426{ 432{
427 DocLnk lnk; 433 DocLnk lnk;
428 emit selector()->newSelected( lnk ); 434 emit selector()->newSelected( lnk );
429} 435}
430 436
431OFileSelectorItem* OFileViewFileListView::currentItem()const 437OFileSelectorItem* OFileViewFileListView::currentItem()const
432{ 438{
433 QListViewItem* item = m_view->currentItem(); 439 QListViewItem* item = m_view->currentItem();
434 if (!item ) 440 if (!item )
435 return 0l; 441 return 0l;
436 442
437 return static_cast<OFileSelectorItem*>(item); 443 return static_cast<OFileSelectorItem*>(item);
438} 444}
439 445
440void OFileViewFileListView::reread( bool all ) 446void OFileViewFileListView::reread( bool all )
441{ 447{
442 m_view->clear(); 448 m_view->clear();
443 449
444 if (selector()->showClose() ) 450 if (selector()->showClose() )
445 m_btnClose->show(); 451 m_btnClose->show();
446 else 452 else
447 m_btnClose->hide(); 453 m_btnClose->hide();
448 454
449 if (selector()->showNew() ) 455 if (selector()->showNew() )
450 m_btnNew->show(); 456 m_btnNew->show();
451 else 457 else
452 m_btnNew->hide(); 458 m_btnNew->hide();
453 459
454 m_mimes = selector()->currentMimeType(); 460 m_mimes = selector()->currentMimeType();
455 m_all = all; 461 m_all = all;
456 462
457 QDir dir( m_currentDir ); 463 QDir dir( m_currentDir );
458 if (!dir.exists() ) 464 if (!dir.exists() )
459 return; 465 return;
460 466
461 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 467 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
462 int filter; 468 int filter;
463 filter = QDir::Dirs; 469 filter = QDir::Dirs;
464 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) 470 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR )
465 filter = filter | QDir::Files | QDir::All; 471 filter = filter | QDir::Files | QDir::All;