author | alwin <alwin> | 2004-11-01 01:58:25 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-01 01:58:25 (UTC) |
commit | d69955ef9cddc3acc37b9dc96945cd4bae56eed5 (patch) (side-by-side diff) | |
tree | 7982a6da8f8141292eb0a1c09ce384784af2801d /noncore | |
parent | 01fb5d6957984fe6fe5ed2109a024be7e8159d16 (diff) | |
download | opie-d69955ef9cddc3acc37b9dc96945cd4bae56eed5.zip opie-d69955ef9cddc3acc37b9dc96945cd4bae56eed5.tar.gz opie-d69955ef9cddc3acc37b9dc96945cd4bae56eed5.tar.bz2 |
some menu working
some debug messages removed
tried to remove some interesting effects when switching view mode
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageinfoui.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 54 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 4 |
5 files changed, 45 insertions, 23 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp index e70d6a6..7afb62d 100644 --- a/noncore/graphics/opie-eye/gui/imageinfoui.cpp +++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp @@ -1,205 +1,204 @@ #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 <qpe/qcopenvelope_qws.h> #include <qpe/resource.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() { - odebug << "init imageinfo keys" << oendl; #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", Resource::loadPixmap("1to1"), 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( Resource::loadPixmap( "UnknownDocument" ))); 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 c7e48cb..86db732 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -1,238 +1,237 @@ #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; } void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) { m_gDisplayType = disptypeGroup; m_gPrevNext = nextprevGroup; m_hGroup = hGroup; } 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::stopSlide() { if (!m_slideTimer) { return; } m_slideTimer->stop(); delete m_slideTimer; m_slideTimer = 0; } 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 = 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(); } 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) +void ImageView::setFullScreen(bool how,bool force) { m_isFullScreen = how; if (how) { m_ignore_next_in = true; setFixedSize(qApp->desktop()->size()); - showFullScreen(); + 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 640905a..2408211 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,76 +1,76 @@ #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); + 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); 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; 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 570ee45..ece51a1 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -1,638 +1,660 @@ /* * 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("phunkview"); - m_cfg->setGroup("Zecke_view" ); + m_cfg = new Opie::Core::OConfig("opie-eye"); + m_cfg->setGroup("main" ); 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("base_showtoolbar",true)); } PMainWindow::~PMainWindow() { } void PMainWindow::slotToggleZoomer() { if (!m_disp) return; bool cur = m_aZoomer->isOn(); m_aZoomer->setOn(!cur); } void PMainWindow::slotZoomerToggled(bool how) { zoomerOn = how; if (m_disp) { m_disp->setShowZoomer(zoomerOn); } } void PMainWindow::slotToggleAutorotate() { if (!m_disp) return; if (!m_aAutoRotate->isEnabled()) return; bool cur = m_aAutoRotate->isOn(); m_aAutoRotate->setOn(!cur); } void PMainWindow::slotToggleAutoscale() { if (!m_disp) return; bool cur = m_aAutoScale->isOn(); m_aAutoScale->setOn(!cur); } void PMainWindow::slotRotateToggled(bool how) { - odebug << "Autorotate: " << how << oendl; autoRotate = how; if (m_disp) { m_disp->setAutoScaleRotate(!m_aAutoScale->isOn(),m_aAutoRotate->isOn()); } } void PMainWindow::slotScaleToggled(bool how) { autoScale = !how; if (!how) { autoRotate = how; } if (!autoScale) { m_aAutoRotate->setOn(false); } if (m_disp) { m_disp->setAutoScaleRotate(!m_aAutoScale->isOn(),m_aAutoRotate->isOn()); } m_aAutoRotate->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 ); BaseSetup*bSetup = new BaseSetup(m_cfg,wid); wid->addTab(bSetup,"SettingsIcon","Basics setup"); 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 ); 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(); bSetup->save_values(); } 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->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); m_disp->setAutoScale(!m_aAutoScale->isOn()); m_disp->setAutoRotate(m_aAutoRotate->isOn()); m_disp->setShowZoomer(m_aZoomer->isOn()); 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))); slotFullScreenToggled(m_aFullScreen->isOn()); } } void PMainWindow::slotToggleFullScreen() { - odebug << "Toggle full " << oendl; bool current = !m_aFullScreen->isOn(); m_aFullScreen->setOn(current); } -void PMainWindow::slotFullScreenToggled(bool current) +void PMainWindow::slotFullScreenButton(bool current) +{ + if (m_disp) odebug << "Disp fenster ist hidden: "<<m_disp->isHidden()<<oendl; + if (!m_disp) return; + + /* I can not solve this effects here - it seems that we require some + status variable, too. so we will live with some interesting effects + meanwhile */ +#if 0 + bool th = m_disp->isHidden(); + setupViewWindow(current, false); + /* realy - after setting up the fullscreenmode while the window is hidden + it is unvisibile not hidden!!!!! Hell. */ + if (th) m_disp->hide(); +#endif + setupViewWindow(current, true); +} + +void PMainWindow::setupViewWindow(bool current, bool forceDisplay) { - odebug << "slotFullScreenToggled " << current << oendl; if (!m_disp) return; 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()); } else { setUpdatesEnabled(false); - odebug << "window" << oendl; if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { m_disp->setMinimumSize(QApplication::desktop()->size()/2); } else { m_disp->setMinimumSize(10,10); } if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { m_disp->reparent(0,QPoint(50,50)); } else { m_disp->reparent(0,QPoint(0,0)); } 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 (forceDisplay || m_disp->isVisible()) + 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); + m_disp->setFullScreen(current,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 ) { - odebug << "slotDisplay: " << inf << oendl; if ( !m_disp ) { 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 (m_disp->fullScreen()) { - //m_disp->showFullScreen(); 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_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 ) { QString file = showImg; DocLnk lnk(showImg); if (lnk.isValid() ) file = lnk.file(); slotDisplay( file ); } 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(); } 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: m_aDirName->setOn(true); break; case 2: m_aDirShort->setOn(true); break; case 1: default: m_aDirLong->setOn(true); } m_gListViewMode->insert(m_aDirLong); m_gListViewMode->insert(m_aDirShort); m_gListViewMode->insert(m_aDirName); m_gPrevNext = new QActionGroup(this,"imageprevnext",false); m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); m_aNext->setToggleAction(false); connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); m_aPrevious->setToggleAction(false); connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); m_gPrevNext->insert(m_aPrevious); m_gPrevNext->insert(m_aNext); m_aFullScreen = new QAction( tr( "Show images fullscreen" ), Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); m_aFullScreen->setToggleAction(true); m_aFullScreen->setOn(false); - connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenToggled(bool))); + connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); m_aAutoRotate->setToggleAction(true); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { m_aAutoRotate->setOn(true); autoRotate = true; } else { m_aAutoRotate->setOn(false); autoRotate = false; } connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); m_aAutoScale = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); m_aAutoScale->setToggleAction(true); m_aAutoScale->setOn (false); connect(m_aAutoScale,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); m_aZoomer->setToggleAction(true); m_aZoomer->setOn (true); zoomerOn = true; connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); m_gDisplayType->insert(m_aAutoRotate); m_gDisplayType->insert(m_aAutoScale); 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_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_aSetup->addTo(fileMenu); m_aTrash->addTo(fileMenu); - m_aHideToolbar->addTo(dispMenu); 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); } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 65151fc..703965b 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h @@ -1,105 +1,107 @@ /* * 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); protected slots: void raiseIconView(); void closeEvent( QCloseEvent* ); void showToolbar(bool); void listviewselected(QAction*); + void slotFullScreenButton(bool); 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 autoRotate; bool autoScale; bool zoomerOn; QToolButton*fsButton; QToolBar *toolBar; - QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu; + 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_aAutoScale,*m_aZoomer; /* init funs */ 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 |