diff --git a/qbs/modules/qtc/qtc.qbs b/qbs/modules/qtc/qtc.qbs index 9fc7d0a4d37cfa585ed4cf5b9b08ab78ed7bc197..cf6a3e9fcf955644b6f0a998c7732310cb1a211f 100644 --- a/qbs/modules/qtc/qtc.qbs +++ b/qbs/modules/qtc/qtc.qbs @@ -1,5 +1,6 @@ import qbs import qbs.Environment +import qbs.FileInfo import "qtc.js" as HelperFunctions Module { @@ -62,6 +63,13 @@ Module { property stringList generalDefines: [ "QT_CREATOR", 'IDE_LIBRARY_BASENAME="' + libDirName + '"', + 'RELATIVE_PLUGIN_PATH="' + FileInfo.relativePath('/' + ide_bin_path, + '/' + ide_plugin_path) + '"', + 'RELATIVE_LIBEXEC_PATH="' + FileInfo.relativePath('/' + ide_bin_path, + '/' + ide_libexec_path) + '"', + 'RELATIVE_DATA_PATH="' + FileInfo.relativePath('/' + ide_bin_path, + '/' + ide_data_path) + '"', + 'RELATIVE_DOC_PATH="' + FileInfo.relativePath('/' + ide_bin_path, '/' + ide_doc_path) + '"', "QT_NO_CAST_TO_ASCII", "QT_RESTRICTED_CAST_FROM_ASCII", "QT_DISABLE_DEPRECATED_BEFORE=0x050600", diff --git a/qtcreator.pri b/qtcreator.pri index 1cabd49f06712f64d8b7ff3c3904cba56ec61eb1..cf6e7fc934a4df9f2d29f374e2e07e07154574f9 100644 --- a/qtcreator.pri +++ b/qtcreator.pri @@ -147,6 +147,15 @@ osx { INSTALL_APP_PATH = $$QTC_PREFIX/bin } +RELATIVE_PLUGIN_PATH = $$relative_path($$IDE_PLUGIN_PATH, $$IDE_BIN_PATH) +RELATIVE_LIBEXEC_PATH = $$relative_path($$IDE_LIBEXEC_PATH, $$IDE_BIN_PATH) +RELATIVE_DATA_PATH = $$relative_path($$IDE_DATA_PATH, $$IDE_BIN_PATH) +RELATIVE_DOC_PATH = $$relative_path($$IDE_DOC_PATH, $$IDE_BIN_PATH) +DEFINES += $$shell_quote(RELATIVE_PLUGIN_PATH=\"$$RELATIVE_PLUGIN_PATH\") +DEFINES += $$shell_quote(RELATIVE_LIBEXEC_PATH=\"$$RELATIVE_LIBEXEC_PATH\") +DEFINES += $$shell_quote(RELATIVE_DATA_PATH=\"$$RELATIVE_DATA_PATH\") +DEFINES += $$shell_quote(RELATIVE_DOC_PATH=\"$$RELATIVE_DOC_PATH\") + INCLUDEPATH += \ $$IDE_BUILD_TREE/src \ # for in case of actual build directory $$IDE_SOURCE_TREE/src \ # for in case of binary package with dev package diff --git a/src/app/main.cpp b/src/app/main.cpp index de23bea974d70eacd2bac05c48264fe6bdd6ff08..ba1af663dae430c4f39ef2a47d21e26383c2fd82 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) /plugins/ + QStringList rc(QDir::cleanPath(QApplication::applicationDirPath() + + '/' + RELATIVE_PLUGIN_PATH)); + // Local plugin path: /plugins/ // where 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)) { diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index ee810e5756a217871c045ceb2853d4e47d98e57b..2790075638ff2808c553b4d12bfd524cd8a55772 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -402,9 +402,7 @@ QString ICore::userInterfaceLanguage() QString ICore::resourcePath() { - const QString sharePath = QLatin1String(Utils::HostOsInfo::isMacHost() - ? "/../Resources" : "/../share/qtcreator"); - return QDir::cleanPath(QCoreApplication::applicationDirPath() + sharePath); + return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DATA_PATH); } QString ICore::userResourcePath() @@ -424,9 +422,7 @@ QString ICore::userResourcePath() QString ICore::documentationPath() { - const QString docPath = QLatin1String(Utils::HostOsInfo::isMacHost() - ? "/../Resources/doc" : "/../share/doc/qtcreator"); - return QDir::cleanPath(QCoreApplication::applicationDirPath() + docPath); + return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH); } /*! @@ -435,21 +431,7 @@ QString ICore::documentationPath() */ QString ICore::libexecPath() { - QString path; - switch (Utils::HostOsInfo::hostOs()) { - case Utils::OsTypeWindows: - path = QCoreApplication::applicationDirPath(); - break; - case Utils::OsTypeMac: - path = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources"); - break; - case Utils::OsTypeLinux: - case Utils::OsTypeOtherUnix: - case Utils::OsTypeOther: - path = QCoreApplication::applicationDirPath() + QLatin1String("/../libexec/qtcreator"); - break; - } - return QDir::cleanPath(path); + return QDir::cleanPath(QApplication::applicationDirPath() + '/' + RELATIVE_LIBEXEC_PATH); } static QString compilerString()