From 7ba8c197150a86c2406a029e4a7f02d1285c47c0 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 7 Jun 2014 23:11:55 +0200 Subject: Add Skip in PictureViewer2 PageDown = back 25 PageUp = forward 25 --- pictureviewer2.cpp | 25 +++++++++++++++++++++++++ pictureviewer2.h | 5 ++++- shemov.cpp | 20 ++++++++++++++++++++ shemov.h | 4 ++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/pictureviewer2.cpp b/pictureviewer2.cpp index b84d07d..6a547f3 100644 --- a/pictureviewer2.cpp +++ b/pictureviewer2.cpp @@ -195,6 +195,19 @@ void PictureViewer2::previous(){ showFile(mFiles.at(mCurPos)); } +void PictureViewer2::skip(int amount){ + int next = mCurPos + amount; + if(next >= mFiles.size()){ + next = next - mFiles.size(); + } + if(next < 0){ + next = mFiles.size() + next; + } + mMarkA->setChecked(mMarkedFiles.contains(mFiles.at(next))); + showFile(mFiles.at(next)); + mCurPos = next; +} + void PictureViewer2::selectPic(const QString &path){ for(int i = 0; i < mFiles.size(); ++i){ if(mFiles.at(i).at(PicFilesModel::FullPath) == path){ @@ -262,6 +275,12 @@ void PictureViewer2::initActions(){ if(a->data().toInt() == DeleteAction){ mDeleteA = a; } + if(a->data().toInt() == SkipForwardAction){ + mSkipForwardA = a; + } + if(a->data().toInt() == SkipBackwardAction){ + mSkipBackwardA = a; + } } } @@ -368,6 +387,12 @@ void PictureViewer2::keyPressEvent(QKeyEvent *e){ deleteCurrent(); next(); } + if(e->key() == Qt::Key_PageDown){ + mSkipForwardA->trigger(); + } + if(e->key() == Qt::Key_PageUp){ + mSkipBackwardA->trigger(); + } e->accept(); } diff --git a/pictureviewer2.h b/pictureviewer2.h index eabc3a0..6a1c92a 100644 --- a/pictureviewer2.h +++ b/pictureviewer2.h @@ -34,7 +34,7 @@ typedef QList > PicDataList; class PictureViewer2 : public QGraphicsView { Q_OBJECT public: - enum AssocActions { SlideAction, HideAction, MarkAction, DeleteAction }; + enum AssocActions { SlideAction, HideAction, MarkAction, DeleteAction, SkipForwardAction, SkipBackwardAction }; explicit PictureViewer2(QWidget *parent = 0); void addFiles(const PicDataList &files, bool clear = true); void addFiles(const QString &dir, bool clear = true); @@ -52,6 +52,7 @@ class PictureViewer2 : public QGraphicsView { public slots: void next(); void previous(); + void skip(int amount); void selectPic(const QString &path); void slide(bool); void readSettings(); @@ -104,6 +105,8 @@ class PictureViewer2 : public QGraphicsView { QAction *mHideA; QAction *mMarkA; QAction *mDeleteA; + QAction *mSkipForwardA; + QAction *mSkipBackwardA; MappingTreeModel *mMappingTreeModel; PicFilesModel *mPicFilesModel; PicData mCurPicData; diff --git a/shemov.cpp b/shemov.cpp index b616f4c..caed7f2 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -562,6 +562,16 @@ void SheMov::createActions(){ connect(mPVSlideA, SIGNAL(toggled(bool)), this, SLOT(setSlide(bool))); picViewer->addAction(createSeparator()); picViewer->addAction(mPVSlideA); + mPVSkipForwardA = new QAction(tr("Skip 25 forward"), this); + connect(mPVSkipForwardA, SIGNAL(triggered()), this, SLOT(skipForward())); + mPVSkipForwardA->setData(PictureViewer2::SkipForwardAction); + mPVSkipBackA = new QAction(tr("Skip 25 back"), this); + connect(mPVSkipBackA, SIGNAL(triggered()), this, SLOT(skipBack())); + mPVSkipBackA->setData(PictureViewer2::SkipBackwardAction); + picViewer->addAction(createSeparator()); + picViewer->addAction(mPVSkipForwardA); + picViewer->addAction(mPVSkipBackA); + picViewer->addAction(createSeparator()); // Shuffle mPVShuffleA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Shuffle"), this); @@ -1073,3 +1083,13 @@ void SheMov::newPicsDialogWithFiles(){ mNewPicsDialog->addFiles(files); mNewPicsDialog->exec(); } + +void SheMov::skipForward(){ + PictureViewer2 *picViewer = SmGlobals::instance()->pictureViewer(); + picViewer->skip(25); +} + +void SheMov::skipBack(){ + PictureViewer2 *picViewer = SmGlobals::instance()->pictureViewer(); + picViewer->skip(-25); +} diff --git a/shemov.h b/shemov.h index f302c59..bc9c962 100644 --- a/shemov.h +++ b/shemov.h @@ -51,6 +51,8 @@ class SheMov : public QMainWindow { void checkMount(bool mounted); void newPicsDialog(); void newPicsDialogWithFiles(); + void skipForward(); + void skipBack(); void analyzeActors(); void analyzeGenres(); @@ -134,6 +136,8 @@ class SheMov : public QMainWindow { QAction *mPVCopyToA; QAction *mPVShowNPDialogA; QAction *mPVAddToNPA; + QAction *mPVSkipForwardA; + QAction *mPVSkipBackA; QActionGroup *mPicActionGroup; //EndActions -- cgit v1.2.3-70-g09d2