Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions qml/FileCopyProgress.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FileCopyProgressForm {
standardButtons: Dialog.Cancel
id: copyFileDialog
closePolicy: Popup.CloseOnEscape
property string targetPath : ""

Connections
{
Expand All @@ -20,7 +21,7 @@ FileCopyProgressForm {

onOpened:
{
filesystem.startCopyFilesToRemovableDrive()
filesystem.startCopyFilesToPath(targetPath)
}

function updateProgress(progress)
Expand All @@ -33,9 +34,4 @@ FileCopyProgressForm {
console.log("Cancel copy")
filesystem.abortCopy()
}

onClosed:
{
filesystem.unmountRemoveableDrive()
}
}
23 changes: 23 additions & 0 deletions qml/SettingsMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,35 @@ SettingsMenuForm {
}
}

CustomFolderDialog
{
id: pictureCopyFolderDialog
title: qsTr("Select Copy Pictures Folder")
anchors.centerIn: parent
width: parent.width - 100
height: parent.height - 100

onAccepted: function()
{
console.log("Selected copy folder: " + pictureCopyFolderDialog.currentFolder)
copyProgressPopup.targetPath = pictureCopyFolderDialog.currentFolder
copyProgressPopup.open()
}
}

buttonSelectPhotoDirectory.onClicked:
{
pictureFolderDialog.currentFolder = applicationSettings.foldername
console.log("selecting pictures folder: " + pictureFolderDialog.currentFolder)
pictureFolderDialog.open()
}

buttonCopyPhotosCustomLocation.onClicked:
{
pictureCopyFolderDialog.currentFolder = StandardPaths.writableLocation(StandardPaths.HomeLocation)
pictureCopyFolderDialog.open()
}

buttonClose.onClicked:
{
exitSettings()
Expand All @@ -139,6 +161,7 @@ SettingsMenuForm {

buttonCopyPhotos.onClicked:
{
copyProgressPopup.targetPath = filesystem.getRemovableDrivePath()
copyProgressPopup.open()
}

Expand Down
11 changes: 11 additions & 0 deletions qml/SettingsMenuForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Item {
property alias switchPrinter: switchPrinter
property alias switchPrintFromGallery: switchPrintFromGallery
property alias buttonCopyPhotos: buttonCopyPhotos
property alias buttonCopyPhotosCustomLocation: buttonCopyPhotosCustomLocation
property alias switchMirrorCamera: switchMirrorCamera
property alias comboBoxPrinter: comboBoxPrinter
property alias comboBoxCamera: comboBoxCamera
Expand Down Expand Up @@ -117,6 +118,16 @@ Item {
text: qsTr("Copy photos to removable disk")
}

Button {
id: buttonCopyPhotosCustomLocation
text: qsTr("Copy photos to custom location")
}

ToolSeparator {
Layout.fillWidth: true
orientation: Qt.Horizontal
}

DelayButton {
id: buttonDeletePhotos
text: qsTr("Delete all photos")
Expand Down
31 changes: 20 additions & 11 deletions src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,23 @@ void FileSystem::unmountRemoveableDrive()
unmountProcess.waitForFinished();
}

void FileSystem::startCopyFilesToRemovableDrive()
void FileSystem::startCopyFilesToPath(const QString &path)
{
QString imagePath = this->getImagePath();
imagePath = imagePath.right(imagePath.length() - QString("file://").length());
QString removableDrivePath = this->getRemovableDrivePath();
qDebug() << "Try to copy all images to removable drive";

if(removableDrivePath.length())
QString copyPath;
if (path.startsWith("file://", Qt::CaseInsensitive))
{
QUrl url(path);
copyPath = QUrl(path).toLocalFile();
}
else
{
copyPath = path;
}

if(copyPath.length())
{
QDir imageDir(imagePath);
QStringList filters;
Expand All @@ -161,7 +170,7 @@ void FileSystem::startCopyFilesToRemovableDrive()
if(!imageDir.isEmpty() && imageDir.exists())
{
qDebug() << "Image folder not empty and found removable disc. Copying...";
m_copyFuture = QtConcurrent::run([removableDrivePath,imagePath, this]() {
m_copyFuture = QtConcurrent::run([copyPath,imagePath, this]() {
QDir imageDir(imagePath);
QStringList filters;
filters << "*.jpg" << "*.JPG";
Expand All @@ -174,13 +183,13 @@ void FileSystem::startCopyFilesToRemovableDrive()
for(i = 0; i < files.count() && !this->m_copyFuture.isCanceled(); i++)
{
int progress = (100 * i + 1) / files.count();
qDebug() << "Copy file: " << imagePath + "/" + files[i] << " to: " << removableDrivePath + "/" + files[i] << " Progress: " << progress;
if(QFile::exists(removableDrivePath + "/" + files[i]))
QFile::remove(removableDrivePath + "/" + files[i]);
qDebug() << "Copy file: " << imagePath + "/" + files[i] << " to: " << copyPath + "/" + files[i] << " Progress: " << progress;
if(QFile::exists(copyPath + "/" + files[i]))
QFile::remove(copyPath + "/" + files[i]);

if(!QFile::copy(imagePath + "/" + files[i], removableDrivePath + "/" + files[i]))
if(!QFile::copy(imagePath + "/" + files[i], copyPath + "/" + files[i]))
{
if(!QFile::copy(imagePath + "/collage/" + files[i], removableDrivePath + "/" + files[i]))
if(!QFile::copy(imagePath + "/collage/" + files[i], copyPath + "/" + files[i]))
{
qDebug() << "Copying file: " << files[i] << " was not successfull";
}
Expand Down Expand Up @@ -211,7 +220,7 @@ void FileSystem::startCopyFilesToRemovableDrive()
QString FileSystem::getRemovableDrivePath()
{
static QRegularExpression regexDrive("\\/dev\\/sd*");
static QRegularExpression regexBoot("\\/boot");
static QRegularExpression regexBoot("^/(boot|home|tmp)?$");
QList<QStorageInfo> drives = QStorageInfo::mountedVolumes();
for(int i = 0; i < drives.count(); i++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class FileSystem : public QObject
Q_INVOKABLE void checkImageFolders();
Q_INVOKABLE bool removableDriveMounted();
Q_INVOKABLE void unmountRemoveableDrive();
Q_INVOKABLE void startCopyFilesToRemovableDrive();
Q_INVOKABLE void startCopyFilesToPath(const QString &path);
Q_INVOKABLE void abortCopy();
Q_INVOKABLE void deleteAllImages();
Q_INVOKABLE bool layoutFilesOnRemovableDrive();
Q_INVOKABLE void copyLayoutFiles();
Q_INVOKABLE QSize getImageSize(QString filename);
Q_INVOKABLE QString getRemovableDrivePath();
protected:
QString getRemovableDrivePath();
QFuture<void> m_copyFuture;
signals:
void copyProgress(int progress);
Expand Down