-rw-r--r-- | noncore/graphics/opie-eye/gui/basesetup.cpp | 28 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/basesetup.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 173 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 4 |
5 files changed, 168 insertions, 43 deletions
diff --git a/noncore/graphics/opie-eye/gui/basesetup.cpp b/noncore/graphics/opie-eye/gui/basesetup.cpp index 20dda5a..fdf3466 100644 --- a/noncore/graphics/opie-eye/gui/basesetup.cpp +++ b/noncore/graphics/opie-eye/gui/basesetup.cpp @@ -15,2 +15,3 @@ BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * n m_SlidetimeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_SlidetimeLayout"); + m_IconsizeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IconsizeLayout"); @@ -31,2 +32,16 @@ BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * n + m_Iconsize = new QSpinBox( this, "m_Iconsize" ); + m_Iconsize->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); + m_Iconsize->setButtonSymbols( QSpinBox::PlusMinus ); + m_Iconsize->setMaxValue( 64 ); + m_Iconsize->setMinValue(12); + m_Iconsize->setValue( 32 ); + m_Iconsize->setSuffix(tr(" pixel")); + m_IconsizeLayout->addWidget( m_Iconsize, 0, 1 ); + m_IconsizeLabel = new QLabel( this, "m_IconsizeLabel" ); + m_IconsizeLabel->setText(tr("Size of thumbnails:")); + m_IconsizeLayout->addWidget( m_IconsizeLabel, 0, 0 ); + m_MainLayout->addLayout(m_IconsizeLayout); + + #if 0 @@ -43,3 +58,3 @@ BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * n - int stime = m_cfg->readNumEntry("base_slideshowtimeout",2); + int stime = m_cfg->readNumEntry("slideshowtimeout",2); if (stime<0) stime=2; @@ -47,3 +62,7 @@ BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * n m_SlideShowTime->setValue(stime); - m_SaveStateAuto->setChecked(m_cfg->readBoolEntry("base_savestatus",false)); + m_SaveStateAuto->setChecked(m_cfg->readBoolEntry("savestatus",true)); + stime = m_cfg->readNumEntry("iconsize", 32); + if (stime<12)stime = 12; + if (stime>64)stime = 64; + m_Iconsize->setValue(stime); } @@ -57,4 +76,5 @@ void BaseSetup::save_values() if (!m_cfg) return; - m_cfg->writeEntry("base_slideshowtimeout",m_SlideShowTime->value()); - m_cfg->writeEntry("base_savestatus",m_SaveStateAuto->isChecked()); + m_cfg->writeEntry("slideshowtimeout",m_SlideShowTime->value()); + m_cfg->writeEntry("savestatus",m_SaveStateAuto->isChecked()); + m_cfg->writeEntry("iconsize",m_Iconsize->value()); } diff --git a/noncore/graphics/opie-eye/gui/basesetup.h b/noncore/graphics/opie-eye/gui/basesetup.h index c343f88..95929f2 100644 --- a/noncore/graphics/opie-eye/gui/basesetup.h +++ b/noncore/graphics/opie-eye/gui/basesetup.h @@ -32,2 +32,5 @@ protected: QSpacerItem *spacer1; + QGridLayout * m_IconsizeLayout; + QSpinBox * m_Iconsize; + QLabel * m_IconsizeLabel; }; diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index eafff1d..c037d0d 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -43,2 +43,3 @@ namespace { static QPixmap* _unkPix = 0; + static QPixmap* _cpyPix = 0; static QPixmap* _emptyPix = 0; @@ -46,3 +47,3 @@ namespace { public: - IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); + IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); QPixmap* pixmap()const; @@ -60,2 +61,4 @@ namespace { mutable QPixmap* m_pix; + int m_iconsize; + void check_pix()const; @@ -70,3 +73,3 @@ namespace { class TextViewItem : public IconViewItem { - TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); + TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); QPixmap *pixmap()const; @@ -75,3 +78,3 @@ namespace { class ThumbViewItem : public IconViewItem { - ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); + ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); QPixmap *pixmap()const; @@ -89,3 +92,3 @@ namespace { IconViewItem::IconViewItem( QIconView* view,const QString& path, - const QString& name, bool isDir ) + const QString& name, int a_iconsize, bool isDir) : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), @@ -93,6 +96,47 @@ namespace { { - if ( isDir && !_dirPix ) - _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); - else if ( !isDir && !_unkPix ) - _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); + m_iconsize = a_iconsize; + if ( isDir ) { + if (_dirPix && _dirPix->width()!=m_iconsize) { + delete _dirPix; + _dirPix = 0; + } + if (!_dirPix ) { + _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); + } + } else { + if (!_unkPix ) { + _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); + } + } + check_pix(); + } + + inline void IconViewItem::check_pix()const + { + if (_cpyPix && _cpyPix->width()!=m_iconsize) { + delete _cpyPix; + _cpyPix = 0; + } + if (_dirPix && _dirPix->width()>m_iconsize) { + QPixmap*Pix = new QPixmap(*_dirPix); + Pix->resize(m_iconsize,m_iconsize); + delete _dirPix; + _dirPix = Pix; + } + if (!_cpyPix && _unkPix) { + if (_unkPix->width()>=m_iconsize) { + _cpyPix = new QPixmap(*_unkPix); + if (_unkPix->width()>m_iconsize) + _cpyPix->resize(m_iconsize,m_iconsize); + } else { + _cpyPix = new QPixmap(m_iconsize,m_iconsize); + _cpyPix->fill(); + QPainter pa(_cpyPix); + int offset = (m_iconsize-_unkPix->width())/2; + int offy = (m_iconsize-_unkPix->height())/2; + if (offy<0) offy=0; + pa.drawPixmap(offset,offy,*_unkPix); + pa.end(); + } + } } @@ -123,12 +167,13 @@ namespace { if (!m_noInfo && !g_stringInf.contains( m_path ) ) { - currentView()->dirLister()->imageInfo( m_path ); g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); + currentView()->dirLister()->imageInfo( m_path ); } - m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); + m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); if (!m_pix && !g_stringPix.contains( m_path )) { - currentView()->dirLister()->thumbNail( m_path, 64, 64 ); + check_pix(); g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); + currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); } - return m_pix ? m_pix : _unkPix; + return m_pix ? m_pix : _cpyPix; } @@ -155,2 +200,3 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) m_mode = 0; + m_iconsize = 32; m_internalReset = false; @@ -177,2 +223,10 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) m_view->setItemTextPos( QIconView::Right ); + if (m_mode >1) { + m_view->setResizeMode(QIconView::Adjust); + } else { + m_view->setResizeMode(QIconView::Fixed); + } + m_iconsize = m_cfg->readNumEntry("iconsize", 32); + if (m_iconsize<12)m_iconsize = 12; + if (m_iconsize>64)m_iconsize = 64; @@ -282,2 +336,6 @@ void PIconView::slotChangeDir(const QString& path) { + // Also invalidate the cache. We can't cancel the operations anyway + g_stringPix.clear(); + g_stringInf.clear(); + /* @@ -289,6 +347,2 @@ void PIconView::slotChangeDir(const QString& path) { - // Also invalidate the cache. We can't cancel the operations anyway - g_stringPix.clear(); - g_stringInf.clear(); - // looks ugly @@ -367,2 +421,12 @@ void PIconView::resetView() { m_internalReset = true; + // Also invalidate the cache. We can't cancel the operations anyway + g_stringPix.clear(); + g_stringInf.clear(); + if (m_mode>1) { + m_iconsize = m_cfg->readNumEntry("iconsize", 32); + if (m_iconsize<12)m_iconsize = 12; + if (m_iconsize>64)m_iconsize = 64; + } else { + m_iconsize = 64; + } slotViewChanged(m_views->currentItem()); @@ -415,4 +479,5 @@ void PIconView::slotViewChanged( int i) { */ - if (!m_internalReset) + if (!m_internalReset) { m_path = lis->defaultPath(); + } QTimer::singleShot( 0, this, SLOT(slotReloadDir())); @@ -434,3 +499,3 @@ void PIconView::addFolders( const QStringList& lst) { for(it=lst.begin(); it != lst.end(); ++it ) { - _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); + _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); if (m_mode==3) _iv->setTextOnly(true); @@ -448,4 +513,4 @@ void PIconView::addFiles( const QStringList& lst) { for (it=lst.begin(); it!= lst.end(); ++it ) { - m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); - _iv = new IconViewItem( m_view, pre+(*it), (*it) ); + m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); + _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); if (m_mode==3) { @@ -526,8 +591,23 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { if (pix.width()>0) { - PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); - item->setPixmap(pix,true); + if (pix.width()<m_iconsize) { + QPixmap p(m_iconsize,m_iconsize); + p.fill(); + QPainter pa(&p); + int offset = (m_iconsize-pix.width())/2; + int offy = (m_iconsize-pix.height())/2; + if (offy<0) offy=0; + pa.drawPixmap(offset,offy,pix); + pa.end(); + PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); + item->setPixmap(p,true); + } else { + PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); + item->setPixmap(pix,true); + } + } else { - PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); + PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); } g_stringPix.remove( _path ); + m_view->arrangeItemsInGrid(true); } @@ -693,3 +773,3 @@ void PIconView::slotStartSlide() { } - int t = m_cfg->readNumEntry("base_slideshowtimeout", 2); + int t = m_cfg->readNumEntry("slideshowtimeout", 2); emit sig_startslide(t); @@ -712,10 +792,23 @@ void PIconView::slotImageInfo( const QString& name) { void PIconView::slotChangeMode( int mode ) { - if ( mode >= 1 && mode <= 3 ) + if ( mode >= 1 && mode <= 3 ) { m_mode = mode; + m_cfg->writeEntry("ListViewMode", m_mode); + /* performance! */ + m_view->clear(); + if (m_mode >1) { + m_view->setResizeMode(QIconView::Adjust); + } else { + m_view->setResizeMode(QIconView::Fixed); + } + if (m_mode==1) { + m_iconsize = 64; + } else { + m_iconsize = m_cfg->readNumEntry("iconsize", 32); + if (m_iconsize<12)m_iconsize = 12; + if (m_iconsize>64)m_iconsize = 64; + } - m_cfg->writeEntry("ListViewMode", m_mode); - /* performance! */ - m_view->clear(); - calculateGrid(); - slotReloadDir(); + calculateGrid(); + slotReloadDir(); + } } @@ -724,4 +817,5 @@ void PIconView::slotChangeMode( int mode ) { void PIconView::resizeEvent( QResizeEvent* re ) { + calculateGrid(re); QVBox::resizeEvent( re ); - calculateGrid(); + //calculateGrid(); } @@ -729,5 +823,11 @@ void PIconView::resizeEvent( QResizeEvent* re ) { -void PIconView::calculateGrid() { - int dw = QApplication::desktop()->width(); - int viewerWidth = dw-style().scrollBarExtent().width(); +void PIconView::calculateGrid(QResizeEvent* re) +{ + int viewerWidth; + if (re) { + viewerWidth=re->size().width(); + } else { + int dw = QApplication::desktop()->width(); + viewerWidth = dw-style().scrollBarExtent().width(); + } @@ -747,4 +847,4 @@ void PIconView::calculateGrid() { case 2: - m_view->setGridX(50); - m_view->setGridY(20); + m_view->setGridX(m_iconsize); + m_view->setGridY(-1); PPixmapCache::self()->setMaxImages(40); @@ -763,2 +863,3 @@ void PIconView::calculateGrid() { } + m_view->setSpacing(10); } diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index bea35c2..b018c51 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h @@ -57,3 +57,3 @@ private: void loadViews(); - void calculateGrid(); + void calculateGrid(QResizeEvent*e = 0); @@ -98,2 +98,3 @@ private: bool m_internalReset:1; + int m_iconsize; }; diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 30c9bf1..67eb277 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -206,3 +206,2 @@ void PMainWindow::slotConfig() { if ( act ) { - m_view->resetView(); keyWid->save(); @@ -212,2 +211,3 @@ void PMainWindow::slotConfig() { bSetup->save_values(); + m_view->resetView(); readConfig(); @@ -694,3 +694,3 @@ void PMainWindow::readConfig() { - autoSave =m_cfg->readBoolEntry("base_savestatus",true); + autoSave =m_cfg->readBoolEntry("savestatus",true); } |