diff options
author | Eike Ziller <eike.ziller@qt.io> | 2016-11-02 11:51:19 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2016-12-01 14:24:53 +0000 |
commit | 36b443dfba3c5cb29b343249810d4513b66fa4b3 (patch) | |
tree | 979b6c7b1411841264952e87857824bc2643a7b6 /src/app/main.cpp | |
parent | b3a9031b9fd97907fdad2c36e5a78c531607ac4e (diff) | |
download | qt-creator-36b443dfba3c5cb29b343249810d4513b66fa4b3.tar.gz |
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>
Diffstat (limited to 'src/app/main.cpp')
-rw-r--r-- | src/app/main.cpp | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp index de23bea974..ba1af663da 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -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)) { |