summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp5
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.cpp6
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp4
3 files changed, 0 insertions, 15 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 9365932..ca5746d 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -72,389 +72,384 @@ namespace {
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( Opie::Core::OResource::loadPixmap("advancedfm/FileBrowser", Opie::Core::OResource::SmallIcon));
}
} else {
if (!_unkPix ) {
_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",
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",
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",
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",
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",
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() ) {
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
index 8f70602..8e31521 100644
--- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
@@ -1,204 +1,198 @@
#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>
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",
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( 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 cda1a96..ec891a8 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,318 +1,314 @@
#include "imageview.h"
#include <opie2/odebug.h>
#include <opie2/oconfig.h>
#include <opie2/okeyconfigwidget.h>
#include <opie2/oresource.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",
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",
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",
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",
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",
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",
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",
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",
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",
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);
}