summaryrefslogtreecommitdiff
authoralwin <alwin>2004-11-06 02:57:25 (UTC)
committer alwin <alwin>2004-11-06 02:57:25 (UTC)
commit90d458c63d274a66ca427710b88e2f090a0ab11b (patch) (side-by-side diff)
tree582f2c051681e5c10313a9a79fdc7b544c288f26
parenta93a0ee1fce8b2fb7abac475a97dac8001aed8e0 (diff)
downloadopie-90d458c63d274a66ca427710b88e2f090a0ab11b.zip
opie-90d458c63d274a66ca427710b88e2f090a0ab11b.tar.gz
opie-90d458c63d274a66ca427710b88e2f090a0ab11b.tar.bz2
a lots of tests with the iconview, user can now setup the prefered icon-size,
but still some rewrites/redesigns needed. QIconView(Item) is sometimes horrible. some default-values changed
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/basesetup.cpp28
-rw-r--r--noncore/graphics/opie-eye/gui/basesetup.h3
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp157
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h3
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp4
5 files changed, 160 insertions, 35 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
@@ -1,60 +1,80 @@
#include "basesetup.h"
#include <qlabel.h>
#include <qlayout.h>
#include <qspinbox.h>
#include <qcheckbox.h>
BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * name, WFlags f)
:QFrame(parent,name,f)
{
setFrameStyle(Box|Raised);
m_cfg = a_cfg;
m_MainLayout = new QVBoxLayout( this, 11, 6, "m_MainLayout");
m_SlidetimeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_SlidetimeLayout");
+ m_IconsizeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IconsizeLayout");
m_SlideShowTime = new QSpinBox( this, "m_SlideShowTime" );
m_SlideShowTime->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed));
m_SlideShowTime->setButtonSymbols( QSpinBox::PlusMinus );
m_SlideShowTime->setMaxValue( 60 );
m_SlideShowTime->setMinValue(0);
m_SlideShowTime->setValue( 2 );
m_SlideShowTime->setSuffix(tr(" seconds"));
m_SlidetimeLayout->addWidget( m_SlideShowTime, 0, 1 );
m_SlidetimeLabel = new QLabel( this, "m_SlidetimeLabel" );
m_SlidetimeLabel->setText(tr("Slideshow timeout:"));
m_SlidetimeLayout->addWidget( m_SlidetimeLabel, 0, 0 );
m_MainLayout->addLayout( m_SlidetimeLayout );
+ 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
m_ShowToolBar = new QCheckBox( this, "m_ShowToolBar" );
m_ShowToolBar->setText(tr("Show toolbar on startup"));
m_MainLayout->addWidget( m_ShowToolBar );
#endif
m_SaveStateAuto = new QCheckBox( this, "m_SaveStateAuto" );
m_SaveStateAuto->setText(tr("Save status of fullscreen/autorotate"));
m_MainLayout->addWidget( m_SaveStateAuto );
spacer1 = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
m_MainLayout->addItem( spacer1 );
- int stime = m_cfg->readNumEntry("base_slideshowtimeout",2);
+ int stime = m_cfg->readNumEntry("slideshowtimeout",2);
if (stime<0) stime=2;
if (stime>60) stime=60;
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);
}
BaseSetup::~BaseSetup()
{
}
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
@@ -1,35 +1,38 @@
#ifndef _BASESETUP_H
#define _BASESETUP_H
#include <opie2/oconfig.h>
#include <qframe.h>
class QVBoxLayout;
class QGridLayout;
class QSpinBox;
class QLabel;
class QCheckBox;
class QSpacerItem;
class BaseSetup:public QFrame
{
Q_OBJECT
public:
BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent=0, const char * name=0, WFlags f=0);
virtual ~BaseSetup();
public slots:
virtual void save_values();
protected:
Opie::Core::OConfig *m_cfg;
QVBoxLayout * m_MainLayout;
QGridLayout * m_SlidetimeLayout;
QSpinBox * m_SlideShowTime;
QLabel * m_SlidetimeLabel;
QCheckBox *m_SaveStateAuto;
QSpacerItem *spacer1;
+ QGridLayout * m_IconsizeLayout;
+ QSpinBox * m_Iconsize;
+ QLabel * m_IconsizeLabel;
};
#endif
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
@@ -1,764 +1,865 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#include "iconview.h"
#include <lib/imagecache.h>
#include <gui/imageinfoui.h>
#include <iface/dirview.h>
#include <iface/dirlister.h>
#include <opie2/oconfig.h>
#include <opie2/okeyconfigwidget.h>
#include <opie2/odebug.h>
#include <opie2/oimagescrollview.h>
#include <qpe/resource.h>
#include <qpe/qpemessagebox.h>
#include <qpe/ir.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qiconview.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qcombobox.h>
#include <qdir.h>
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtimer.h>
#include <qstyle.h>
using Opie::Core::OKeyConfigItem;
/*
* The Icons, Request Cache and IconViewItem for the IconView
*/
namespace {
static QPixmap* _dirPix = 0;
static QPixmap* _unkPix = 0;
+ static QPixmap* _cpyPix = 0;
static QPixmap* _emptyPix = 0;
class IconViewItem : public QIconViewItem {
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;
QString path()const { return m_path; }
bool isDir()const { return m_isDir; }
void setText( const QString& );
bool textOnly()const{return m_textOnly;}
void setTextOnly(bool how){m_textOnly=how;}
/* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
/* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon);
protected:
mutable QPixmap* m_pix;
+ int m_iconsize;
+ void check_pix()const;
private:
QString m_path;
bool m_isDir : 1;
bool m_noInfo :1;
bool m_textOnly:1;
bool m_NameOnly:1;
bool m_Pixset:1;
};
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;
void setText( const QString& );
};
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;
void setText( const QString& );
};
/*
* If we request an Image or String
* we add it to the map
*/
static QMap<QString, IconViewItem*> g_stringInf;
static QMap<QString, IconViewItem*> g_stringPix;
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 ),
m_noInfo( false ),m_textOnly(false),m_Pixset(false)
{
- if ( isDir && !_dirPix )
+ 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 ( !isDir && !_unkPix )
+ }
+ } 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();
+ }
+ }
+ }
inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
{
m_Pixset = true;
calcRect(text());
}
inline void IconViewItem::setPixmap( const QPixmap & )
{
m_Pixset = true;
calcRect(text());
}
inline QPixmap* IconViewItem::pixmap()const {
// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
// << " " << iconView()->contentsY() << oendl;
if (textOnly()&&!m_isDir) {
if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
return _emptyPix;
}
if ( m_isDir )
return _dirPix;
else{
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;
}
}
inline void IconViewItem::setText( const QString& str ) {
QString text = QIconViewItem::text()+"\n"+str;
m_noInfo = true;
QIconViewItem::setText( text );
}
}
/*
* Set up the GUI.. initialize the slave set up gui
* and also load a dir
*/
PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
: QVBox( wid ), m_cfg( cfg ), m_updatet( false )
{
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
}
m_path = QDir::homeDirPath();
m_mode = 0;
+ m_iconsize = 32;
m_internalReset = false;
QHBox *hbox = new QHBox( this );
QLabel* lbl = new QLabel( hbox );
lbl->setText( tr("View as" ) );
m_views = new QComboBox( hbox, "View As" );
m_view= new QIconView( this );
connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
this, SLOT(slotClicked(QIconViewItem*)) );
connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
this, SLOT(slotClicked(QIconViewItem*)) );
m_view->setArrangement( QIconView::LeftToRight );
m_mode = m_cfg->readNumEntry("ListViewMode", 1);
QString lastView = m_cfg->readEntry("LastView","");
if (m_mode < 1 || m_mode>3) m_mode = 1;
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;
calculateGrid();
initKeys();
loadViews();
int cc=0;
for (; cc<m_views->count();++cc) {
if (m_views->text(cc)==lastView) {
break;
}
}
if (cc<m_views->count()) {
m_views->setCurrentItem(cc);
slotViewChanged(cc);
} else {
slotViewChanged(m_views->currentItem());
}
connect( m_views, SIGNAL(activated(int)),
this, SLOT(slotViewChanged(int)) );
}
/*
* Unref the slave and save the keyboard manager
*/
PIconView::~PIconView() {
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
}
m_viewManager->save();
delete m_viewManager;
}
Opie::Core::OKeyConfigManager* PIconView::manager() {
return m_viewManager;
}
/*
* init the KeyBoard Shortcuts
* called from the c'tor
*/
void PIconView::initKeys() {
Opie::Core::OKeyPair::List lst;
lst.append( Opie::Core::OKeyPair::upArrowKey() );
lst.append( Opie::Core::OKeyPair::downArrowKey() );
lst.append( Opie::Core::OKeyPair::leftArrowKey() );
lst.append( Opie::Core::OKeyPair::rightArrowKey() );
lst.append( Opie::Core::OKeyPair::returnKey() );
m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
lst, false,this, "keyconfig name" );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
Resource::loadPixmap("beam"), BeamItem,
Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
this, SLOT(slotBeam())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
Resource::loadPixmap("trash"), DeleteItem,
Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
this, SLOT(slotTrash())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
Resource::loadPixmap("1to1"), ViewItem,
Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
this, SLOT(slotShowImage())));
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
Resource::loadPixmap("DocumentTypeWord"), InfoItem,
Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
this, SLOT(slotImageInfo()) ) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
Resource::loadPixmap("1to1"), SlideItem,
Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
this, SLOT(slotStartSlide())));
m_viewManager->load();
m_viewManager->handleWidget( m_view );
}
/*
* change one dir up
*/
void PIconView::slotDirUp()
{
slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
}
/*
* change the dir
*/
void PIconView::slotChangeDir(const QString& path) {
if ( !currentView() )
return;
PDirLister *lister = currentView()->dirLister();
if (!lister )
return;
/*
* Say what we want and take what we get
*/
lister->setStartPath( path );
m_path = lister->currentPath();
m_view->viewport()->setUpdatesEnabled( false );
m_view->clear();
+ // Also invalidate the cache. We can't cancel the operations anyway
+ g_stringPix.clear();
+ g_stringInf.clear();
+
/*
* add files and folders
*/
addFolders( lister->folders() );
addFiles( lister->files() );
m_view->viewport()->setUpdatesEnabled( true );
- // Also invalidate the cache. We can't cancel the operations anyway
- g_stringPix.clear();
- g_stringInf.clear();
-
// looks ugly
static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
}
/**
* get the current file name
* @param isDir see if this is a dir or real file
*/
QString PIconView::currentFileName(bool &isDir)const {
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
QString PIconView::nextFileName(bool &isDir)const
{
isDir = false;
QIconViewItem* _it1 = m_view->currentItem();
if ( !_it1 )
return QString::null;
QIconViewItem* _it = _it1->nextItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
QString PIconView::prevFileName(bool &isDir)const{
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
_it = _it->prevItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
void PIconView::slotTrash() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
if (!QPEMessageBox::confirmDelete( this,
tr("Delete Image" ),
tr("the Image %1" ).arg(pa)))
return
currentView()->dirLister()->deleteImage( pa );
delete m_view->currentItem();
}
/*
* see what views are available
*/
void PIconView::loadViews() {
ViewMap::Iterator it;
ViewMap* map = viewMap();
for ( it = map->begin(); it != map->end(); ++it )
m_views->insertItem( it.key() );
}
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());
m_internalReset = false;
}
/*
*swicth view reloadDir and connect signals
*/
void PIconView::slotViewChanged( int i) {
if (!m_views->count() ) {
setCurrentView( 0l);
return;
}
PDirView* cur = currentView();
if (cur) delete cur;
QString str = m_views->text(i);
ViewMap* map = viewMap();
if (!map) {
setCurrentView(0l);
return;
}
if (map->find(str) == map->end()) {
owarn << "Key not found" << oendl;
setCurrentView(0l);
return;
}
m_cfg->writeEntry("LastView",str);
m_cfg->write();
cur = (*(*map)[str])(*m_cfg);
setCurrentView( cur );
/* connect to the signals of the lister */
PDirLister* lis = cur->dirLister();
connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
this, SLOT( slotThumbInfo(const QString&, const QString&)));
connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
connect(lis, SIGNAL(sig_start()),
this, SLOT(slotStart()));
connect(lis, SIGNAL(sig_end()) ,
this, SLOT(slotEnd()) );
/* reload now with default Path
* but only if it isn't a reset like from setupdlg
*/
- if (!m_internalReset)
+ if (!m_internalReset) {
m_path = lis->defaultPath();
+ }
QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
}
void PIconView::slotReloadDir() {
slotChangeDir( m_path );
}
/*
* add files and folders
*/
void PIconView::addFolders( const QStringList& lst) {
QStringList::ConstIterator it;
IconViewItem * _iv;
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);
}
}
void PIconView::addFiles( const QStringList& lst) {
QStringList::ConstIterator it;
IconViewItem * _iv;
QPixmap*m_pix = 0;
QString pre = "";
if (!m_path.isEmpty()) {
pre = m_path+"/";
}
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) {
_iv->setTextOnly(true);
_iv->setPixmap(QPixmap());
} else {
if (m_pix) _iv->setPixmap(*m_pix);
}
}
}
/*
* user clicked on the item. Change dir or view
*/
void PIconView::slotClicked(QIconViewItem* _it) {
if(!_it )
return;
IconViewItem* it = static_cast<IconViewItem*>(_it);
if( it->isDir() )
slotChangeDir( it->path() );
else // view image
slotShowImage();
}
/*
* Return was pressed. which is triggered by the keydown
* handler. The problem is that the key up will be handled
* by the ImageDisplayer and goes to the next image
*/
void PIconView::slotRetrun( QIconViewItem *_it ) {
if(!_it )
return;
IconViewItem* it = static_cast<IconViewItem*>(_it);
if( it->isDir() )
slotChangeDir( it->path() );
else
QTimer::singleShot(0, this, SLOT(slotShowImage()) );
}
/*
* got thumb info add to the cache if items is visible
* we later need update after processing of slave is done
*/
void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
IconViewItem* item = g_stringInf[_path];
if (!item )
return;
if (m_mode == 2) {
return;
}
if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
m_view->contentsWidth(), m_view->contentsHeight() ) ) )
m_updatet = true;
item->setText( str );
g_stringInf.remove( _path );
}
/*
* got thumbnail and see if it is visible so we need to update later
*/
void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
IconViewItem* item = g_stringPix[_path];
if (!item )
return;
if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
m_view->contentsWidth(), m_view->contentsHeight() ) ) )
m_updatet = true;
if (pix.width()>0) {
- PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
+ 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);
}
/*
* FIXME rename
*/
void PIconView::slotRename() {
}
/*
* BEAM the current file
*/
void PIconView::slotBeam() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
Ir* ir = new Ir( this );
connect( ir, SIGNAL(done(Ir*)),
this, SLOT(slotBeamDone(Ir*)));
ir->send(pa, tr( "Image" ) );
}
/*
* BEAM done clean up
*/
void PIconView::slotBeamDone( Ir* ir) {
delete ir;
}
void PIconView::slotStart() {
m_view->viewport()->setUpdatesEnabled( false );
}
void PIconView::slotEnd() {
if ( m_updatet )
m_view->arrangeItemsInGrid( );
m_view->viewport()->setUpdatesEnabled( true );
m_updatet = false;
}
void PIconView::slotShowLast()
{
QIconViewItem* last_it = m_view->lastItem();
if (!last_it) return;
m_view->setCurrentItem(last_it);
IconViewItem* it = static_cast<IconViewItem*>( last_it );
bool isDir = it->isDir();
QString name = it->path();
if (!isDir && !name.isEmpty()) {
slotShowImage(name);
return;
}
bool first_loop = true;
while(isDir==true) {
if (!first_loop) {
m_view->setCurrentItem(m_view->currentItem()->prevItem());
} else {
first_loop = false;
}
name = prevFileName(isDir);
}
if (name.isEmpty()) return;
/* if we got a name we have a prev item */
m_view->setCurrentItem(m_view->currentItem()->prevItem());
slotShowImage(name);
}
bool PIconView::slotShowFirst()
{
/* stop when reached - otherwise we may get an endless loop */
QIconViewItem* first_it = m_view->firstItem();
if (!first_it) return false;
m_view->setCurrentItem(first_it);
IconViewItem* it = static_cast<IconViewItem*>( first_it );
bool isDir = it->isDir();
QString name = it->path();
if (!isDir && !name.isEmpty()) {
slotShowImage(name);
return false;
}
bool first_loop = true;
while(isDir==true) {
/* if name is empty isDir is false, too. */
if (!first_loop) {
m_view->setCurrentItem(m_view->currentItem()->nextItem());
} else {
first_loop = false;
}
name = nextFileName(isDir);
}
if (name.isEmpty()) return false;
/* if we got a name we have a next item */
m_view->setCurrentItem(m_view->currentItem()->nextItem());
slotShowImage(name);
return true;
}
void PIconView::slotShowNext()
{
bool isDir = false;
QString name = nextFileName(isDir);
while (isDir==true) {
m_view->setCurrentItem(m_view->currentItem()->nextItem());
name = nextFileName(isDir);
}
if (name.isEmpty()) {
slotShowFirst();
return;
}
if (isDir) return;
/* if we got a name we have a next item */
m_view->setCurrentItem(m_view->currentItem()->nextItem());
slotShowImage(name);
}
void PIconView::slotShowPrev()
{
bool isDir = false;
QString name = prevFileName(isDir);
while (isDir==true) {
/* if name is empty isDir is false, too. */
m_view->setCurrentItem(m_view->currentItem()->prevItem());
name = prevFileName(isDir);
}
if (name.isEmpty()) {
slotShowLast();
return;
}
if (isDir) return;
/* if we got a name we have a prev item */
m_view->setCurrentItem(m_view->currentItem()->prevItem());
slotShowImage(name);
}
void PIconView::slotShowImage()
{
bool isDir = false;
QString name = currentFileName(isDir);
if (isDir) return;
slotShowImage( name );
}
void PIconView::slotShowImage( const QString& name) {
PDirLister *lister = currentView()->dirLister();
QString r_name = lister->nameToFname(name);
emit sig_display(r_name);
}
void PIconView::slotStartSlide() {
bool isDir = false;
QString name = currentFileName(isDir);
if (isDir) {
if (!slotShowFirst())
return;
} else {
slotShowImage( name );
}
- int t = m_cfg->readNumEntry("base_slideshowtimeout", 2);
+ int t = m_cfg->readNumEntry("slideshowtimeout", 2);
emit sig_startslide(t);
}
void PIconView::slotImageInfo() {
bool isDir = false;
QString name = currentFileName(isDir);
if (isDir) return;
slotImageInfo( name );
}
void PIconView::slotImageInfo( const QString& name) {
PDirLister *lister = currentView()->dirLister();
QString r_name = lister->nameToFname(name);
emit sig_showInfo(r_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;
+ }
+
calculateGrid();
slotReloadDir();
}
+}
void PIconView::resizeEvent( QResizeEvent* re ) {
+ calculateGrid(re);
QVBox::resizeEvent( re );
- calculateGrid();
+ //calculateGrid();
}
-void PIconView::calculateGrid() {
+void PIconView::calculateGrid(QResizeEvent* re)
+{
+ int viewerWidth;
+ if (re) {
+ viewerWidth=re->size().width();
+ } else {
int dw = QApplication::desktop()->width();
- int viewerWidth = dw-style().scrollBarExtent().width();
+ viewerWidth = dw-style().scrollBarExtent().width();
+ }
QIconView::ItemTextPos pos;
switch( m_mode ) {
case 2:
pos = QIconView::Bottom;
break;
case 3:
case 1:
default:
pos = QIconView::Right;
break;
}
m_view->setItemTextPos( pos );
switch (m_mode) {
case 2:
- m_view->setGridX(50);
- m_view->setGridY(20);
+ m_view->setGridX(m_iconsize);
+ m_view->setGridY(-1);
PPixmapCache::self()->setMaxImages(40);
break;
case 3:
m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
m_view->setGridY(8);
PPixmapCache::self()->setMaxImages(2);
break;
case 1:
default:
m_view->setGridX( viewerWidth-3*m_view->spacing());
m_view->setGridY( fontMetrics().height()*2+40 );
PPixmapCache::self()->setMaxImages(20);
break;
}
+ 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
@@ -1,101 +1,102 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#ifndef PHUNK_ICON_VIEW_H
#define PHUNK_ICON_VIEW_H
#include <qvbox.h>
class QIconView;
class QIconViewItem;
class QComboBox;
class PIconViewItem;
class PDirLister;
class Ir;
namespace Opie {
namespace Core{
class OConfig;
class OKeyConfigManager;
}
}
class PIconView : public QVBox {
Q_OBJECT
friend class PIconViewItem;
enum ActionIds {
BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem
};
public:
PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
~PIconView();
void resetView();
Opie::Core::OKeyConfigManager* manager();
signals:
void sig_showInfo( const QString& );
void sig_display(const QString&);
void sig_startslide(int timeout);
public slots:
virtual void slotShowNext();
virtual void slotShowPrev();
virtual void slotShowLast();
virtual bool slotShowFirst();
protected:
void resizeEvent( QResizeEvent* );
private:
void initKeys();
QString currentFileName(bool &isDir)const;
QString nextFileName(bool &isDir)const;
QString prevFileName(bool &isDir)const;
void loadViews();
- void calculateGrid();
+ void calculateGrid(QResizeEvent*e = 0);
private slots:
void slotDirUp();
void slotChangeDir(const QString&);
void slotTrash();
void slotViewChanged( int );
void slotReloadDir();
void slotRename();
void slotBeam();
void slotBeamDone( Ir* );
void slotShowImage();
void slotShowImage( const QString& );
void slotImageInfo();
void slotImageInfo( const QString& );
void slotStartSlide();
void slotStart();
void slotEnd();
/* for performance reasons make it inline in the future */
void addFolders( const QStringList& );
void addFiles( const QStringList& );
void slotClicked(QIconViewItem* );
void slotRetrun(QIconViewItem* );
/**/
void slotThumbInfo(const QString&, const QString&);
void slotThumbNail(const QString&, const QPixmap&);
void slotChangeMode( int );
private:
Opie::Core::OKeyConfigManager *m_viewManager;
Opie::Core::OConfig *m_cfg;
QComboBox* m_views;
QIconView* m_view;
QString m_path;
bool m_updatet : 1;
int m_mode;
bool m_internalReset:1;
+ int m_iconsize;
};
#endif
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
@@ -111,198 +111,198 @@ void PMainWindow::slotRotateToggled(bool how)
}
if (m_disp) {
m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
}
}
void PMainWindow::slotScaleToggled(bool how)
{
if (autoSave) {
m_cfg->writeEntry("unscaled",how);
}
odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
odebug << "How: " << how << oendl;
if (how) {
m_aAutoRotate->setOn(false);
}
if (m_disp) {
m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
}
m_aAutoRotate->setEnabled(!how);
odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
}
void PMainWindow::slotConfig() {
/*
* have a tab with the possible views
* a tab for globals image cache size.. scaled loading
* and one tab for the KeyConfigs
*/
QDialog dlg(this, 0, true);
dlg.setCaption( tr("Opie Eye - Config" ) );
QHBoxLayout *lay = new QHBoxLayout(&dlg);
Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
lay->addWidget( wid );
BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
wid->addTab(bSetup,"SettingsIcon","Basics setup");
ViewMap *vM = viewMap();
ViewMap::Iterator _it = vM->begin();
QMap<PDirView*, QWidget*> lst;
for( ; _it != vM->end(); ++_it ) {
PDirView *view = (_it.data())(*m_cfg);
PInterfaceInfo *inf = view->interfaceInfo();
QWidget *_wid = inf->configWidget( *m_cfg );
if (!_wid) continue;
_wid->reparent(wid, QPoint() );
lst.insert( view, _wid );
wid->addTab( _wid, "fileopen", inf->name() );
}
/*
* Add the KeyConfigWidget
*/
Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
QWidget*w = m_stack->visibleWidget();
bool reminfo = false;
if ( !m_info ) {
reminfo = true;
initInfo();
m_info->hide();
}
keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
bool remdisp = false;
if ( !m_disp ) {
remdisp = true;
initDisp();
m_disp->hide();
}
keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
keyWid->load();
wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
wid->setCurrentTab(0);
bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
/*
* clean up
*apply changes
*/
QMap<PDirView*, QWidget*>::Iterator it;
for ( it = lst.begin(); it != lst.end(); ++it ) {
if ( act )
it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
delete it.key();
}
if ( act ) {
- m_view->resetView();
keyWid->save();
m_disp->manager()->save();
m_info->manager()->save();
m_view->manager()->save();
bSetup->save_values();
+ m_view->resetView();
readConfig();
}
delete keyWid;
m_stack->raiseWidget(w);
if (remdisp) {
m_disp->hide();
}
if (reminfo) {
m_info->hide();
}
}
/*
* create a new image info component
* and detach the current one
* we will make the other delete on exit
*/
template<class T>
void PMainWindow::initT( const char* name, T** ptr, int id) {
if ( *ptr ) {
(*ptr)->disconnect(this, SLOT(slotReturn()));
(*ptr)->setDestructiveClose();
m_stack->removeWidget( *ptr );
}
*ptr = new T(m_cfg, m_stack, name );
m_stack->addWidget( *ptr, id );
connect(*ptr, SIGNAL(sig_return()),
this,SLOT(slotReturn()));
}
void PMainWindow::initInfo() {
initT<imageinfo>( "Image Info", &m_info, ImageInfo );
connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
}
void PMainWindow::initDisp() {
initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
if (m_disp) {
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
}
m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
m_disp->setAutoScale(!m_aUnscaled->isOn());
m_disp->setAutoRotate(m_aAutoRotate->isOn());
m_disp->setShowZoomer(m_aZoomer->isOn());
m_disp->setBackgroundColor(white);
connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
slotFullScreenToggled(m_aFullScreen->isOn());
}
}
void PMainWindow::slotToggleFullScreen()
{
bool current = !m_aFullScreen->isOn();
m_aFullScreen->setOn(current);
}
void PMainWindow::slotFullScreenButton(bool current)
{
if (autoSave) {
m_cfg->writeEntry("fullscreen",current);
}
if (!m_disp) return;
if (m_disp->isVisible()) {
setupViewWindow(current, true);
}
}
void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
{
if (!m_disp) return;
if (current) {
m_disp->setBackgroundColor(black);
m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
} else {
setUpdatesEnabled(false);
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
} else {
m_disp->setMinimumSize(10,10);
}
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
@@ -599,98 +599,98 @@ void PMainWindow::setupActions()
m_hGroup = new QActionGroup(this,"actioncollection",false);
m_hGroup->insert(m_aFullScreen);
}
void PMainWindow::setupToolbar()
{
toolBar = new QToolBar( this );
addToolBar(toolBar);
toolBar->setHorizontalStretchable( true );
setToolBarsMovable( false );
m_aDirUp->addTo( toolBar );
fsButton = new PFileSystem( toolBar );
connect( fsButton, SIGNAL( changeDir( const QString& ) ),
m_view, SLOT(slotChangeDir( const QString& ) ) );
connect( this, SIGNAL( changeDir( const QString& ) ),
m_view, SLOT(slotChangeDir( const QString& ) ) );
if (m_aBeam) {
m_aBeam->addTo( toolBar );
}
m_aShowInfo->addTo(toolBar);
m_aTrash->addTo(toolBar);
// m_aSetup->addTo(toolBar);
m_gDisplayType->addTo(toolBar);
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_gPrevNext->addTo(toolBar);
} else {
m_gPrevNext->setEnabled(false);
}
}
void PMainWindow::setupMenu()
{
fileMenu = new QPopupMenu( menuBar() );
menuBar()->insertItem( tr( "File" ), fileMenu );
dispMenu = new QPopupMenu( menuBar() );
menuBar()->insertItem( tr( "Show" ), dispMenu );
settingsMenu = new QPopupMenu( menuBar() );
menuBar()->insertItem( tr( "Settings" ), settingsMenu );
m_aViewfile->addTo(fileMenu);
m_aShowInfo->addTo(fileMenu);
m_aStartSlide->addTo(fileMenu);
fileMenu->insertSeparator();
m_aDirUp->addTo( fileMenu );
fsMenu = new QPopupMenu(fileMenu);
fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu);
connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) );
dirChanged();
if ( m_aBeam ) {
fileMenu->insertSeparator();
m_aBeam->addTo( fileMenu );
}
fileMenu->insertSeparator();
m_aTrash->addTo(fileMenu);
listviewMenu = new QPopupMenu(dispMenu);
dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
m_gListViewMode->addTo(listviewMenu);
dispMenu->insertSeparator();
m_aFullScreen->addTo(dispMenu);
m_gDisplayType->addTo(dispMenu);
dispMenu->insertSeparator();
m_gPrevNext->addTo(dispMenu);
m_aSetup->addTo(settingsMenu);
m_aHideToolbar->addTo(settingsMenu);
}
void PMainWindow::listviewselected(QAction*which)
{
if (!which || which->isOn()==false) return;
int val = 1;
// QString name;
if (which==m_aDirName) {
val = 3;
// name = "opie-eye/opie-eye-textview";
} else if (which==m_aDirShort) {
val = 2;
// name = "opie-eye/opie-eye-thumbonly";
} else if (which==m_aDirLong) {
val = 1;
// name = "opie-eye/opie-eye-thumb";
}
emit changeListMode(val);
}
void PMainWindow::readConfig()
{
- autoSave =m_cfg->readBoolEntry("base_savestatus",true);
+ autoSave =m_cfg->readBoolEntry("savestatus",true);
}