Skip to content

Commit

Permalink
update to in_docs feature
Browse files Browse the repository at this point in the history
- inform user about the move
- don’t create ‚sketches‘ folder
aknoerig committed Apr 7, 2016
1 parent b368c11 commit 83b9e1d
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/utils/folderutils.cpp
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ along with Fritzing. If not, see <http://www.gnu.org/licenses/>.
#include "folderutils.h"
#include "lockmanager.h"
#include "textutils.h"
#include "fmessagebox.h"
#include <QDesktopServices>
#include <QCoreApplication>
#include <QSettings>
@@ -693,7 +694,6 @@ void FolderUtils::createUserDataStoreFolders() {

QDir documents(getTopLevelDocumentsPath());
QStringList documentFolders(singleton->m_documentFolders);
documentFolders << "sketches";
foreach(QString folder, documentFolders) {
QString path = documents.absoluteFilePath(folder);
if(!QFileInfo(path).exists()) {
@@ -702,21 +702,35 @@ void FolderUtils::createUserDataStoreFolders() {
}

// in older versions of Fritzing, local parts and bins were in userDataStore
// copy these into the new locations
QList<QDir> toRemove;
QStringList folders;
folders << "bins" << "parts";
bool foundOld = false;
foreach(QString folder, folders ) {
QDir source(userDataStore.absoluteFilePath(folder));
QDir target(documents.absoluteFilePath(folder));
if (source.exists()) {
replicateDir(source, target);
toRemove << source;
}
foundOld || QFileInfo(userDataStore.absoluteFilePath(folder)).exists();
}

// now remove the obsolete locations
foreach (QDir dir, toRemove) {
rmdir(dir);
if (foundOld) {
// inform user about the move
FMessageBox::information(NULL, QCoreApplication::translate("FolderUtils", "Moving your custom parts"),
QCoreApplication::translate("FolderUtils", "<p>Your custom-made parts and bins are moved from the hidden "
"app data folder to your fritzing documents folder at <br/><br/><em>%1</em><br/><br/>"
"This way we hope to make it easier for you to find and edit them manually.</p>")
.arg(documents.absolutePath()));

// copy these into the new locations
foreach(QString folder, folders ) {
QDir source(userDataStore.absoluteFilePath(folder));
QDir target(documents.absoluteFilePath(folder));
if (source.exists()) {
replicateDir(source, target);
toRemove << source;
}
}

// now remove the obsolete locations
foreach (QDir dir, toRemove) {
rmdir(dir);
}
}
}

0 comments on commit 83b9e1d

Please sign in to comment.