Gui Enhancement: Support for macros in AppUserHome/Macro
===================================================== What? It was suggested that the macros should be moved to AppUserHome/Macro http://forum.freecadweb.org/viewtopic.php?f=10&t=13433 Solution: The solution is backwards compatible in the sense that if you have a running configuration, updating should not change anything. For new installations the macro directory will default to AppUserHome/Macro. However this would break all the installation scripts (probably also ME's plugin manager). Conflicts: src/Mod/Path/Gui/AppPathGuiPy.cpp
This commit is contained in:
parent
f78a239167
commit
7fc7bdc302
|
@ -522,6 +522,12 @@ std::string Application::getUserAppDataDir()
|
|||
return mConfig["UserAppData"];
|
||||
}
|
||||
|
||||
std::string Application::getUserMacroDir()
|
||||
{
|
||||
std::string path("Macro/");
|
||||
return mConfig["UserAppData"] + path;
|
||||
}
|
||||
|
||||
std::string Application::getResourceDir()
|
||||
{
|
||||
#ifdef RESOURCEDIR
|
||||
|
|
|
@ -247,6 +247,7 @@ public:
|
|||
static std::string getTempPath();
|
||||
static std::string getTempFileName(const char* FileName=0);
|
||||
static std::string getUserAppDataDir();
|
||||
static std::string getUserMacroDir();
|
||||
static std::string getResourceDir();
|
||||
static std::string getHelpDir();
|
||||
//@}
|
||||
|
|
|
@ -722,7 +722,7 @@ void MacroCommand::activated(int iMsg)
|
|||
{
|
||||
std::string cMacroPath = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Macro")->GetASCII("MacroPath",
|
||||
App::Application::getUserAppDataDir().c_str());
|
||||
App::Application::getUserMacroDir().c_str());
|
||||
|
||||
QDir d(QString::fromUtf8(cMacroPath.c_str()));
|
||||
QFileInfo fi(d, QString::fromUtf8(sScriptName));
|
||||
|
|
|
@ -62,7 +62,7 @@ DlgCustomActionsImp::DlgCustomActionsImp( QWidget* parent )
|
|||
// search for all macros
|
||||
std::string cMacroPath = App::GetApplication().
|
||||
GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
|
||||
->GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str());
|
||||
->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str());
|
||||
|
||||
QDir d(QString::fromUtf8(cMacroPath.c_str()), QLatin1String("*.FCMacro *.py"));
|
||||
actionMacros->insertItems(0, d.entryList());
|
||||
|
|
|
@ -79,7 +79,7 @@ DlgMacroExecuteImp::DlgMacroExecuteImp( QWidget* parent, Qt::WindowFlags fl )
|
|||
this->setupUi(this);
|
||||
// retrieve the macro path from parameter or use the user data as default
|
||||
std::string path = getWindowParameter()->GetASCII("MacroPath",
|
||||
App::Application::getUserAppDataDir().c_str());
|
||||
App::Application::getUserMacroDir().c_str());
|
||||
this->macroPath = QString::fromUtf8(path.c_str());
|
||||
fileChooser->setFileName(this->macroPath);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ DlgMacroRecordImp::DlgMacroRecordImp( QWidget* parent, Qt::WindowFlags fl )
|
|||
|
||||
// get the macro home path
|
||||
this->macroPath = QString::fromUtf8(getWindowParameter()->GetASCII("MacroPath",
|
||||
App::Application::getUserAppDataDir().c_str()).c_str());
|
||||
App::Application::getUserMacroDir().c_str()).c_str());
|
||||
this->macroPath = QDir::toNativeSeparators(QDir(this->macroPath).path() + QDir::separator());
|
||||
|
||||
// set the edit fields
|
||||
|
|
|
@ -39,7 +39,7 @@ DlgSettingsMacroImp::DlgSettingsMacroImp( QWidget* parent )
|
|||
{
|
||||
this->setupUi(this);
|
||||
if (MacroPath->fileName().isEmpty()) {
|
||||
QDir d(QString::fromUtf8(App::GetApplication().getUserAppDataDir().c_str()));
|
||||
QDir d(QString::fromUtf8(App::GetApplication().getUserMacroDir().c_str()));
|
||||
MacroPath->setFileName(d.path());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1196,7 +1196,7 @@ void PythonConsole::onClearConsole()
|
|||
void PythonConsole::onSaveHistoryAs()
|
||||
{
|
||||
QString cMacroPath = QString::fromUtf8(getDefaultParameter()->GetGroup( "Macro" )->
|
||||
GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str()).c_str());
|
||||
GetASCII("MacroPath",App::Application::getUserMacroDir().c_str()).c_str());
|
||||
QString fn = FileDialog::getSaveFileName(this, tr("Save History"), cMacroPath,
|
||||
QString::fromLatin1("%1 (*.FCMacro *.py)").arg(tr("Macro Files")));
|
||||
if (!fn.isEmpty()) {
|
||||
|
|
|
@ -63,7 +63,7 @@ static PyObject * open(PyObject *self, PyObject *args)
|
|||
path += "Mod/Path/PathScripts/";
|
||||
QDir dir1(QString::fromUtf8(path.c_str()), QString::fromLatin1("*_pre.py"));
|
||||
std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
|
||||
->GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str());
|
||||
->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str());
|
||||
QDir dir2(QString::fromUtf8(cMacroPath.c_str()), QString::fromLatin1("*_pre.py"));
|
||||
QFileInfoList list = dir1.entryInfoList();
|
||||
list << dir2.entryInfoList();
|
||||
|
@ -124,7 +124,7 @@ static PyObject * importer(PyObject *self, PyObject *args)
|
|||
path += "Mod/Path/PathScripts/";
|
||||
QDir dir1(QString::fromUtf8(path.c_str()), QString::fromLatin1("*_pre.py"));
|
||||
std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
|
||||
->GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str());
|
||||
->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str());
|
||||
QDir dir2(QString::fromUtf8(cMacroPath.c_str()), QString::fromLatin1("*_pre.py"));
|
||||
QFileInfoList list = dir1.entryInfoList();
|
||||
list << dir2.entryInfoList();
|
||||
|
@ -194,7 +194,7 @@ static PyObject * exporter(PyObject *self, PyObject *args)
|
|||
path += "Mod/Path/PathScripts/";
|
||||
QDir dir1(QString::fromUtf8(path.c_str()), QString::fromLatin1("*_post.py"));
|
||||
std::string cMacroPath = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
|
||||
->GetASCII("MacroPath",App::Application::getUserAppDataDir().c_str());
|
||||
->GetASCII("MacroPath",App::Application::getUserMacroDir().c_str());
|
||||
QDir dir2(QString::fromUtf8(cMacroPath.c_str()), QString::fromLatin1("*_post.py"));
|
||||
QFileInfoList list = dir1.entryInfoList();
|
||||
list << dir2.entryInfoList();
|
||||
|
|
Loading…
Reference in New Issue
Block a user