summaryrefslogtreecommitdiffstats
path: root/pictureviewer2.cpp
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 /pictureviewer2.cpp
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.
Diffstat (limited to 'pictureviewer2.cpp')
-rw-r--r--pictureviewer2.cpp21
1 files changed, 21 insertions, 0 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){