summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/imageview.cpp
Side-by-side diff
Diffstat (limited to 'noncore/graphics/opie-eye/gui/imageview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index 994fe12..b919ca8 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,121 +1,120 @@
#include "imageview.h"
#include <opie2/odebug.h>
#include <opie2/oconfig.h>
#include <opie2/okeyconfigwidget.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qaction.h>
using namespace Opie::Core;
ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
: Opie::MM::OImageScrollView(parent,name,fl)
{
m_viewManager = 0;
focus_in_count = 0;
m_cfg = cfg;
m_isFullScreen = false;
m_ignore_next_in = false;
m_slideTimer = 0;
QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
initKeys();
m_slideValue = 5;
m_gDisplayType = 0;
m_gPrevNext = 0;
m_hGroup = 0;
m_gBright = 0;
m_Rotated = false;
closeIfHide = false;
int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()?
QApplication::desktop()->size().height():QApplication::desktop()->size().width();
if (min>320) {
// bigscreen
setMinimumSize(min/3,min/3);
} else {
setMinimumSize(10,10);
}
connect(this,SIGNAL(incBrightness()),this,SLOT(slotIncBrightness()));
connect(this,SIGNAL(decBrightness()),this,SLOT(slotDecBrightness()));
m_sysChannel = new QCopChannel( "QPE/System", this );
connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
+ setKeyCompression(true);
}
void ImageView::slotIncBrightness()
{
int lb = Intensity()+5;
if (lb>100) lb=100;
setIntensity(lb,true);
}
void ImageView::slotDecBrightness()
{
int lb = Intensity()-5;
if (lb<-100) lb=-100;
setIntensity(lb,true);
}
void ImageView::systemMessage( const QCString& msg, const QByteArray& data )
{
int _newrotation;
QDataStream stream( data, IO_ReadOnly );
- odebug << "received system message: " << msg << oendl;
if ( msg == "setCurrentRotation(int)" )
{
stream >> _newrotation;
- odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
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();
@@ -191,131 +190,129 @@ void ImageView::initKeys()
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->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness",
Resource::loadPixmap("up"), Incbrightness,
Opie::Core::OKeyPair(Qt::Key_B,0),
this, SIGNAL(incBrightness())));
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness",
Resource::loadPixmap("down"), Decbrightness,
Opie::Core::OKeyPair(Qt::Key_D,0),
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);
}
- odebug << "Popup " << oendl;
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.
- 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_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);
}