mirror of
https://github.com/leozide/leocad
synced 2025-01-13 08:01:38 +01:00
Added option to set an extra path to scan for the LDraw library.
This commit is contained in:
parent
62cec48d93
commit
c0db665346
4 changed files with 57 additions and 42 deletions
|
@ -64,55 +64,58 @@ void lcApplication::SetClipboard(lcFile* Clipboard)
|
||||||
gMainWindow->UpdatePaste(mClipboard != NULL);
|
gMainWindow->UpdatePaste(mClipboard != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LibraryCachePath)
|
bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath)
|
||||||
{
|
{
|
||||||
if (mLibrary == NULL)
|
if (mLibrary == NULL)
|
||||||
mLibrary = new lcPiecesLibrary();
|
mLibrary = new lcPiecesLibrary();
|
||||||
|
|
||||||
if (LibPath && LibPath[0])
|
if (LibPath && LibPath[0])
|
||||||
|
return mLibrary->Load(LibPath, LibraryCachePath);
|
||||||
|
|
||||||
|
char* EnvPath = getenv("LEOCAD_LIB");
|
||||||
|
|
||||||
|
if (EnvPath && EnvPath[0])
|
||||||
{
|
{
|
||||||
if (mLibrary->Load(LibPath, LibraryCachePath))
|
return mLibrary->Load(EnvPath, LibraryCachePath);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
char CustomPath[LC_MAXPATH];
|
||||||
|
strcpy(CustomPath, lcGetProfileString(LC_PROFILE_PARTS_LIBRARY));
|
||||||
|
|
||||||
|
if (CustomPath[0])
|
||||||
|
return mLibrary->Load(CustomPath, LibraryCachePath);
|
||||||
|
|
||||||
|
if (LibraryInstallPath && LibraryInstallPath[0])
|
||||||
{
|
{
|
||||||
char* EnvPath = getenv("LEOCAD_LIB");
|
char LibraryPath[LC_MAXPATH];
|
||||||
|
|
||||||
if (EnvPath && EnvPath[0])
|
strcpy(LibraryPath, LibraryInstallPath);
|
||||||
|
|
||||||
|
int i = strlen(LibraryPath) - 1;
|
||||||
|
if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/'))
|
||||||
|
strcat(LibraryPath, "/");
|
||||||
|
|
||||||
|
strcat(LibraryPath, "library.bin");
|
||||||
|
|
||||||
|
if (mLibrary->Load(LibraryPath, LibraryCachePath))
|
||||||
{
|
{
|
||||||
if (mLibrary->Load(EnvPath, LibraryCachePath))
|
mLibrary->SetOfficialPieces();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
char CustomPath[LC_MAXPATH];
|
|
||||||
|
|
||||||
strcpy(CustomPath, lcGetProfileString(LC_PROFILE_PARTS_LIBRARY));
|
if (LDrawPath && LDrawPath[0])
|
||||||
|
{
|
||||||
|
char LibraryPath[LC_MAXPATH];
|
||||||
|
|
||||||
if (CustomPath[0])
|
strcpy(LibraryPath, LDrawPath);
|
||||||
{
|
|
||||||
if (mLibrary->Load(CustomPath, LibraryCachePath))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (LibraryInstallPath && LibraryInstallPath[0])
|
|
||||||
{
|
|
||||||
char LibraryPath[LC_MAXPATH];
|
|
||||||
|
|
||||||
strcpy(LibraryPath, LibraryInstallPath);
|
int i = strlen(LibraryPath) - 1;
|
||||||
|
if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/'))
|
||||||
|
strcat(LibraryPath, "/");
|
||||||
|
|
||||||
int i = strlen(LibraryPath) - 1;
|
if (mLibrary->Load(LibraryPath, LibraryCachePath))
|
||||||
if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/'))
|
return true;
|
||||||
strcat(LibraryPath, "/");
|
|
||||||
|
|
||||||
strcat(LibraryPath, "library.bin");
|
|
||||||
|
|
||||||
if (mLibrary->Load(LibraryPath, LibraryCachePath))
|
|
||||||
{
|
|
||||||
mLibrary->SetOfficialPieces();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -150,7 +153,7 @@ void lcApplication::ParseStringArgument(int* CurArg, int argc, char* argv[], cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstallPath, const char* LibraryCachePath)
|
bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath)
|
||||||
{
|
{
|
||||||
char* LibPath = NULL;
|
char* LibPath = NULL;
|
||||||
|
|
||||||
|
@ -240,7 +243,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LoadPiecesLibrary(LibPath, LibraryInstallPath, LibraryCachePath))
|
if (!LoadPiecesLibrary(LibPath, LibraryInstallPath, LDrawPath, LibraryCachePath))
|
||||||
{
|
{
|
||||||
if (SaveImage)
|
if (SaveImage)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,11 +38,11 @@ public:
|
||||||
lcApplication();
|
lcApplication();
|
||||||
~lcApplication();
|
~lcApplication();
|
||||||
|
|
||||||
bool Initialize(int argc, char *argv[], const char* LibraryInstallPath, const char* LibraryCachePath);
|
bool Initialize(int argc, char *argv[], const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void ShowPreferencesDialog();
|
void ShowPreferencesDialog();
|
||||||
|
|
||||||
bool LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LibraryCachePath);
|
bool LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath);
|
||||||
|
|
||||||
void OpenURL(const char* URL);
|
void OpenURL(const char* URL);
|
||||||
void RunProcess(const char* ExecutablePath, const lcArray<String>& Arguments);
|
void RunProcess(const char* ExecutablePath, const lcArray<String>& Arguments);
|
||||||
|
|
10
leocad.pro
10
leocad.pro
|
@ -48,7 +48,6 @@ unix:!macx {
|
||||||
isEmpty(DESKTOP_DIR):DESKTOP_DIR = $$INSTALL_PREFIX/share/applications
|
isEmpty(DESKTOP_DIR):DESKTOP_DIR = $$INSTALL_PREFIX/share/applications
|
||||||
isEmpty(MIME_DIR):MIME_DIR = $$INSTALL_PREFIX/share/mime/packages
|
isEmpty(MIME_DIR):MIME_DIR = $$INSTALL_PREFIX/share/mime/packages
|
||||||
isEmpty(MIME_ICON_DIR):MIME_ICON_DIR = $$INSTALL_PREFIX/share/icons/hicolor/scalable/mimetypes
|
isEmpty(MIME_ICON_DIR):MIME_ICON_DIR = $$INSTALL_PREFIX/share/icons/hicolor/scalable/mimetypes
|
||||||
isEmpty(DISABLE_UPDATE_CHECK):DISABLE_UPDATE_CHECK = 0
|
|
||||||
|
|
||||||
target.path = $$BIN_DIR
|
target.path = $$BIN_DIR
|
||||||
docs.path = $$DOCS_DIR
|
docs.path = $$DOCS_DIR
|
||||||
|
@ -67,7 +66,14 @@ unix:!macx {
|
||||||
INSTALLS += target docs man desktop icon mime mime_icon
|
INSTALLS += target docs man desktop icon mime mime_icon
|
||||||
|
|
||||||
DEFINES += LC_INSTALL_PREFIX=\\\"$$INSTALL_PREFIX\\\"
|
DEFINES += LC_INSTALL_PREFIX=\\\"$$INSTALL_PREFIX\\\"
|
||||||
DEFINES += LC_DISABLE_UPDATE_CHECK=$$DISABLE_UPDATE_CHECK
|
|
||||||
|
!isEmpty(DISABLE_UPDATE_CHECK) {
|
||||||
|
DEFINES += LC_DISABLE_UPDATE_CHECK=$$DISABLE_UPDATE_CHECK
|
||||||
|
}
|
||||||
|
|
||||||
|
!isEmpty(LDRAW_LIBRARY_PATH) {
|
||||||
|
DEFINES += LC_LDRAW_LIBRARY_PATH=\\\"$$LDRAW_LIBRARY_PATH\\\"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macx {
|
macx {
|
||||||
|
|
|
@ -152,7 +152,13 @@ int main(int argc, char *argv[])
|
||||||
QByteArray pathArray = bundlePath.absolutePath().toLocal8Bit();
|
QByteArray pathArray = bundlePath.absolutePath().toLocal8Bit();
|
||||||
const char* libPath = pathArray.data();
|
const char* libPath = pathArray.data();
|
||||||
#else
|
#else
|
||||||
const char* libPath = LC_INSTALL_PREFIX"/share/leocad/";
|
const char* libPath = LC_INSTALL_PREFIX "/share/leocad/";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LC_LDRAW_LIBRARY_PATH
|
||||||
|
const char* LDrawPath = LC_LDRAW_LIBRARY_PATH;
|
||||||
|
#else
|
||||||
|
const char* LDrawPath = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
@ -165,7 +171,7 @@ int main(int argc, char *argv[])
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkpath(cachePath);
|
dir.mkpath(cachePath);
|
||||||
|
|
||||||
if (!g_App->Initialize(argc, argv, libPath, cachePath.toLocal8Bit().data()))
|
if (!g_App->Initialize(argc, argv, libPath, LDrawPath, cachePath.toLocal8Bit().data()))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
lcQMainWindow w;
|
lcQMainWindow w;
|
||||||
|
|
Loading…
Reference in a new issue