summaryrefslogtreecommitdiff
authoralwin <alwin>2004-11-12 15:57:59 (UTC)
committer alwin <alwin>2004-11-12 15:57:59 (UTC)
commite1ed329d0b8be10ac6e019d37b82afcf21990691 (patch) (side-by-side diff)
tree0c84e2c4fd062487932de9add39a083da194cca0
parentde558d6f0bc31f58ffaa894a0236f0d9cb5d73e0 (diff)
downloadopie-e1ed329d0b8be10ac6e019d37b82afcf21990691.zip
opie-e1ed329d0b8be10ac6e019d37b82afcf21990691.tar.gz
opie-e1ed329d0b8be10ac6e019d37b82afcf21990691.tar.bz2
- fixed a bug in docview-lister: different files may have same docview
name. So mapping filenames to docname isn't usefull. - when opie-eye is started from doctab closing the imagewindow closes the application - when a doc-link is changed while opie-eye is running it get the changes, too.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp58
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h4
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp15
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.h2
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp37
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h3
-rw-r--r--noncore/graphics/opie-eye/impl/doc/doc_lister.cpp129
-rw-r--r--noncore/graphics/opie-eye/impl/doc/doc_lister.h8
8 files changed, 166 insertions, 90 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 948477c..138e661 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -103,241 +103,228 @@ namespace {
if (!_unkPix ) {
_unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
}
}
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);
- 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)) );
+
+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),
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 );
@@ -348,289 +335,318 @@ void PIconView::slotChangeDir(const QString& 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) {
int osize = m_iconsize;
m_iconsize = m_cfg->readNumEntry("iconsize", 32);
if (m_iconsize<12)m_iconsize = 12;
if (m_iconsize>64)m_iconsize = 64;
if (osize != m_iconsize) {
if (_dirPix){
delete _dirPix;
_dirPix = 0;
}
if (_cpyPix){
delete _cpyPix;
_cpyPix = 0;
}
calculateGrid();
}
} else {
m_iconsize = 64;
}
slotViewChanged(m_views->currentItem());
m_internalReset = false;
}
+void PIconView::polish()
+{
+ odebug << "===\n"
+ << "PIconView::polish()\n"
+ << "====" << oendl;
+ 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 );
}
g_stringPix.remove( _path );
m_view->arrangeItemsInGrid(true);
}
/*
* FIXME rename
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index 78dda58..6e08fd8 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,104 +1,108 @@
/*
* 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();
+ void setDoccalled(bool);
+
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();
+ virtual void polish();
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(QResizeEvent*e = 0);
+ bool m_setDocCalled:1;
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;
QHBox*m_hbox;
QWidget*m_customWidget;
};
#endif
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index ebdfc60..ac6474c 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,242 +1,255 @@
#include "imageview.h"
#include <opie2/odebug.h>
#include <opie2/oconfig.h>
#include <opie2/okeyconfigwidget.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.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;
+ closeIfHide = false;
}
void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup)
{
m_gDisplayType = disptypeGroup;
m_gPrevNext = nextprevGroup;
m_hGroup = hGroup;
}
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),
this, SLOT(slotShowImageInfo())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
Resource::loadPixmap("rotate"), 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),
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),
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),
this, SIGNAL(dispPrev())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen",
Resource::loadPixmap("fullscreen"), 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),
this, SIGNAL(toggleZoomer())));
m_viewManager->handleWidget( this );
m_viewManager->load();
}
void ImageView::keyReleaseEvent(QKeyEvent * e)
{
if (!e || e->state()!=0) {
return;
}
- if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe();
+ 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);
}
odebug << "Popup " << oendl;
QPopupMenu *m = new QPopupMenu(0);
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);
}
}
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);
}
delete m;
}
void ImageView::setFullScreen(bool how,bool force)
{
m_isFullScreen = how;
if (how) {
m_ignore_next_in = true;
setFixedSize(qApp->desktop()->size());
if (force) showFullScreen();
} else {
setMinimumSize(10,10);
}
}
void ImageView::focusInEvent(QFocusEvent *)
{
// Always do it here, no matter the size.
odebug << "Focus in (view)" << oendl;
//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_NoBorder, 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/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h
index 2408211..f1067bb 100644
--- a/noncore/graphics/opie-eye/gui/imageview.h
+++ b/noncore/graphics/opie-eye/gui/imageview.h
@@ -1,76 +1,78 @@
#ifndef _IMAGE_VIEW_H
#define _IMAGE_VIEW_H
#include <opie2/oimagescrollview.h>
#include <qwidget.h>
class QTimer;
class QActionGroup;
class QAction;
namespace Opie {
namespace Core {
class OConfig;
class OKeyConfigManager;
}
}
class ImageView:public Opie::MM::OImageScrollView
{
Q_OBJECT
enum ActionIds {
ViewInfo,
FullScreen,
ShowNext,
ShowPrevious,
Zoomer,
Autorotate,
Autoscale
};
public:
ImageView(Opie::Core::OConfig *cfg,QWidget* parent,const char* name = 0, WFlags fl = 0 );
virtual ~ImageView();
Opie::Core::OKeyConfigManager* manager();
void setFullScreen(bool how,bool force=true);
bool fullScreen(){return m_isFullScreen;}
virtual void enableFullscreen();
void stopSlide();
void setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup);
+ void setCloseIfHide(bool);
signals:
void dispImageInfo(const QString&);
void dispNext();
void dispPrev();
void toggleFullScreen();
void hideMe();
void toggleZoomer();
void toggleAutoscale();
void toggleAutorotate();
protected:
Opie::Core::OConfig * m_cfg;
Opie::Core::OKeyConfigManager*m_viewManager;
void initKeys();
bool m_isFullScreen:1;
bool m_ignore_next_in:1;
int focus_in_count;
QTimer*m_slideTimer;
int m_slideValue;
virtual void focusInEvent ( QFocusEvent * );
QActionGroup *m_gDisplayType,*m_gPrevNext,*m_hGroup;
+ bool closeIfHide:1;
public slots:
virtual void hide();
virtual void startSlide(int);
virtual void nextSlide();
protected slots:
virtual void slotShowImageInfo();
virtual void keyReleaseEvent(QKeyEvent * e);
virtual void contentsMousePressEvent ( QMouseEvent * e);
};
#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index f443ccb..295f93f 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,144 +1,146 @@
/*
* 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 <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>
//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 Caramba" ) );
m_cfg = new Opie::Core::OConfig("opie-eye");
m_cfg->setGroup("main" );
readConfig();
+ m_setDocCalled = false;
+ m_polishDone = false;
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)));
m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
listviewMenu = 0;
/* setup menu and toolbar */
setupActions();
setupToolbar();
setupMenu();
m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
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);
@@ -326,219 +328,221 @@ void PMainWindow::setupViewWindow(bool current, bool 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_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
m_aNext->removeFrom(toolBar);
m_aPrevious->removeFrom(toolBar);
m_aNext->setEnabled(false);
m_aPrevious->setEnabled(false);
m_aDirUp->setEnabled(false);
m_aShowInfo->setEnabled(false);
m_aViewfile->setEnabled(true);
m_aStartSlide->setEnabled(false);
fsButton->hide();
}
m_stack->raiseWidget( ImageInfo );
}
void PMainWindow::slotDisplay( const QString& inf ) {
bool nwindow = false;
if ( !m_disp ) {
nwindow = true;
initDisp();
}
m_disp->setImage( inf );
if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
if (m_gPrevNext->isEnabled()==false) {
m_gPrevNext->addTo(toolBar);
m_gPrevNext->setEnabled(true);
m_aDirUp->setEnabled(false);
m_aShowInfo->setEnabled(true);
m_aViewfile->setEnabled(false);
m_aStartSlide->setEnabled(false);
fsButton->hide();
}
}
if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
slotFullScreenToggled(m_aFullScreen->isOn());
}
if (m_disp->fullScreen()) {
qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
} else {
m_stack->raiseWidget( ImageDisplay );
}
}
void PMainWindow::raiseIconView() {
setUpdatesEnabled(false);
if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
m_gPrevNext->removeFrom(toolBar);
m_gPrevNext->setEnabled(false);
m_aDirUp->setEnabled(true);
m_aShowInfo->setEnabled(true);
m_aViewfile->setEnabled(true);
m_aStartSlide->setEnabled(true);
fsButton->show();
}
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 )
{
- bool first_start = m_disp==0;
-
QString file = showImg;
DocLnk lnk(showImg);
if (lnk.isValid() )
file = lnk.file();
slotDisplay( file );
- if (first_start && m_aFullScreen->isOn()) {
+#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->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->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->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->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->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->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->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->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->setToggleAction(true);
m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 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->setToggleAction(true);
int mode = m_cfg->readNumEntry("ListViewMode", 1);
if (mode < 1 || mode>3) mode = 1;
switch (mode) {
case 3:
@@ -596,115 +600,134 @@ void PMainWindow::setupActions()
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->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);
}
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("savestatus",true);
}
+
+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) {
+ }
+ }
+}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 465e352..2f54090 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -1,107 +1,110 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#ifndef PHUNK_MAIN_WINDOW_H
#define PHUNK_MAIN_WINDOW_H
#include <opie2/oconfig.h>
#include <qmainwindow.h>
namespace Opie {
namespace Ui{
class OWidgetStack;
}
namespace Core{
class OKeyConfigManager;
}
}
class ImageView;
class ImageWidget;
class PIconView;
class imageinfo;
class QMenuBar;
class QToolBar;
class QPopupMenu;
class QAction;
class QActionGroup;
class StorageInfo;
class PMainWindow : public QMainWindow {
Q_OBJECT
enum Views { IconView, ImageInfo, ImageDisplay };
public:
static QString appName() { return QString::fromLatin1("opie-eye" ); }
PMainWindow(QWidget*, const char*, WFlags );
~PMainWindow();
signals:
void configChanged();
void changeDir( const QString& );
void changeListMode(int);
public slots:
void slotShowInfo( const QString& inf );
void slotDisplay( const QString& inf );
void slotReturn();
void slotRotateToggled(bool);
void slotScaleToggled(bool);
void slotZoomerToggled(bool);
void slotToggleZoomer();
void slotToggleAutorotate();
void slotToggleAutoscale();
void setDocument( const QString& );
virtual void slotToggleFullScreen();
virtual void slotFullScreenToggled(bool);
+ virtual void polish();
protected slots:
void raiseIconView();
void closeEvent( QCloseEvent* );
void showToolbar(bool);
void listviewselected(QAction*);
void slotFullScreenButton(bool);
void check_view_fullscreen();
private:
template<class T> void initT( const char* name, T**, int );
void initInfo();
void initDisp();
void setupViewWindow(bool full, bool forceDisplay);
private:
Opie::Core::OConfig *m_cfg;
Opie::Ui::OWidgetStack *m_stack;
PIconView* m_view;
imageinfo *m_info;
ImageView *m_disp;
bool autoSave;
+ bool m_setDocCalled:1;
+ bool m_polishDone:1;
QToolButton*fsButton;
QToolBar *toolBar;
QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu,*settingsMenu;
QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide;
QAction*m_aHideToolbar,*m_aSetup,*m_aDirName,*m_aDirShort,*m_aDirLong;
QActionGroup *m_gListViewMode,*m_gDisplayType,*m_gPrevNext,*m_hGroup;
QAction *m_aNext,*m_aPrevious,*m_aFullScreen;
QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer;
/* init funs */
void readConfig();
void setupActions();
void setupToolbar();
void setupMenu();
/* for the device submenu - ToDo: Merge with the special button */
StorageInfo *m_storage;
QMap<QString, QString> m_dev;
private slots:
void slotConfig();
void slotSelectDir(int);
void dirChanged();
};
#endif
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp
index f5c711a..8bcf01d 100644
--- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp
+++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp
@@ -1,188 +1,201 @@
/*
* GPLv2 zecke@handhelds.org
*/
#include "doc_lister.h"
#include <lib/slavemaster.h>
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
+#include <opie2/oglobal.h>
#include <qtopia/private/categories.h>
#include <qtopia/categoryselect.h>
using namespace Opie::Core;
/* QT */
#include <qdir.h>
#include <qfileinfo.h>
+#include <qtopia/qcopenvelope_qws.h>
Doc_DirLister::Doc_DirLister()
: PDirLister( "doc_dir_lister" )
{
/* connect the signals */
m_catFilter = 0;
SlaveMaster* master = SlaveMaster::self();
connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) );
connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) );
connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)),
this, SLOT(slotThumbInfo(const QString&, const QString&)) );
connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
this, SLOT(slotFullInfo(const QString&, const QString&)) );
connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)),
this, SLOT(slotThumbNail(const QString&, const QPixmap&)) );
-
- m_namemap.clear();
- m_filemap.clear();
m_docreads = false;
+ syschannel = new QCopChannel("QPE/System", this);
+ connect(syschannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(systemMsg(const QCString&,const QByteArray&)) );
+}
+
+Doc_DirLister::~Doc_DirLister()
+{
}
QString Doc_DirLister::defaultPath()const {
return QString::null;
}
-bool Doc_DirLister::matchCat(const AppLnk* app)
+bool Doc_DirLister::matchCat(const AppLnk* app)const
{
if (!app) return false;
if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) {
return true;
}
return false;
}
QString Doc_DirLister::setStartPath(const QString&) {
static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png");
- if (m_namemap.isEmpty()) {
if (!m_docreads) {
Global::findDocuments(&m_ds,Mtype_str);
m_docreads = true;
}
- QListIterator<DocLnk> dit(m_ds.children());
- for( ; dit.current(); ++dit) {
- if (!matchCat((*dit))) continue;
- m_namemap[(*dit)->name()]=(*dit)->file();
- m_filemap[(*dit)->file()]=(*dit)->name();
- }
- }
return QString::null;
}
-QString Doc_DirLister::currentPath()const {
+QString Doc_DirLister::currentPath()const
+{
return QString::null;
}
QStringList Doc_DirLister::folders()const {
return QStringList();
}
QStringList Doc_DirLister::files()const {
QStringList out;
- QMap<QString,QString>::ConstIterator it;
- for (it = m_namemap.begin();it != m_namemap.end();++it) {
- out.append(it.key());
+ QListIterator<DocLnk> dit(m_ds.children());
+ for( ; dit.current(); ++dit) {
+ if (!matchCat((*dit))) continue;
+ QString s = (*dit)->name();
+ s+=char(0);
+ s+=(*dit)->file();
+ out.append(s);
}
return out;
}
void Doc_DirLister::deleteImage( const QString& )
{
}
-void Doc_DirLister::thumbNail( const QString& str, int w, int h) {
- if (m_namemap.find(str)==m_namemap.end()) {
- return;
- }
- QString fname = m_namemap[str];
- SlaveMaster::self()->thumbNail( fname, w, h );
+void Doc_DirLister::thumbNail( const QString& str, int w, int h)
+{
+ SlaveMaster::self()->thumbNail( str, w, h );
}
-QImage Doc_DirLister::image( const QString& str, Factor f, int m) {
- if (m_namemap.find(str)==m_namemap.end()) {
- return QImage();
- }
- QString fname = m_namemap[str];
- return SlaveMaster::self()->image( fname, f, m );
+QImage Doc_DirLister::image( const QString& str, Factor f, int m)
+{
+ return SlaveMaster::self()->image(str, f, m );
}
void Doc_DirLister::imageInfo( const QString& str) {
- if (m_namemap.find(str)==m_namemap.end()) {
- return;
- }
- QString fname = m_namemap[str];
- SlaveMaster::self()->thumbInfo( fname );
+ SlaveMaster::self()->thumbInfo( str );
}
void Doc_DirLister::fullImageInfo( const QString& str) {
- if (m_namemap.find(str)==m_namemap.end()) {
- return;
- }
- QString fname = m_namemap[str];
- SlaveMaster::self()->imageInfo( fname );
+ SlaveMaster::self()->imageInfo(str);
}
void Doc_DirLister::slotFullInfo(const QString&f, const QString&t)
{
- if (m_filemap.find(f)==m_filemap.end()) {
- return;
- }
- QString name = m_filemap[f];
- emit sig_fullInfo(name, t);
+ emit sig_fullInfo(f, t);
}
void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t)
{
- if (m_filemap.find(f)==m_filemap.end()) {
- return;
- }
- QString name = m_filemap[f];
- emit sig_thumbInfo(name, t);
+ emit sig_thumbInfo(f, t);
}
void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p)
{
- if (m_filemap.find(f)==m_filemap.end()) {
- return;
- }
- QString name = m_filemap[f];
- emit sig_thumbNail(name, p);
+ emit sig_thumbNail(f, p);
}
QString Doc_DirLister::nameToFname(const QString&name)const
{
- if (m_namemap.find(name)==m_namemap.end()) {
- return QString::null;
- }
- return m_namemap[name];
+ return name;
}
QString Doc_DirLister::dirUp( const QString& p ) const{
return p;
}
QWidget* Doc_DirLister::widget(QWidget*parent)
{
CategorySelect * catmb = new CategorySelect(parent);
Categories cats( 0 );
cats.load( categoryFileName() );
QArray<int> vl( 0 );
catmb->setCategories( vl, "Document View", // No tr
"Document View" );
catmb->setRemoveCategoryEdit( TRUE );
catmb->setAllCategories( TRUE );
connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
catmb->setCurrentCategory(-2);
return catmb;
}
void Doc_DirLister::showCategory(int which)
{
m_catFilter = which==-2?0:which;
- m_namemap.clear();
setStartPath("");
emit sig_reloadDir();
}
+
+void Doc_DirLister::systemMsg(const QCString &msg, const QByteArray &data)
+{
+ if ( msg != "linkChanged(QString)"||!m_docreads) {
+ return;
+ }
+ QString link;
+ QDataStream stream( data, IO_ReadOnly );
+ stream >> link;
+ odebug << "Doc_DirLister systemMsg -> linkchanged( " << link << " )" << oendl;
+ if ( link.isNull() || OGlobal::isAppLnkFileName(link) ) {
+ return;
+ }
+ QListIterator<DocLnk> dit(m_ds.children());
+ bool must_reload = false;
+ bool found = false;
+ while ( dit.current() ) {
+ DocLnk *doc = dit.current();
+ ++dit;
+ if (doc->linkFile() == link) {
+ found = true;
+ DocLnk* dl = new DocLnk(link);
+ if (dl->fileKnown()) {
+ // changing
+ m_ds.add(dl);
+ } else {
+ delete dl;
+ }
+ if (matchCat(doc) || matchCat(dl)) {
+ must_reload = true;
+ }
+ m_ds.remove( doc ); // remove old link from docLnkSet
+ delete doc;
+ }
+ }
+ if (must_reload) {
+ setStartPath("");
+ emit sig_reloadDir();
+ }
+}
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h
index 403241c..3f8825f 100644
--- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h
+++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h
@@ -1,53 +1,55 @@
/*
* GPLv2 zecke@handhelds.org
*/
#ifndef DOC_LISTER_INTERFACE_LISTER_H
#define DOC_LISTER_INTERFACE_LISTER_H
#include <iface/dirlister.h>
#include <qpe/applnk.h>
#include <qstring.h>
#include <qmap.h>
class Config;
class AppLnk;
+class QCopChannel;
class Doc_DirLister : public PDirLister {
Q_OBJECT
public:
Doc_DirLister();
- virtual ~Doc_DirLister(){}
+ virtual ~Doc_DirLister();
QString defaultPath()const;
QString setStartPath( const QString& );
QString currentPath()const;
QStringList folders()const;
QStringList files()const;
void deleteImage( const QString& );
void thumbNail( const QString&, int, int );
QImage image( const QString&, Factor, int );
void imageInfo( const QString& );
void fullImageInfo( const QString& );
virtual QString nameToFname(const QString&name)const;
QString dirUp( const QString& )const;
QWidget* widget(QWidget*parent);
private:
- QMap<QString,QString> m_namemap,m_filemap;
int m_catFilter;
- bool matchCat(const AppLnk* app);
+ bool matchCat(const AppLnk* app)const;
bool m_docreads;
DocLnkSet m_ds;
protected slots:
virtual void slotFullInfo(const QString&, const QString&);
virtual void slotThumbInfo(const QString&, const QString&);
virtual void slotThumbNail(const QString&, const QPixmap&);
virtual void showCategory(int);
+ void systemMsg(const QCString &, const QByteArray &);
+ QCopChannel *syschannel;
};
#endif