summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-10-13 06:10:11 +0200
committerArno <arno@disconnect.de>2018-10-13 06:10:11 +0200
commitd8e62dd6e715fcc19b7e7d4d466a586c62ccc4e6 (patch)
treef62268b207ebd60f409809a1ba2a92124af700c0
parent63925668bf49473c2095c30c59e75f9cf1e46918 (diff)
downloadBeetPlayer-d8e62dd6e715fcc19b7e7d4d466a586c62ccc4e6.tar.gz
BeetPlayer-d8e62dd6e715fcc19b7e7d4d466a586c62ccc4e6.tar.bz2
BeetPlayer-d8e62dd6e715fcc19b7e7d4d466a586c62ccc4e6.zip
Actually do something when calling CopyDialg::copy()
Implement copying files. The GUI is quite slow when copying to a device mounted with flush, eg. an USB-Stick, but that's to be expected...
-rw-r--r--copydialog.cpp23
-rw-r--r--copydialog.h2
2 files changed, 24 insertions, 1 deletions
diff --git a/copydialog.cpp b/copydialog.cpp
index 0ae2f73..957dfe5 100644
--- a/copydialog.cpp
+++ b/copydialog.cpp
@@ -7,6 +7,8 @@
#include <QSettings>
#include <QCloseEvent>
#include <QFileDialog>
+#include <QProgressDialog>
+#include <QMessageBox>
#include "copydialog.h"
@@ -45,6 +47,7 @@ CopyDialog::CopyDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
resultGB->setLayout(resultL);
QHBoxLayout *buttonL = new QHBoxLayout;
QPushButton *copyB = new QPushButton(tr("Copy!"));
+ connect(copyB, &QPushButton::clicked, this, &CopyDialog::copy);
buttonL->addStretch();
buttonL->addWidget(copyB);
QPushButton *closeB = new QPushButton(tr("Close"));
@@ -96,6 +99,26 @@ void CopyDialog::refresh(){
mResultTE->setText(res);
}
+void CopyDialog::copy(){
+ QString destDir = QString("%1/%2").arg(mDstE->text()).arg(mFolderE->text());
+ QFile destF(destDir);
+ if(destF.exists()){
+ QMessageBox::critical(this, tr("Error"), tr("Destination directory already exists!"));
+ return;
+ }
+ QDir ddir(mDstE->text());
+ ddir.mkdir(mFolderE->text());
+ QProgressDialog progress(tr("Copying files..."), tr("Cancel"), 0, mSources.count(), this);
+ progress.setWindowModality(Qt::WindowModal);
+ for(int i = 0; i < mSources.count(); ++i){
+ progress.setValue(i);
+ QString dest = getDestinationFile(mSources.at(i));
+ QFile::copy(mSources.at(i), dest);
+ }
+ progress.setValue(mSources.count());
+ close();
+}
+
QString CopyDialog::getDestinationFile(const QString &srcFn){
QFileInfo fi(srcFn);
if(fi.exists()){
diff --git a/copydialog.h b/copydialog.h
index 10d46b9..563a5c8 100644
--- a/copydialog.h
+++ b/copydialog.h
@@ -17,7 +17,7 @@ class CopyDialog : public QDialog {
void setDestFolder(const QString &dst);
void setSources(const QStringList &sources);
void refresh();
-
+ void copy();
protected:
QString getDestinationFile(const QString &srcFn);