author | alwin <alwin> | 2004-04-13 21:44:12 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-13 21:44:12 (UTC) |
commit | e61f3d63c310e4e560bc38f41c1390f246b5f670 (patch) (side-by-side diff) | |
tree | 2403a3b3ba1a47e6122d259b6b761f45c37f504d | |
parent | 482750c5b2494b7b2b94c13bf4743349b67d188a (diff) | |
download | opie-e61f3d63c310e4e560bc38f41c1390f246b5f670.zip opie-e61f3d63c310e4e560bc38f41c1390f246b5f670.tar.gz opie-e61f3d63c310e4e560bc38f41c1390f246b5f670.tar.bz2 |
zoomer widget better integrated, size of it depends on the size of the displayed image,
may switched off by user and so on.
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 44 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 2 |
4 files changed, 56 insertions, 9 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index 5b12258..2f16d82 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp @@ -1,400 +1,426 @@ #include "imagescrollview.h" #include <opie2/odebug.h> using namespace Opie::Core; #include <qimage.h> #include <qlayout.h> ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), - rotate_to_fit(true),first_resize_done(false),m_lastName("") + rotate_to_fit(true),show_zoomer(true),first_resize_done(false),m_lastName("") { init(); } ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), - rotate_to_fit(rfit),first_resize_done(false),m_lastName("") + rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") { _original_data.convertDepth(QPixmap::defaultDepth()); _original_data.setAlphaBuffer(false); init(); } ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), - rotate_to_fit(rfit),first_resize_done(false),m_lastName("") + rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") { init(); setImage(img); } void ImageScrollView::setImage(const QImage&img) { _image_data = QImage(); _original_data=img; _original_data.convertDepth(QPixmap::defaultDepth()); _original_data.setAlphaBuffer(false); m_lastName = ""; if (first_resize_done) { generateImage(); } } void ImageScrollView::setImage( const QString& path ) { odebug << "load new image " << oendl; if (m_lastName == path) return; m_lastName = path; _original_data.load(path); _original_data.convertDepth(QPixmap::defaultDepth()); _original_data.setAlphaBuffer(false); _image_data = QImage(); if (first_resize_done) { generateImage(); } } /* should be called every time the QImage changed it content */ void ImageScrollView::init() { odebug << "init " << oendl; /* * create the zoomer * and connect ther various signals */ _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), this, SLOT(scrollBy(int,int)) ); connect(this,SIGNAL(contentsMoving(int,int)), _zoomer, (SLOT(setVisiblePoint(int,int))) ); connect(this,SIGNAL(imageSizeChanged(const QSize&)), _zoomer, SLOT(setImageSize(const QSize&)) ); connect(this,SIGNAL(viewportSizeChanged(const QSize&)), _zoomer, SLOT(setViewPortSize(const QSize&)) ); viewport()->setBackgroundColor(white); setFocusPolicy(QWidget::StrongFocus); if (first_resize_done) { last_rot = Rotate0; generateImage(); - odebug << "reinit display " << oendl; } else if (_original_data.size().isValid()) { + if (image_fit_into(_original_data.size()) || !show_zoomer) _zoomer->hide(); resizeContents(_original_data.width(),_original_data.height()); } } void ImageScrollView::setAutoRotate(bool how) { /* to avoid double repaints */ if (rotate_to_fit != how) { rotate_to_fit = how; _image_data = QImage(); generateImage(); } } void ImageScrollView::setAutoScale(bool how) { scale_to_fit = how; if (!how) { rotate_to_fit = false; } _image_data = QImage(); generateImage(); } ImageScrollView::~ImageScrollView() { } void ImageScrollView::rescaleImage(int w, int h) { if (_image_data.width()==w && _image_data.height()==h) { return; } double hs = (double)h / (double)_image_data.height() ; double ws = (double)w / (double)_image_data.width() ; double scaleFactor = (hs > ws) ? ws : hs; int smoothW = (int)(scaleFactor * _image_data.width()); int smoothH = (int)(scaleFactor * _image_data.height()); _image_data = _image_data.smoothScale(smoothW,smoothH); } void ImageScrollView::rotate_into_data(Rotation r) { /* realy - we must do this that way, 'cause when acting direct on _image_data the app will segfault :( */ QImage dest; int x, y; if ( _original_data.depth() > 8 ) { unsigned int *srcData, *destData; switch ( r ) { case Rotate90: dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); for ( y=0; y < _original_data.height(); ++y ) { srcData = (unsigned int *)_original_data.scanLine(y); for ( x=0; x < _original_data.width(); ++x ) { destData = (unsigned int *)dest.scanLine(x); destData[_original_data.height()-y-1] = srcData[x]; } } break; case Rotate180: dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); for ( y=0; y < _original_data.height(); ++y ) { srcData = (unsigned int *)_original_data.scanLine(y); destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); for ( x=0; x < _original_data.width(); ++x ) destData[_original_data.width()-x-1] = srcData[x]; } break; case Rotate270: dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); for ( y=0; y < _original_data.height(); ++y ) { srcData = (unsigned int *)_original_data.scanLine(y); for ( x=0; x < _original_data.width(); ++x ) { destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); destData[y] = srcData[x]; } } break; default: dest = _original_data; break; } } else { unsigned char *srcData, *destData; unsigned int *srcTable, *destTable; switch ( r ) { case Rotate90: dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); dest.setNumColors(_original_data.numColors()); srcTable = (unsigned int *)_original_data.colorTable(); destTable = (unsigned int *)dest.colorTable(); for ( x=0; x < _original_data.numColors(); ++x ) destTable[x] = srcTable[x]; for ( y=0; y < _original_data.height(); ++y ) { srcData = (unsigned char *)_original_data.scanLine(y); for ( x=0; x < _original_data.width(); ++x ) { destData = (unsigned char *)dest.scanLine(x); destData[_original_data.height()-y-1] = srcData[x]; } } break; case Rotate180: dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); dest.setNumColors(_original_data.numColors()); srcTable = (unsigned int *)_original_data.colorTable(); destTable = (unsigned int *)dest.colorTable(); for ( x=0; x < _original_data.numColors(); ++x ) destTable[x] = srcTable[x]; for ( y=0; y < _original_data.height(); ++y ) { srcData = (unsigned char *)_original_data.scanLine(y); destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); for ( x=0; x < _original_data.width(); ++x ) destData[_original_data.width()-x-1] = srcData[x]; } break; case Rotate270: dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); dest.setNumColors(_original_data.numColors()); srcTable = (unsigned int *)_original_data.colorTable(); destTable = (unsigned int *)dest.colorTable(); for ( x=0; x < _original_data.numColors(); ++x ) destTable[x] = srcTable[x]; for ( y=0; y < _original_data.height(); ++y ) { srcData = (unsigned char *)_original_data.scanLine(y); for ( x=0; x < _original_data.width(); ++x ) { destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); destData[y] = srcData[x]; } } break; default: dest = _original_data; break; } } _image_data = dest; } void ImageScrollView::generateImage() { Rotation r = Rotate0; if (width()>height()&&_original_data.width()<_original_data.height() || width()<height()&&_original_data.width()>_original_data.height()) { if (rotate_to_fit) r = Rotate90; } odebug << " r = " << r << oendl; if (scale_to_fit) { if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { odebug << "Rescaling data" << oendl; if (r==Rotate0) { _image_data = _original_data; } else { rotate_into_data(r); } } rescaleImage(width(),height()); resizeContents(_image_data.width(),_image_data.height()); } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) { if (r==Rotate0) { _image_data = _original_data; } else { rotate_into_data(r); } last_rot = r; resizeContents(_image_data.width(),_image_data.height()); } _pdata.convertFromImage(_image_data); + /* * update the zoomer */ + check_zoomer(); emit imageSizeChanged( _image_data.size() ); rescaleImage( 128, 128 ); + /* + * move scrollbar + */ + _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, + _image_data.width()/2, _image_data.height()/2 ); + _zoomer->setImage( _image_data ); - /* * invalidate */ _image_data=QImage(); } void ImageScrollView::resizeEvent(QResizeEvent * e) { odebug << "ImageScrollView resizeEvent" << oendl; QScrollView::resizeEvent(e); generateImage(); first_resize_done = true; emit viewportSizeChanged( viewport()->size() ); - /* - * move scrollbar - */ - _zoomer->setGeometry( viewport()->width()-100, viewport()->height()-50, 100, 50 ); } void ImageScrollView::keyPressEvent(QKeyEvent * e) { if (!e) return; int dx = horizontalScrollBar()->lineStep(); int dy = verticalScrollBar()->lineStep(); if (e->key()==Qt::Key_Right) { scrollBy(dx,0); e->accept(); } else if (e->key()==Qt::Key_Left) { scrollBy(0-dx,0); e->accept(); } else if (e->key()==Qt::Key_Up) { scrollBy(0,0-dy); e->accept(); } else if (e->key()==Qt::Key_Down) { scrollBy(0,dy); e->accept(); } else { e->ignore(); } QScrollView::keyPressEvent(e); } void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) { int w = clipw; int h = cliph; int x = clipx; int y = clipy; bool erase = false; if (!_pdata.size().isValid()) { p->fillRect(clipx,clipy,clipw,cliph,white); return; } if (w>_pdata.width()) { w=_pdata.width(); x = 0; erase = true; } else if (x+w>_pdata.width()){ x = _pdata.width()-w; } if (h>_pdata.height()) { h=_pdata.height(); y = 0; erase = true; } else if (y+h>_pdata.height()){ y = _pdata.height()-h; } if (erase||_original_data.hasAlphaBuffer()) { p->fillRect(clipx,clipy,clipw,cliph,white); } p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); } /* using the real geometry points and not the translated points is wanted! */ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) { odebug << "Move X and Y " << e->x() << " " << e->y() << oendl; int mx, my; mx = e->x(); my = e->y(); if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) { int diffx = _mouseStartPosX-mx; int diffy = _mouseStartPosY-my; #if 0 QScrollBar*xbar = horizontalScrollBar(); QScrollBar*ybar = verticalScrollBar(); if (xbar->value()+diffx>xbar->maxValue()) { diffx = xbar->maxValue()-xbar->value(); } else if (xbar->value()+diffx<0) { diffx=0-xbar->value(); } if (ybar->value()+diffy>ybar->maxValue()) { diffy = ybar->maxValue()-ybar->value(); } else if (ybar->value()+diffy<0) { diffy=0-ybar->value(); } #endif scrollBy(diffx,diffy); } _mouseStartPosX=mx; _mouseStartPosY=my; } void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) { odebug << " X and Y " << e->x() << " " << e->y() << oendl; /* this marks the beginning of a possible mouse move. Due internal reasons of QT the geometry values here may real differ from that set in MoveEvent (I don't know why). For getting them in real context, we use the first move-event to set the start position ;) */ _mouseStartPosX = -1; _mouseStartPosY = -1; } void ImageScrollView::setDestructiveClose() { WFlags fl = getWFlags(); /* clear it just in case */ fl &= ~WDestructiveClose; fl |= WDestructiveClose; setWFlags( fl ); } + +bool ImageScrollView::image_fit_into(const QSize&s ) +{ + if (s.width()>width()||s.height()>height()) { + return false; + } + return true; +} + +void ImageScrollView::setShowZoomer(bool how) +{ + show_zoomer = how; + check_zoomer(); +} + +void ImageScrollView::check_zoomer() +{ + if ( (!show_zoomer||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { + _zoomer->hide(); + } else if ( show_zoomer && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ + _zoomer->show(); + } +} diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index 1b25103..e209dfb 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h @@ -1,71 +1,75 @@ #ifndef _IMAGE_SCROLL_VIEW_H #define _IMAGE_SCROLL_VIEW_H #include <lib/oimagezoomer.h> #include <qscrollview.h> #include <qimage.h> #include <qpixmap.h> #include <qstring.h> #include <qdialog.h> class QPainter; class ImageScrollView:public QScrollView { Q_OBJECT public: ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); virtual ~ImageScrollView(); virtual void setImage(const QImage&); virtual void setImage( const QString& path ); virtual void setDestructiveClose(); virtual void setAutoRotate(bool); virtual void setAutoScale(bool); + virtual void setShowZoomer(bool); enum Rotation { Rotate0, Rotate90, Rotate180, Rotate270 }; signals: void sig_return(); void imageSizeChanged( const QSize& ); void viewportSizeChanged( const QSize& ); protected: virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); void init(); Opie::MM::OImageZoomer *_zoomer; QImage _image_data; QImage _original_data; QPixmap _pdata; int _mouseStartPosX,_mouseStartPosY; bool scale_to_fit; bool rotate_to_fit; + bool show_zoomer; bool first_resize_done; Rotation last_rot; QString m_lastName; virtual void rescaleImage(int w, int h); virtual void rotate_into_data(Rotation r); virtual void generateImage(); + bool image_fit_into(const QSize&s); + void check_zoomer(); protected slots: virtual void viewportMouseMoveEvent(QMouseEvent* e); virtual void contentsMousePressEvent ( QMouseEvent * e); virtual void resizeEvent(QResizeEvent * e); virtual void keyPressEvent(QKeyEvent * e); }; #endif diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 3650493..ef23f79 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -13,281 +13,296 @@ #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/applnk.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qmap.h> #include <qtimer.h> OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 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("phunkview"); m_cfg->setGroup("Zecke_view" ); // qDebug( "Process-wide OApplication object @ %0x", oApp ); /* * Initialize ToolBar and IconView * And Connect Them */ QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( true ); setToolBarsMovable( false ); 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&)) ); QToolButton *btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "up" ) ); connect( btn, SIGNAL(clicked()), m_view, SLOT(slotDirUp()) ); btn = new PFileSystem( bar ); connect( btn, SIGNAL( changeDir( const QString& ) ), m_view, SLOT(slotChangeDir( const QString& ) ) ); btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "edit" ) ); connect( btn, SIGNAL(clicked()), m_view, SLOT(slotRename()) ); if ( Ir::supported() ) { btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "beam" ) ); connect( btn, SIGNAL(clicked()), m_view, SLOT(slotBeam()) ); } btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "trash" ) ); connect( btn, SIGNAL(clicked() ), m_view, SLOT(slotTrash() ) ); btn = new QToolButton( bar ); btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); connect( btn, SIGNAL(clicked() ), this, SLOT(slotConfig() ) ); rotateButton = new QToolButton(bar); rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); rotateButton->setToggleButton(true); rotateButton->setOn(true); connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); autoRotate = true; btn = new QToolButton(bar); btn->setIconSet( Resource::loadIconSet( "1to1" ) ); btn->setToggleButton(true); btn->setOn(false); connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); autoScale = true; + btn = new QToolButton(bar); + btn->setIconSet( Resource::loadIconSet( "mag" ) ); + btn->setToggleButton(true); + btn->setOn(true); + connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); + zoomerOn = true; } PMainWindow::~PMainWindow() { odebug << "Shutting down" << oendl; } +void PMainWindow::slotZoomerToggled(bool how) +{ + zoomerOn = how; + if (m_disp) { + m_disp->setShowZoomer(zoomerOn); + } +} + void PMainWindow::slotRotateToggled(bool how) { autoRotate = how; if (m_disp) { m_disp->setAutoRotate(how); } } void PMainWindow::slotScaleToggled(bool how) { autoScale = !how; if (m_disp) { m_disp->setAutoScale(autoScale); } if (!autoScale && autoRotate) { rotateButton->setOn(false); } rotateButton->setEnabled(!how); } 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("Phunk View - Config" ) ); QHBoxLayout *lay = new QHBoxLayout(&dlg); Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); lay->addWidget( wid ); ViewMap *vM = viewMap(); ViewMap::Iterator _it = vM->begin(); QMap<PDirView*, QWidget*> lst; for( ; _it != vM->end(); ++_it ) { PDirView *view = (_it.data())(*m_cfg); PInterfaceInfo *inf = view->interfaceInfo(); QWidget *_wid = inf->configWidget( *m_cfg ); _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) { m_disp->setAutoScale(autoScale); m_disp->setAutoRotate(autoRotate); + m_disp->setShowZoomer(zoomerOn); connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); } } /** * 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_info ) { initInfo(); } m_info->setPath( inf ); m_stack->raiseWidget( ImageInfo ); } void PMainWindow::slotDisplay( const QString& inf ) { if ( !m_disp ) { initDisp(); } m_disp->setImage( inf ); 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 ) { raiseIconView(); ev->ignore(); return; } ev->accept(); QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } void PMainWindow::raiseIconView() { m_stack->raiseWidget( IconView ); } void PMainWindow::setDocument( const QString& showImg ) { QString file = showImg; DocLnk lnk(showImg); if (lnk.isValid() ) file = lnk.file(); slotDisplay( file ); } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 59dba30..e9b16d0 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h @@ -1,70 +1,72 @@ /* * 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 PIconView; class imageinfo; class ImageView; 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(); public slots: void slotShowInfo( const QString& inf ); void slotDisplay( const QString& inf ); void slotReturn(); void slotRotateToggled(bool); void slotScaleToggled(bool); + void slotZoomerToggled(bool); void setDocument( const QString& ); protected: void raiseIconView(); void closeEvent( QCloseEvent* ); private: template<class T> void initT( const char* name, T**, int ); void initInfo(); void initDisp(); private: Opie::Core::OConfig *m_cfg; Opie::Ui::OWidgetStack *m_stack; PIconView* m_view; imageinfo *m_info; ImageView *m_disp; bool autoRotate; bool autoScale; + bool zoomerOn; QToolButton*rotateButton; private slots: void slotConfig(); }; #endif |