@@ -144,14 +144,23 @@ void FileSystem::unmountRemoveableDrive()
144144 unmountProcess.waitForFinished ();
145145}
146146
147- void FileSystem::startCopyFilesToRemovableDrive ( )
147+ void FileSystem::startCopyFilesToPath ( const QString &path )
148148{
149149 QString imagePath = this ->getImagePath ();
150150 imagePath = imagePath.right (imagePath.length () - QString (" file://" ).length ());
151- QString removableDrivePath = this ->getRemovableDrivePath ();
152- qDebug () << " Try to copy all images to removable drive" ;
153151
154- if (removableDrivePath.length ())
152+ QString copyPath;
153+ if (path.startsWith (" file://" , Qt::CaseInsensitive))
154+ {
155+ QUrl url (path);
156+ copyPath = QUrl (path).toLocalFile ();
157+ }
158+ else
159+ {
160+ copyPath = path;
161+ }
162+
163+ if (copyPath.length ())
155164 {
156165 QDir imageDir (imagePath);
157166 QStringList filters;
@@ -161,7 +170,7 @@ void FileSystem::startCopyFilesToRemovableDrive()
161170 if (!imageDir.isEmpty () && imageDir.exists ())
162171 {
163172 qDebug () << " Image folder not empty and found removable disc. Copying..." ;
164- m_copyFuture = QtConcurrent::run ([removableDrivePath ,imagePath, this ]() {
173+ m_copyFuture = QtConcurrent::run ([copyPath ,imagePath, this ]() {
165174 QDir imageDir (imagePath);
166175 QStringList filters;
167176 filters << " *.jpg" << " *.JPG" ;
@@ -174,13 +183,13 @@ void FileSystem::startCopyFilesToRemovableDrive()
174183 for (i = 0 ; i < files.count () && !this ->m_copyFuture .isCanceled (); i++)
175184 {
176185 int progress = (100 * i + 1 ) / files.count ();
177- qDebug () << " Copy file: " << imagePath + " /" + files[i] << " to: " << removableDrivePath + " /" + files[i] << " Progress: " << progress;
178- if (QFile::exists (removableDrivePath + " /" + files[i]))
179- QFile::remove (removableDrivePath + " /" + files[i]);
186+ qDebug () << " Copy file: " << imagePath + " /" + files[i] << " to: " << copyPath + " /" + files[i] << " Progress: " << progress;
187+ if (QFile::exists (copyPath + " /" + files[i]))
188+ QFile::remove (copyPath + " /" + files[i]);
180189
181- if (!QFile::copy (imagePath + " /" + files[i], removableDrivePath + " /" + files[i]))
190+ if (!QFile::copy (imagePath + " /" + files[i], copyPath + " /" + files[i]))
182191 {
183- if (!QFile::copy (imagePath + " /collage/" + files[i], removableDrivePath + " /" + files[i]))
192+ if (!QFile::copy (imagePath + " /collage/" + files[i], copyPath + " /" + files[i]))
184193 {
185194 qDebug () << " Copying file: " << files[i] << " was not successfull" ;
186195 }
@@ -211,7 +220,7 @@ void FileSystem::startCopyFilesToRemovableDrive()
211220QString FileSystem::getRemovableDrivePath ()
212221{
213222 static QRegularExpression regexDrive (" \\ /dev\\ /sd*" );
214- static QRegularExpression regexBoot (" \\ / boot" );
223+ static QRegularExpression regexBoot (" ^/( boot|home|tmp)?$ " );
215224 QList<QStorageInfo> drives = QStorageInfo::mountedVolumes ();
216225 for (int i = 0 ; i < drives.count (); i++)
217226 {
0 commit comments