diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-10-26 10:55:45 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-10-26 10:55:50 +0100 |
commit | 6d4135d8f0fc0e5e827e1141c44a9ac332376334 (patch) | |
tree | bcc95eaf44054a2b885a2f4ec640306b29b70dc7 /src/app | |
parent | 1b6d97b27f69cf5c55b5fa0092fd7a248f8eb811 (diff) | |
parent | 0fcac3085ad0a175e6abe54be1415a9bac5d695f (diff) | |
download | qt-creator-6d4135d8f0fc0e5e827e1141c44a9ac332376334.tar.gz |
Merge remote-tracking branch 'origin/3.6'
Change-Id: Iddfa0d2f3c0fb8ba65c0e5d479ad8e2f2cb95685
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/main.cpp | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp index bb10f99790..1cfccf42cf 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -96,42 +96,35 @@ const char PLUGINPATH_OPTION[] = "-pluginpath"; typedef QList<PluginSpec *> PluginSpecSet; // Helpers for displaying messages. Note that there is no console on Windows. -#ifdef Q_OS_WIN -// Format as <pre> HTML -static inline void toHtml(QString &t) -{ - t.replace(QLatin1Char('&'), QLatin1String("&")); - t.replace(QLatin1Char('<'), QLatin1String("<")); - t.replace(QLatin1Char('>'), QLatin1String(">")); - t.insert(0, QLatin1String("<html><pre>")); - t.append(QLatin1String("</pre></html>")); -} -static void displayHelpText(QString t) // No console on Windows. -{ - toHtml(t); - QMessageBox::information(0, QLatin1String(appNameC), t); -} - -static void displayError(const QString &t) // No console on Windows. +// Format as <pre> HTML +static inline QString toHtml(const QString &t) { - QMessageBox::critical(0, QLatin1String(appNameC), t); + QString res = t; + res.replace(QLatin1Char('&'), QLatin1String("&")); + res.replace(QLatin1Char('<'), QLatin1String("<")); + res.replace(QLatin1Char('>'), QLatin1String(">")); + res.insert(0, QLatin1String("<html><pre>")); + res.append(QLatin1String("</pre></html>")); + return res; } -#else - static void displayHelpText(const QString &t) { - qWarning("%s", qPrintable(t)); + if (Utils::HostOsInfo::isWindowsHost()) + QMessageBox::information(0, QLatin1String(appNameC), toHtml(t)); + else + qWarning("%s", qPrintable(t)); } static void displayError(const QString &t) { - qCritical("%s", qPrintable(t)); + if (Utils::HostOsInfo::isWindowsHost()) + QMessageBox::critical(0, QLatin1String(appNameC), t); + else + qCritical("%s", qPrintable(t)); } -#endif - static void printVersion(const PluginSpec *coreplugin) { QString version; @@ -200,19 +193,19 @@ static inline QStringList getPluginPaths() QDir rootDir = QApplication::applicationDirPath(); rootDir.cdUp(); const QString rootDirPath = rootDir.canonicalPath(); -#if !defined(Q_OS_MAC) - // 1) "plugins" (Win/Linux) - QString pluginPath = rootDirPath; - pluginPath += QLatin1Char('/'); - pluginPath += QLatin1String(IDE_LIBRARY_BASENAME); - pluginPath += QLatin1String("/qtcreator/plugins"); - rc.push_back(pluginPath); -#else - // 2) "PlugIns" (OS X) - QString pluginPath = rootDirPath; - pluginPath += QLatin1String("/PlugIns"); - rc.push_back(pluginPath); -#endif + 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> // where <localappdata> is e.g. // "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later @@ -225,11 +218,7 @@ static inline QStringList getPluginPaths() pluginPath += QLatin1Char('/') + QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR) + QLatin1Char('/'); -#if !defined(Q_OS_MAC) - pluginPath += QLatin1String("qtcreator"); -#else - pluginPath += QLatin1String("Qt Creator"); -#endif + pluginPath += QLatin1String(Utils::HostOsInfo::isMacHost() ? "Qt Creator" : "qtcreator"); pluginPath += QLatin1String("/plugins/"); pluginPath += QLatin1String(Core::Constants::IDE_VERSION_LONG); rc.push_back(pluginPath); @@ -286,11 +275,8 @@ static inline QSettings *userSettings() return createUserSettings(); } -#ifdef Q_OS_MAC -# define SHARE_PATH "/../Resources" -#else -# define SHARE_PATH "/../share/qtcreator" -#endif +static const char *SHARE_PATH = + Utils::HostOsInfo::isMacHost() ? "/../Resources" : "/../share/qtcreator"; int main(int argc, char **argv) { @@ -391,7 +377,7 @@ int main(int argc, char **argv) if (!overrideLanguage.isEmpty()) uiLanguages.prepend(overrideLanguage); const QString &creatorTrPath = QCoreApplication::applicationDirPath() - + QLatin1String(SHARE_PATH "/translations"); + + QLatin1String(SHARE_PATH) + QLatin1String("/translations"); foreach (QString locale, uiLanguages) { locale = QLocale(locale).name(); if (translator.load(QLatin1String("qtcreator_") + locale, creatorTrPath)) { |