summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2012-09-08 11:38:09 +0200
committerArno <am@disconnect.de>2012-09-08 11:38:09 +0200
commitc90f920ebc2dd3386d4f84df3ad25480fbaf616b (patch)
tree8c86019127587816564ce11249343cd7c980f921
parent2edb6f9b4d70b85b9209d75d1baa7a16e3b8d279 (diff)
downloadSheMov-c90f920ebc2dd3386d4f84df3ad25480fbaf616b.tar.gz
SheMov-c90f920ebc2dd3386d4f84df3ad25480fbaf616b.tar.bz2
SheMov-c90f920ebc2dd3386d4f84df3ad25480fbaf616b.zip
Implement copy file from PictureViewer2
Add an action to PictureViewer2 for copying the current pic to another directory. When I tried to add the QAction to the context menu, I realized that I chose the variable names picView and picViewer in shemov.cpp very poorly. Took some time to sift though it. Eventually I shifted some code around to make it more readable. While at it I replaced the individual separators with createSeparator(). Other than adding the Copy To action no functional changes.
-rw-r--r--pictureviewer2.cpp21
-rw-r--r--pictureviewer2.h1
-rw-r--r--shemov.cpp142
-rw-r--r--shemov.h1
4 files changed, 99 insertions, 66 deletions
diff --git a/pictureviewer2.cpp b/pictureviewer2.cpp
index eee77af..bf2dbce 100644
--- a/pictureviewer2.cpp
+++ b/pictureviewer2.cpp
@@ -24,6 +24,9 @@
#include <QDir>
#include <QFileInfo>
#include <QFileInfoList>
+#include <QFileDialog>
+#include <QFile>
+#include <QMessageBox>
#include "pictureviewer2.h"
#include "pictureswidget.h"
@@ -197,6 +200,24 @@ void PictureViewer2::initActions(){
}
}
+void PictureViewer2::copyCurrent(){
+ QString fullPath = mFiles.at(mCurPos).at(PicFilesModel::FullPath).toString();
+ QSettings s;
+ QString lastDir = s.value("ui/pvlastdir", QDir::homePath()).toString();
+ QString destDir = QFileDialog::getExistingDirectory(this, tr("Copy picture"), lastDir);
+ if(!destDir.isEmpty()){
+ QFileInfo fi(fullPath);
+ QString copyTo = QString("%1/%2").arg(destDir).arg(fi.fileName());
+ bool success = QFile::copy(fullPath, copyTo);
+ if(!success){
+ QString msg = QString(tr("File copy %1 -> %2 failed!")).arg(fullPath).arg(copyTo);
+ QMessageBox::critical(this, tr("Error"), msg);
+ }else{
+ s.setValue("ui/pvlastdir", destDir);
+ }
+ }
+}
+
void PictureViewer2::wheelEvent(QWheelEvent *event){
int steps = event->delta() / 8 / 15;
if(steps < 0){
diff --git a/pictureviewer2.h b/pictureviewer2.h
index 95f4824..d9fec03 100644
--- a/pictureviewer2.h
+++ b/pictureviewer2.h
@@ -49,6 +49,7 @@ class PictureViewer2 : public QGraphicsView {
void writeSettings();
void shuffle();
void initActions();
+ void copyCurrent();
protected:
virtual void wheelEvent(QWheelEvent *event);
diff --git a/shemov.cpp b/shemov.cpp
index 6857b39..f9859be 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -596,72 +596,82 @@ void SheMov::createActions(){
mPlaySelectedArchiveFilesA = new QAction(tr("Play selected...."), this);
connect(mPlaySelectedArchiveFilesA, SIGNAL(triggered()), mATree->filesWidget(), SLOT(playSelected()));
- //picture widget
- // delete + edit
- mPWDeletePicFromA = new QAction(QIcon(":/huge_balls_pierced.png"), tr("Delete..."), this);
- mPicWidget->picView()->addAction(mPWDeletePicFromA);
- connect(mPWDeletePicFromA, SIGNAL(triggered()), mPicWidget->picView(), SLOT(deletePics()));
- mPWEditPicMappingsA = new QAction(QIcon(":/squirting_nipple.png"), tr("Edit mappings..."), this);
- mPicWidget->picView()->addAction(mPWEditPicMappingsA);
- connect(mPWEditPicMappingsA, SIGNAL(triggered()), mPicWidget->picView(), SIGNAL(editPicsMappings()));
- QAction *pvSep1 = new QAction(this);
- pvSep1->setSeparator(true);
- mPicWidget->picView()->addAction(pvSep1);
-
- // viewer actions
- PictureViewer2 *picViewer = SmGlobals::instance()->pictureViewer();
- mPVToggleA = new QAction(QIcon(":/dick_in_cage.png"), tr("Show/Hide Picture Viewer"), this);
- mPVToggleA->setCheckable(true);
- mPVToggleA->setData(PictureViewer2::HideAction);
- connect(mPVToggleA, SIGNAL(toggled(bool)), picViewer, SLOT(setVisible(bool)));
- mPVToggleA->setChecked(false);
- mPicWidget->picView()->addAction(mPVToggleA);
- picViewer->addAction(mPVToggleA);
-
- //add or replace pictures: pictureviewer
- QSignalMapper *PVAddMapper = new QSignalMapper(this);
- mPVAddA = new QAction(QIcon(":/used_tampon.png"), tr("Add selected"), this);
- connect(mPVAddA, SIGNAL(triggered()), PVAddMapper, SLOT(map()));
- PVAddMapper->setMapping(mPVAddA, false);
- mPicWidget->picView()->addAction(mPVAddA);
- mPVReplaceA = new QAction(QIcon(":/clean_tampon.png"), tr("Replace with selected"), this);
- connect(mPVReplaceA, SIGNAL(triggered()), PVAddMapper, SLOT(map()));
- PVAddMapper->setMapping(mPVReplaceA, true);
- mPicWidget->picView()->addAction(mPVReplaceA);
- connect(PVAddMapper, SIGNAL(mapped(int)), mPicWidget->picView(), SLOT(setPVData(int)));
-
- //select all from current, see tabChanged(int)
- mPVSelectAllA = new QAction(QIcon(":/blue_syringe.png"), tr("Select all pics"), this);
- picViewer->addAction(mPVSelectAllA);
-
- //slide
- QAction *pvSep2 = new QAction(this);
- pvSep2->setSeparator(true);
- mPicWidget->picView()->addAction(pvSep2);
- mPVSlideA = new QAction(QIcon(":/chastity_belt_with_cuffs.png"), tr("Slide"), this);
- mPVSlideA->setCheckable(true);
- mPVSlideA->setData(PictureViewer2::SlideAction);
- connect(mPVSlideA, SIGNAL(toggled(bool)), picViewer, SLOT(slide(bool)));
- connect(mPVSlideA, SIGNAL(toggled(bool)), this, SLOT(setSlide(bool)));
- QAction *pv2Sep1 = new QAction(this);
- pv2Sep1->setSeparator(true);
- picViewer->addAction(pv2Sep1);
- picViewer->addAction(mPVSlideA);
-
- //shuffle
- QAction *pvSep3 = new QAction(this);
- pvSep3->setSeparator(true);
- mPicWidget->picView()->addAction(pvSep3);
- mPVShuffleA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Shuffle"), this);
- connect(mPVShuffleA, SIGNAL(triggered()), picViewer, SLOT(shuffle()));
- picViewer->addAction(mPVShuffleA);
-
- // refresh
- mPWRefreshA = new QAction(QIcon(":/huge_bra.png"), tr("Refresh"), this);
- mPicWidget->picView()->addAction(mPWRefreshA);
- connect(mPWRefreshA, SIGNAL(triggered()), mPicWidget->picView(), SLOT(refresh()));
- mPicWidget->setPicViewerAction(mPVToggleA);
- picViewer->initActions();
+ /* very unfortunate naming of variables:
+ * picViewer: the actual PictureViewer2 window
+ * picView: the picture files TreeView
+ * First: the Treeview -> picView */
+
+ // Delete... + Edit Mappings...
+ mPWDeletePicFromA = new QAction(QIcon(":/huge_balls_pierced.png"), tr("Delete..."), this);
+ mPicWidget->picView()->addAction(mPWDeletePicFromA);
+ connect(mPWDeletePicFromA, SIGNAL(triggered()), mPicWidget->picView(), SLOT(deletePics()));
+ mPWEditPicMappingsA = new QAction(QIcon(":/squirting_nipple.png"), tr("Edit mappings..."), this);
+ mPicWidget->picView()->addAction(mPWEditPicMappingsA);
+ connect(mPWEditPicMappingsA, SIGNAL(triggered()), mPicWidget->picView(), SIGNAL(editPicsMappings()));
+ mPicWidget->picView()->addAction(createSeparator());
+
+ // Show/Hide Picture Viewer
+ PictureViewer2 *picViewer = SmGlobals::instance()->pictureViewer();
+ mPVToggleA = new QAction(QIcon(":/dick_in_cage.png"), tr("Show/Hide Picture Viewer"), this);
+ mPVToggleA->setCheckable(true);
+ mPVToggleA->setData(PictureViewer2::HideAction);
+ connect(mPVToggleA, SIGNAL(toggled(bool)), picViewer, SLOT(setVisible(bool)));
+ mPVToggleA->setChecked(false);
+ mPicWidget->picView()->addAction(mPVToggleA);
+
+ // Add selected + Replace with selected
+ QSignalMapper *PVAddMapper = new QSignalMapper(this);
+ mPVAddA = new QAction(QIcon(":/used_tampon.png"), tr("Add selected"), this);
+ connect(mPVAddA, SIGNAL(triggered()), PVAddMapper, SLOT(map()));
+ PVAddMapper->setMapping(mPVAddA, false);
+ mPicWidget->picView()->addAction(mPVAddA);
+ mPVReplaceA = new QAction(QIcon(":/clean_tampon.png"), tr("Replace with selected"), this);
+ connect(mPVReplaceA, SIGNAL(triggered()), PVAddMapper, SLOT(map()));
+ PVAddMapper->setMapping(mPVReplaceA, true);
+ mPicWidget->picView()->addAction(mPVReplaceA);
+ connect(PVAddMapper, SIGNAL(mapped(int)), mPicWidget->picView(), SLOT(setPVData(int)));
+
+ // Refresh
+ mPicWidget->picView()->addAction(createSeparator());
+ mPWRefreshA = new QAction(QIcon(":/huge_bra.png"), tr("Refresh"), this);
+ mPicWidget->picView()->addAction(mPWRefreshA);
+ connect(mPWRefreshA, SIGNAL(triggered()), mPicWidget->picView(), SLOT(refresh()));
+ mPicWidget->setPicViewerAction(mPVToggleA);
+
+ /* Now the context menu for the actual Viewer
+ * picViewer -> PictureViewer2 */
+
+ // Show/Hide Picture Viewer
+ picViewer->addAction(mPVToggleA);
+
+ // Select all pics
+ mPVSelectAllA = new QAction(QIcon(":/blue_syringe.png"), tr("Select all pics"), this);
+ picViewer->addAction(mPVSelectAllA);
+
+ // Slide
+ mPVSlideA = new QAction(QIcon(":/chastity_belt_with_cuffs.png"), tr("Slide"), this);
+ mPVSlideA->setCheckable(true);
+ mPVSlideA->setData(PictureViewer2::SlideAction);
+ connect(mPVSlideA, SIGNAL(toggled(bool)), picViewer, SLOT(slide(bool)));
+ connect(mPVSlideA, SIGNAL(toggled(bool)), this, SLOT(setSlide(bool)));
+ picViewer->addAction(createSeparator());
+ picViewer->addAction(mPVSlideA);
+
+ // Shuffle
+ mPVShuffleA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Shuffle"), this);
+ connect(mPVShuffleA, SIGNAL(triggered()), picViewer, SLOT(shuffle()));
+ picViewer->addAction(mPVShuffleA);
+ picViewer->addAction(createSeparator());
+
+ // Copy to...
+ mPVCopyToA = new QAction(tr("Copy to..."), this);
+ connect(mPVCopyToA, SIGNAL(triggered()), picViewer, SLOT(copyCurrent()));
+ picViewer->addAction(mPVCopyToA);
+
+ // assign actions to PictureViewer2 members, so they can be toggled from within
+ picViewer->initActions();
+
+ /* picView(er) END Actions! */
//don't add actions with checkable(true) unless you know what you're doing!
mPicActionGroup = new QActionGroup(this);
diff --git a/shemov.h b/shemov.h
index 186a79f..33fd743 100644
--- a/shemov.h
+++ b/shemov.h
@@ -178,6 +178,7 @@ class SheMov : public QMainWindow {
QAction *mPVSelectAllA;
QAction *mPVSlideA;
QAction *mPVShuffleA;
+ QAction *mPVCopyToA;
QActionGroup *mPicActionGroup;
//EndActions