Skip to content

Commit

Permalink
Merge branch 'in_docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
aknoerig committed Mar 26, 2016
2 parents 6fd6af2 + 2901262 commit 6fc011f
Show file tree
Hide file tree
Showing 25 changed files with 178 additions and 227 deletions.
12 changes: 6 additions & 6 deletions src/autoroute/drc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ QStringList DRC::start(bool showOkMessage, double keepoutMils) {
}

#ifndef QT_NO_DEBUG
m_displayImage->save(FolderUtils::getUserDataStorePath("") + "/testDRCDisplay.png");
m_displayImage->save(FolderUtils::getTopLevelUserDataStorePath() + "/testDRCDisplay.png");
#endif

emit wantBothVisible();
Expand Down Expand Up @@ -542,8 +542,8 @@ bool DRC::startAux(QString & message, QStringList & messages, QList<CollidingThi
if (pixelsCollide(m_plusImage, m_minusImage, m_displayImage, l, t, r, b, 1 /* 0x80ff0000 */, atPixels)) {

#ifndef QT_NO_DEBUG
m_plusImage->save(FolderUtils::getUserDataStorePath("") + QString("/collidePlus%1_%2.png").arg(viewLayerPlacement).arg(index));
m_minusImage->save(FolderUtils::getUserDataStorePath("") + QString("/collideMinus%1_%2.png").arg(viewLayerPlacement).arg(index));
m_plusImage->save(FolderUtils::getTopLevelUserDataStorePath() + QString("/collidePlus%1_%2.png").arg(viewLayerPlacement).arg(index));
m_minusImage->save(FolderUtils::getTopLevelUserDataStorePath() + QString("/collideMinus%1_%2.png").arg(viewLayerPlacement).arg(index));
#endif

CollidingThing * collidingThing = findItemsAt(atPixels, m_board, viewLayerIDs, keepoutMils, dpi, false, equ);
Expand Down Expand Up @@ -607,7 +607,7 @@ bool DRC::makeBoard(QImage * image, QRectF & sourceRes) {
// board should be white, borders should be black

#ifndef QT_NO_DEBUG
image->save(FolderUtils::getUserDataStorePath("") + "/testDRCBoard.png");
image->save(FolderUtils::getTopLevelUserDataStorePath() + "/testDRCBoard.png");
#endif

return true;
Expand Down Expand Up @@ -638,7 +638,7 @@ void DRC::splitNet(QDomDocument * masterDoc, QList<ConnectorItem *> & equi, QIma
}

#ifndef QT_NO_DEBUG
plusImage->save(FolderUtils::getUserDataStorePath("") + QString("/splitNetPlus%1_%2.png").arg(viewLayerPlacement).arg(index));
plusImage->save(FolderUtils::getTopLevelUserDataStorePath() + QString("/splitNetPlus%1_%2.png").arg(viewLayerPlacement).arg(index));
#else
Q_UNUSED(viewLayerPlacement);
Q_UNUSED(index);
Expand All @@ -660,7 +660,7 @@ void DRC::splitNet(QDomDocument * masterDoc, QList<ConnectorItem *> & equi, QIma

ItemBase::renderOne(masterDoc, minusImage, sourceRes);
#ifndef QT_NO_DEBUG
minusImage->save(FolderUtils::getUserDataStorePath("") + QString("/splitNetMinus%1_%2.png").arg(viewLayerPlacement).arg(index));
minusImage->save(FolderUtils::getTopLevelUserDataStorePath() + QString("/splitNetMinus%1_%2.png").arg(viewLayerPlacement).arg(index));
#endif

// master doc restored to original state
Expand Down
4 changes: 2 additions & 2 deletions src/autoroute/panelizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void Panelizer::panelize(FApplication * app, const QString & panelFilename, bool
board = boards.firstChildElement("board");
if (!checkBoards(board, fzzFilePaths)) return;

app->createUserDataStoreFolderStructure();
app->createUserDataStoreFolderStructures();
app->registerFonts();
app->loadReferenceModel("", false);

Expand Down Expand Up @@ -1327,7 +1327,7 @@ void Panelizer::inscribe(FApplication * app, const QString & panelFilename, bool
board = boards.firstChildElement("board");
if (!checkBoards(board, fzzFilePaths)) return;

app->createUserDataStoreFolderStructure();
app->createUserDataStoreFolderStructures();
app->registerFonts();
app->loadReferenceModel("", false);

Expand Down
2 changes: 1 addition & 1 deletion src/debugdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ DebugDialog::DebugDialog(QWidget *parent)
m_textEdit = new QTextEdit(this);
m_textEdit->setGeometry(QRect(10, 10, 381, 281));

QString path = FolderUtils::getUserDataStorePath("");
QString path = FolderUtils::getTopLevelUserDataStorePath();
path += "/debug.txt";

m_file.setFileName(path);
Expand Down
84 changes: 21 additions & 63 deletions src/fapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool FApplication::init() {
(m_arguments[i].compare("--parts", Qt::CaseInsensitive) == 0) ||
(m_arguments[i].compare("--partsparent", Qt::CaseInsensitive) == 0))
{
FolderUtils::setPartsPath(m_arguments[i + 1]);
FolderUtils::setAppPartsPath(m_arguments[i + 1]);
// delete these so we don't try to process them as files later
toRemove << i << i + 1;
}
Expand Down Expand Up @@ -787,7 +787,7 @@ bool FApplication::loadReferenceModel(const QString & databaseName, bool fullLoa

bool FApplication::loadReferenceModel(const QString & databaseName, bool fullLoad, ReferenceModel * referenceModel)
{
QDir dir = FolderUtils::getPartsSubFolder("");
QDir dir = FolderUtils::getAppPartsSubFolder("");
QString dbPath = dir.absoluteFilePath("parts.db");
QFileInfo info(dbPath);
bool dbExists = info.exists();
Expand Down Expand Up @@ -918,7 +918,7 @@ void FApplication::runGerberServiceAux()

void FApplication::initService()
{
createUserDataStoreFolderStructure();
createUserDataStoreFolderStructures();
registerFonts();
loadReferenceModel("", false);
}
Expand Down Expand Up @@ -961,7 +961,7 @@ void FApplication::runSvgServiceAux()

void FApplication::runDatabaseService()
{
createUserDataStoreFolderStructure();
createUserDataStoreFolderStructures();

DebugDialog::setEnabled(true);

Expand Down Expand Up @@ -1173,7 +1173,7 @@ int FApplication::startup()

cleanFzzs();

createUserDataStoreFolderStructure();
createUserDataStoreFolderStructures();

ProcessEventBlocker::processEvents();

Expand Down Expand Up @@ -1227,7 +1227,7 @@ int FApplication::startup()
m_splash = NULL;

m_updateDialog = new UpdateDialog();
m_updateDialog->setRepoPath(FolderUtils::getPartsSubFolderPath(""), m_referenceModel->sha());
m_updateDialog->setRepoPath(FolderUtils::getAppPartsSubFolderPath(""), m_referenceModel->sha());
connect(m_updateDialog, SIGNAL(enableAgainSignal(bool)), this, SLOT(enableCheckUpdates(bool)));
connect(m_updateDialog, SIGNAL(installNewParts()), this, SLOT(installNewParts()));
checkForUpdates(false);
Expand Down Expand Up @@ -1452,22 +1452,11 @@ void FApplication::enableCheckUpdates(bool enabled)
//DebugDialog::debug("after enable check updates");
}

void FApplication::createUserDataStoreFolderStructure() {
// make sure that the folder structure for parts and bins, exists
QString userDataStorePath = FolderUtils::getUserDataStorePath();
QDir dataStore(userDataStorePath);
QStringList dataFolders = FolderUtils::getUserDataStoreFolders();
foreach(QString folder, dataFolders) {
if(!QFileInfo(dataStore.absolutePath()+folder).exists()) {
QString folderaux = folder.startsWith("/")? folder.remove(0,1): folder;
dataStore.mkpath(folder);
}
}

void FApplication::createUserDataStoreFolderStructures() {
FolderUtils::createUserDataStoreFolders();
FolderUtils::copyBin(BinManager::MyPartsBinLocation, BinManager::MyPartsBinTemplateLocation);
FolderUtils::copyBin(BinManager::SearchBinLocation, BinManager::SearchBinTemplateLocation);
PartFactory::initFolder();

}


Expand Down Expand Up @@ -1632,30 +1621,26 @@ bool FApplication::notify(QObject *receiver, QEvent *e)
}

void FApplication::loadSomething(const QString & prevVersion) {
// At this point we're trying to determine what sketches to load which are from one of the following sources:
// At this point we're trying to determine what sketches to load from one of the following sources:
// Only one of these sources will actually provide sketches to load and they're listed in order of priority:

// We found sketch backups to recover
// there's a previous version (open an empty sketch)
// files were double-clicked
// The last opened sketch
// Files were double-clicked
// The last opened sketch (obsolete)
// A new blank sketch


Q_UNUSED(prevVersion);

initFilesToLoad(); // sets up m_filesToLoad from the command line on PC and Linux; mac uses a FileOpen event instead

initBackups();

DebugDialog::debug("checking for backups");
QList<MainWindow*> sketchesToLoad = recoverBackups();

bool loadPrevious = false;
if (sketchesToLoad.isEmpty()) {
loadPrevious = !prevVersion.isEmpty() && Version::greaterThan(prevVersion, Version::FirstVersionWithDetachedUserData);
}

DebugDialog::debug(QString("load previous %1").arg(loadPrevious));

if (!loadPrevious && sketchesToLoad.isEmpty()) {
if (sketchesToLoad.isEmpty()) {
// Check for double-clicked files to load
DebugDialog::debug(QString("check files to load %1").arg(m_filesToLoad.count()));

Expand All @@ -1675,10 +1660,11 @@ void FApplication::loadSomething(const QString & prevVersion) {
ProcessEventBlocker::processEvents();

// Find any previously open sketches to reload
if (!loadPrevious && sketchesToLoad.isEmpty()) {
DebugDialog::debug(QString("load last open"));
if (sketchesToLoad.isEmpty()) {
// new logic here, we no longer open the most recent sketch, since it can be reached in one click from the welcome page
//sketchesToLoad = loadLastOpenSketch();

// DebugDialog::debug(QString("load last open"));
//sketchesToLoad = loadLastOpenSketch();
}

MainWindow * newBlankSketch = NULL;
Expand All @@ -1701,12 +1687,7 @@ void FApplication::loadSomething(const QString & prevVersion) {
sketch->clearFileProgressDialog();
}

ProcessEventBlocker::processEvents();

if (loadPrevious) {
doLoadPrevious(newBlankSketch);
}
else if (newBlankSketch) {
if (newBlankSketch) {
newBlankSketch->hideTempPartsBin();
// new empty sketch defaults to welcome view
newBlankSketch->showWelcomeView();
Expand All @@ -1733,29 +1714,6 @@ QList<MainWindow *> FApplication::loadLastOpenSketch() {
return sketches;
}

void FApplication::doLoadPrevious(MainWindow * sketchWindow) {
// Here we check if files need to be imported from an earlier version.
// This should be done before any files are loaded as it requires a restart.
// As this can generate UI it should come after the splash screen has closed.

FMessageBox messageBox(sketchWindow);
messageBox.setWindowTitle(tr("Import files from previous version?"));
messageBox.setText(tr("Do you want to import parts and bins that you have created with earlier versions of Fritzing?\n"));
messageBox.setInformativeText(tr("\nNote: You can import them later using the \"Help\" > \"Import parts and bins "
"from old version...\" menu action."));
messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
messageBox.setDefaultButton(QMessageBox::Cancel);
messageBox.setIcon(QMessageBox::Question);
messageBox.setWindowModality(Qt::WindowModal);
messageBox.setButtonText(QMessageBox::Ok, tr("Import"));
messageBox.setButtonText(QMessageBox::Cancel, tr("Do not import now"));
QMessageBox::StandardButton answer = (QMessageBox::StandardButton) messageBox.exec();

if(answer == QMessageBox::Ok) {
sketchWindow->importFilesFromPrevInstall();
}
}

QList<MainWindow *> FApplication::recoverBackups()
{
QFileInfoList backupList;
Expand Down Expand Up @@ -2080,7 +2038,7 @@ void FApplication::regeneratePartsDatabase() {

void FApplication::regeneratePartsDatabaseAux(QDialog * progressDialog) {
ReferenceModel * referenceModel = new CurrentReferenceModel();
QDir dir = FolderUtils::getPartsSubFolder("");
QDir dir = FolderUtils::getAppPartsSubFolder("");
QString dbPath = dir.absoluteFilePath("parts.db");
RegenerateDatabaseThread *thread = new RegenerateDatabaseThread(dbPath, progressDialog, referenceModel);
connect(thread, SIGNAL(finished()), this, SLOT(regenerateDatabaseFinished()));
Expand Down
2 changes: 1 addition & 1 deletion src/fapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public slots:
void checkForUpdates();
void checkForUpdates(bool atUserRequest);
void enableCheckUpdates(bool enabled);
void createUserDataStoreFolderStructure();
void createUserDataStoreFolderStructures();
void changeActivation(bool activate, QWidget * originator);
void updateActivation();
void topLevelWidgetDestroyed(QObject *);
Expand Down
2 changes: 1 addition & 1 deletion src/items/layerkinpaletteitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void SchematicTextLayerKinPaletteItem::renderText(QImage & image, QDomElement &
painter.end();

#ifndef QT_NO_DEBUG
image.save(FolderUtils::getUserDataStorePath("") + "/renderText.png");
image.save(FolderUtils::getTopLevelUserDataStorePath() + "/renderText.png");
#endif

viewBox = renderer.viewBoxF();
Expand Down
10 changes: 5 additions & 5 deletions src/items/partfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ QString PartFactory::getSvgFilename(ModelPart * modelPart, const QString & baseN
{
QStringList tempPaths;
QString postfix = "/"+ SvgFilesDir +"/%1/"+ baseName;
QString userStore = FolderUtils::getUserDataStorePath("parts")+postfix;
QString userStore = FolderUtils::getUserPartsPath()+postfix;
QString pfPath = PartFactory::folderPath() + postfix;
if(!modelPart->path().isEmpty()) {
QString path = modelPart->path();
QDir dir(path); // is a path to a filename
dir.cdUp(); // lop off the filename
dir.cdUp(); // parts root
tempPaths << dir.absolutePath() + postfix;
tempPaths << FolderUtils::getPartsSubFolderPath("")+postfix; // some svgs may still be in the fritzing parts folder, though the other svgs are in the user folder
tempPaths << FolderUtils::getAppPartsSubFolderPath("")+postfix; // some svgs may still be in the fritzing parts folder, though the other svgs are in the user folder
if (tempPaths.at(0).compare(userStore) != 0) {
tempPaths << userStore;
}
Expand All @@ -245,7 +245,7 @@ QString PartFactory::getSvgFilename(ModelPart * modelPart, const QString & baseN
}
else {
DebugDialog::debug("modelPart with no path--this shouldn't happen");
tempPaths << FolderUtils::getPartsSubFolderPath("")+postfix;
tempPaths << FolderUtils::getAppPartsSubFolderPath("")+postfix;
tempPaths << userStore;
}
tempPaths << ":resources/parts/svg/%1/" + baseName;
Expand Down Expand Up @@ -419,7 +419,7 @@ QString PartFactory::getSvgFilename(const QString & fileName)
}

bool PartFactory::svgFileExists(const QString & expectedFileName, QString & path) {
QString p = FolderUtils::getPartsSubFolderPath("") + "/"+ SvgFilesDir + "/core/";
QString p = FolderUtils::getAppPartsSubFolderPath("") + "/"+ SvgFilesDir + "/core/";
if (QFileInfo(p + expectedFileName).exists()) {
path = expectedFileName;
return true;
Expand All @@ -446,7 +446,7 @@ QString PartFactory::getSvgFilenameAux(const QString & expectedFileName, GenSvg

bool PartFactory::fzpFileExists(const QString & moduleID, QString & path) {
QString expectedFileName = moduleID + FritzingPartExtension;
path = FolderUtils::getPartsSubFolderPath("") + "/core/" + expectedFileName;
path = FolderUtils::getAppPartsSubFolderPath("") + "/core/" + expectedFileName;
if (QFileInfo(path).exists()) {
path = expectedFileName;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/items/resizableboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ QStringList & Board::getNewImageNames() {
void Board::fileNameEntry(const QString & filename) {
foreach (QString name, getImageNames()) {
if (filename.compare(name) == 0) {
QString f = FolderUtils::getPartsSubFolderPath("") + "/svg/core/pcb/" + filename + ".svg";
QString f = FolderUtils::getAppPartsSubFolderPath("") + "/svg/core/pcb/" + filename + ".svg";
prepLoadImageAux(f, false);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QtMessageHandler originalMsgHandler;
#endif

void writeCrashMessage(const char * msg) {
QString path = FolderUtils::getUserDataStorePath("");
QString path = FolderUtils::getTopLevelUserDataStorePath();
path += "/fritzingcrash.txt";
QFile file(path);
if (file.open(QIODevice::Append | QIODevice::Text)) {
Expand Down Expand Up @@ -108,7 +108,7 @@ int main(int argc, char *argv[])
#ifndef QT_NO_DEBUG
#ifdef WIN_CHECK_LEAKS
HANDLE hLogFile;
QString path = FolderUtils::getUserDataStorePath("") + "/fritzing_leak_log.txt";
QString path = FolderUtils::getTopLevelUserDataStorePath() + "/fritzing_leak_log.txt";
std::wstring wstr = path.toStdWString();
LPCWSTR ptr = wstr.c_str();
hLogFile = CreateFile(ptr, GENERIC_WRITE,
Expand Down
Loading

0 comments on commit 6fc011f

Please sign in to comment.