Handle resource layout on linux and add translation files to openscad.pro.

master
Torsten Paul 2014-10-18 19:32:54 +02:00
parent afd52b3075
commit cfe14254d4
3 changed files with 47 additions and 12 deletions

View File

@ -8,7 +8,12 @@
# OPENCSGDIR
# OPENSCAD_LIBRARIES
#
# Please see the 'Building' sections of the OpenSCAD user manual
# qmake Variables to define the installation:
#
# PREFIX defines the base installation folder
# LOCALE_PREFIX can overwrite the location of the gettext message catalogs
#
# Please see the 'Building' sections of the OpenSCAD user manual
# for updated tips & workarounds.
#
# http://en.wikibooks.org/wiki/OpenSCAD_User_Manual
@ -473,6 +478,19 @@ isEmpty(PREFIX):PREFIX = /usr/local
target.path = $$PREFIX/bin/
INSTALLS += target
LINGUAS = $$cat(po/LINGUAS)
isEmpty(LOCALE_PREFIX):LOCALE_PREFIX = $$PREFIX/share/openscad/po
for(language, LINGUAS) {
catalog = po/$$language/LC_MESSAGES/openscad.mo
exists($$catalog) {
translation_path = translation_$${language}.path
translation_files = translation_$${language}.files
$$translation_path = $$LOCALE_PREFIX/$$language/LC_MESSAGES/
$$translation_files = $$catalog
INSTALLS += translation_$$language
}
}
examples.path = $$PREFIX/share/openscad/examples/
examples.files = examples/*
INSTALLS += examples

View File

@ -571,6 +571,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
PlatformUtils::registerApplicationPath(app_path.toLocal8Bit().constData());
parser_init(PlatformUtils::applicationPath());
QSettings settings;
if (settings.value("advanced/localization", false).toBool()) {
localization_init();

View File

@ -22,22 +22,38 @@ fs::path get_resource_dir(const std::string &resource_folder)
}
fs::path basepath(applicationdir);
fs::path paths[] = {
#if __APPLE__
// Application layout when installed on MacOS
basepath.parent_path().parent_path() / "Contents" / "Resources",
#endif
#ifdef __unix__
// Different unix installation layouts are possible, this
// tries to capture the most obvious cases.
basepath.parent_path() / "share" / "openscad",
basepath.parent_path().parent_path() / "share" / "openscad",
fs::path("..") / "..",
#endif
#ifdef OPENSCAD_TESTING
basepath = "..";
#endif
#ifdef __APPLE__
fs::path bundlepath = basepath.parent_path().parent_path();
if (bundlepath.filename().string() == "OpenSCAD.app") {
basepath = bundlepath / "Contents" / "Resources";
}
// Used when running the test cases from source code layout.
fs::path(".."),
#endif
// Try to fall back to path relative to the executable and
// relative to the current working directory.
basepath,
fs::path("."),
fs::path(), // end of list marker
};
fs::path resource_dir = basepath / resource_folder;
if (!fs::is_directory(resource_dir)) {
return fs::path();
for (int a = 0;!paths[a].empty();a++) {
fs::path resource_dir = paths[a] / resource_folder;
if (fs::is_directory(resource_dir)) {
return resource_dir;
}
}
return resource_dir;
return fs::path();
}
/*!