author | drw <drw> | 2005-05-23 23:25:38 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-23 23:25:38 (UTC) |
commit | 3e2acb4665ddcdb24e0749e3ebfc589313be0065 (patch) (side-by-side diff) | |
tree | b7884a189d1b4928e61d71c1c4b5f908205a3655 | |
parent | 71ecaf241641c2c58b997df56074cf4849e6d6c5 (diff) | |
download | opie-3e2acb4665ddcdb24e0749e3ebfc589313be0065.zip opie-3e2acb4665ddcdb24e0749e3ebfc589313be0065.tar.gz opie-3e2acb4665ddcdb24e0749e3ebfc589313be0065.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/graphics/opie-eye/gui/filesystem.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 38 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 73 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.h | 2 |
7 files changed, 93 insertions, 64 deletions
diff --git a/noncore/graphics/opie-eye/gui/filesystem.cpp b/noncore/graphics/opie-eye/gui/filesystem.cpp index 8efcdf7..d84e9f8 100644 --- a/noncore/graphics/opie-eye/gui/filesystem.cpp +++ b/noncore/graphics/opie-eye/gui/filesystem.cpp @@ -1,65 +1,66 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #include <stdlib.h> #include <qpopupmenu.h> #include <qtoolbar.h> -#include <qpe/resource.h> +#include <opie2/oresource.h> + #include <qpe/storage.h> #include "filesystem.h" PFileSystem::PFileSystem( QToolBar* bar) : QToolButton( bar ) { - setIconSet( Resource::loadIconSet( "cardmon/pcmcia" ) ); + setIconSet( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); m_pop = new QPopupMenu( this ); connect( m_pop, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); m_storage = new StorageInfo(); connect(m_storage, SIGNAL(disksChanged() ), this, SLOT( changed() ) ); changed(); connect(this,SIGNAL(pressed()),SLOT(slotPopUp())); } PFileSystem::~PFileSystem() { delete m_storage; } void PFileSystem::changed() { m_pop->clear(); m_dev.clear(); /* home dir, too */ QString f = getenv( "HOME" ); if (!f.isEmpty()) { m_dev.insert("Home directory",f); m_pop->insertItem("Home directory"); } const QList<FileSystem> &fs = m_storage->fileSystems(); QListIterator<FileSystem> it(fs ); for ( ; it.current(); ++it ) { const QString disk = (*it)->name(); const QString path = (*it)->path(); m_dev.insert( disk, path ); m_pop->insertItem( disk ); } } void PFileSystem::slotPopUp() { m_pop->exec(QCursor::pos()); setDown(false); } void PFileSystem::slotSelectDir( int id ) { emit changeDir( m_dev[m_pop->text(id )] ); } diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 59091a8..9365932 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -1,913 +1,914 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #include "iconview.h" #include "messagebox.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 <opie2/oresource.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; const int PIconView::sMAX_ICON_SIZE = 128; const int PIconView::sMIN_ICON_SIZE = 12; const int PIconView::sDEF_ICON_SIZE = 64; /* * 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,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, 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, 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, int a_iconsize, bool isDir) : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), m_noInfo( false ),m_textOnly(false),m_Pixset(false) { m_iconsize = a_iconsize; if ( isDir ) { if (!_dirPix ) { - _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); + _dirPix = new QPixmap( Opie::Core::OResource::loadPixmap("advancedfm/FileBrowser", Opie::Core::OResource::SmallIcon)); } } else { if (!_unkPix ) { - _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); + _unkPix = new QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ) ); } } check_pix(); } inline void IconViewItem::check_pix()const { if (_dirPix && _dirPix->width()>m_iconsize) { QImage Pix = _dirPix->convertToImage(); *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); } if (!_cpyPix && _unkPix) { if (_unkPix->width()>=m_iconsize) { QImage Pix = _unkPix->convertToImage(); _cpyPix = new QPixmap(); if (_unkPix->width()>m_iconsize) { *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); } else { _cpyPix->convertFromImage(Pix); } } 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 ) ) { g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); currentView()->dirLister()->imageInfo( m_path ); } m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); if (!m_pix && !g_stringPix.contains( m_path )) { 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 : _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; m_customWidget = 0; m_setDocCalled = false; m_hbox = new QHBox( this ); QLabel* lbl = new QLabel( m_hbox ); lbl->setText( tr("View as" ) ); m_views = new QComboBox( m_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); 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<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; calculateGrid(); initKeys(); loadViews(); } void PIconView::setDoccalled(bool how) { m_setDocCalled = how; } /* * 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), + Opie::Core::OResource::loadPixmap("beam", Opie::Core::OResource::SmallIcon), + 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), + Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), + 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), + Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), + 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 ), + Opie::Core::OResource::loadPixmap("DocumentTypeWord", Opie::Core::OResource::SmallIcon), + 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), + Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), + 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 ); // 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 (!OMessageBox::confirmDelete( this, tr("the Image"), pa, tr("Delete Image" ))) 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) { int osize = m_iconsize; m_iconsize = m_cfg->readNumEntry("iconsize", 32); if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; if (osize != m_iconsize) { if (_dirPix){ delete _dirPix; _dirPix = 0; } if (_cpyPix){ delete _cpyPix; _cpyPix = 0; } calculateGrid(); } } else { m_iconsize = sDEF_ICON_SIZE; } slotViewChanged(m_views->currentItem()); m_internalReset = false; } void PIconView::polish() { QVBox::polish(); QString lastView = m_cfg->readEntry("LastView",""); 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)) ); } /* *swicth view reloadDir and connect signals */ void PIconView::slotViewChanged( int i) { if (!m_views->count() ) { setCurrentView( 0l); return; } if (m_customWidget) { delete m_customWidget; m_customWidget = 0; } 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 ); m_customWidget = cur->widget(m_hbox); if (m_customWidget) { odebug << "Got a widget" << oendl; m_customWidget->show(); } /* 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()) ); connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); /* reload now with default Path * but only if it isn't a reset like from setupdlg */ 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),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+"/"; } QString s = ""; int pos; for (it=lst.begin(); it!= lst.end(); ++it ) { s = (*it); pos = s.find(char(0)); m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); if (pos>-1) { _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); } else { _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) { 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" ), m_iconsize, m_iconsize ); + PPixmapCache::self()->insertImage( _path, Opie::Core::OResource::loadPixmap( "UnknownDocument", + Opie::Core::OResource::SmallIcon ), 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("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 ) { 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 = sDEF_ICON_SIZE; } else { m_iconsize = m_cfg->readNumEntry("iconsize", 32); if (m_iconsize<sMIN_ICON_SIZE)m_iconsize = sMIN_ICON_SIZE; if (m_iconsize>sMAX_ICON_SIZE)m_iconsize = sMAX_ICON_SIZE; } if (_dirPix){ delete _dirPix; _dirPix = 0; } if (_cpyPix){ delete _cpyPix; _cpyPix = 0; } calculateGrid(); slotReloadDir(); } } void PIconView::resizeEvent( QResizeEvent* re ) { calculateGrid(re); QVBox::resizeEvent( re ); //calculateGrid(); } void PIconView::calculateGrid(QResizeEvent* re) { int viewerWidth; if (re) { viewerWidth=re->size().width(); } else { int dw = QApplication::desktop()->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; } int cache = 0; m_view->setItemTextPos( pos ); switch (m_mode) { case 2: m_view->setSpacing(2); m_view->setGridX(m_iconsize); m_view->setGridY(-1); cache = (int)((double)sDEF_ICON_SIZE/(double)m_iconsize*80.0); odebug << "cache size: " << cache << oendl; PPixmapCache::self()->setMaxImages(cache); break; case 3: m_view->setSpacing(10); m_view->setGridX( fontMetrics().width("testimage.jpg")+20); m_view->setGridY(8); PPixmapCache::self()->setMaxImages(2); break; case 1: default: m_view->setSpacing(10); m_view->setGridX( viewerWidth-3*m_view->spacing()); m_view->setGridY( fontMetrics().height()*2+40 ); PPixmapCache::self()->setMaxImages(20); break; } } diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp index 7afb62d..8f70602 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp +++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp @@ -1,204 +1,204 @@ #include "imageinfoui.h" #include <qframe.h> #include <qlabel.h> #include <qpushbutton.h> #include <qtextview.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include <qstring.h> #include <qfileinfo.h> #include "lib/slavemaster.h" #include "lib/imagecache.h" #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> #include <opie2/odebug.h> +#include <opie2/oresource.h> #include <qpe/qcopenvelope_qws.h> -#include <qpe/resource.h> static const int THUMBSIZE = 128; using namespace Opie::Core; imageinfo::imageinfo(Opie::Core::OConfig *cfg,QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { m_viewManager = 0; m_cfg = cfg; init(name); initKeys(); } imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ),currentFile(_path) { m_viewManager = 0; m_cfg = 0; init(name); initKeys(); slotChangeName(_path); } Opie::Core::OKeyConfigManager* imageinfo::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void imageinfo::initKeys() { #if 0 if (!m_cfg) { m_cfg = new Opie::Core::OConfig("phunkview"); m_cfg->setGroup("imageinfo_keys" ); } #endif 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, "imageinfo_keys", lst, false,this, "keyconfig name" ); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Full Image"), "infoview", - Resource::loadPixmap("1to1"), ViewItem, - Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), + Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), + ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), this, SLOT(slotShowImage()))); m_viewManager->load(); m_viewManager->handleWidget( this ); m_viewManager->handleWidget( TextView1 ); } void imageinfo::slotShowImage() { emit dispImage(currentFile); } void imageinfo::init(const char* name) { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); } if ( !name ) setName( "imageinfo" ); resize( 289, 335 ); setCaption( tr( "Image info" ) ); imageinfoLayout = new QVBoxLayout( this ); imageinfoLayout->setSpacing(2); imageinfoLayout->setMargin(4); PixmapLabel1 = new QLabel( this, "PixmapLabel1" ); PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, PixmapLabel1->sizePolicy().hasHeightForWidth() ) ); QWhatsThis::add( PixmapLabel1, tr("Displays an thumbnail of the image") ); imageinfoLayout->addWidget( PixmapLabel1 ); Line1 = new QFrame( this, "Line1" ); Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); imageinfoLayout->addWidget( Line1 ); fnameLabel = new QLabel( this, "FnameLabel" ); imageinfoLayout->addWidget( fnameLabel); TextView1 = new QTextView( this, "TextView1" ); TextView1->setFrameShadow( QTextView::Sunken ); TextView1->setResizePolicy( QTextView::AutoOneFit ); TextView1->setBackgroundOrigin( QTextView::ParentOrigin ); TextView1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, TextView1->sizePolicy().hasHeightForWidth() ) ); // TextView1->setVScrollBarMode(QScrollView::AlwaysOn); QWhatsThis::add( TextView1, tr("Displays info of selected image") ); imageinfoLayout->addWidget( TextView1 ); SlaveMaster* master = SlaveMaster::self(); connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), this, SLOT(slot_fullInfo(const QString&, const QString&)) ); connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), this, SLOT(slotThumbNail(const QString&, const QPixmap&))); } void imageinfo::slotChangeName(const QString&_path) { currentFile=_path; QFileInfo fi(_path); fnameLabel->setText("<qt><center><b>"+fi.fileName()+"</b></center></qt>"); SlaveMaster::self()->imageInfo( currentFile ); QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, THUMBSIZE,THUMBSIZE ); if (!m_pix) { - PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" ))); + PixmapLabel1->setPixmap(QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ))); SlaveMaster::self()->thumbNail(currentFile,THUMBSIZE,THUMBSIZE); } else { PixmapLabel1->setPixmap(*m_pix); } } imageinfo::~imageinfo() { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); } if (m_viewManager) { delete m_viewManager; } } void imageinfo::slot_fullInfo(const QString&_path, const QString&_t) { if (_path == currentFile) { odebug << _t << oendl; QString t = _t; t.replace(QRegExp("\n"),"<br>"); TextView1->setText(t); } } void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix) { if (_path == currentFile) { if (_pix.width()>0) { PPixmapCache::self()->insertImage( _path, _pix, THUMBSIZE, THUMBSIZE ); PixmapLabel1->setPixmap( _pix ); PixmapLabel1->resize(QSize(_pix.width(),_pix.height())); } } } void imageinfo::setPath( const QString& str ) { slotChangeName( str ); } void imageinfo::setDestructiveClose() { WFlags fl = getWFlags(); /* clear it just in case */ fl &= ~WDestructiveClose; fl |= WDestructiveClose; setWFlags( fl ); } /* for testing */ infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name) :QDialog(parent,name,true,WStyle_ContextHelp) { QVBoxLayout*dlglayout = new QVBoxLayout(this); dlglayout->setSpacing(2); dlglayout->setMargin(1); imageinfo*inf = new imageinfo(fname,this); dlglayout->addWidget(inf); } infoDlg::~infoDlg() { } diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index b919ca8..cda1a96 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -1,318 +1,318 @@ #include "imageview.h" #include <opie2/odebug.h> #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> +#include <opie2/oresource.h> -#include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qaction.h> using namespace Opie::Core; ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) : Opie::MM::OImageScrollView(parent,name,fl) { m_viewManager = 0; focus_in_count = 0; m_cfg = cfg; m_isFullScreen = false; m_ignore_next_in = false; m_slideTimer = 0; QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); initKeys(); m_slideValue = 5; m_gDisplayType = 0; m_gPrevNext = 0; m_hGroup = 0; m_gBright = 0; m_Rotated = false; closeIfHide = false; int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? QApplication::desktop()->size().height():QApplication::desktop()->size().width(); if (min>320) { // bigscreen setMinimumSize(min/3,min/3); } else { setMinimumSize(10,10); } connect(this,SIGNAL(incBrightness()),this,SLOT(slotIncBrightness())); connect(this,SIGNAL(decBrightness()),this,SLOT(slotDecBrightness())); m_sysChannel = new QCopChannel( "QPE/System", this ); connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); setKeyCompression(true); } void ImageView::slotIncBrightness() { int lb = Intensity()+5; if (lb>100) lb=100; setIntensity(lb,true); } void ImageView::slotDecBrightness() { int lb = Intensity()-5; if (lb<-100) lb=-100; setIntensity(lb,true); } void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) { int _newrotation; QDataStream stream( data, IO_ReadOnly ); if ( msg == "setCurrentRotation(int)" ) { stream >> _newrotation; if (!fullScreen()) { m_rotation = _newrotation; return; } } } void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup,QActionGroup*brightGroup) { m_gDisplayType = disptypeGroup; m_gPrevNext = nextprevGroup; m_hGroup = hGroup; m_gBright = brightGroup; } ImageView::~ImageView() { odebug << "Destructor imageview" << oendl; delete m_viewManager; } Opie::Core::OKeyConfigManager* ImageView::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void ImageView::startSlide(int value) { if (!m_slideTimer) { m_slideTimer = new QTimer(this); } m_slideValue=value; connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); /* this "+1" is one millisecond. with that we can setup a slideshowvalue of 0. eg "as fast as possible". */ m_slideTimer->start(m_slideValue*1000+1,true); } void ImageView::stopSlide() { if (!m_slideTimer) { return; } m_slideTimer->stop(); delete m_slideTimer; m_slideTimer = 0; } void ImageView::nextSlide() { if (!m_slideTimer) { return; } #if 0 if (isHidden()) { delete m_slideTimer; m_slideTimer = 0; return; } #endif emit dispNext(); m_slideTimer->start(m_slideValue*1000,true); } void ImageView::initKeys() { odebug << "init imageview keys" << oendl; if (!m_cfg) { m_cfg = new Opie::Core::OConfig("opie-eye"); m_cfg->setGroup("image_view_keys" ); } 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(Qt::Key_Escape,0)); m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", lst, false,this, "image_view_keys" ); /** * Handle KeyEvents when they're pressed. This avoids problems * with 'double next' on Return. * The Return press would switch to this view and the return * release would emit the dispNext Signal. */ m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", - Resource::loadPixmap("1to1"), ViewInfo, - Opie::Core::OKeyPair(Qt::Key_I,0), + Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), + ViewInfo, Opie::Core::OKeyPair(Qt::Key_I,0), this, SLOT(slotShowImageInfo()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", - Resource::loadPixmap("rotate"), Autorotate, - Opie::Core::OKeyPair(Qt::Key_R,0), + Opie::Core::OResource::loadPixmap("rotate", Opie::Core::OResource::SmallIcon), + Autorotate, Opie::Core::OKeyPair(Qt::Key_R,0), this, SIGNAL(toggleAutorotate()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", - Resource::loadPixmap("1to1"), Autoscale, - Opie::Core::OKeyPair(Qt::Key_S,0), + Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), + Autoscale, Opie::Core::OKeyPair(Qt::Key_S,0), this, SIGNAL(toggleAutoscale()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", - Resource::loadPixmap("forward"), ShowNext, - Opie::Core::OKeyPair(Qt::Key_Return,0), + Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), + ShowNext, Opie::Core::OKeyPair(Qt::Key_Return,0), this, SIGNAL(dispNext()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", - Resource::loadPixmap("back"), ShowPrevious, - Opie::Core::OKeyPair(Qt::Key_P,0), + Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), + ShowPrevious, Opie::Core::OKeyPair(Qt::Key_P,0), this, SIGNAL(dispPrev()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", - Resource::loadPixmap("fullscreen"), FullScreen, - Opie::Core::OKeyPair(Qt::Key_F,0), + Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), + FullScreen, Opie::Core::OKeyPair(Qt::Key_F,0), this, SIGNAL(toggleFullScreen()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", - Resource::loadPixmap("mag"), Zoomer, - Opie::Core::OKeyPair(Qt::Key_T,0), + Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), + Zoomer, Opie::Core::OKeyPair(Qt::Key_T,0), this, SIGNAL(toggleZoomer()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness", - Resource::loadPixmap("up"), Incbrightness, - Opie::Core::OKeyPair(Qt::Key_B,0), + Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon), + Incbrightness, Opie::Core::OKeyPair(Qt::Key_B,0), this, SIGNAL(incBrightness()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness", - Resource::loadPixmap("down"), Decbrightness, - Opie::Core::OKeyPair(Qt::Key_D,0), + Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon), + Decbrightness, Opie::Core::OKeyPair(Qt::Key_D,0), this, SIGNAL(decBrightness()))); m_viewManager->handleWidget( this ); m_viewManager->load(); } void ImageView::keyReleaseEvent(QKeyEvent * e) { if (!e || e->state()!=0) { return; } if (e->key()==Qt::Key_Escape) { if (fullScreen()) { emit hideMe(); } if (closeIfHide) { QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } } } void ImageView::setCloseIfHide(bool how) { closeIfHide = how; } void ImageView::slotShowImageInfo() { emit dispImageInfo(m_lastName); } void ImageView::contentsMousePressEvent ( QMouseEvent * e) { if (e->button()==1) { return OImageScrollView::contentsMousePressEvent(e); } QPopupMenu *m = new QPopupMenu(this); if (!m) return; if (m_hGroup) { m_hGroup->addTo(m); } if (fullScreen()) { if (m_gPrevNext) { m->insertSeparator(); m_gPrevNext->addTo(m); } if (m_gDisplayType) { m->insertSeparator(); m_gDisplayType->addTo(m); } if (m_gBright) { m->insertSeparator(); m_gBright->addTo(m); } } m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); if (m_hGroup) { m_hGroup->removeFrom(m); } if (m_gPrevNext) { m_gPrevNext->removeFrom(m); } if (m_gDisplayType) { m_gDisplayType->removeFrom(m); } if (m_gBright) { m_gBright->removeFrom(m); } delete m; } void ImageView::setFullScreen(bool how,bool force) { m_isFullScreen = how; if (how) { m_ignore_next_in = true; // setFixedSize(qApp->desktop()->size()); setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); if (force) showFullScreen(); } else { // setMinimumSize(10,10); } } void ImageView::focusInEvent(QFocusEvent *) { // Always do it here, no matter the size. //if (fullScreen()) parentWidget()->showNormal(); if (m_ignore_next_in){m_ignore_next_in=false;return;} if (fullScreen()) enableFullscreen(); } void ImageView::hide() { if (fullScreen()) { m_ignore_next_in = true; showNormal(); } QWidget::hide(); } void ImageView::enableFullscreen() { if (!fullScreen()) return; if (m_ignore_next_in) {m_ignore_next_in = false;return;} setUpdatesEnabled(false); // This is needed because showNormal() forcefully changes the window // style to WSTyle_TopLevel. reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); // Enable fullscreen. /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus * so we must block it here! */ m_ignore_next_in = true; showFullScreen(); setUpdatesEnabled(true); } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 3efbb53..d4c5b42 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -1,840 +1,867 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #include "mainwindow.h" #include "imageview.h" #include "iconview.h" #include "filesystem.h" #include "imageinfoui.h" #include "viewmodebutton.h" #include "basesetup.h" #include <iface/ifaceinfo.h> #include <iface/dirview.h> #include <opie2/odebug.h> #include <opie2/owidgetstack.h> #include <opie2/oapplicationfactory.h> #include <opie2/otabwidget.h> #include <opie2/okeyconfigwidget.h> #include <opie2/owait.h> #include <opie2/oapplication.h> +#include <opie2/oresource.h> -#include <qpe/resource.h> #include <qpe/config.h> #include <qpe/ir.h> #include <qpe/storage.h> #include <qpe/applnk.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qmap.h> #include <qtimer.h> #include <qframe.h> #include <qmenubar.h> #include <qaction.h> #include <qspinbox.h> //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) { setCaption( QObject::tr("Opie Eye" ) ); m_cfg = new Opie::Core::OConfig("opie-eye"); m_cfg->setGroup("main" ); readConfig(); m_setDocCalled = false; m_polishDone = false; m_SmallWindow = QApplication::desktop()->size().width()<330; m_storage = new StorageInfo(); connect(m_storage, SIGNAL(disksChanged() ), this, SLOT( dirChanged() ) ); m_stack = new Opie::Ui::OWidgetStack( this ); setCentralWidget( m_stack ); m_view = new PIconView( m_stack, m_cfg ); m_stack->addWidget( m_view, IconView ); m_stack->raiseWidget( IconView ); connect(m_view, SIGNAL(sig_display(const QString&)), this, SLOT(slotDisplay(const QString&))); connect(m_view, SIGNAL(sig_showInfo(const QString&)), this, SLOT(slotShowInfo(const QString&)) ); connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); listviewMenu = 0; /* setup menu and toolbar */ setupActions(); setupToolbar(); setupMenu(); m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); if (m_aForceSmall) { m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true)); } odebug << "mainwindow constructor done" << oendl; } PMainWindow::~PMainWindow() { } void PMainWindow::slotToggleZoomer() { m_aZoomer->setOn(!m_aZoomer->isOn()); } void PMainWindow::slotZoomerToggled(bool how) { if (m_disp) { m_disp->setShowZoomer(how); } if (autoSave) { m_cfg->writeEntry("zoomeron",how); } } void PMainWindow::slotToggleAutorotate() { if (!m_aAutoRotate->isEnabled()) return; m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); } void PMainWindow::slotToggleAutoscale() { m_aUnscaled->setOn(!m_aUnscaled->isOn()); } void PMainWindow::slotRotateToggled(bool how) { if (autoSave) { m_cfg->writeEntry("autorotate",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 ) { 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(); } if (m_disp) { m_disp->setIntensity(m_Intensity,true); } } /* * 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_hBright); 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))); connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness())); connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness())); 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_NoBorderEx, QPoint(0,0)); m_disp->setVScrollBarMode(QScrollView::AlwaysOff); m_disp->setHScrollBarMode(QScrollView::AlwaysOff); m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); m_disp->setFullScreen(current,forceDisplay); } else { setUpdatesEnabled(false); #if 0 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { //m_disp->setMinimumSize(QApplication::desktop()->size()/2); } else { //m_disp->setMinimumSize(10,10); } #endif m_disp->setBackgroundColor(white); m_stack->addWidget(m_disp,ImageDisplay); m_disp->setVScrollBarMode(QScrollView::Auto); m_disp->setHScrollBarMode(QScrollView::Auto); if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); } if (forceDisplay || m_disp->isVisible()) { m_stack->raiseWidget(m_disp); m_disp->setFocus(); } setUpdatesEnabled(true); } m_disp->setFullScreen(current,forceDisplay); } void PMainWindow::slotFullScreenToggled(bool current) { setupViewWindow(current,true); } /** * With big Screen the plan could be to 'detach' the image * window if visible and to create a ne wone * init* already supports it but I make no use of it for * now. We set filename and raise * * ### FIXME and talk to alwin */ void PMainWindow::slotShowInfo( const QString& inf ) { if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { return; } if ( !m_info ) { initInfo(); } m_info->setPath( inf ); if (m_SmallWindow) { m_aNext->removeFrom(toolBar); m_aPrevious->removeFrom(toolBar); fsButton->hide(); } m_aNext->setEnabled(false); m_aPrevious->setEnabled(false); m_aDirUp->setEnabled(false); m_aShowInfo->setEnabled(false); m_aViewfile->setEnabled(true); m_aStartSlide->setEnabled(false); m_stack->raiseWidget( ImageInfo ); } void PMainWindow::slotDisplay( const QString& inf ) { bool nwindow = false; if ( !m_disp ) { nwindow = true; initDisp(); m_disp->setIntensity(m_Intensity); m_setCurrentBrightness->setEnabled(true); m_hBright->setEnabled(true); } m_disp->setImage( inf ); if (m_SmallWindow) { if (m_gPrevNext->isEnabled()==false) { m_gPrevNext->addTo(toolBar); fsButton->hide(); } } m_gPrevNext->setEnabled(true); m_aDirUp->setEnabled(false); m_aShowInfo->setEnabled(true); m_aViewfile->setEnabled(false); m_aStartSlide->setEnabled(false); if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { slotFullScreenToggled(m_aFullScreen->isOn()); } if (m_disp->fullScreen()) { if (!m_disp->isVisible()) { m_disp->showFullScreen(); qwsDisplay()->requestFocus( m_disp->winId(), TRUE); } } else { m_stack->raiseWidget( ImageDisplay ); } } void PMainWindow::raiseIconView() { setUpdatesEnabled(false); if (m_SmallWindow) { m_gPrevNext->removeFrom(toolBar); fsButton->show(); } m_gPrevNext->setEnabled(false); m_aDirUp->setEnabled(true); m_aShowInfo->setEnabled(true); m_aViewfile->setEnabled(true); m_aStartSlide->setEnabled(true); if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { m_disp->stopSlide(); m_disp->hide(); } m_stack->raiseWidget( IconView ); setUpdatesEnabled(true); repaint(); } void PMainWindow::slotReturn() { raiseIconView(); } void PMainWindow::closeEvent( QCloseEvent* ev ) { /* * return from view * or properly quit */ if (!m_setDocCalled) { if ( m_stack->visibleWidget() == m_info || m_stack->visibleWidget() == m_disp ) { ev->ignore(); raiseIconView(); return; } } if (m_disp && m_disp->fullScreen()) { /* otherwise opie-eye crashes in bigscreen mode! */ m_disp->reparent(0,QPoint(0,0)); m_stack->addWidget(m_disp,ImageDisplay); } ev->accept(); QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } void PMainWindow::setDocument( const QString& showImg ) { QString file = showImg; DocLnk lnk(showImg); if (lnk.isValid() ) file = lnk.file(); slotDisplay( file ); #if 0 if (!m_polishDone) { QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); } #endif } void PMainWindow::check_view_fullscreen() { if (!m_view) return; if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { qwsDisplay()->requestFocus( m_disp->winId(), TRUE); } } void PMainWindow::slotSelectDir(int id) { emit changeDir( m_dev[fsMenu->text(id )] ); } void PMainWindow::dirChanged() { fsMenu->clear(); m_dev.clear(); /* home dir, too */ QString f = getenv( "HOME" ); if (!f.isEmpty()) { m_dev.insert("Home directory",f); fsMenu->insertItem("Home directory"); } const QList<FileSystem> &fs = m_storage->fileSystems(); QListIterator<FileSystem> it(fs ); for ( ; it.current(); ++it ) { const QString disk = (*it)->name(); const QString path = (*it)->path(); m_dev.insert( disk, path ); fsMenu->insertItem( disk ); } } void PMainWindow::showToolbar(bool how) { if (!how) toolBar->hide(); else toolBar->show(); if (autoSave) { m_cfg->writeEntry("showtoolbar",how); } } void PMainWindow::setupActions() { - m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); + m_aDirUp = new QAction( tr( "Go dir up" ), Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true ); m_aDirUp->setToggleAction(false); connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); if ( Ir::supported() ) { - m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); + m_aBeam = new QAction( tr( "Beam file" ), Opie::Core::OResource::loadPixmap( "beam", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true ); m_aBeam->setToggleAction(false); connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); } else { m_aBeam = 0; } - m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); + m_aShowInfo = new QAction( tr( "Show imageinfo" ), Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true ); m_aShowInfo->setToggleAction(false); connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); - m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); + m_aTrash = new QAction( tr( "Delete file" ), Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), + 0, 0, this, 0, true ); m_aTrash->setToggleAction(false); connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); - m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); + m_aViewfile = new QAction( tr( "Display image" ), Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), + 0, 0, this, 0, true ); m_aViewfile->setToggleAction(false); connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); - m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); + m_aStartSlide = new QAction( tr( "Start slideshow" ), Opie::Core::OResource::loadPixmap("play", Opie::Core::OResource::SmallIcon), + 0, 0, this, 0, true ); m_aStartSlide->setToggleAction(false); connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); - m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); + m_aHideToolbar = new QAction( tr( "Show toolbar" ), Opie::Core::OResource::loadPixmap( "UtilsIcon", + Opie::Core::OResource::SmallIcon ), 0, 0, this, 0, true ); m_aHideToolbar->setOn (true); connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); - m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); + m_aSetup = new QAction( tr( "Settings" ), Opie::Core::OResource::loadPixmap("SettingsIcon", Opie::Core::OResource::SmallIcon), + 0, 0, this, 0, true ); m_aSetup->setToggleAction(false); connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); m_gListViewMode = new QActionGroup(this,"Select listmode",true); connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); - m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); + m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", + Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); m_aDirLong->setToggleAction(true); - m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); + m_aDirShort = new QAction( tr( "Thumbnail and name" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumbonly", + Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); m_aDirShort->setToggleAction(true); - m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); + m_aDirName = new QAction( tr( "Name only" ), Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-textview", + Opie::Core::OResource::SmallIcon),0, 0, this, 0, true ); m_aDirName->setToggleAction(true); int mode = m_cfg->readNumEntry("ListViewMode", 1); if (mode < 1 || mode>3) mode = 1; switch (mode) { case 3: m_aDirName->setOn(true); break; case 2: m_aDirShort->setOn(true); break; case 1: default: m_aDirLong->setOn(true); } m_gListViewMode->insert(m_aDirLong); m_gListViewMode->insert(m_aDirShort); m_gListViewMode->insert(m_aDirName); m_gPrevNext = new QActionGroup(this,"imageprevnext",false); - m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); + m_aNext = new QAction( tr( "Next image" ),Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), + 0, 0, this, 0, true ); m_aNext->setToggleAction(false); connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); - m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); + m_aPrevious = new QAction( tr( "Previous image" ),Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), + 0, 0, this, 0, true ); m_aPrevious->setToggleAction(false); connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); m_gPrevNext->insert(m_aPrevious); m_gPrevNext->insert(m_aNext); m_aFullScreen = new QAction( tr( "Show images fullscreen" ), - Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); + Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); m_aFullScreen->setToggleAction(true); if (autoSave) { m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); } else { m_aFullScreen->setOn(false); } connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); - m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); + m_aAutoRotate = new QAction( tr( "Auto rotate images" ), + Opie::Core::OResource::loadPixmap( "rotate", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true ); m_aAutoRotate->setToggleAction(true); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { m_aAutoRotate->setOn(true); } else { m_aAutoRotate->setOn(false); } if (autoSave) { m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); } connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); - m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); + m_aUnscaled = new QAction( tr( "Show images unscaled" ), + Opie::Core::OResource::loadPixmap( "1to1", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true ); m_aUnscaled->setToggleAction(true); connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); if (autoSave) { m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); } else { m_aUnscaled->setOn(false); } - m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); + m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), + Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true ); m_aZoomer->setToggleAction(true); if (autoSave) { m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); } else { m_aZoomer->setOn (true); } connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); m_gDisplayType->insert(m_aAutoRotate); m_gDisplayType->insert(m_aUnscaled); m_gDisplayType->insert(m_aZoomer); m_hGroup = new QActionGroup(this,"actioncollection",false); m_hGroup->insert(m_aFullScreen); if (!m_SmallWindow) { - m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true); + m_aForceSmall = new QAction(tr("Dont show seperate windows"), + Opie::Core::OResource::loadPixmap( "AppsIcon", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, true); m_aForceSmall->setToggleAction(true); connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); } else { m_aForceSmall = 0; } m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); - m_IncBrightness = new QAction(tr("Increase brightness by 5"),Resource::loadIconSet( "up" ),0, 0, this, 0, false); - m_DecBrightness = new QAction(tr("Decrease brightness by 5"),Resource::loadIconSet( "down" ),0, 0, this, 0, false); + m_IncBrightness = new QAction(tr("Increase brightness by 5"), + Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, false); + m_DecBrightness = new QAction(tr("Decrease brightness by 5"), + Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ), + 0, 0, this, 0, false); m_hBright = new QActionGroup(this,"actioncollection",false), m_hBright->insert(m_setCurrentBrightness); m_hBright->insert(m_IncBrightness); m_hBright->insert(m_DecBrightness); } void PMainWindow::setupBrightness() { if (!m_disp) { return; } bool reshow=false; if (m_disp->isVisible()&&m_disp->fullScreen()) { m_disp->hide(); reshow = true; } int lb = m_disp->Intensity(); if (Valuebox(0,-100,100,lb,lb)) { m_disp->setIntensity(lb,true); } if (reshow) { m_disp->showFullScreen(); qwsDisplay()->requestFocus( m_disp->winId(), TRUE); } } 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_gDisplayType->addTo(toolBar); if (!m_SmallWindow) { 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); + fileMenu->insertItem(Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ), + 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); + dispMenu->insertItem(Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", Opie::Core::OResource::SmallIcon), + tr("Listview mode"),listviewMenu); m_gListViewMode->addTo(listviewMenu); dispMenu->insertSeparator(); m_aFullScreen->addTo(dispMenu); m_gDisplayType->addTo(dispMenu); dispMenu->insertSeparator(); m_gPrevNext->addTo(dispMenu); dispMenu->insertSeparator(); m_hBright->addTo(dispMenu); m_hBright->setEnabled(false); if (m_aForceSmall) { dispMenu->insertSeparator(); m_aForceSmall->addTo(dispMenu); } m_aSetup->addTo(settingsMenu); m_aHideToolbar->addTo(settingsMenu); } void PMainWindow::listviewselected(QAction*which) { if (!which || which->isOn()==false) return; int val = 1; if (which==m_aDirName) { val = 3; } else if (which==m_aDirShort) { val = 2; } else if (which==m_aDirLong) { val = 1; } emit changeListMode(val); } void PMainWindow::readConfig() { autoSave =m_cfg->readBoolEntry("savestatus",true); m_Intensity = m_cfg->readNumEntry("intensity",0); } void PMainWindow::polish() { if (m_disp) { odebug << "======================\n" << "Called via setdocument\n" << "======================" << oendl; m_setDocCalled = true; m_view->setDoccalled(true); m_disp->setCloseIfHide(true); } else { m_setDocCalled = false; m_view->setDoccalled(false); } m_polishDone = true; QMainWindow::polish(); if (m_setDocCalled) { if (m_aFullScreen->isOn()) { QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { } } } void PMainWindow::slotForceSmall(bool how) { odebug << "Disable separate windows: " << how << oendl; if (m_stack) { if (how) { m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); } else { m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); } } if (autoSave) { m_cfg->writeEntry("dontshowseperate",how); } } bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) { QDialog dlg(parent,"brightnessbox",true); QVBoxLayout * m_MainLayout; QGridLayout * m_IntensityLayout; QSpinBox * m_Intensity; QLabel * m_IntensityLabel; m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); m_Intensity->setMaxValue( max ); m_Intensity->setMinValue(min); m_Intensity->setValue( current ); m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); m_IntensityLabel->setText(QObject::tr("Display brightness:")); m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); m_MainLayout->addLayout(m_IntensityLayout); if (dlg.exec()) { store = m_Intensity->value(); return true; } return false; } diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp index aa15d31..5680454 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp @@ -1,48 +1,48 @@ #include "viewmodebutton.h" /* OPIE */ #include <opie2/odebug.h> using namespace Opie::Core; /* QT */ #include <qtoolbar.h> #include <qpopupmenu.h> ViewModeButton::ViewModeButton( QToolBar* bar,int def ) : QToolButton( bar ) { slotChange( def ); QPopupMenu *pop= new QPopupMenu( this ); pop->setCheckable( true ); pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); pop->insertItem( tr("Thumbnail and Name" ), 2 ); pop->insertItem( tr("Name Only" ), 3 ); connect(pop, SIGNAL(activated(int)), this, SIGNAL(changeMode(int)) ); connect(pop, SIGNAL(activated(int)), this, SLOT(slotChange(int)) ); setPopup( pop ); } ViewModeButton::~ViewModeButton() { } void ViewModeButton::slotChange( int i ) { QString name; switch( i ) { case 1: name = "opie-eye/opie-eye-thumb"; break; case 2: name = "opie-eye/opie-eye-thumbonly"; break; case 3: name = "opie-eye/opie-eye-textview"; break; } owarn << "foo " << name << oendl; - setIconSet( Resource::loadIconSet( name ) ); + setIconSet( Opie::Core::OResource::loadPixmap( name, Opie::Core::OResource::SmallIcon ) ); } diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.h b/noncore/graphics/opie-eye/gui/viewmodebutton.h index 48f0e67..1637888 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.h +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.h @@ -1,25 +1,25 @@ /* * GPLv2 only * zecke@handhelds.org */ #ifndef PHUNK_VIEW_MODE_BUTTON_H #define PHUNK_VIEW_MODE_BUTTON_H -#include <qpe/resource.h> +#include <opie2/oresource.h> #include <qtoolbutton.h> class ViewModeButton : public QToolButton { Q_OBJECT public: ViewModeButton( QToolBar*,int def=1 ); ~ViewModeButton(); signals: void changeMode( int ); private slots: void slotChange( int i ); }; #endif |