summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-15 16:14:56 (UTC)
committer alwin <alwin>2004-04-15 16:14:56 (UTC)
commita002be54e33d64e69c7edf2960d5e68a9a0609e4 (patch) (side-by-side diff)
treec58f7bce41920a86f077d0c371bcf166a03d6489
parentfd31b11688704c214034a0e28ca7c0a56a6a2988 (diff)
downloadopie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.zip
opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.gz
opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.bz2
previous/next image keys implemented
ToDo: make it via keywidget, this moment the keywidget sends a key twice (on press and on release)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp48
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h6
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp25
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.h5
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp2
5 files changed, 86 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 5633312..f6e1816 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -263,16 +263,45 @@ QString PIconView::currentFileName(bool &isDir)const {
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();
+ m_view->setCurrentItem(_it);
+ 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();
+ m_view->setCurrentItem(_it);
+ return it->path();
+}
+
void PIconView::slotTrash() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
if (!QPEMessageBox::confirmDelete( this,
tr("Delete Image" ),
@@ -441,16 +470,35 @@ void PIconView::slotStart() {
void PIconView::slotEnd() {
if ( m_updatet )
m_view->arrangeItemsInGrid( );
m_view->viewport()->setUpdatesEnabled( true );
m_updatet = false;
}
+void PIconView::slotShowNext()
+{
+ bool isDir = false;
+ QString name = nextFileName(isDir);
+ if (isDir) return;
+ if (name.isEmpty()) return;
+ odebug << "Show next: " << name << oendl;
+ slotShowImage(name);
+}
+
+void PIconView::slotShowPrev()
+{
+ bool isDir = false;
+ QString name = prevFileName(isDir);
+ if (isDir) return;
+ if (name.isEmpty()) return;
+ slotShowImage(name);
+}
+
void PIconView::slotShowImage()
{
bool isDir = false;
QString name = currentFileName(isDir);
if (isDir) return;
slotShowImage( name );
}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index 903c4fd..14ad168 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -34,22 +34,28 @@ public:
~PIconView();
void resetView();
Opie::Core::OKeyConfigManager* manager();
signals:
void sig_showInfo( const QString& );
void sig_display( const QString& );
+public slots:
+ virtual void slotShowNext();
+ virtual void slotShowPrev();
+
protected:
void resizeEvent( QResizeEvent* );
private:
void initKeys();
QString currentFileName(bool &isDir)const;
+ QString nextFileName(bool &isDir)const;
+ QString prevFileName(bool &isDir)const;
void loadViews();
void calculateGrid();
private slots:
void slotDirUp();
void slotChangeDir(const QString&);
void slotTrash();
void slotViewChanged( int );
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index db3ae74..aa2b9bc 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -45,16 +45,41 @@ void ImageView::initKeys()
lst.append( Opie::Core::OKeyPair::rightArrowKey() );
m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
lst, false,this, "image_view_keys" );
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
Resource::loadPixmap("1to1"), ViewInfo,
Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton),
this, SLOT(slotShowImageInfo())));
+#if 0
+ m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage",
+ Resource::loadPixmap("next"), ViewInfo,
+ Opie::Core::OKeyPair(Qt::Key_N,0),
+ this, SLOT(slotDispNext())));
+#endif
m_viewManager->handleWidget( this );
m_viewManager->load();
}
+void ImageView::keyReleaseEvent(QKeyEvent * e)
+{
+ if (!e || e->state()!=0) {
+ return;
+ }
+ if (e->key()==Qt::Key_N) slotDispNext();
+ if (e->key()==Qt::Key_P) slotDispPrev();
+}
+
+void ImageView::slotDispNext()
+{
+ emit dispNext();
+}
+
+void ImageView::slotDispPrev()
+{
+ emit dispPrev();
+}
+
void ImageView::slotShowImageInfo()
{
emit dispImageInfo(m_lastName);
}
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h
index 1790c4f..f467f00 100644
--- a/noncore/graphics/opie-eye/gui/imageview.h
+++ b/noncore/graphics/opie-eye/gui/imageview.h
@@ -20,17 +20,22 @@ class ImageView:public Opie::MM::OImageScrollView
public:
ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 );
virtual ~ImageView();
Opie::Core::OKeyConfigManager* manager();
signals:
void dispImageInfo(const QString&);
+ void dispNext();
+ void dispPrev();
protected:
Opie::Core::OConfig * m_cfg;
Opie::Core::OKeyConfigManager*m_viewManager;
void initKeys();
protected slots:
virtual void slotShowImageInfo();
+ virtual void slotDispNext();
+ virtual void slotDispPrev();
+ virtual void keyReleaseEvent(QKeyEvent * e);
};
#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 09f562a..57be247 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -261,16 +261,18 @@ void PMainWindow::initDisp() {
if (m_disp) {
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
}
m_disp->setAutoScale(autoScale);
m_disp->setAutoRotate(autoRotate);
m_disp->setShowZoomer(zoomerOn);
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()));
}
}
/**
* 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