forked from qt-creator/qt-creator
Add defines for relative data paths
Derive the relative paths used in code from the paths used by the build system. Change-Id: I208ee55d3c1ee76921734f5c1c6c40d3fcb9724c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -198,30 +198,14 @@ static bool copyRecursively(const QString &srcFilePath,
|
||||
|
||||
static inline QStringList getPluginPaths()
|
||||
{
|
||||
QStringList rc;
|
||||
// Figure out root: Up one from 'bin'
|
||||
QDir rootDir = QApplication::applicationDirPath();
|
||||
rootDir.cdUp();
|
||||
const QString rootDirPath = rootDir.canonicalPath();
|
||||
QString pluginPath;
|
||||
if (Utils::HostOsInfo::isMacHost()) {
|
||||
// 1) "PlugIns" (OS X)
|
||||
pluginPath = rootDirPath + QLatin1String("/PlugIns");
|
||||
rc.push_back(pluginPath);
|
||||
} else {
|
||||
// 2) "plugins" (Win/Linux)
|
||||
pluginPath = rootDirPath;
|
||||
pluginPath += QLatin1Char('/');
|
||||
pluginPath += QLatin1String(IDE_LIBRARY_BASENAME);
|
||||
pluginPath += QLatin1String("/qtcreator/plugins");
|
||||
rc.push_back(pluginPath);
|
||||
}
|
||||
// 3) <localappdata>/plugins/<ideversion>
|
||||
QStringList rc(QDir::cleanPath(QApplication::applicationDirPath()
|
||||
+ '/' + RELATIVE_PLUGIN_PATH));
|
||||
// Local plugin path: <localappdata>/plugins/<ideversion>
|
||||
// where <localappdata> is e.g.
|
||||
// "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later
|
||||
// "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux
|
||||
// "~/Library/Application Support/QtProject/Qt Creator" on Mac
|
||||
pluginPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
QString pluginPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost())
|
||||
pluginPath += QLatin1String("/data");
|
||||
pluginPath += QLatin1Char('/')
|
||||
@@ -284,13 +268,9 @@ static inline QSettings *userSettings()
|
||||
return createUserSettings();
|
||||
}
|
||||
|
||||
static const char *SHARE_PATH =
|
||||
Utils::HostOsInfo::isMacHost() ? "/../Resources" : "/../share/qtcreator";
|
||||
|
||||
void loadFonts()
|
||||
{
|
||||
const QDir dir(QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH)
|
||||
+ QLatin1String("/fonts/"));
|
||||
const QDir dir(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DATA_PATH + "/fonts/");
|
||||
|
||||
foreach (const QFileInfo &fileInfo, dir.entryInfoList(QStringList("*.ttf"), QDir::Files))
|
||||
QFontDatabase::addApplicationFont(fileInfo.absoluteFilePath());
|
||||
@@ -329,7 +309,8 @@ int main(int argc, char **argv)
|
||||
QThreadPool::globalInstance()->setMaxThreadCount(qMax(4, 2 * threadCount));
|
||||
|
||||
// Display a backtrace once a serious signal is delivered (Linux only).
|
||||
const QString libexecPath = QCoreApplication::applicationDirPath() + "/../libexec/qtcreator";
|
||||
const QString libexecPath = QCoreApplication::applicationDirPath()
|
||||
+ '/' + RELATIVE_LIBEXEC_PATH;
|
||||
CrashHandlerSetup setupCrashHandler(appNameC, CrashHandlerSetup::EnableRestart, libexecPath);
|
||||
|
||||
#ifdef ENABLE_QT_BREAKPAD
|
||||
@@ -378,7 +359,7 @@ int main(int argc, char **argv)
|
||||
|
||||
// Must be done before any QSettings class is created
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope,
|
||||
QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH));
|
||||
QCoreApplication::applicationDirPath() + '/' + RELATIVE_DATA_PATH);
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
// plugin manager takes control of this settings object
|
||||
QSettings *settings = userSettings();
|
||||
@@ -399,7 +380,7 @@ int main(int argc, char **argv)
|
||||
if (!overrideLanguage.isEmpty())
|
||||
uiLanguages.prepend(overrideLanguage);
|
||||
const QString &creatorTrPath = QCoreApplication::applicationDirPath()
|
||||
+ QLatin1String(SHARE_PATH) + QLatin1String("/translations");
|
||||
+ '/' + RELATIVE_DATA_PATH + "/translations";
|
||||
foreach (QString locale, uiLanguages) {
|
||||
locale = QLocale(locale).name();
|
||||
if (translator.load(QLatin1String("qtcreator_") + locale, creatorTrPath)) {
|
||||
|
||||
Reference in New Issue
Block a user