[fixed] wrong default folder for saving and creating pages

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

[fixed] wrong default folder for saving and creating pages

Post by uwestoehr »

- take a document without yet any page
- create a new page using a template

result: you get correctly the TD template folder open to select a template file

- select a template of your choice
- select the page in the document tree and use the File menu to export the page as SVG

result: you get the TD template folder as proposal

This should not happen because a template folder is for templates, and , more important for users without admin permissions on Windows, they cannot write into the template folder.
Therefore the proposed folder should be the one where the file is currently saved in.

- nevertheless, choose a folder of your choice and export the page as SVG
- now create a new page from template

result: you don't get the templates folder but the folder where you just exported the SVG to

This is a problem, because one is a bit lost where to get the templates. Since the templates folder is known, one should in every case this folder when creating new pages from templates.
Last edited by uwestoehr on Thu Jan 28, 2021 3:30 pm, edited 1 time in total.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: wrong default folder for saving and creating pages

Post by ulrich1a »

This seems to be a general problem in FreeCAD 0.19. Opening a document starts for me in the binary folder, despite there is a path saved in user.sys where I did saved my last document. This should be the folder where I want to open my documents.
There should be predefined pathes given for the opening of drawings, images, templates, macros, render settings and what else FreeCAD is dealing with.

Ulrich
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: wrong default folder for saving and creating pages

Post by uwestoehr »

ulrich1a wrote: Mon Dec 09, 2019 10:23 pm This seems to be a general problem in FreeCAD 0.19. Opening a document starts for me in the binary folder, despite there is a path saved in user.sys where I did saved my last document.
I cannot reproduce this. On Windows 10 and Windows 7 I get with FC 0.18.4 and

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18846 (Git)
Build type: Release
Branch: master
Hash: ceeb776fff25c679752571d5d8e6c4c8b1fd9008
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)

File -> Open opens the last used folder.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: wrong default folder for saving and creating pages

Post by uwestoehr »

Hi aapo,

this is one of the known TD issues I once listed here:
https://forum.freecadweb.org/viewtopic.php?f=35&t=40608

that I could not fix yet. Can you reproduce this and/or have an idea how to fix this?

I thought this can easily be solved via the Qt file dialog settings but I was stuck since the native Win file dialog is used.
In principle we know the FC file location, so the fix would simply be to open the file dialog with this folder when exporting a page.

aapo wrote: .
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: wrong default folder for saving and creating pages

Post by aapo »

uwestoehr wrote: Thu Jan 28, 2021 2:46 am this is one of the known TD issues I once listed here:
https://forum.freecadweb.org/viewtopic.php?f=35&t=40608

that I could not fix yet. Can you reproduce this and/or have an idea how to fix this?
Yep, the problem seems to simply be that Gui::FileDialog::getOpenFileName() and Gui::FileDialog::getSaveFileName() understandably keep track of the latest opened directory. However, with TD templates there seems to be a hard-coded directory path for templates, and therefore we need to make sure that when we open a template using Gui::FileDialog::getOpenFileName() we don't overwrite the default working dir with the template dir. The easiest way that occurred to me, is to keep track of the real working directory in the template opening function, and set it back to correct one after finding the template file name.

The PR is here, it's just two lines of code: https://github.com/FreeCAD/FreeCAD/pull/4326
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: wrong default folder for saving and creating pages

Post by aapo »

Aaaanndd, it's already committed, 12 minutes after I made the PR. So, no need to review the changes! Thanks! :D
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: wrong default folder for saving and creating pages

Post by uwestoehr »

aapo wrote: Thu Jan 28, 2021 2:01 pm Aaaanndd, it's already committed, 12 minutes after I made the PR. So, no need to review the changes! Thanks! :D
Aaaanndd, it's working for me. Many thanks!
Post Reply