summaryrefslogtreecommitdiff
authoralwin <alwin>2004-10-30 02:18:52 (UTC)
committer alwin <alwin>2004-10-30 02:18:52 (UTC)
commit3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25 (patch) (side-by-side diff)
tree087361e8ec23fcae50ab146d6d2e2d366a54fe74
parentdca4423e3b0966fe26ba4183e5b6ad4666c61e86 (diff)
downloadopie-3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25.zip
opie-3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25.tar.gz
opie-3fcdb4e6f576f5e3eec072efe87a44bf58fdbf25.tar.bz2
slide show implemented
on next/previous images: if end/begin of list is reached it starts again on begin/end (it was required for slideshow so what ;) zecke: so we have a feature for OPIE 1.1.7 ;)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp94
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp26
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp1
5 files changed, 130 insertions, 3 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 7196aba..0499af9 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -149,192 +149,196 @@ 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;
QHBox *hbox = new QHBox( this );
QLabel* lbl = new QLabel( hbox );
lbl->setText( tr("View as" ) );
m_views = new QComboBox( hbox, "View As" );
m_view= new QIconView( this );
connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
this, SLOT(slotClicked(QIconViewItem*)) );
connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
this, SLOT(slotClicked(QIconViewItem*)) );
m_view->setArrangement( QIconView::LeftToRight );
m_mode = m_cfg->readNumEntry("ListViewMode", 1);
QString lastView = m_cfg->readEntry("LastView","");
if (m_mode < 1 || m_mode>3) m_mode = 1;
m_view->setItemTextPos( QIconView::Right );
calculateGrid();
initKeys();
loadViews();
int cc=0;
for (; cc<m_views->count();++cc) {
if (m_views->text(cc)==lastView) {
break;
}
}
if (cc<m_views->count()) {
m_views->setCurrentItem(cc);
slotViewChanged(cc);
} else {
slotViewChanged(m_views->currentItem());
}
connect( m_views, SIGNAL(activated(int)),
this, SLOT(slotViewChanged(int)) );
}
/*
* Unref the slave and save the keyboard manager
*/
PIconView::~PIconView() {
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
}
m_viewManager->save();
delete m_viewManager;
}
Opie::Core::OKeyConfigManager* PIconView::manager() {
return m_viewManager;
}
/*
* init the KeyBoard Shortcuts
* called from the c'tor
*/
void PIconView::initKeys() {
Opie::Core::OKeyPair::List lst;
lst.append( Opie::Core::OKeyPair::upArrowKey() );
lst.append( Opie::Core::OKeyPair::downArrowKey() );
lst.append( Opie::Core::OKeyPair::leftArrowKey() );
lst.append( Opie::Core::OKeyPair::rightArrowKey() );
lst.append( Opie::Core::OKeyPair::returnKey() );
m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
lst, false,this, "keyconfig name" );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
Resource::loadPixmap("beam"), BeamItem,
Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
this, SLOT(slotBeam())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
Resource::loadPixmap("trash"), DeleteItem,
Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
this, SLOT(slotTrash())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
Resource::loadPixmap("1to1"), ViewItem,
Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
this, SLOT(slotShowImage())));
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
Resource::loadPixmap("DocumentTypeWord"), InfoItem,
Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
this, SLOT(slotImageInfo()) ) );
+ m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
+ Resource::loadPixmap("1to1"), SlideItem,
+ Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
+ this, SLOT(slotStartSlide())));
m_viewManager->load();
m_viewManager->handleWidget( m_view );
}
/*
* change one dir up
*/
void PIconView::slotDirUp()
{
slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
}
/*
* change the dir
*/
void PIconView::slotChangeDir(const QString& path) {
if ( !currentView() )
return;
PDirLister *lister = currentView()->dirLister();
if (!lister )
return;
/*
* Say what we want and take what we get
*/
lister->setStartPath( path );
m_path = lister->currentPath();
m_view->viewport()->setUpdatesEnabled( false );
m_view->clear();
/*
* add files and folders
*/
addFolders( lister->folders() );
addFiles( lister->files() );
m_view->viewport()->setUpdatesEnabled( true );
// Also invalidate the cache. We can't cancel the operations anyway
g_stringPix.clear();
g_stringInf.clear();
// looks ugly
static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
}
/**
* get the current file name
* @param isDir see if this is a dir or real file
*/
QString PIconView::currentFileName(bool &isDir)const {
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
QString PIconView::nextFileName(bool &isDir)const
{
isDir = false;
QIconViewItem* _it1 = m_view->currentItem();
if ( !_it1 )
return QString::null;
QIconViewItem* _it = _it1->nextItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
QString PIconView::prevFileName(bool &isDir)const{
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
_it = _it->prevItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
void PIconView::slotTrash() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
@@ -471,198 +475,284 @@ void PIconView::slotClicked(QIconViewItem* _it) {
* by the ImageDisplayer and goes to the next image
*/
void PIconView::slotRetrun( QIconViewItem *_it ) {
if(!_it )
return;
IconViewItem* it = static_cast<IconViewItem*>(_it);
if( it->isDir() )
slotChangeDir( it->path() );
else
QTimer::singleShot(0, this, SLOT(slotShowImage()) );
}
/*
* got thumb info add to the cache if items is visible
* we later need update after processing of slave is done
*/
void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
IconViewItem* item = g_stringInf[_path];
if (!item )
return;
if (m_mode == 2) {
return;
}
if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
m_view->contentsWidth(), m_view->contentsHeight() ) ) )
m_updatet = true;
item->setText( str );
g_stringInf.remove( _path );
}
/*
* got thumbnail and see if it is visible so we need to update later
*/
void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
IconViewItem* item = g_stringPix[_path];
if (!item )
return;
if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
m_view->contentsWidth(), m_view->contentsHeight() ) ) )
m_updatet = true;
if (pix.width()>0) {
PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
item->setPixmap(pix,true);
} else {
PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 );
}
g_stringPix.remove( _path );
}
/*
* 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);
- if (name.isEmpty()) return;
+ 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);
- if (name.isEmpty()) return;
+ 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 );
+ }
+ emit sig_startslide(2);
+}
+
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();
calculateGrid();
slotReloadDir();
}
void PIconView::resizeEvent( QResizeEvent* re ) {
QVBox::resizeEvent( re );
calculateGrid();
}
void PIconView::calculateGrid() {
int dw = QApplication::desktop()->width();
int viewerWidth = dw-style().scrollBarExtent().width();
QIconView::ItemTextPos pos;
switch( m_mode ) {
case 2:
pos = QIconView::Bottom;
break;
case 3:
case 1:
default:
pos = QIconView::Right;
break;
}
m_view->setItemTextPos( pos );
switch (m_mode) {
case 2:
m_view->setGridX(50);
m_view->setGridY(20);
PPixmapCache::self()->setMaxImages(40);
break;
case 3:
m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
m_view->setGridY(8);
PPixmapCache::self()->setMaxImages(2);
break;
case 1:
default:
m_view->setGridX( viewerWidth-3*m_view->spacing());
m_view->setGridY( fontMetrics().height()*2+40 );
PPixmapCache::self()->setMaxImages(20);
break;
}
}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index a424c5c..bccbb0e 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,96 +1,100 @@
/*
* 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
+ BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem
};
public:
PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
~PIconView();
void resetView();
Opie::Core::OKeyConfigManager* manager();
signals:
void sig_showInfo( const QString& );
void sig_display( const QString& );
+ void sig_startslide(int timeout);
public slots:
virtual void slotShowNext();
virtual void slotShowPrev();
+ virtual void slotShowLast();
+ virtual bool slotShowFirst();
protected:
void resizeEvent( QResizeEvent* );
private:
void initKeys();
QString currentFileName(bool &isDir)const;
QString nextFileName(bool &isDir)const;
QString prevFileName(bool &isDir)const;
void loadViews();
void calculateGrid();
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;
};
#endif
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index 5522131..b699aa1 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,134 +1,160 @@
#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>
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;
}
ImageView::~ImageView()
{
odebug << "Delete 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()));
+ m_slideTimer->start(m_slideValue*1000,true);
+}
+
+void ImageView::nextSlide()
+{
+ if (!m_slideTimer) {
+ return;
+ }
+ if (isHidden()) {
+ delete m_slideTimer;
+ m_slideTimer = 0;
+ return;
+ }
+ 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("phunkview");
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();
}
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;
m->insertItem(tr("Toggle fullscreen"),this, SIGNAL(toggleFullScreen()));
if (fullScreen()) {
m->insertSeparator();
m->insertItem(tr("Previous image"),this,SIGNAL(dispPrev()));
m->insertItem(tr("Next image"),this,SIGNAL(dispNext()));
m->insertSeparator();
m->insertItem(tr("Toggle autoscale"),this, SIGNAL(toggleAutoscale()));
m->insertItem(tr("Toggle autorotate"),this, SIGNAL(toggleAutorotate()));
m->insertItem(tr("Toggle thumbnail"),this, SIGNAL(toggleZoomer()));
}
m->setFocus();
m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
delete m;
}
void ImageView::setFullScreen(bool how)
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h
index 18697e0..f0e6541 100644
--- a/noncore/graphics/opie-eye/gui/imageview.h
+++ b/noncore/graphics/opie-eye/gui/imageview.h
@@ -1,65 +1,71 @@
#ifndef _IMAGE_VIEW_H
#define _IMAGE_VIEW_H
#include <opie2/oimagescrollview.h>
#include <qwidget.h>
+class QTimer;
+
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 fullScreen(){return m_isFullScreen;}
virtual void enableFullscreen();
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 * );
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 438fbf2..3c946b6 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -218,192 +218,193 @@ void PMainWindow::slotConfig() {
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() );
if ( !m_info ) {
initInfo();
}
keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
if ( !m_disp ) {
initDisp();
}
keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
keyWid->load();
wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
/*
* clean up
*apply changes
*/
QMap<PDirView*, QWidget*>::Iterator it;
for ( it = lst.begin(); it != lst.end(); ++it ) {
if ( act )
it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
delete it.key();
}
if ( act ) {
m_view->resetView();
keyWid->save();
m_disp->manager()->save();
m_info->manager()->save();
m_view->manager()->save();
}
delete keyWid;
}
/*
* 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->setAutoScale(autoScale);
m_disp->setAutoRotate(autoRotate);
m_disp->setShowZoomer(zoomerOn);
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)));
}
}
void PMainWindow::slotToggleFullScreen()
{
odebug << "Toggle full " << oendl;
if (!m_disp) return;
bool current = !m_disp->fullScreen();
odebug << "Current = " << current << oendl;
if (current) {
odebug << "full" << oendl;
m_disp->setBackgroundColor(black);
m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
//m_disp->showFullScreen();
//qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
} else {
setUpdatesEnabled(false);
odebug << "window" << oendl;
m_disp->reparent(0,QPoint(0,0));
m_disp->showNormal();
m_disp->setBackgroundColor(white);
m_stack->addWidget(m_disp,ImageDisplay);
m_disp->setVScrollBarMode(QScrollView::Auto);
m_disp->setHScrollBarMode(QScrollView::Auto);
m_stack->raiseWidget(m_disp);
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->resize(m_disp->minimumSize());
}
setUpdatesEnabled(true);
}
m_disp->setFullScreen(current);
}
/**
* 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) {
prevButton->hide();
nextButton->hide();
upButton->hide();
fsButton->hide();
viewModeButton->hide();
}
m_stack->raiseWidget( ImageInfo );
}
void PMainWindow::slotDisplay( const QString& inf ) {
if ( !m_disp ) {
initDisp();
}
m_disp->setImage( inf );
if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
prevButton->show();
nextButton->show();
upButton->hide();
fsButton->hide();
viewModeButton->hide();
}
if (m_disp->fullScreen()) {
//m_disp->showFullScreen();
qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
} else {
m_stack->raiseWidget( ImageDisplay );
}
}
void PMainWindow::slotReturn() {
raiseIconView();
}
void PMainWindow::closeEvent( QCloseEvent* ev ) {
/*
* return from view
* or properly quit
*/
if ( m_stack->visibleWidget() == m_info ||
m_stack->visibleWidget() == m_disp ) {
ev->ignore();
raiseIconView();