aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorChristian Kandeler <[email protected]>2012-08-23 15:53:58 +0200
committerhjk <[email protected]>2012-08-27 17:00:03 +0200
commite669f054069c3a1214a31c4c1d7d9269659c31c4 (patch)
treed611e865215dc8ee705a640fdf3e35660542632f /src/plugins
parentb674b59b3d652fa9c5d74dc4e16380e3a5d23882 (diff)
Utils: Introduce HostOsInfo class.
The class' member functions are intended to be used instead of the Q_OS_* macros in all contexts where the latter are not syntactically required. This lowers the likelihood of changes made on one platform breaking the build on another, e.g. due to the code model missing symbols in #ifdef'ed out code when refactoring. Change-Id: I4a54788591b4c8f8d589b8368a6c683d4155c9fa Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/androidconfigurations.cpp27
-rw-r--r--src/plugins/android/androidsettingswidget.cpp21
-rw-r--r--src/plugins/android/androidtoolchain.cpp39
-rw-r--r--src/plugins/clearcase/clearcaseplugin.cpp8
-rw-r--r--src/plugins/clearcase/clearcasesettings.cpp6
-rw-r--r--src/plugins/coreplugin/actionmanager/command.cpp7
-rw-r--r--src/plugins/coreplugin/actionmanager/commandmappings.cpp21
-rw-r--r--src/plugins/coreplugin/basefilewizard.cpp19
-rw-r--r--src/plugins/coreplugin/dialogs/externaltoolconfig.cpp15
-rw-r--r--src/plugins/coreplugin/dialogs/saveitemsdialog.cpp28
-rw-r--r--src/plugins/coreplugin/dialogs/settingsdialog.cpp10
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp30
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp10
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.cpp11
-rw-r--r--src/plugins/coreplugin/editortoolbar.cpp9
-rw-r--r--src/plugins/coreplugin/fancytabwidget.cpp5
-rw-r--r--src/plugins/coreplugin/fileiconprovider.cpp10
-rw-r--r--src/plugins/coreplugin/outputpanemanager.cpp7
-rw-r--r--src/plugins/cpaster/codepasterprotocol.cpp10
-rw-r--r--src/plugins/cpaster/pasteselectdialog.cpp6
-rw-r--r--src/plugins/cpaster/settings.cpp9
-rw-r--r--src/plugins/cppeditor/cppplugin.cpp21
-rw-r--r--src/plugins/cpptools/cppfilesettingspage.cpp8
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp31
-rw-r--r--src/plugins/cvs/cvssettings.cpp6
-rw-r--r--src/plugins/debugger/breakhandler.cpp7
-rw-r--r--src/plugins/debugger/commonoptionspage.cpp48
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp11
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp7
-rw-r--r--src/plugins/debugger/gdb/localplaingdbadapter.cpp8
-rw-r--r--src/plugins/debugger/gdb/termgdbadapter.cpp9
-rw-r--r--src/plugins/debugger/moduleswindow.cpp8
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp6
-rw-r--r--src/plugins/find/findtoolbar.cpp15
-rw-r--r--src/plugins/git/gerrit/gerritparameters.cpp19
-rw-r--r--src/plugins/git/gitclient.cpp25
-rw-r--r--src/plugins/git/gitsettings.cpp7
-rw-r--r--src/plugins/git/settingspage.cpp27
-rw-r--r--src/plugins/help/externalhelpwindow.cpp23
-rw-r--r--src/plugins/help/helpplugin.cpp25
-rw-r--r--src/plugins/help/helpviewer_qtb.cpp10
-rw-r--r--src/plugins/help/helpviewer_qwv.cpp10
-rw-r--r--src/plugins/help/openpagesswitcher.cpp14
-rw-r--r--src/plugins/locator/locatorwidget.cpp26
-rw-r--r--src/plugins/madde/maemodeploybymountsteps.cpp45
-rw-r--r--src/plugins/madde/maemoglobal.cpp51
-rw-r--r--src/plugins/madde/maemopackagecreationstep.cpp23
-rw-r--r--src/plugins/madde/maemoqemuruntimeparser.cpp45
-rw-r--r--src/plugins/madde/maemoqtversion.cpp6
-rw-r--r--src/plugins/madde/maemoremotecopyfacility.cpp15
-rw-r--r--src/plugins/perforce/perforcesettings.cpp9
-rw-r--r--src/plugins/projectexplorer/buildstepspage.cpp31
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp18
-rw-r--r--src/plugins/projectexplorer/environmentitemswidget.cpp6
-rw-r--r--src/plugins/projectexplorer/gcctoolchain.cpp72
-rw-r--r--src/plugins/projectexplorer/projectexplorersettingspage.cpp5
-rw-r--r--src/plugins/projectexplorer/settingsaccessor.cpp169
-rw-r--r--src/plugins/qmldesigner/components/integration/xuifiledialog.cpp30
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp13
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp10
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.cpp29
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp13
-rw-r--r--src/plugins/qnx/blackberryqtversion.cpp18
-rw-r--r--src/plugins/qnx/qnxqtversion.cpp34
-rw-r--r--src/plugins/qt4projectmanager/addlibrarywizard.cpp10
-rw-r--r--src/plugins/qt4projectmanager/librarydetailscontroller.cpp45
-rw-r--r--src/plugins/qt4projectmanager/qmakestep.cpp30
-rw-r--r--src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp15
-rw-r--r--src/plugins/qt4projectmanager/qt4nodes.cpp24
-rw-r--r--src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp10
-rw-r--r--src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp6
-rw-r--r--src/plugins/qtsupport/baseqtversion.cpp246
-rw-r--r--src/plugins/qtsupport/qmldumptool.cpp6
-rw-r--r--src/plugins/qtsupport/qtoptionspage.cpp8
-rw-r--r--src/plugins/subversion/subversionplugin.cpp14
-rw-r--r--src/plugins/subversion/subversionsettings.cpp9
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp30
-rw-r--r--src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp9
-rw-r--r--src/plugins/texteditor/codeassist/genericproposalwidget.cpp42
-rw-r--r--src/plugins/valgrind/callgrind/callgrindcontroller.cpp7
-rw-r--r--src/plugins/valgrind/valgrindconfigwidget.cpp13
-rw-r--r--src/plugins/valgrind/valgrindplugin.cpp6
-rw-r--r--src/plugins/valgrind/valgrindrunner.cpp10
-rw-r--r--src/plugins/vcsbase/commonvcssettings.cpp8
-rw-r--r--src/plugins/welcome/welcomeplugin.cpp29
85 files changed, 925 insertions, 973 deletions
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp
index 256c1f68ba3..453c4b57462 100644
--- a/src/plugins/android/androidconfigurations.cpp
+++ b/src/plugins/android/androidconfigurations.cpp
@@ -33,6 +33,7 @@
#include "ui_addnewavddialog.h"
#include <coreplugin/icore.h>
+#include <utils/hostosinfo.h>
#include <utils/persistentsettings.h>
#include <QDateTime>
@@ -268,19 +269,19 @@ FileName AndroidConfigurations::adbToolPath() const
FileName AndroidConfigurations::androidToolPath() const
{
-#ifdef Q_OS_WIN32
- // I want to switch from using android.bat to using an executable. All it really does is call
- // Java and I've made some progress on it. So if android.exe exists, return that instead.
- FileName path = m_config.sdkLocation;
- path.appendPath(QLatin1String("tools/android"ANDROID_EXE_SUFFIX));
- if (path.toFileInfo().exists())
- return path;
- path = m_config.sdkLocation;
- return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX));
-#else
- FileName path = m_config.sdkLocation;
- return path.appendPath(QLatin1String("tools/android"));
-#endif
+ if (HostOsInfo::isWindowsHost()) {
+ // I want to switch from using android.bat to using an executable. All it really does is call
+ // Java and I've made some progress on it. So if android.exe exists, return that instead.
+ FileName path = m_config.sdkLocation;
+ path.appendPath(QLatin1String("tools/android"ANDROID_EXE_SUFFIX));
+ if (path.toFileInfo().exists())
+ return path;
+ path = m_config.sdkLocation;
+ return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX));
+ } else {
+ FileName path = m_config.sdkLocation;
+ return path.appendPath(QLatin1String("tools/android"));
+ }
}
FileName AndroidConfigurations::antToolPath() const
diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp
index ae6b7ac2294..259fee43f78 100644
--- a/src/plugins/android/androidsettingswidget.cpp
+++ b/src/plugins/android/androidsettingswidget.cpp
@@ -36,6 +36,8 @@
#include "androidconstants.h"
+#include <utils/hostosinfo.h>
+
#include <QFile>
#include <QTextStream>
#include <QProcess>
@@ -336,16 +338,15 @@ void AndroidSettingsWidget::browseNDKLocation()
void AndroidSettingsWidget::browseAntLocation()
{
- QString dir = QDir::homePath();
-#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
- dir = QLatin1String("/usr/bin/ant");
- QLatin1String antApp("ant");
-#elif defined(Q_OS_WIN)
- QLatin1String antApp("ant.bat");
-#elif defined(Q_OS_DARWIN)
- dir = QLatin1String("/opt/local/bin/ant");
- QLatin1String antApp("ant");
-#endif
+ QString dir;
+ QString antApp;
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ dir = QDir::homePath();
+ antApp = QLatin1String("ant.bat");
+ } else {
+ dir = QLatin1String("/usr/bin/ant");
+ antApp = QLatin1String("ant");
+ }
const QString file =
QFileDialog::getOpenFileName(this, tr("Select ant Script"), dir, antApp);
if (!file.length())
diff --git a/src/plugins/android/androidtoolchain.cpp b/src/plugins/android/androidtoolchain.cpp
index 6b0a7e94f10..07ba1ecd869 100644
--- a/src/plugins/android/androidtoolchain.cpp
+++ b/src/plugins/android/androidtoolchain.cpp
@@ -42,6 +42,7 @@
#include <qtsupport/qtversionmanager.h>
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFormLayout>
@@ -53,6 +54,7 @@ namespace Internal {
using namespace ProjectExplorer;
using namespace Qt4ProjectManager;
+using namespace Utils;
static const char ANDROID_QT_VERSION_KEY[] = "Qt4ProjectManager.Android.QtVersion";
@@ -85,7 +87,7 @@ bool AndroidToolChain::isValid() const
return GccToolChain::isValid() && m_qtVersionId >= 0 && targetAbi().isValid();
}
-void AndroidToolChain::addToEnvironment(Utils::Environment &env) const
+void AndroidToolChain::addToEnvironment(Environment &env) const
{
// TODO this vars should be configurable in projects -> build tab
@@ -96,18 +98,23 @@ void AndroidToolChain::addToEnvironment(Utils::Environment &env) const
|| QtSupport::QtProfileInformation::qtVersion(qt4pro->activeTarget()->profile())->type() != QLatin1String(Constants::ANDROIDQT))
return;
- QString ndk_host = QLatin1String(
-#if defined(Q_OS_LINUX)
- "linux-x86"
-#elif defined(Q_OS_WIN)
- "windows"
-#elif defined(Q_OS_MAC)
- "darwin-x86"
-#endif
- );
+ QString ndkHost;
+ switch (HostOsInfo::hostOs()) {
+ case HostOsInfo::HostOsLinux:
+ ndkHost = QLatin1String("linux-x86");
+ break;
+ case HostOsInfo::HostOsWindows:
+ ndkHost = QLatin1String("windows");
+ break;
+ case HostOsInfo::HostOsMac:
+ ndkHost = QLatin1String("darwin-x86");
+ break;
+ default:
+ break;
+ }
// this env vars are used by qmake mkspecs to generate makefiles (check QTDIR/mkspecs/android-g++/qmake.conf for more info)
- env.set(QLatin1String("ANDROID_NDK_HOST"), ndk_host);
+ env.set(QLatin1String("ANDROID_NDK_HOST"), ndkHost);
env.set(QLatin1String("ANDROID_NDK_ROOT"), AndroidConfigurations::instance().config().ndkLocation.toUserOutput());
env.set(QLatin1String("ANDROID_NDK_TOOLCHAIN_PREFIX"), AndroidConfigurations::toolchainPrefix(targetAbi().architecture()));
env.set(QLatin1String("ANDROID_NDK_TOOLS_PREFIX"), AndroidConfigurations::toolsPrefix(targetAbi().architecture()));
@@ -147,18 +154,14 @@ bool AndroidToolChain::fromMap(const QVariantMap &data)
return isValid();
}
-QList<Utils::FileName> AndroidToolChain::suggestedMkspecList() const
+QList<FileName> AndroidToolChain::suggestedMkspecList() const
{
- return QList<Utils::FileName>()<< Utils::FileName::fromString(QLatin1String("android-g++"));
+ return QList<FileName>()<< FileName::fromString(QLatin1String("android-g++"));
}
QString AndroidToolChain::makeCommand() const
{
-#if defined(Q_OS_WIN)
- return QLatin1String("ma-make.exe");
-#else
- return QLatin1String("make");
-#endif
+ return HostOsInfo::isWindowsHost() ? QLatin1String("ma-make.exe") : QLatin1String("make");
}
void AndroidToolChain::setQtVersionId(int id)
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp
index 26953cab715..c6526bfc56a 100644
--- a/src/plugins/clearcase/clearcaseplugin.cpp
+++ b/src/plugins/clearcase/clearcaseplugin.cpp
@@ -59,6 +59,7 @@
#include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
#include <utils/fileutils.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <vcsbase/basevcseditorfactory.h>
@@ -681,11 +682,10 @@ bool ClearCasePlugin::vcsUndoHijack(const QString &workingDir, const QString &fi
QStringList args(QLatin1String("update"));
args << QLatin1String(keep ? "-rename" : "-overwrite");
args << QLatin1String("-log");
-#ifdef Q_OS_WIN32
- args << QLatin1String("NUL");
-#else
+ if (Utils::HostOsInfo::isWindowsHost())
+ args << QLatin1String("NUL");
+ else
args << QLatin1String("/dev/null");
-#endif
args << QDir::toNativeSeparators(fileName);
const ClearCaseResponse response =
diff --git a/src/plugins/clearcase/clearcasesettings.cpp b/src/plugins/clearcase/clearcasesettings.cpp
index 313d081fe4b..f47dacba724 100644
--- a/src/plugins/clearcase/clearcasesettings.cpp
+++ b/src/plugins/clearcase/clearcasesettings.cpp
@@ -33,6 +33,7 @@
#include "clearcasesettings.h"
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <QSettings>
@@ -58,9 +59,8 @@ enum { defaultTimeOutS = 30, defaultHistoryCount = 50 };
static QString defaultCommand()
{
QString rc(QLatin1String("cleartool"));
-#if defined(Q_OS_WIN32)
- rc.append(QLatin1String(".exe"));
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ rc.append(QLatin1String(".exe"));
return rc;
}
diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp
index b320e43dced..bab9fed6284 100644
--- a/src/plugins/coreplugin/actionmanager/command.cpp
+++ b/src/plugins/coreplugin/actionmanager/command.cpp
@@ -34,6 +34,8 @@
#include "icontext.h"
#include "id.h"
+#include <utils/hostosinfo.h>
+
#include <QDebug>
#include <QTextStream>
@@ -438,9 +440,8 @@ static QString msgActionWarning(QAction *newAction, int k, QAction *oldAction)
void Action::addOverrideAction(QAction *action, const Core::Context &context, bool scriptable)
{
-#ifdef Q_OS_MAC
- action->setIconVisibleInMenu(false);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ action->setIconVisibleInMenu(false);
if (isEmpty())
m_action->initialize(action);
if (context.isEmpty()) {
diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
index 5d9ebc24c36..08d2632e7ca 100644
--- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp
+++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
@@ -37,6 +37,7 @@
#include "icore.h"
#include "id.h"
+#include <utils/hostosinfo.h>
#include <utils/treewidgetcolumnstretcher.h>
#include <QKeyEvent>
@@ -166,18 +167,18 @@ bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item)
int columnCount = item->columnCount();
for (int i = 0; !visible && i < columnCount; ++i) {
QString text = item->text(i);
-#ifdef Q_OS_MAC
- // accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd
- if (i == columnCount - 1) {
- QKeySequence key = QKeySequence::fromString(text, QKeySequence::NativeText);
- if (!key.isEmpty()) {
- text = key.toString(QKeySequence::PortableText);
- text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd"));
- text.replace(QLatin1String("Meta"), QLatin1String("Ctrl"));
- text.replace(QLatin1String("Alt"), QLatin1String("Opt"));
+ if (Utils::HostOsInfo::isMacHost()) {
+ // accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd
+ if (i == columnCount - 1) {
+ QKeySequence key = QKeySequence::fromString(text, QKeySequence::NativeText);
+ if (!key.isEmpty()) {
+ text = key.toString(QKeySequence::PortableText);
+ text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd"));
+ text.replace(QLatin1String("Meta"), QLatin1String("Ctrl"));
+ text.replace(QLatin1String("Alt"), QLatin1String("Opt"));
+ }
}
}
-#endif
visible |= (bool)text.contains(filterString, Qt::CaseInsensitive);
}
diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp
index d7a8eaaf1aa..4f93a27d4dd 100644
--- a/src/plugins/coreplugin/basefilewizard.cpp
+++ b/src/plugins/coreplugin/basefilewizard.cpp
@@ -41,6 +41,7 @@
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/fileutils.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFile>
@@ -604,15 +605,15 @@ void BaseFileWizard::setupWizard(QWizard *w)
w->setOption(QWizard::NoBackButtonOnStartPage, true);
w->setWindowFlags(w->windowFlags() & ~Qt::WindowContextHelpButtonHint);
-#ifdef Q_OS_MAC
- w->setButtonLayout(QList<QWizard::WizardButton>()
- << QWizard::CancelButton
- << QWizard::Stretch
- << QWizard::BackButton
- << QWizard::NextButton
- << QWizard::CommitButton
- << QWizard::FinishButton);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ w->setButtonLayout(QList<QWizard::WizardButton>()
+ << QWizard::CancelButton
+ << QWizard::Stretch
+ << QWizard::BackButton
+ << QWizard::NextButton
+ << QWizard::CommitButton
+ << QWizard::FinishButton);
+ }
}
/*!
diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
index 1d9ea58c033..31d8bbc91c3 100644
--- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
+++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
@@ -31,6 +31,7 @@
#include "externaltoolconfig.h"
#include "ui_externaltoolconfig.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <coreplugin/coreconstants.h>
@@ -351,13 +352,13 @@ QModelIndex ExternalToolModel::addTool(const QModelIndex &atIndex)
tool->setDescription(tr("This tool prints a line of useful text"));
//: Sample external tool text
const QString text = tr("Useful text");
-#ifdef Q_OS_WIN
- tool->setExecutables(QStringList(QLatin1String("cmd")));
- tool->setArguments(QLatin1String("/c echo ") + text);
-#else
- tool->setExecutables(QStringList(QLatin1String("echo")));
- tool->setArguments(text);
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ tool->setExecutables(QStringList(QLatin1String("cmd")));
+ tool->setArguments(QLatin1String("/c echo ") + text);
+ } else {
+ tool->setExecutables(QStringList(QLatin1String("echo")));
+ tool->setArguments(text);
+ }
int pos;
QModelIndex parent;
diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
index 89cedb58ab6..bbd8ee8f8f6 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
@@ -34,6 +34,7 @@
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/idocument.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFileInfo>
@@ -54,12 +55,10 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
{
m_ui.setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
-#ifdef Q_OS_MAC
+
// QDialogButtonBox's behavior for "destructive" is wrong, the "do not save" should be left-aligned
- QDialogButtonBox::ButtonRole discardButtonRole = QDialogButtonBox::ResetRole;
-#else
- QDialogButtonBox::ButtonRole discardButtonRole = QDialogButtonBox::DestructiveRole;
-#endif
+ const QDialogButtonBox::ButtonRole discardButtonRole = Utils::HostOsInfo::isMacHost()
+ ? QDialogButtonBox::ResetRole : QDialogButtonBox::DestructiveRole;
QPushButton *discardButton = m_ui.buttonBox->addButton(tr("Do not Save"), discardButtonRole);
m_ui.buttonBox->button(QDialogButtonBox::Save)->setDefault(true);
m_ui.treeWidget->setFocus();
@@ -86,9 +85,8 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
m_ui.treeWidget->resizeColumnToContents(0);
m_ui.treeWidget->selectAll();
-#ifdef Q_OS_MAC
- m_ui.treeWidget->setAlternatingRowColors(true);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ m_ui.treeWidget->setAlternatingRowColors(true);
adjustButtonWidths();
updateSaveButton();
@@ -135,13 +133,13 @@ void SaveItemsDialog::adjustButtonWidths()
if (hint > maxTextWidth)
maxTextWidth = hint;
}
-#ifdef Q_OS_MAC
- QPushButton *cancelButton = m_ui.buttonBox->button(QDialogButtonBox::Cancel);
- int cancelButtonWidth = cancelButton->sizeHint().width();
- if (cancelButtonWidth > maxTextWidth)
- maxTextWidth = cancelButtonWidth;
- cancelButton->setMinimumWidth(maxTextWidth);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ QPushButton *cancelButton = m_ui.buttonBox->button(QDialogButtonBox::Cancel);
+ int cancelButtonWidth = cancelButton->sizeHint().width();
+ if (cancelButtonWidth > maxTextWidth)
+ maxTextWidth = cancelButtonWidth;
+ cancelButton->setMinimumWidth(maxTextWidth);
+ }
saveButton->setMinimumWidth(maxTextWidth);
}
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
index ba6c8c72925..eea0b197dcb 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
@@ -33,6 +33,7 @@
#include <extensionsystem/pluginmanager.h>
#include "icore.h"
+#include <utils/hostosinfo.h>
#include <utils/filterlineedit.h>
#include <QSettings>
@@ -295,11 +296,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
createGui();
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
-#ifdef Q_OS_MAC
- setWindowTitle(tr("Preferences"));
-#else
- setWindowTitle(tr("Options"));
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ setWindowTitle(tr("Preferences"));
+ else
+ setWindowTitle(tr("Options"));
m_model->setPages(m_pages,
ExtensionSystem::PluginManager::getObjects<IOptionsPageProvider>());
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 7a1b0c5ab35..a604f00974c 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -42,6 +42,7 @@
#include "vcsmanager.h"
#include "coreconstants.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
#include <utils/reloadpromptutils.h>
@@ -178,17 +179,17 @@ QFileSystemWatcher *DocumentManagerPrivate::fileWatcher()
QFileSystemWatcher *DocumentManagerPrivate::linkWatcher()
{
-#ifdef Q_OS_UNIX
- if (!m_linkWatcher) {
- m_linkWatcher = new QFileSystemWatcher(m_instance);
- m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));
- QObject::connect(m_linkWatcher, SIGNAL(fileChanged(QString)),
- m_instance, SLOT(changedFile(QString)));
+ if (Utils::HostOsInfo::isAnyUnixHost()) {
+ if (!m_linkWatcher) {
+ m_linkWatcher = new QFileSystemWatcher(m_instance);
+ m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));
+ QObject::connect(m_linkWatcher, SIGNAL(fileChanged(QString)),
+ m_instance, SLOT(changedFile(QString)));
+ }
+ return m_linkWatcher;
}
- return m_linkWatcher;
-#else
+
return fileWatcher();
-#endif
}
DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
@@ -197,11 +198,7 @@ DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
m_linkWatcher(0),
m_blockActivated(false),
m_lastVisitedDirectory(QDir::currentPath()),
-#ifdef Q_OS_MAC // Creator is in bizarre places when launched via finder.
- m_useProjectsDirectory(true),
-#else
- m_useProjectsDirectory(false),
-#endif
+ m_useProjectsDirectory(Utils::HostOsInfo::isMacHost()), // Creator is in bizarre places when launched via finder.
m_blockedIDocument(0)
{
}
@@ -489,9 +486,8 @@ QString DocumentManager::fixFileName(const QString &fileName, FixMode fixmode)
s = QDir::cleanPath(s);
}
s = QDir::toNativeSeparators(s);
-#ifdef Q_OS_WIN
- s = s.toLower();
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ s = s.toLower();
return s;
}
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index c0d9eeced8a..06c7d1d8254 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -61,6 +61,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/consoleprocess.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDateTime>
@@ -1700,9 +1701,8 @@ void EditorManager::updateActions()
fName = curEditor->displayName();
}
-#ifdef Q_OS_MAC
- window()->setWindowModified(curEditor->document()->isModified());
-#endif
+ if (HostOsInfo::isMacHost())
+ window()->setWindowModified(curEditor->document()->isModified());
bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
if (ww != curEditor->document()->hasWriteWarning()) {
curEditor->document()->setWriteWarning(ww);
@@ -1739,10 +1739,8 @@ void EditorManager::updateActions()
curEditor->document()->infoBar()->removeInfo(QLatin1String("Core.EditorManager.MakeWritable"));
}
}
-#ifdef Q_OS_MAC
- } else { // curEditor
+ } else /* curEditor */ if (HostOsInfo::isMacHost()) {
window()->setWindowModified(false);
-#endif
}
setCloseSplitEnabled(d->m_splitter, d->m_splitter->isSplitter());
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index 460c46acf6d..7ebe2662a76 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -34,6 +34,7 @@
#include "editorview.h"
#include "idocument.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QFocusEvent>
@@ -61,16 +62,14 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
m_editorList->setIndentation(0);
m_editorList->setSelectionMode(QAbstractItemView::SingleSelection);
m_editorList->setTextElideMode(Qt::ElideMiddle);
-#ifdef Q_OS_MAC
- m_editorList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ m_editorList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_editorList->installEventFilter(this);
// We disable the frame on this list view and use a QFrame around it instead.
// This improves the look with QGTKStyle.
-#ifndef Q_OS_MAC
- setFrameStyle(m_editorList->frameStyle());
-#endif
+ if (!Utils::HostOsInfo::isMacHost())
+ setFrameStyle(m_editorList->frameStyle());
m_editorList->setFrameStyle(QFrame::NoFrame);
QVBoxLayout *layout = new QVBoxLayout(this);
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index d44006c4f34..368b25dba63 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -44,6 +44,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
+#include <utils/hostosinfo.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
@@ -152,10 +153,10 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_forwardButton= new QToolButton(this);
d->m_forwardButton->setDefaultAction(d->m_goForwardAction);
-#ifdef Q_OS_MAC
- d->m_horizontalSplitAction->setIconVisibleInMenu(false);
- d->m_verticalSplitAction->setIconVisibleInMenu(false);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ d->m_horizontalSplitAction->setIconVisibleInMenu(false);
+ d->m_verticalSplitAction->setIconVisibleInMenu(false);
+ }
d->m_splitButton->setIcon(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)));
d->m_splitButton->setToolTip(tr("Split"));
diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp
index 2517bfc2734..2bed5a079af 100644
--- a/src/plugins/coreplugin/fancytabwidget.cpp
+++ b/src/plugins/coreplugin/fancytabwidget.cpp
@@ -29,6 +29,7 @@
**************************************************************************/
#include "fancytabwidget.h"
+#include <utils/hostosinfo.h>
#include <utils/stylehelper.h>
#include <utils/styledbar.h>
@@ -289,8 +290,7 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
} else {
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
}
-#ifndef Q_OS_MAC
- if (!selected && enabled) {
+ if (!Utils::HostOsInfo::isMacHost() && !selected && enabled) {
painter->save();
int fader = int(m_tabs[tabIndex]->fader());
QLinearGradient grad(rect.topLeft(), rect.topRight());
@@ -303,7 +303,6 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
painter->restore();
}
-#endif
if (!enabled)
painter->setOpacity(0.7);
diff --git a/src/plugins/coreplugin/fileiconprovider.cpp b/src/plugins/coreplugin/fileiconprovider.cpp
index 3541027cd0a..ffc94139a9b 100644
--- a/src/plugins/coreplugin/fileiconprovider.cpp
+++ b/src/plugins/coreplugin/fileiconprovider.cpp
@@ -31,6 +31,7 @@
#include "fileiconprovider.h"
#include "mimedatabase.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QApplication>
@@ -44,6 +45,8 @@
#include <QIcon>
#include <QStyle>
+using namespace Utils;
+
/*!
\class Core::FileIconProvider
@@ -139,14 +142,13 @@ QIcon FileIconProvider::icon(const QFileInfo &fileInfo) const
}
}
// Get icon from OS.
-#if defined(Q_WS_WIN) || defined(Q_OS_MAC)
- return QFileIconProvider::icon(fileInfo);
-#else
+ if (HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost())
+ return QFileIconProvider::icon(fileInfo);
+
// File icons are unknown on linux systems.
return (fileInfo.isDir()) ?
QFileIconProvider::icon(fileInfo) :
d->m_unknownFileIcon;
-#endif
}
/*!
diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp
index 7d7cf98cdec..7996768fe93 100644
--- a/src/plugins/coreplugin/outputpanemanager.cpp
+++ b/src/plugins/coreplugin/outputpanemanager.cpp
@@ -48,6 +48,7 @@
#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/styledbar.h>
#include <utils/qtcassert.h>
@@ -198,11 +199,7 @@ QWidget *OutputPaneManager::buttonsWidget()
// Return shortcut as Ctrl+<number>
static inline int paneShortCut(int number)
{
-#ifdef Q_OS_MAC
- int modifier = Qt::CTRL;
-#else
- int modifier = Qt::ALT;
-#endif
+ const int modifier = Utils::HostOsInfo::isMacHost() ? Qt::CTRL : Qt::ALT;
return modifier | (Qt::Key_0 + number);
}
diff --git a/src/plugins/cpaster/codepasterprotocol.cpp b/src/plugins/cpaster/codepasterprotocol.cpp
index 427a8bdd195..8e3679f23b8 100644
--- a/src/plugins/cpaster/codepasterprotocol.cpp
+++ b/src/plugins/cpaster/codepasterprotocol.cpp
@@ -38,6 +38,7 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/messageoutputwindow.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QListWidget>
@@ -77,12 +78,9 @@ bool CodePasterProtocol::checkConfiguration(QString *errorMessage)
const QString hostName = m_page->hostName();
if (hostName.isEmpty()) {
if (errorMessage) {
- *errorMessage =
-#ifdef Q_OS_MAC
- tr("No Server defined in the CodePaster preferences.");
-#else
- tr("No Server defined in the CodePaster options.");
-#endif
+ *errorMessage = Utils::HostOsInfo::isMacHost()
+ ? tr("No Server defined in the CodePaster preferences.")
+ : tr("No Server defined in the CodePaster options.");
}
return false;
}
diff --git a/src/plugins/cpaster/pasteselectdialog.cpp b/src/plugins/cpaster/pasteselectdialog.cpp
index aa67a49ed94..f4058190065 100644
--- a/src/plugins/cpaster/pasteselectdialog.cpp
+++ b/src/plugins/cpaster/pasteselectdialog.cpp
@@ -31,6 +31,7 @@
#include "pasteselectdialog.h"
#include "protocol.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDebug>
@@ -56,9 +57,8 @@ PasteSelectDialog::PasteSelectDialog(const QList<Protocol*> &protocols,
connect(m_refreshButton, SIGNAL(clicked()), this, SLOT(list()));
m_ui.listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
-#ifndef Q_OS_MACX
- m_ui.listWidget->setFrameStyle(QFrame::NoFrame);
-#endif // Q_OS_MACX
+ if (!Utils::HostOsInfo::isMacHost())
+ m_ui.listWidget->setFrameStyle(QFrame::NoFrame);
// Proportional formatting of columns for CodePaster
QFont listFont = m_ui.listWidget->font();
listFont.setFamily(QLatin1String("Courier"));
diff --git a/src/plugins/cpaster/settings.cpp b/src/plugins/cpaster/settings.cpp
index 1ca72725c78..d943147a8c7 100644
--- a/src/plugins/cpaster/settings.cpp
+++ b/src/plugins/cpaster/settings.cpp
@@ -31,6 +31,8 @@
#include "settings.h"
#include "pastebindotcomprotocol.h"
+#include <utils/hostosinfo.h>
+
#include <QVariant>
#include <QSettings>
@@ -65,11 +67,8 @@ void Settings::toSettings(QSettings *settings) const
void Settings::fromSettings(const QSettings *settings)
{
const QString rootKey = QLatin1String(groupC) + QLatin1Char('/');
-#ifdef Q_OS_WIN
- const QString defaultUser = QString::fromLocal8Bit(qgetenv("USERNAME"));
-#else
- const QString defaultUser = QString::fromLocal8Bit(qgetenv("USER"));
-#endif
+ const char * const envKey = Utils::HostOsInfo::isWindowsHost() ? "USERNAME" : "USER";
+ const QString defaultUser = QString::fromLocal8Bit(qgetenv(envKey));
username = settings->value(rootKey + QLatin1String(userNameKeyC), defaultUser).toString();
protocol = settings->value(rootKey + QLatin1String(defaultProtocolKeyC), PasteBinDotComProtocol::protocolName()).toString();
copyToClipboard = settings->value(rootKey + QLatin1String(copyToClipboardKeyC), true).toBool();
diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp
index 264f3b9f25e..8225a801065 100644
--- a/src/plugins/cppeditor/cppplugin.cpp
+++ b/src/plugins/cppeditor/cppplugin.cpp
@@ -55,6 +55,7 @@
#include <texteditor/texteditorplugin.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/texteditorconstants.h>
+#include <utils/hostosinfo.h>
#include <cpptools/ModelManagerInterface.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpptoolssettings.h>
@@ -84,16 +85,16 @@ CppEditorFactory::CppEditorFactory(CppPlugin *owner) :
<< QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE)
<< QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE);
-#if !defined(Q_OS_MAC) && !defined(Q_WS_WIN)
- Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
- Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase();
- iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_cpp.png")),
- mimeDatabase->findByType(QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE)));
- iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_c.png")),
- mimeDatabase->findByType(QLatin1String(CppEditor::Constants::C_SOURCE_MIMETYPE)));
- iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_h.png")),
- mimeDatabase->findByType(QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE)));
-#endif
+ if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) {
+ Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
+ Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase();
+ iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_cpp.png")),
+ mimeDatabase->findByType(QLatin1String(CppEditor::Constants::CPP_SOURCE_MIMETYPE)));
+ iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_c.png")),
+ mimeDatabase->findByType(QLatin1String(CppEditor::Constants::C_SOURCE_MIMETYPE)));
+ iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/cppeditor/images/qt_h.png")),
+ mimeDatabase->findByType(QLatin1String(CppEditor::Constants::CPP_HEADER_MIMETYPE)));
+ }
}
Core::Id CppEditorFactory::id() const
diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp
index d2c01d01d63..2f11b68387d 100644
--- a/src/plugins/cpptools/cppfilesettingspage.cpp
+++ b/src/plugins/cpptools/cppfilesettingspage.cpp
@@ -39,6 +39,7 @@
#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/fileutils.h>
#include <QSettings>
@@ -150,11 +151,8 @@ static bool keyWordReplacement(const QString &keyWord,
return true;
}
if (keyWord == QLatin1String("%USER%")) {
-#ifdef Q_OS_WIN
- *value = QString::fromLocal8Bit(qgetenv("USERNAME"));
-#else
- *value = QString::fromLocal8Bit(qgetenv("USER"));
-#endif
+ const char * const envKey = Utils::HostOsInfo::isWindowsHost() ? "USERNAME" : "USER";
+ *value = QString::fromLocal8Bit(qgetenv(envKey));
return true;
}
// Environment variables (for example '%$EMAIL%').
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 5cb7fd87307..853658a9362 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -62,6 +62,7 @@
# include <QDir>
#endif
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <TranslationUnit.h>
@@ -235,23 +236,23 @@ void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
for (int i = 0; i < includePaths.size(); ++i) {
const QString &path = includePaths.at(i);
-#ifdef Q_OS_DARWIN
- if (i + 1 < includePaths.size() && path.endsWith(QLatin1String(".framework/Headers"))) {
- const QFileInfo pathInfo(path);
- const QFileInfo frameworkFileInfo(pathInfo.path());
- const QString frameworkName = frameworkFileInfo.baseName();
-
- const QFileInfo nextIncludePath = includePaths.at(i + 1);
- if (nextIncludePath.fileName() == frameworkName) {
- // We got a QtXXX.framework/Headers followed by $QTDIR/include/QtXXX.
- // In this case we prefer to include files from $QTDIR/include/QtXXX.
- continue;
+ if (Utils::HostOsInfo::isMacHost()) {
+ if (i + 1 < includePaths.size() && path.endsWith(QLatin1String(".framework/Headers"))) {
+ const QFileInfo pathInfo(path);
+ const QFileInfo frameworkFileInfo(pathInfo.path());
+ const QString frameworkName = frameworkFileInfo.baseName();
+
+ const QFileInfo nextIncludePath = includePaths.at(i + 1);
+ if (nextIncludePath.fileName() == frameworkName) {
+ // We got a QtXXX.framework/Headers followed by $QTDIR/include/QtXXX.
+ // In this case we prefer to include files from $QTDIR/include/QtXXX.
+ continue;
+ }
}
+ m_includePaths.append(path);
+ } else {
+ m_includePaths.append(path);
}
- m_includePaths.append(path);
-#else
- m_includePaths.append(path);
-#endif
}
}
diff --git a/src/plugins/cvs/cvssettings.cpp b/src/plugins/cvs/cvssettings.cpp
index e22a7bb8985..7a00c132a5e 100644
--- a/src/plugins/cvs/cvssettings.cpp
+++ b/src/plugins/cvs/cvssettings.cpp
@@ -31,6 +31,7 @@
#include "cvssettings.h"
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <QSettings>
#include <QTextStream>
@@ -50,9 +51,8 @@ static QString defaultCommand()
{
QString rc;
rc = QLatin1String("cvs");
-#if defined(Q_OS_WIN32)
- rc.append(QLatin1String(".exe"));
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ rc.append(QLatin1String(".exe"));
return rc;
}
diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp
index 86acab94c44..191f2218a6a 100644
--- a/src/plugins/debugger/breakhandler.cpp
+++ b/src/plugins/debugger/breakhandler.cpp
@@ -38,6 +38,7 @@
#include "debuggerstringutils.h"
#include "stackframe.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#if USE_BREAK_MODEL_TEST
@@ -181,11 +182,9 @@ QIcon BreakHandler::emptyIcon()
static inline bool fileNameMatch(const QString &f1, const QString &f2)
{
-#ifdef Q_OS_WIN
- return f1.compare(f2, Qt::CaseInsensitive) == 0;
-#else
+ if (Utils::HostOsInfo::isWindowsHost())
+ return f1.compare(f2, Qt::CaseInsensitive) == 0;
return f1 == f2;
-#endif
}
static bool isSimilarTo(const BreakpointParameters &data, const BreakpointResponse &needle)
diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp
index 495f28af0fb..1b94f7c22f3 100644
--- a/src/plugins/debugger/commonoptionspage.cpp
+++ b/src/plugins/debugger/commonoptionspage.cpp
@@ -37,6 +37,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/manhattanstyle.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <projectexplorer/projectexplorer.h>
@@ -98,36 +99,35 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
m_group->insert(dc->action(VerboseLog), 0);
m_group->insert(dc->action(BreakOnThrow), 0);
m_group->insert(dc->action(BreakOnCatch), 0);
-#ifdef Q_OS_WIN
- Utils::SavedAction *registerAction = dc->action(RegisterForPostMortem);
- m_group->insert(registerAction,
- m_ui.checkBoxRegisterForPostMortem);
- connect(registerAction, SIGNAL(toggled(bool)),
- m_ui.checkBoxRegisterForPostMortem, SLOT(setChecked(bool)));
-#else
- m_ui.checkBoxRegisterForPostMortem->setVisible(false);
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ Utils::SavedAction *registerAction = dc->action(RegisterForPostMortem);
+ m_group->insert(registerAction,
+ m_ui.checkBoxRegisterForPostMortem);
+ connect(registerAction, SIGNAL(toggled(bool)),
+ m_ui.checkBoxRegisterForPostMortem, SLOT(setChecked(bool)));
+ } else {
+ m_ui.checkBoxRegisterForPostMortem->setVisible(false);
+ }
}
QString CommonOptionsPageWidget::searchKeyWords() const
{
QString rc;
const QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui.checkBoxUseAlternatingRowColors->text()
- << sep << m_ui.checkBoxFontSizeFollowsEditor->text()
- << sep << m_ui.checkBoxUseToolTipsInMainEditor->text()
- << sep << m_ui.checkBoxListSourceFiles->text()
- << sep << m_ui.checkBoxBreakpointsFullPath->text()
-#ifdef Q_OS_WIN
- << sep << m_ui.checkBoxRegisterForPostMortem->text()
-#endif
- << sep << m_ui.checkBoxCloseBuffersOnExit->text()
- << sep << m_ui.checkBoxSwitchModeOnExit->text()
- << sep << m_ui.labelMaximalStackDepth->text()
- << sep << m_ui.checkBoxBringToForegroundOnInterrrupt->text()
- << sep << m_ui.checkBoxShowQmlObjectTree->text()
- ;
+ QTextStream stream(&rc);
+ stream << sep << m_ui.checkBoxUseAlternatingRowColors->text()
+ << sep << m_ui.checkBoxFontSizeFollowsEditor->text()
+ << sep << m_ui.checkBoxUseToolTipsInMainEditor->text()
+ << sep << m_ui.checkBoxListSourceFiles->text()
+ << sep << m_ui.checkBoxBreakpointsFullPath->text()
+ << sep << m_ui.checkBoxCloseBuffersOnExit->text()
+ << sep << m_ui.checkBoxSwitchModeOnExit->text()
+ << sep << m_ui.labelMaximalStackDepth->text()
+ << sep << m_ui.checkBoxBringToForegroundOnInterrrupt->text()
+ << sep << m_ui.checkBoxShowQmlObjectTree->text();
+ if (Utils::HostOsInfo::isWindowsHost())
+ stream << sep << m_ui.checkBoxRegisterForPostMortem->text();
+
rc.remove(QLatin1Char('&'));
return rc;
}
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 87ae97d8ee0..0e820d241a4 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -115,6 +115,7 @@
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorsettings.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
#include <utils/styledbar.h>
@@ -2898,11 +2899,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
act->setText(tr("Attach to QML Port..."));
connect(act, SIGNAL(triggered()), SLOT(attachToQmlPort()));
-#ifdef Q_OS_WIN
- m_startRemoteCdbAction = new QAction(tr("Attach to Remote CDB Session..."), this);
- connect(m_startRemoteCdbAction, SIGNAL(triggered()),
- SLOT(startRemoteCdbSession()));
-#endif
+ if (HostOsInfo::isWindowsHost()) {
+ m_startRemoteCdbAction = new QAction(tr("Attach to Remote CDB Session..."), this);
+ connect(m_startRemoteCdbAction, SIGNAL(triggered()),
+ SLOT(startRemoteCdbSession()));
+ }
act = m_detachAction = new QAction(this);
act->setText(tr("Detach Debugger"));
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 161d48c424a..2ad658598ab 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -76,6 +76,7 @@
#include <projectexplorer/itaskhandler.h>
#include <texteditor/itexteditor.h>
#include <utils/elfreader.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/savedaction.h>
@@ -4980,11 +4981,7 @@ void GdbEngine::finishInferiorSetup()
void GdbEngine::handleDebugInfoLocation(const GdbResponse &response)
{
-#ifdef Q_OS_WIN
- const char pathSep = ';';
-#else
- const char pathSep = ':';
-#endif
+ const char pathSep = HostOsInfo::isWindowsHost() ? ';' : ':';
if (response.resultClass == GdbResultDone) {
const QByteArray debugInfoLocation = startParameters().debugInfoLocation.toLocal8Bit();
if (QFile::exists(QString::fromLocal8Bit(debugInfoLocation))) {
diff --git a/src/plugins/debugger/gdb/localplaingdbadapter.cpp b/src/plugins/debugger/gdb/localplaingdbadapter.cpp
index 59a02f59673..de0b736bc7d 100644
--- a/src/plugins/debugger/gdb/localplaingdbadapter.cpp
+++ b/src/plugins/debugger/gdb/localplaingdbadapter.cpp
@@ -38,6 +38,7 @@
#include <projectexplorer/abi.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
@@ -62,11 +63,8 @@ GdbLocalPlainEngine::GdbLocalPlainEngine(const DebuggerStartParameters &startPar
GdbEngine::DumperHandling GdbLocalPlainEngine::dumperHandling() const
{
// LD_PRELOAD fails for System-Qt on Mac.
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
- return DumperLoadedByGdb;
-#else
- return DumperLoadedByGdbPreload;
-#endif
+ return Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()
+ ? DumperLoadedByGdb : DumperLoadedByGdbPreload;
}
void GdbLocalPlainEngine::setupEngine()
diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp
index f41ec430743..8714786a983 100644
--- a/src/plugins/debugger/gdb/termgdbadapter.cpp
+++ b/src/plugins/debugger/gdb/termgdbadapter.cpp
@@ -38,6 +38,7 @@
#include "debuggercore.h"
#include "shared/hostutils.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
@@ -80,11 +81,9 @@ GdbTermEngine::~GdbTermEngine()
GdbEngine::DumperHandling GdbTermEngine::dumperHandling() const
{
// LD_PRELOAD fails for System-Qt on Mac.
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
- return DumperLoadedByGdb;
-#else
- return DumperLoadedByAdapter; // Handles loading itself via LD_PRELOAD
-#endif
+ return Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()
+ ? DumperLoadedByGdb
+ : DumperLoadedByAdapter; // Handles loading itself via LD_PRELOAD
}
void GdbTermEngine::setupEngine()
diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp
index 4451c13100e..31ce3ae3c6f 100644
--- a/src/plugins/debugger/moduleswindow.cpp
+++ b/src/plugins/debugger/moduleswindow.cpp
@@ -35,6 +35,7 @@
#include "debuggercore.h"
#include "debuggerengine.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
@@ -133,10 +134,9 @@ void ModulesTreeView::contextMenuEvent(QContextMenuEvent *ev)
actShowModuleSymbols->setEnabled(engine->hasCapability(ShowModuleSymbolsCapability));
actShowDependencies = new QAction(tr("Show Dependencies of \"%1\"").arg(name), &menu);
actShowDependencies->setEnabled(!fileName.isEmpty());
-#ifndef Q_OS_WIN
- // FIXME: Dependencies only available on Windows, when "depends" is installed.
- actShowDependencies->setEnabled(false);
-#endif
+ if (!Utils::HostOsInfo::isWindowsHost())
+ // FIXME: Dependencies only available on Windows, when "depends" is installed.
+ actShowDependencies->setEnabled(false);
}
menu.addAction(actUpdateModuleList);
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 5da22a6f8c6..ab78588c999 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -60,6 +60,7 @@
#include "fakevimhandler.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDebug>
@@ -3870,9 +3871,8 @@ bool FakeVimHandler::Private::handleExBangCommand(const ExCommand &cmd) // :!
QProcess proc;
proc.start(command);
proc.waitForStarted();
-#ifdef Q_OS_WIN
- text.replace(_("\n"), _("\r\n"));
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ text.replace(_("\n"), _("\r\n"));
proc.write(text.toUtf8());
proc.closeWriteChannel();
proc.waitForFinished();
diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp
index c9e8bf9c0ec..73b6195c46d 100644
--- a/src/plugins/find/findtoolbar.cpp
+++ b/src/plugins/find/findtoolbar.cpp
@@ -44,6 +44,7 @@
#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/stylehelper.h>
#include <utils/flowlayout.h>
@@ -285,14 +286,12 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
}
}
+ const Qt::KeyboardModifier modifier = Utils::HostOsInfo::isMacHost()
+ ? Qt::ControlModifier : Qt::MetaModifier;
if ((obj == m_ui.findEdit || obj == m_findCompleter->popup())
&& event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
-#ifdef Q_OS_MAC
- if (ke->key() == Qt::Key_Space && (ke->modifiers() & Qt::MetaModifier)) {
-#else
- if (ke->key() == Qt::Key_Space && (ke->modifiers() & Qt::ControlModifier)) {
-#endif
+ if (ke->key() == Qt::Key_Space && (ke->modifiers() & modifier)) {
QString completedText = m_currentDocumentFind->completedFindString();
if (!completedText.isEmpty()) {
setFindText(completedText);
@@ -309,11 +308,7 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
event->accept();
return true;
}
-#ifdef Q_OS_MAC
- } else if (ke->key() == Qt::Key_Space && (ke->modifiers() & Qt::MetaModifier)) {
-#else
- } else if (ke->key() == Qt::Key_Space && (ke->modifiers() & Qt::ControlModifier)) {
-#endif
+ } else if (ke->key() == Qt::Key_Space && (ke->modifiers() & modifier)) {
event->accept();
return true;
}
diff --git a/src/plugins/git/gerrit/gerritparameters.cpp b/src/plugins/git/gerrit/gerritparameters.cpp
index db28b564f2f..340e4ed7130 100644
--- a/src/plugins/git/gerrit/gerritparameters.cpp
+++ b/src/plugins/git/gerrit/gerritparameters.cpp
@@ -36,6 +36,7 @@
#else
# include <utils/environment.h>
#endif
+#include <utils/hostosinfo.h>
#include <utils/pathchooser.h>
#include <QDebug>
#include <QFileInfo>
@@ -72,16 +73,16 @@ static inline QString detectSsh()
#endif
if (!ssh.isEmpty())
return ssh;
-#ifdef Q_OS_WIN // Windows: Use ssh.exe from git if it cannot be found.
- const QString git = GerritPlugin::gitBinary();
- if (!git.isEmpty()) {
- // Is 'git\cmd' in the path (folder containing .bats)?
- QString path = QFileInfo(git).absolutePath();
- if (path.endsWith(QLatin1String("cmd"), Qt::CaseInsensitive))
- path.replace(path.size() - 3, 3, QLatin1String("bin"));
- ssh = path + QLatin1Char('/') + QLatin1String(defaultSshC);
+ if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
+ const QString git = GerritPlugin::gitBinary();
+ if (!git.isEmpty()) {
+ // Is 'git\cmd' in the path (folder containing .bats)?
+ QString path = QFileInfo(git).absolutePath();
+ if (path.endsWith(QLatin1String("cmd"), Qt::CaseInsensitive))
+ path.replace(path.size() - 3, 3, QLatin1String("bin"));
+ ssh = path + QLatin1Char('/') + QLatin1String(defaultSshC);
+ }
}
-#endif
return ssh;
}
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 1ae8a662ff4..1c60966bffc 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -52,6 +52,7 @@
#include <coreplugin/variablemanager.h>
#include <texteditor/itexteditor.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/synchronousprocess.h>
@@ -1441,7 +1442,6 @@ VcsBase::Command *GitClient::executeGit(const QString &workingDirectory,
QProcessEnvironment GitClient::processEnvironment() const
{
-
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString gitPath = settings()->stringValue(GitSettings::pathKey);
if (!gitPath.isEmpty()) {
@@ -1449,10 +1449,10 @@ QProcessEnvironment GitClient::processEnvironment() const
gitPath += environment.value(QLatin1String("PATH"));
environment.insert(QLatin1String("PATH"), gitPath);
}
-#ifdef Q_OS_WIN
- if (settings()->boolValue(GitSettings::winSetHomeEnvironmentKey))
+ if (Utils::HostOsInfo::isWindowsHost()
+ && settings()->boolValue(GitSettings::winSetHomeEnvironmentKey)) {
environment.insert(QLatin1String("HOME"), QDir::toNativeSeparators(QDir::homePath()));
-#endif // Q_OS_WIN
+ }
// Set up SSH and C locale (required by git using perl).
VcsBase::VcsBasePlugin::setProcessEnvironment(&environment, false);
return environment;
@@ -1659,15 +1659,16 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
const QString &gitBinDirectory,
bool silent)
{
-#ifdef Q_OS_WIN
- // Launch 'wish' shell from git binary directory with the gitk located there
- const QString binary = gitBinDirectory + QLatin1String("/wish");
- QStringList arguments(gitBinDirectory + QLatin1String("/gitk"));
-#else
- // Simple: Run gitk from binary path
- const QString binary = gitBinDirectory + QLatin1String("/gitk");
+ QString binary;
QStringList arguments;
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ // Launch 'wish' shell from git binary directory with the gitk located there
+ binary = gitBinDirectory + QLatin1String("/wish");
+ arguments << (gitBinDirectory + QLatin1String("/gitk"));
+ } else {
+ // Simple: Run gitk from binary path
+ binary = gitBinDirectory + QLatin1String("/gitk");
+ }
VcsBase::VcsBaseOutputWindow *outwin = VcsBase::VcsBaseOutputWindow::instance();
const QString gitkOpts = settings()->stringValue(GitSettings::gitkOptionsKey);
if (!gitkOpts.isEmpty())
diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp
index 53810909683..5ec9297a86a 100644
--- a/src/plugins/git/gitsettings.cpp
+++ b/src/plugins/git/gitsettings.cpp
@@ -30,6 +30,7 @@
#include "gitsettings.h"
+#include <utils/hostosinfo.h>
#include <utils/synchronousprocess.h>
#include <QCoreApplication>
@@ -54,11 +55,7 @@ GitSettings::GitSettings()
setSettingsGroup(QLatin1String("Git"));
declareKey(binaryPathKey, QLatin1String("git"));
-#ifdef Q_OS_WIN
- declareKey(timeoutKey, 60);
-#else
- declareKey(timeoutKey, 30);
-#endif
+ declareKey(timeoutKey, Utils::HostOsInfo::isWindowsHost() ? 60 : 30);
declareKey(pathKey, QString());
declareKey(pullRebaseKey, false);
declareKey(omitAnnotationDateKey, false);
diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp
index 01fd37abd0c..82c2f111324 100644
--- a/src/plugins/git/settingspage.cpp
+++ b/src/plugins/git/settingspage.cpp
@@ -34,6 +34,7 @@
#include "gitclient.h"
#include <vcsbase/vcsbaseconstants.h>
+#include <utils/hostosinfo.h>
#include <utils/pathchooser.h>
#include <QCoreApplication>
@@ -51,19 +52,19 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
-#ifdef Q_OS_WIN
- const QByteArray currentHome = qgetenv("HOME");
- const QString toolTip
- = tr("Set the environment variable HOME to '%1'\n(%2).\n"
- "This causes msysgit to look for the SSH-keys in that location\n"
- "instead of its installation directory when run outside git bash.").
- arg(QDir::homePath(),
- currentHome.isEmpty() ? tr("not currently set") :
- tr("currently set to '%1'").arg(QString::fromLocal8Bit(currentHome)));
- m_ui.winHomeCheckBox->setToolTip(toolTip);
-#else
- m_ui.winHomeCheckBox->setVisible(false);
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ const QByteArray currentHome = qgetenv("HOME");
+ const QString toolTip
+ = tr("Set the environment variable HOME to '%1'\n(%2).\n"
+ "This causes msysgit to look for the SSH-keys in that location\n"
+ "instead of its installation directory when run outside git bash.").
+ arg(QDir::homePath(),
+ currentHome.isEmpty() ? tr("not currently set") :
+ tr("currently set to '%1'").arg(QString::fromLocal8Bit(currentHome)));
+ m_ui.winHomeCheckBox->setToolTip(toolTip);
+ } else {
+ m_ui.winHomeCheckBox->setVisible(false);
+ }
m_ui.repBrowserCommandPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command"));
}
diff --git a/src/plugins/help/externalhelpwindow.cpp b/src/plugins/help/externalhelpwindow.cpp
index df328832e95..5c77d01bf0c 100644
--- a/src/plugins/help/externalhelpwindow.cpp
+++ b/src/plugins/help/externalhelpwindow.cpp
@@ -36,6 +36,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
+#include <utils/hostosinfo.h>
#include <QAction>
#include <QHBoxLayout>
@@ -143,17 +144,17 @@ ExternalHelpWindow::ExternalHelpWindow(QWidget *parent)
tr("Show Sidebar"), this);
connect(action, SIGNAL(triggered()), this, SIGNAL(showHideSidebar()));
-#ifdef Q_OS_MAC
- reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
- action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
- ctrlTab->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab));
- ctrlShiftTab->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab));
-#else
- reset->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
- action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
- ctrlTab->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
- ctrlShiftTab->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
+ action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
+ ctrlTab->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab));
+ ctrlShiftTab->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab));
+ } else {
+ reset->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
+ action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
+ ctrlTab->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
+ ctrlShiftTab->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
+ }
QToolButton *button = new QToolButton;
button->setDefaultAction(action);
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 2af6e437e1e..e6d7bc11d30 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -67,6 +67,7 @@
#include <extensionsystem/pluginmanager.h>
#include <find/findplugin.h>
#include <texteditor/texteditorconstants.h>
+#include <utils/hostosinfo.h>
#include <utils/styledbar.h>
#include <QDir>
@@ -251,12 +252,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
connect(action, SIGNAL(triggered()), this, SLOT(activateContext()));
-#ifndef Q_OS_MAC
- action = new QAction(this);
- action->setSeparator(true);
- cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator"), globalcontext);
- Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
-#endif
+ if (!Utils::HostOsInfo::isMacHost()) {
+ action = new QAction(this);
+ action->setSeparator(true);
+ cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator"), globalcontext);
+ Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
+ }
action = new QAction(tr("Technical Support"), this);
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.TechSupport"), globalcontext);
@@ -268,12 +269,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
connect(action, SIGNAL(triggered()), this, SLOT(slotReportBug()));
-#ifndef Q_OS_MAC
- action = new QAction(this);
- action->setSeparator(true);
- cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator2"), globalcontext);
- Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
-#endif
+ if (!Utils::HostOsInfo::isMacHost()) {
+ action = new QAction(this);
+ action->setSeparator(true);
+ cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator2"), globalcontext);
+ Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
+ }
action = new QAction(this);
Core::ActionManager::registerAction(action, Core::Constants::PRINT, modecontext);
diff --git a/src/plugins/help/helpviewer_qtb.cpp b/src/plugins/help/helpviewer_qtb.cpp
index 4b60c422596..0c72233396e 100644
--- a/src/plugins/help/helpviewer_qtb.cpp
+++ b/src/plugins/help/helpviewer_qtb.cpp
@@ -36,6 +36,8 @@
#include "helpviewer_p.h"
#include "localhelpmanager.h"
+#include <utils/hostosinfo.h>
+
#include <QApplication>
#include <QClipboard>
#include <QContextMenuEvent>
@@ -286,19 +288,15 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
void HelpViewer::mousePressEvent(QMouseEvent *e)
{
-#ifdef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(e))
+ if (Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
return;
-#endif
QTextBrowser::mousePressEvent(e);
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
-#ifndef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(e))
+ if (!Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
return;
-#endif
bool controlPressed = e->modifiers() & Qt::ControlModifier;
if ((controlPressed && d->hasAnchorAt(this, e->pos())) ||
diff --git a/src/plugins/help/helpviewer_qwv.cpp b/src/plugins/help/helpviewer_qwv.cpp
index 76baa1ad496..52573bf105f 100644
--- a/src/plugins/help/helpviewer_qwv.cpp
+++ b/src/plugins/help/helpviewer_qwv.cpp
@@ -37,6 +37,8 @@
#include "localhelpmanager.h"
#include "openpagesmanager.h"
+#include <utils/hostosinfo.h>
+
#include <QDebug>
#include <QFileInfo>
#include <QString>
@@ -529,10 +531,8 @@ void HelpViewer::wheelEvent(QWheelEvent *event)
void HelpViewer::mousePressEvent(QMouseEvent *event)
{
-#ifdef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(event))
+ if (Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(event))
return;
-#endif
if (HelpPage *currentPage = static_cast<HelpPage*> (page())) {
currentPage->m_pressedButtons = event->buttons();
@@ -544,10 +544,8 @@ void HelpViewer::mousePressEvent(QMouseEvent *event)
void HelpViewer::mouseReleaseEvent(QMouseEvent *event)
{
-#ifndef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(event))
+ if (!Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(event))
return;
-#endif
QWebView::mouseReleaseEvent(event);
}
diff --git a/src/plugins/help/openpagesswitcher.cpp b/src/plugins/help/openpagesswitcher.cpp
index c20f8e37cf7..b0d4303104a 100644
--- a/src/plugins/help/openpagesswitcher.cpp
+++ b/src/plugins/help/openpagesswitcher.cpp
@@ -34,6 +34,8 @@
#include "openpagesmodel.h"
#include "openpageswidget.h"
+#include <utils/hostosinfo.h>
+
#include <QEvent>
#include <QKeyEvent>
@@ -54,9 +56,8 @@ OpenPagesSwitcher::OpenPagesSwitcher(OpenPagesModel *model)
// We disable the frame on this list view and use a QFrame around it instead.
// This improves the look with QGTKStyle.
-#ifndef Q_OS_MAC
- setFrameStyle(m_openPagesWidget->frameStyle());
-#endif
+ if (!Utils::HostOsInfo::isMacHost())
+ setFrameStyle(m_openPagesWidget->frameStyle());
m_openPagesWidget->setFrameStyle(QFrame::NoFrame);
m_openPagesWidget->allowContextMenu(false);
@@ -125,11 +126,8 @@ bool OpenPagesSwitcher::eventFilter(QObject *object, QEvent *event)
emit setCurrentPage(m_openPagesWidget->currentIndex());
return true;
}
-#ifdef Q_OS_MAC
- const Qt::KeyboardModifier modifier = Qt::AltModifier;
-#else
- const Qt::KeyboardModifier modifier = Qt::ControlModifier;
-#endif
+ const Qt::KeyboardModifiers modifier = Utils::HostOsInfo::isMacHost()
+ ? Qt::AltModifier : Qt::ControlModifier;
if (key == Qt::Key_Backtab
&& (ke->modifiers() == (modifier | Qt::ShiftModifier)))
gotoNextPage();
diff --git a/src/plugins/locator/locatorwidget.cpp b/src/plugins/locator/locatorwidget.cpp
index 7d5b84f844c..910f64cac44 100644
--- a/src/plugins/locator/locatorwidget.cpp
+++ b/src/plugins/locator/locatorwidget.cpp
@@ -45,6 +45,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/fileiconprovider.h>
#include <utils/filterlineedit.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
@@ -221,12 +222,12 @@ CompletionList::CompletionList(QWidget *parent)
// This is too slow when done on all results
//header()->setResizeMode(QHeaderView::ResizeToContents);
setWindowFlags(Qt::ToolTip);
-#ifdef Q_OS_MAC
- if (horizontalScrollBar())
- horizontalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
- if (verticalScrollBar())
- verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ if (horizontalScrollBar())
+ horizontalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
+ if (verticalScrollBar())
+ verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
+ }
}
void CompletionList::updatePreferredSize()
@@ -408,11 +409,14 @@ bool LocatorWidget::eventFilter(QObject *obj, QEvent *event)
}
}
} else if (obj == m_fileLineEdit && event->type() == QEvent::FocusOut) {
-#if defined(Q_OS_WIN)
- QFocusEvent *fev = static_cast<QFocusEvent*>(event);
- if (fev->reason() != Qt::ActiveWindowFocusReason ||
- (fev->reason() == Qt::ActiveWindowFocusReason && !m_completionList->isActiveWindow()))
-#endif
+ bool hideList = true;
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ QFocusEvent *fev = static_cast<QFocusEvent*>(event);
+ if (fev->reason() == Qt::ActiveWindowFocusReason &&
+ !(fev->reason() == Qt::ActiveWindowFocusReason && !m_completionList->isActiveWindow()))
+ hideList = false;
+ }
+ if (hideList)
m_completionList->hide();
} else if (obj == m_fileLineEdit && event->type() == QEvent::FocusIn) {
showPopupNow();
diff --git a/src/plugins/madde/maemodeploybymountsteps.cpp b/src/plugins/madde/maemodeploybymountsteps.cpp
index 0967ae9f25b..70b460ca9d6 100644
--- a/src/plugins/madde/maemodeploybymountsteps.cpp
+++ b/src/plugins/madde/maemodeploybymountsteps.cpp
@@ -45,6 +45,7 @@
#include <qtsupport/qtprofileinformation.h>
#include <remotelinux/abstractremotelinuxdeployservice.h>
#include <remotelinux/linuxdevice.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <ssh/sshconnection.h>
@@ -345,29 +346,31 @@ bool MaemoMountAndCopyFilesService::isDeploymentNecessary() const
QList<MaemoMountSpecification> MaemoMountAndCopyFilesService::mountSpecifications() const
{
QList<MaemoMountSpecification> mountSpecs;
-#ifdef Q_OS_WIN
- bool drivesToMount[26];
- qFill(drivesToMount, drivesToMount + sizeof drivesToMount / sizeof drivesToMount[0], false);
- for (int i = 0; i < m_filesToCopy.count(); ++i) {
- const QString localDir = m_filesToCopy.at(i).localFilePath().toFileInfo().canonicalPath();
- const char driveLetter = localDir.at(0).toLower().toLatin1();
- if (driveLetter < 'a' || driveLetter > 'z') {
- qWarning("Weird: drive letter is '%c'.", driveLetter);
- continue;
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ bool drivesToMount[26];
+ qFill(drivesToMount, drivesToMount + sizeof drivesToMount / sizeof drivesToMount[0], false);
+ for (int i = 0; i < m_filesToCopy.count(); ++i) {
+ const QString localDir
+ = m_filesToCopy.at(i).localFilePath().toFileInfo().canonicalPath();
+ const char driveLetter = localDir.at(0).toLower().toLatin1();
+ if (driveLetter < 'a' || driveLetter > 'z') {
+ qWarning("Weird: drive letter is '%c'.", driveLetter);
+ continue;
+ }
+
+ const int index = driveLetter - 'a';
+ if (drivesToMount[index])
+ continue;
+
+ const QString mountPoint = deployMountPoint() + QLatin1Char('/')
+ + QLatin1Char(driveLetter);
+ const MaemoMountSpecification mountSpec(localDir.left(3), mountPoint);
+ mountSpecs << mountSpec;
+ drivesToMount[index] = true;
}
-
- const int index = driveLetter - 'a';
- if (drivesToMount[index])
- continue;
-
- const QString mountPoint = deployMountPoint() + QLatin1Char('/') + QLatin1Char(driveLetter);
- const MaemoMountSpecification mountSpec(localDir.left(3), mountPoint);
- mountSpecs << mountSpec;
- drivesToMount[index] = true;
+ } else {
+ mountSpecs << MaemoMountSpecification(QLatin1String("/"), deployMountPoint());
}
-#else
- mountSpecs << MaemoMountSpecification(QLatin1String("/"), deployMountPoint());
-#endif
return mountSpecs;
}
diff --git a/src/plugins/madde/maemoglobal.cpp b/src/plugins/madde/maemoglobal.cpp
index 7ae076e6215..fe4635f9b93 100644
--- a/src/plugins/madde/maemoglobal.cpp
+++ b/src/plugins/madde/maemoglobal.cpp
@@ -40,6 +40,7 @@
#include <qtsupport/qtprofileinformation.h>
#include <remotelinux/remotelinux_constants.h>
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFileInfo>
@@ -51,6 +52,7 @@ using namespace ProjectExplorer;
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Constants;
using namespace RemoteLinux;
+using namespace Utils;
namespace Madde {
namespace Internal {
@@ -144,13 +146,13 @@ QString MaemoGlobal::remoteSourceProfilesCommand()
return QString::fromAscii(remoteCall);
}
-Utils::PortList MaemoGlobal::freePorts(const Profile *profile)
+PortList MaemoGlobal::freePorts(const Profile *profile)
{
IDevice::ConstPtr device = DeviceProfileInformation::device(profile);
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtProfileInformation::qtVersion(profile);
if (!device || !qtVersion)
- return Utils::PortList();
+ return PortList();
if (device->machineType() == IDevice::Emulator) {
MaemoQemuRuntime rt;
const int id = qtVersion->uniqueId();
@@ -167,18 +169,15 @@ QString MaemoGlobal::maddeRoot(const QString &qmakePath)
return dir.absolutePath();
}
-Utils::FileName MaemoGlobal::maddeRoot(const Profile *profile)
+FileName MaemoGlobal::maddeRoot(const Profile *profile)
{
return SysRootProfileInformation::sysRoot(profile).parentDir().parentDir();
}
QString MaemoGlobal::targetRoot(const QString &qmakePath)
{
-#ifdef Q_OS_WIN
- Qt::CaseSensitivity cs = Qt::CaseInsensitive;
-#else
- Qt::CaseSensitivity cs = Qt::CaseSensitive;
-#endif
+ const Qt::CaseSensitivity cs = HostOsInfo::isWindowsHost()
+ ? Qt::CaseInsensitive : Qt::CaseSensitive;
return QDir::cleanPath(qmakePath).remove(binQmake, cs);
}
@@ -227,32 +226,26 @@ QString MaemoGlobal::architecture(const QString &qmakePath)
return arch;
}
-void MaemoGlobal::addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath)
+void MaemoGlobal::addMaddeEnvironment(Environment &env, const QString &qmakePath)
{
- Utils::Environment maddeEnv;
-#ifdef Q_OS_WIN
- const QString root = maddeRoot(qmakePath);
- env.prependOrSetPath(root + QLatin1String("/bin"));
- env.prependOrSet(QLatin1String("HOME"),
- QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
-#else
- Q_UNUSED(qmakePath);
-#endif
- for (Utils::Environment::const_iterator it = maddeEnv.constBegin(); it != maddeEnv.constEnd(); ++it)
+ Environment maddeEnv;
+ if (HostOsInfo::isWindowsHost()) {
+ const QString root = maddeRoot(qmakePath);
+ env.prependOrSetPath(root + QLatin1String("/bin"));
+ env.prependOrSet(QLatin1String("HOME"),
+ QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
+ }
+ for (Environment::const_iterator it = maddeEnv.constBegin(); it != maddeEnv.constEnd(); ++it)
env.prependOrSet(it.key(), it.value());
}
void MaemoGlobal::transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath)
{
-#ifdef Q_OS_WIN
- const QString root = maddeRoot(qmakePath);
- args.prepend(command);
- command = root + QLatin1String("/bin/sh.exe");
-#else
- Q_UNUSED(command);
- Q_UNUSED(args);
- Q_UNUSED(qmakePath);
-#endif
+ if (HostOsInfo::isWindowsHost()) {
+ const QString root = maddeRoot(qmakePath);
+ args.prepend(command);
+ command = root + QLatin1String("/bin/sh.exe");
+ }
}
bool MaemoGlobal::callMad(QProcess &proc, const QStringList &args,
@@ -277,7 +270,7 @@ bool MaemoGlobal::callMaddeShellScript(QProcess &proc,
return false;
QString actualCommand = command;
QStringList actualArgs = targetArgs(qmakePath, useTarget) + args;
- Utils::Environment env(proc.systemEnvironment());
+ Environment env(proc.systemEnvironment());
addMaddeEnvironment(env, qmakePath);
proc.setEnvironment(env.toStringList());
transformMaddeCall(actualCommand, actualArgs, qmakePath);
diff --git a/src/plugins/madde/maemopackagecreationstep.cpp b/src/plugins/madde/maemopackagecreationstep.cpp
index 16789d70118..36cc0bae4be 100644
--- a/src/plugins/madde/maemopackagecreationstep.cpp
+++ b/src/plugins/madde/maemopackagecreationstep.cpp
@@ -42,6 +42,7 @@
#include <qtsupport/qtprofileinformation.h>
#include <utils/environment.h>
#include <utils/fileutils.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDateTime>
@@ -57,6 +58,7 @@ using ProjectExplorer::BuildStepList;
using ProjectExplorer::BuildStepConfigWidget;
using ProjectExplorer::Task;
using namespace Qt4ProjectManager;
+using namespace Utils;
namespace Madde {
namespace Internal {
@@ -225,7 +227,7 @@ bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc,
void AbstractMaemoPackageCreationStep::preparePackagingProcess(QProcess *proc,
const Qt4BuildConfiguration *bc, const QString &workingDir)
{
- Utils::Environment env = bc->environment();
+ Environment env = bc->environment();
if (bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild) {
env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"),
QLatin1String("nostrip"), QLatin1String(" "));
@@ -329,12 +331,12 @@ bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc,
bool MaemoDebianPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const
{
- const Utils::FileName debianPath = DebianManager::debianDirectory(target());
+ const FileName debianPath = DebianManager::debianDirectory(target());
if (packageDate <= debianPath.toFileInfo().lastModified())
return true;
const QStringList debianFiles = DebianManager::debianFiles(debianPath);
foreach (const QString &debianFile, debianFiles) {
- Utils::FileName absFilePath = debianPath;
+ FileName absFilePath = debianPath;
absFilePath.appendPath(debianFile);
if (packageDate <= absFilePath.toFileInfo().lastModified())
return true;
@@ -351,7 +353,7 @@ void MaemoDebianPackageCreationStep::checkProjectName()
"Debian packages.\nThey must only use lower-case letters, "
"numbers, '-', '+' and '.'.\n""We will try to work around that, "
"but you may experience problems."),
- Utils::FileName(), -1, Core::Id(TASK_CATEGORY_BUILDSYSTEM)));
+ FileName(), -1, Core::Id(TASK_CATEGORY_BUILDSYSTEM)));
}
}
@@ -370,7 +372,7 @@ bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
return false;
}
QString error;
- if (!Utils::FileUtils::removeRecursively(debianDirPath, &error)) {
+ if (!FileUtils::removeRecursively(debianDirPath, &error)) {
raiseError(tr("Packaging failed: Could not remove directory '%1': %2")
.arg(debianDirPath, error));
return false;
@@ -396,7 +398,7 @@ bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
}
if (newFileName == DebianManager::packageName(DebianManager::debianDirectory(target())) + QLatin1String(".aegis")) {
- Utils::FileReader reader;
+ FileReader reader;
if (!reader.fetch(srcFile)) {
raiseError(tr("Could not read manifest file '%1': %2.")
.arg(QDir::toNativeSeparators(srcFile), reader.errorString()));
@@ -436,9 +438,8 @@ bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
QString MaemoDebianPackageCreationStep::packagingCommand(const QString &maddeRoot, const QString &commandName)
{
QString perl;
-#ifdef Q_OS_WIN
- perl = maddeRoot + QLatin1String("/bin/perl.exe ");
-#endif
+ if (HostOsInfo::isWindowsHost())
+ perl = maddeRoot + QLatin1String("/bin/perl.exe ");
return perl + maddeRoot + QLatin1String("/madbin/") + commandName;
}
@@ -457,7 +458,7 @@ void MaemoDebianPackageCreationStep::ensureShlibdeps(QByteArray &rulesContent)
bool MaemoDebianPackageCreationStep::adaptRulesFile(
const QString &templatePath, const QString &rulesFilePath)
{
- Utils::FileReader reader;
+ FileReader reader;
if (!reader.fetch(templatePath)) {
raiseError(reader.errorString());
return false;
@@ -467,7 +468,7 @@ bool MaemoDebianPackageCreationStep::adaptRulesFile(
if (!m_debugBuild)
ensureShlibdeps(content);
- Utils::FileSaver saver(rulesFilePath);
+ FileSaver saver(rulesFilePath);
saver.write(content);
if (!saver.finalize()) {
raiseError(saver.errorString());
diff --git a/src/plugins/madde/maemoqemuruntimeparser.cpp b/src/plugins/madde/maemoqemuruntimeparser.cpp
index f1191255ad9..c1709152fc7 100644
--- a/src/plugins/madde/maemoqemuruntimeparser.cpp
+++ b/src/plugins/madde/maemoqemuruntimeparser.cpp
@@ -33,6 +33,7 @@
#include "maemoqemusettings.h"
#include <qtsupport/baseqtversion.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDir>
@@ -199,17 +200,17 @@ void MaemoQemuRuntimeParserV1::fillRuntimeInformation(MaemoQemuRuntime *runtime)
// This is complex because of extreme MADDE weirdness.
const QString root = m_maddeRoot + QLatin1Char('/');
const bool pathIsRelative = QFileInfo(runtime->m_bin).isRelative();
- runtime->m_bin =
- #ifdef Q_OS_WIN
- root + (pathIsRelative
- ? QLatin1String("madlib/") + runtime->m_bin // Fremantle.
- : runtime->m_bin) // Harmattan.
- + QLatin1String(".exe");
- #else
- pathIsRelative
- ? root + QLatin1String("madlib/") + runtime->m_bin // Fremantle.
- : runtime->m_bin; // Harmattan.
- #endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ runtime->m_bin =
+ root + (pathIsRelative
+ ? QLatin1String("madlib/") + runtime->m_bin // Fremantle.
+ : runtime->m_bin) // Harmattan.
+ + QLatin1String(".exe");
+ } else {
+ runtime->m_bin = pathIsRelative
+ ? root + QLatin1String("madlib/") + runtime->m_bin // Fremantle.
+ : runtime->m_bin; // Harmattan.
+ }
}
}
}
@@ -336,17 +337,17 @@ void MaemoQemuRuntimeParserV2::handleEnvironmentTag(MaemoQemuRuntime &runtime)
while (m_madInfoReader.readNextStartElement())
handleVariableTag(runtime);
-#ifdef Q_OS_WIN
- const QString root = QDir::toNativeSeparators(m_maddeRoot)
- + QLatin1Char('/');
- const QLatin1Char colon(';');
- const QLatin1String key("PATH");
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- runtime.m_normalVars << MaemoQemuRuntime::Variable(key,
- root + QLatin1String("bin") + colon + env.value(key));
- runtime.m_normalVars << MaemoQemuRuntime::Variable(key,
- root + QLatin1String("madlib") + colon + env.value(key));
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ const QString root = QDir::toNativeSeparators(m_maddeRoot)
+ + QLatin1Char('/');
+ const QLatin1Char colon(';');
+ const QLatin1String key("PATH");
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ runtime.m_normalVars << MaemoQemuRuntime::Variable(key,
+ root + QLatin1String("bin") + colon + env.value(key));
+ runtime.m_normalVars << MaemoQemuRuntime::Variable(key,
+ root + QLatin1String("madlib") + colon + env.value(key));
+ }
}
void MaemoQemuRuntimeParserV2::handleVariableTag(MaemoQemuRuntime &runtime)
diff --git a/src/plugins/madde/maemoqtversion.cpp b/src/plugins/madde/maemoqtversion.cpp
index 21e1309f089..bc6acb400b6 100644
--- a/src/plugins/madde/maemoqtversion.cpp
+++ b/src/plugins/madde/maemoqtversion.cpp
@@ -35,6 +35,7 @@
#include <projectexplorer/profileinformation.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qtsupport/qtsupportconstants.h>
+#include <utils/hostosinfo.h>
#include <QCoreApplication>
#include <QFile>
@@ -125,10 +126,7 @@ QString MaemoQtVersion::description() const
bool MaemoQtVersion::supportsShadowBuilds() const
{
-#ifdef Q_OS_WIN
- return false;
-#endif
- return true;
+ return !Utils::HostOsInfo::isWindowsHost();
}
Core::Id MaemoQtVersion::deviceType() const
diff --git a/src/plugins/madde/maemoremotecopyfacility.cpp b/src/plugins/madde/maemoremotecopyfacility.cpp
index 7292f55cc18..283b9100f7f 100644
--- a/src/plugins/madde/maemoremotecopyfacility.cpp
+++ b/src/plugins/madde/maemoremotecopyfacility.cpp
@@ -33,6 +33,7 @@
#include <ssh/sshconnection.h>
#include <ssh/sshremoteprocessrunner.h>
+#include <utils/hostosinfo.h>
#include <QDir>
@@ -124,13 +125,13 @@ void MaemoRemoteCopyFacility::copyNextFile()
const DeployableFile &d = m_deployables.first();
QString sourceFilePath = m_mountPoint;
-#ifdef Q_OS_WIN
- const QString localFilePath = QDir::fromNativeSeparators(d.localFilePath().toString());
- sourceFilePath += QLatin1Char('/') + localFilePath.at(0).toLower()
- + localFilePath.mid(2);
-#else
- sourceFilePath += d.localFilePath().toString();
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ const QString localFilePath = QDir::fromNativeSeparators(d.localFilePath().toString());
+ sourceFilePath += QLatin1Char('/') + localFilePath.at(0).toLower()
+ + localFilePath.mid(2);
+ } else {
+ sourceFilePath += d.localFilePath().toString();
+ }
QString command = QString::fromLatin1("%1 mkdir -p %3 && %1 cp -a %2 %3")
.arg(MaemoGlobal::remoteSudo(m_devConf->type(), m_devConf->sshParameters().userName),
diff --git a/src/plugins/perforce/perforcesettings.cpp b/src/plugins/perforce/perforcesettings.cpp
index 2dcd24f9e5c..bb659b81ece 100644
--- a/src/plugins/perforce/perforcesettings.cpp
+++ b/src/plugins/perforce/perforcesettings.cpp
@@ -34,6 +34,7 @@
#include <utils/qtcassert.h>
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <QDebug>
#include <QSettings>
@@ -57,11 +58,9 @@ enum { defaultTimeOutS = 30, defaultLogCount = 1000 };
static QString defaultCommand()
{
- QString rc;
- rc = QLatin1String("p4");
-#if defined(Q_OS_WIN32)
- rc.append(QLatin1String(".exe"));
-#endif
+ QString rc = QLatin1String("p4");
+ if (Utils::HostOsInfo::isWindowsHost())
+ rc.append(QLatin1String(".exe"));
return rc;
}
diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp
index e0f3d96d4f2..c8b9f45a146 100644
--- a/src/plugins/projectexplorer/buildstepspage.cpp
+++ b/src/plugins/projectexplorer/buildstepspage.cpp
@@ -39,6 +39,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
#include <utils/detailswidget.h>
+#include <utils/hostosinfo.h>
#include <QSignalMapper>
@@ -54,6 +55,7 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
+using namespace Utils;
ToolWidget::ToolWidget(QWidget *parent)
: Utils::FadingPanel(parent), m_buildStepEnabled(true)
@@ -68,11 +70,7 @@ ToolWidget::ToolWidget(QWidget *parent)
hbox->setContentsMargins(0, 0, 0, 0);
hbox->setSpacing(0);
m_firstWidget->setLayout(hbox);
-#ifdef Q_OS_MAC
- QSize buttonSize(20, 20);
-#else
- QSize buttonSize(20, 26);
-#endif
+ QSize buttonSize(20, HostOsInfo::isMacHost() ? 20 : 26);
m_disableButton = new QToolButton(m_firstWidget);
m_disableButton->setAutoRaise(true);
@@ -139,17 +137,15 @@ void ToolWidget::setBuildStepEnabled(bool b)
{
m_buildStepEnabled = b;
if (m_buildStepEnabled) {
-#ifdef Q_OS_MAC
- m_firstWidget->setOpacity(m_targetOpacity);
-#else
- m_firstWidget->fadeTo(m_targetOpacity);
-#endif
+ if (HostOsInfo::isMacHost())
+ m_firstWidget->setOpacity(m_targetOpacity);
+ else
+ m_firstWidget->fadeTo(m_targetOpacity);
} else {
-#ifdef Q_OS_MAC
- m_firstWidget->setOpacity(1.0);
-#else
- m_firstWidget->fadeTo(1.0);
-#endif
+ if (HostOsInfo::isMacHost())
+ m_firstWidget->setOpacity(1.0);
+ else
+ m_firstWidget->fadeTo(1.0);
}
m_disableButton->setChecked(!b);
}
@@ -462,9 +458,8 @@ void BuildStepListWidget::setupUi()
hboxLayout->addStretch(10);
-#ifdef Q_OS_MAC
- m_addButton->setAttribute(Qt::WA_MacSmallSize);
-#endif
+ if (HostOsInfo::isMacHost())
+ m_addButton->setAttribute(Qt::WA_MacSmallSize);
m_vbox->addLayout(hboxLayout);
diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
index 8acb23033ec..0cdb7e6e50d 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
@@ -32,6 +32,7 @@
#include "customwizard.h"
#include "customwizardparameters.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QProcess>
@@ -66,15 +67,16 @@ QStringList fixGeneratorScript(const QString &configFile, QString binary)
}
} // not absolute
QStringList rc(binary);
-#ifdef Q_OS_WIN // Windows: Cannot run scripts by QProcess, do 'cmd /c'
- const QString extension = binaryInfo.suffix();
- if (!extension.isEmpty() && extension.compare(QLatin1String("exe"), Qt::CaseInsensitive) != 0) {
- rc.push_front(QLatin1String("/C"));
- rc.push_front(QString::fromLocal8Bit(qgetenv("COMSPEC")));
- if (rc.front().isEmpty())
- rc.front() = QLatin1String("cmd.exe");
+ if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Cannot run scripts by QProcess, do 'cmd /c'
+ const QString extension = binaryInfo.suffix();
+ if (!extension.isEmpty() && extension.compare(QLatin1String("exe"),
+ Qt::CaseInsensitive) != 0) {
+ rc.push_front(QLatin1String("/C"));
+ rc.push_front(QString::fromLocal8Bit(qgetenv("COMSPEC")));
+ if (rc.front().isEmpty())
+ rc.front() = QLatin1String("cmd.exe");
+ }
}
-#endif
return rc;
}
diff --git a/src/plugins/projectexplorer/environmentitemswidget.cpp b/src/plugins/projectexplorer/environmentitemswidget.cpp
index b503e74e926..ecc3b11f48d 100644
--- a/src/plugins/projectexplorer/environmentitemswidget.cpp
+++ b/src/plugins/projectexplorer/environmentitemswidget.cpp
@@ -31,6 +31,7 @@
#include "environmentitemswidget.h"
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <texteditor/snippets/snippeteditor.h>
#include <texteditor/texteditorsettings.h>
@@ -54,9 +55,8 @@ QList<Utils::EnvironmentItem> EnvironmentItemsWidgetPrivate::cleanUp(
QSet<QString> uniqueSet;
for (int i = items.count() - 1; i >= 0; i--) {
Utils::EnvironmentItem item = items.at(i);
-#if defined(Q_OS_WIN)
- item.name = item.name.toUpper();
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ item.name = item.name.toUpper();
const QString &itemName = item.name;
QString emptyName = itemName;
emptyName.remove(QLatin1Char(' '));
diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp
index cdae6badcd4..92aef556098 100644
--- a/src/plugins/projectexplorer/gcctoolchain.cpp
+++ b/src/plugins/projectexplorer/gcctoolchain.cpp
@@ -38,6 +38,7 @@
#include <utils/detailswidget.h>
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <utils/synchronousprocess.h>
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
@@ -132,19 +133,19 @@ static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &ar
arguments << QLatin1String("-");
QByteArray predefinedMacros = runGcc(gcc, arguments, env);
-#ifdef Q_OS_MAC
- // Turn off flag indicating Apple's blocks support
- const QByteArray blocksDefine("#define __BLOCKS__ 1");
- const QByteArray blocksUndefine("#undef __BLOCKS__");
- const int idx = predefinedMacros.indexOf(blocksDefine);
- if (idx != -1) {
- predefinedMacros.replace(idx, blocksDefine.length(), blocksUndefine);
- }
+ if (Utils::HostOsInfo::isMacHost()) {
+ // Turn off flag indicating Apple's blocks support
+ const QByteArray blocksDefine("#define __BLOCKS__ 1");
+ const QByteArray blocksUndefine("#undef __BLOCKS__");
+ const int idx = predefinedMacros.indexOf(blocksDefine);
+ if (idx != -1) {
+ predefinedMacros.replace(idx, blocksDefine.length(), blocksUndefine);
+ }
- // Define __strong and __weak (used for Apple's GC extension of C) to be empty
- predefinedMacros.append("#define __strong\n");
- predefinedMacros.append("#define __weak\n");
-#endif // Q_OS_MAC
+ // Define __strong and __weak (used for Apple's GC extension of C) to be empty
+ predefinedMacros.append("#define __strong\n");
+ predefinedMacros.append("#define __weak\n");
+ }
return predefinedMacros;
}
@@ -587,11 +588,11 @@ ToolChain *Internal::GccToolChainFactory::create()
QList<ToolChain *> Internal::GccToolChainFactory::autoDetect()
{
QList<ToolChain *> tcs;
-#ifdef Q_OS_MAC
- // Old mac compilers needed to support macx-gccXY mkspecs:
- tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), Abi::hostAbi()));
- tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), Abi::hostAbi()));
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ // Old mac compilers needed to support macx-gccXY mkspecs:
+ tcs.append(autoDetectToolchains(QLatin1String("g++-4.0"), Abi::hostAbi()));
+ tcs.append(autoDetectToolchains(QLatin1String("g++-4.2"), Abi::hostAbi()));
+ }
tcs.append(autoDetectToolchains(QLatin1String("g++"), Abi::hostAbi()));
return tcs;
@@ -764,11 +765,9 @@ QString ClangToolChain::typeDisplayName() const
QString ClangToolChain::makeCommand() const
{
-#if defined(Q_OS_WIN)
- return QLatin1String("mingw32-make.exe");
-#else
+ if (Utils::HostOsInfo::isWindowsHost())
+ return QLatin1String("mingw32-make.exe");
return QLatin1String("make");
-#endif
}
QList<FileName> ClangToolChain::suggestedMkspecList() const
@@ -865,29 +864,26 @@ QString MingwToolChain::typeDisplayName() const
QList<FileName> MingwToolChain::suggestedMkspecList() const
{
-#if defined(Q_OS_WIN)
- return QList<FileName>() << FileName::fromString(QLatin1String("win32-g++"));
-#elif defined(Q_OS_LINUX)
- if (version().startsWith("4.6."))
- return QList<FileName>()
- << FileName::fromString(QLatin1String("win32-g++-4.6-cross"))
- << FileName::fromString(QLatin1String("unsupported/win32-g++-4.6-cross"));
- else
- return QList<FileName>()
- << FileName::fromString(QLatin1String("win32-g++-cross"))
- << FileName::fromString(QLatin1String("unsupported/win32-g++-cross"));
-#else
+ if (Utils::HostOsInfo::isWindowsHost())
+ return QList<FileName>() << FileName::fromString(QLatin1String("win32-g++"));
+ if (Utils::HostOsInfo::isLinuxHost()) {
+ if (version().startsWith("4.6."))
+ return QList<FileName>()
+ << FileName::fromString(QLatin1String("win32-g++-4.6-cross"))
+ << FileName::fromString(QLatin1String("unsupported/win32-g++-4.6-cross"));
+ else
+ return QList<FileName>()
+ << FileName::fromString(QLatin1String("win32-g++-cross"))
+ << FileName::fromString(QLatin1String("unsupported/win32-g++-cross"));
+ }
return QList<FileName>();
-#endif
}
QString MingwToolChain::makeCommand() const
{
-#ifdef Q_OS_WIN
- return QLatin1String("mingw32-make.exe");
-#else
+ if (Utils::HostOsInfo::isWindowsHost())
+ return QLatin1String("mingw32-make.exe");
return QLatin1String("make");
-#endif
}
ToolChain *MingwToolChain::clone() const
diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp
index efac70bc758..f5b6fc4b501 100644
--- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp
+++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp
@@ -35,6 +35,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/documentmanager.h>
+#include <utils/hostosinfo.h>
#include <QLabel>
#include <QCoreApplication>
@@ -48,9 +49,7 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
-#ifndef Q_OS_WIN
- setJomVisible(false);
-#endif
+ setJomVisible(Utils::HostOsInfo::isWindowsHost());
m_ui.directoryButtonGroup->setId(m_ui.currentDirectoryRadioButton, UseCurrentDirectory);
m_ui.directoryButtonGroup->setId(m_ui.directoryRadioButton, UseProjectDirectory);
connect(m_ui.directoryButtonGroup, SIGNAL(buttonClicked(int)),
diff --git a/src/plugins/projectexplorer/settingsaccessor.cpp b/src/plugins/projectexplorer/settingsaccessor.cpp
index 1816a9bb3c7..63cd30181e4 100644
--- a/src/plugins/projectexplorer/settingsaccessor.cpp
+++ b/src/plugins/projectexplorer/settingsaccessor.cpp
@@ -43,6 +43,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/persistentsettings.h>
@@ -1894,7 +1895,6 @@ static const char * const lameArgListKeys[] = {
0
};
-#ifdef Q_OS_UNIX
inline static bool isSpecialChar(ushort c)
{
// Chars that should be quoted (TM). This includes:
@@ -1913,27 +1913,26 @@ inline static bool hasSpecialChars(const QString &arg)
return true;
return false;
}
-#endif
// These were split according to sane (even if a bit arcane) rules
static QVariant version8ArgNodeHandler(const QVariant &var)
{
QString ret;
foreach (const QVariant &svar, var.toList()) {
-#ifdef Q_OS_UNIX
- // We don't just addArg, so we don't disarm existing env expansions.
- // This is a bit fuzzy logic ...
- QString s = svar.toString();
- s.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
- s.replace(QLatin1Char('"'), QLatin1String("\\\""));
- s.replace(QLatin1Char('`'), QLatin1String("\\`"));
- if (s != svar.toString() || hasSpecialChars(s))
- s.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
- Utils::QtcProcess::addArgs(&ret, s);
-#else
- // Under windows, env expansions cannot be quoted anyway.
- Utils::QtcProcess::addArg(&ret, svar.toString());
-#endif
+ if (Utils::HostOsInfo::isAnyUnixHost()) {
+ // We don't just addArg, so we don't disarm existing env expansions.
+ // This is a bit fuzzy logic ...
+ QString s = svar.toString();
+ s.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
+ s.replace(QLatin1Char('"'), QLatin1String("\\\""));
+ s.replace(QLatin1Char('`'), QLatin1String("\\`"));
+ if (s != svar.toString() || hasSpecialChars(s))
+ s.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
+ Utils::QtcProcess::addArgs(&ret, s);
+ } else {
+ // Under windows, env expansions cannot be quoted anyway.
+ Utils::QtcProcess::addArg(&ret, svar.toString());
+ }
}
return QVariant(ret);
}
@@ -1988,13 +1987,13 @@ static const char * const envExpandedKeys[] = {
static QString version8NewVar(const QString &old)
{
QString ret = old;
-#ifdef Q_OS_UNIX
- ret.prepend(QLatin1String("${"));
- ret.append(QLatin1Char('}'));
-#else
- ret.prepend(QLatin1Char('%'));
- ret.append(QLatin1Char('%'));
-#endif
+ if (Utils::HostOsInfo::isAnyUnixHost()) {
+ ret.prepend(QLatin1String("${"));
+ ret.append(QLatin1Char('}'));
+ } else {
+ ret.prepend(QLatin1Char('%'));
+ ret.append(QLatin1Char('%'));
+ }
return ret;
}
@@ -2008,65 +2007,65 @@ static QVariant version8EnvNodeTransform(const QVariant &var)
QLatin1String("%{sourceDir}"));
result.replace(QRegExp(QLatin1String("%BUILDDIR%|\\$(BUILDDIR\\b|\\{BUILDDIR\\})")),
QLatin1String("%{buildDir}"));
-#ifdef Q_OS_UNIX
- for (int vStart = -1, i = 0; i < result.length(); ) {
- QChar c = result.at(i++);
- if (c == QLatin1Char('%')) {
- if (vStart > 0 && vStart < i - 1) {
- QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
- result.replace(vStart - 1, i - vStart + 1, nv);
- i = vStart - 1 + nv.length();
- vStart = -1;
- } else {
- vStart = i;
+ if (Utils::HostOsInfo::isAnyUnixHost()) {
+ for (int vStart = -1, i = 0; i < result.length(); ) {
+ QChar c = result.at(i++);
+ if (c == QLatin1Char('%')) {
+ if (vStart > 0 && vStart < i - 1) {
+ QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
+ result.replace(vStart - 1, i - vStart + 1, nv);
+ i = vStart - 1 + nv.length();
+ vStart = -1;
+ } else {
+ vStart = i;
+ }
+ } else if (vStart > 0) {
+ // Sanity check so we don't catch too much garbage
+ if (!c.isLetterOrNumber() && c != QLatin1Char('_'))
+ vStart = -1;
}
- } else if (vStart > 0) {
- // Sanity check so we don't catch too much garbage
- if (!c.isLetterOrNumber() && c != QLatin1Char('_'))
- vStart = -1;
}
- }
-#else
- enum { BASE, OPTIONALVARIABLEBRACE, VARIABLE, BRACEDVARIABLE } state = BASE;
- int vStart = -1;
-
- for (int i = 0; i < result.length();) {
- QChar c = result.at(i++);
- if (state == BASE) {
- if (c == QLatin1Char('$'))
- state = OPTIONALVARIABLEBRACE;
- } else if (state == OPTIONALVARIABLEBRACE) {
- if (c == QLatin1Char('{')) {
- state = BRACEDVARIABLE;
- vStart = i;
- } else if (c.isLetterOrNumber() || c == QLatin1Char('_')) {
- state = VARIABLE;
- vStart = i - 1;
- } else {
- state = BASE;
- }
- } else if (state == BRACEDVARIABLE) {
- if (c == QLatin1Char('}')) {
- QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
- result.replace(vStart - 2, i - vStart + 2, nv);
- i = vStart + nv.length();
- state = BASE;
- }
- } else if (state == VARIABLE) {
- if (!c.isLetterOrNumber() && c != QLatin1Char('_')) {
- QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
- result.replace(vStart - 1, i - vStart, nv);
- i = vStart - 1 + nv.length(); // On the same char - could be next expansion.
- state = BASE;
+ } else {
+ enum { BASE, OPTIONALVARIABLEBRACE, VARIABLE, BRACEDVARIABLE } state = BASE;
+ int vStart = -1;
+
+ for (int i = 0; i < result.length();) {
+ QChar c = result.at(i++);
+ if (state == BASE) {
+ if (c == QLatin1Char('$'))
+ state = OPTIONALVARIABLEBRACE;
+ } else if (state == OPTIONALVARIABLEBRACE) {
+ if (c == QLatin1Char('{')) {
+ state = BRACEDVARIABLE;
+ vStart = i;
+ } else if (c.isLetterOrNumber() || c == QLatin1Char('_')) {
+ state = VARIABLE;
+ vStart = i - 1;
+ } else {
+ state = BASE;
+ }
+ } else if (state == BRACEDVARIABLE) {
+ if (c == QLatin1Char('}')) {
+ QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
+ result.replace(vStart - 2, i - vStart + 2, nv);
+ i = vStart + nv.length();
+ state = BASE;
+ }
+ } else if (state == VARIABLE) {
+ if (!c.isLetterOrNumber() && c != QLatin1Char('_')) {
+ QString nv = version8NewVar(result.mid(vStart, i - 1 - vStart));
+ result.replace(vStart - 1, i - vStart, nv);
+ i = vStart - 1 + nv.length(); // On the same char - could be next expansion.
+ state = BASE;
+ }
}
}
+ if (state == VARIABLE) {
+ QString nv = version8NewVar(result.mid(vStart));
+ result.truncate(vStart - 1);
+ result += nv;
+ }
}
- if (state == VARIABLE) {
- QString nv = version8NewVar(result.mid(vStart));
- result.truncate(vStart - 1);
- result += nv;
- }
-#endif
return QVariant(result);
}
@@ -2522,13 +2521,15 @@ void Version11Handler::addRunConfigurations(Profile *p,
static QString targetRoot(const QString &qmakePath)
{
-#ifdef Q_OS_WIN
- Qt::CaseSensitivity cs = Qt::CaseInsensitive;
- const QString binQmake = "/bin/qmake.exe";
-#else
- Qt::CaseSensitivity cs = Qt::CaseSensitive;
- const QString binQmake = "/bin/qmake";
-#endif
+ Qt::CaseSensitivity cs;
+ QString binQmake;
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ cs = Qt::CaseInsensitive;
+ binQmake = "/bin/qmake.exe";
+ } else {
+ cs = Qt::CaseSensitive;
+ binQmake = "/bin/qmake";
+ }
return QDir::cleanPath(qmakePath).remove(binQmake, cs);
}
diff --git a/src/plugins/qmldesigner/components/integration/xuifiledialog.cpp b/src/plugins/qmldesigner/components/integration/xuifiledialog.cpp
index 33100e411a1..3e95ba74738 100644
--- a/src/plugins/qmldesigner/components/integration/xuifiledialog.cpp
+++ b/src/plugins/qmldesigner/components/integration/xuifiledialog.cpp
@@ -28,6 +28,8 @@
**
**************************************************************************/
+#include <utils/hostosinfo.h>
+
#include <QDebug>
#include <QDir>
#include <QObject>
@@ -57,21 +59,21 @@ void XUIFileDialog::runSaveFileDialog(const QString& path, QWidget* parent, QObj
if (dir.isNull())
dir = XUIFileDialog::defaultFolder();
-#ifdef Q_OS_MAC
- QFileDialog *dialog = new QFileDialog(parent, Qt::Sheet);
- dialog->setFileMode(QFileDialog::AnyFile);
- dialog->setAcceptMode(QFileDialog::AcceptSave);
- dialog->setNameFilters(XUIFileDialog::fileNameFilters());
- dialog->setDirectory(dir);
- dialog->open(receiver, member);
-#else // !Q_OS_MAC
- QString caption = QCoreApplication::translate("QmlDesigner::XUIFileDialog", "Save File");
- QString fileName = QFileDialog::getSaveFileName(parent, caption, dir, XUIFileDialog::fileNameFilters().join(";;"));
+ if (Utils::HostOsInfo::isMacHost()) {
+ QFileDialog *dialog = new QFileDialog(parent, Qt::Sheet);
+ dialog->setFileMode(QFileDialog::AnyFile);
+ dialog->setAcceptMode(QFileDialog::AcceptSave);
+ dialog->setNameFilters(XUIFileDialog::fileNameFilters());
+ dialog->setDirectory(dir);
+ dialog->open(receiver, member);
+ } else {
+ QString caption = QCoreApplication::translate("QmlDesigner::XUIFileDialog", "Save File");
+ QString fileName = QFileDialog::getSaveFileName(parent, caption, dir, XUIFileDialog::fileNameFilters().join(";;"));
- QmlDesigner::Internal::SignalEmitter emitter;
- QObject::connect(&emitter, SIGNAL(fileNameSelected(QString)), receiver, member);
- emitter.emitFileNameSelected(fileName);
-#endif // Q_OS_MAC
+ QmlDesigner::Internal::SignalEmitter emitter;
+ QObject::connect(&emitter, SIGNAL(fileNameSelected(QString)), receiver, member);
+ emitter.emitFileNameSelected(fileName);
+ }
}
QStringList XUIFileDialog::fileNameFilters()
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
index b5a73d95327..e4f33136db1 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
@@ -70,6 +70,9 @@
#include "nodeinstanceview.h"
#include "import.h"
+
+#include <utils/hostosinfo.h>
+
#include <QMessageBox>
@@ -445,9 +448,8 @@ QString NodeInstanceServerProxy::qmlPuppetApplicationName() const
} else {
appName = QLatin1String("qmlpuppet");
}
- #ifdef Q_OS_WIN
- appName += QLatin1String(".exe");
- #endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ appName += QLatin1String(".exe");
return appName;
}
@@ -455,9 +457,8 @@ QString NodeInstanceServerProxy::qmlPuppetApplicationName() const
QString NodeInstanceServerProxy::macOSBundlePath(const QString &path) const
{
QString applicationPath = path;
-#ifdef Q_OS_MACX
- applicationPath += QLatin1String("/qmlpuppet.app/Contents/MacOS");
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ applicationPath += QLatin1String("/qmlpuppet.app/Contents/MacOS");
return applicationPath;
}
diff --git a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
index 3e949364d6d..be56367eca1 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/subcomponentmanager.cpp
@@ -32,6 +32,8 @@
#include "model.h"
#include "metainfo.h"
+#include <utils/hostosinfo.h>
+
#include <QDir>
#include <QMetaType>
#include <QUrl>
@@ -56,12 +58,8 @@ static inline QStringList importPaths() {
// env import paths
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
if (!envImportPath.isEmpty()) {
-#if defined(Q_OS_WIN)
- QLatin1Char pathSep(';');
-#else
- QLatin1Char pathSep(':');
-#endif
- paths = QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts);
+ const QChar sep = Utils::HostOsInfo::isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
+ paths = QString::fromLatin1(envImportPath).split(sep, QString::SkipEmptyParts);
}
return paths;
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 378d2dc9e36..40c5788cc6e 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -55,6 +55,7 @@
#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <integrationcore.h>
@@ -128,13 +129,10 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
m_designerCore = new QmlDesigner::IntegrationCore;
m_pluginInstance = this;
-#ifdef Q_OS_MAC
- const QString pluginPath = QCoreApplication::applicationDirPath() + "/../PlugIns/QmlDesigner";
-#else
- const QString pluginPath = QCoreApplication::applicationDirPath() + "/../"
- + QLatin1String(IDE_LIBRARY_BASENAME) + "/qtcreator/qmldesigner";
-#endif
-
+ const QString pluginPath = Utils::HostOsInfo::isMacHost()
+ ? QString(QCoreApplication::applicationDirPath() + "/../PlugIns/QmlDesigner")
+ : QString(QCoreApplication::applicationDirPath() + "/../"
+ + QLatin1String(IDE_LIBRARY_BASENAME) + "/qtcreator/qmldesigner");
m_designerCore->pluginManager()->setPluginPaths(QStringList() << pluginPath);
createDesignModeWidget();
@@ -260,15 +258,14 @@ void BauhausPlugin::createDesignModeWidget()
command = Core::ActionManager::registerAction(m_mainWidget->hideSidebarsAction(),
Core::Constants::TOGGLE_SIDEBAR, qmlDesignerMainContext);
-#ifdef Q_OS_MACX
- // add second shortcut to trigger delete
- QAction *deleteAction = new QAction(m_mainWidget);
- deleteAction->setShortcut(QKeySequence(QLatin1String("Backspace")));
- connect(deleteAction, SIGNAL(triggered()), m_mainWidget->deleteAction(),
- SIGNAL(triggered()));
-
- m_mainWidget->addAction(deleteAction);
-#endif // Q_OS_MACX
+ if (Utils::HostOsInfo::isMacHost()) {
+ // add second shortcut to trigger delete
+ QAction *deleteAction = new QAction(m_mainWidget);
+ deleteAction->setShortcut(QKeySequence(QLatin1String("Backspace")));
+ connect(deleteAction, SIGNAL(triggered()), m_mainWidget->deleteAction(),
+ SIGNAL(triggered()));
+ m_mainWidget->addAction(deleteAction);
+ }
connect(m_editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateEditor(Core::IEditor*)));
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 45ebc6f3f8e..abbd051f138 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -51,6 +51,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <qtsupport/baseqtversion.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFile>
@@ -465,9 +466,9 @@ static bool findNewQmlLibraryInPath(const QString &path,
return false;
}
-#ifdef Q_OS_WIN
- // QTCREATORBUG-3402 - be case sensitive even here?
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ // QTCREATORBUG-3402 - be case sensitive even here?
+ }
// found a new library!
qmldirFile.open(QFile::ReadOnly);
@@ -654,11 +655,7 @@ static QStringList environmentImportPaths()
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
-#if defined(Q_OS_WIN)
- QLatin1Char pathSep(';');
-#else
- QLatin1Char pathSep(':');
-#endif
+ const QChar pathSep = Utils::HostOsInfo::isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) {
QString canonicalPath = QDir(path).canonicalPath();
if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath))
diff --git a/src/plugins/qnx/blackberryqtversion.cpp b/src/plugins/qnx/blackberryqtversion.cpp
index 259bc32ca03..3e86121d4cb 100644
--- a/src/plugins/qnx/blackberryqtversion.cpp
+++ b/src/plugins/qnx/blackberryqtversion.cpp
@@ -35,6 +35,7 @@
#include "qnxconstants.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QTextStream>
@@ -72,11 +73,8 @@ QMultiMap<QString, QString> parseEnvironmentFile(const QString &fileName)
QMapIterator<QString, QString> it(fileContent);
while (it.hasNext()) {
it.next();
-#if defined Q_OS_WIN
- QStringList values = it.value().split(QLatin1Char(';'));
-#elif defined Q_OS_UNIX
- QStringList values = it.value().split(QLatin1Char(':'));
-#endif
+ const QChar sep = Utils::HostOsInfo::isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
+ const QStringList values = it.value().split(sep);
QString key = it.key();
foreach (const QString &value, values) {
const QString ownKeyAsWindowsVar = QLatin1Char('%') + key + QLatin1Char('%');
@@ -145,11 +143,11 @@ QMultiMap<QString, QString> BlackBerryQtVersion::environment() const
if (sdkPath().isEmpty())
return QMultiMap<QString, QString>();
-#if defined Q_OS_WIN
- const QString envFile = sdkPath() + QLatin1String("/bbndk-env.bat");
-#elif defined Q_OS_UNIX
- const QString envFile = sdkPath() + QLatin1String("/bbndk-env.sh");
-#endif
+ QString envFile;
+ if (Utils::HostOsInfo::isWindowsHost())
+ envFile = sdkPath() + QLatin1String("/bbndk-env.bat");
+ else if (Utils::HostOsInfo::isAnyUnixHost())
+ envFile = sdkPath() + QLatin1String("/bbndk-env.sh");
return parseEnvironmentFile(envFile);
}
diff --git a/src/plugins/qnx/qnxqtversion.cpp b/src/plugins/qnx/qnxqtversion.cpp
index fff076867f1..bc5169f8365 100644
--- a/src/plugins/qnx/qnxqtversion.cpp
+++ b/src/plugins/qnx/qnxqtversion.cpp
@@ -35,6 +35,8 @@
#include "qnxconstants.h"
+#include <utils/hostosinfo.h>
+
using namespace Qnx;
using namespace Qnx::Internal;
@@ -96,26 +98,26 @@ QMultiMap<QString, QString> QnxQtVersion::environment() const
QMultiMap<QString, QString> environment;
-#if defined Q_OS_WIN
- // TODO:
- //environment.insert(QLatin1String("QNX_CONFIGURATION"), QLatin1String("/etc/qnx"));
- environment.insert(QLatin1String(Constants::QNX_TARGET_KEY), sdkPath() + QLatin1String("/target/qnx6"));
- environment.insert(QLatin1String(Constants::QNX_HOST_KEY), sdkPath() + QLatin1String("/host/win32/x86"));
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ // TODO:
+ //environment.insert(QLatin1String("QNX_CONFIGURATION"), QLatin1String("/etc/qnx"));
+ environment.insert(QLatin1String(Constants::QNX_TARGET_KEY), sdkPath() + QLatin1String("/target/qnx6"));
+ environment.insert(QLatin1String(Constants::QNX_HOST_KEY), sdkPath() + QLatin1String("/host/win32/x86"));
- environment.insert(QLatin1String("PATH"), sdkPath() + QLatin1String("/host/win32/x86/usr/bin"));
+ environment.insert(QLatin1String("PATH"), sdkPath() + QLatin1String("/host/win32/x86/usr/bin"));
- // TODO:
- //environment.insert(QLatin1String("PATH"), QLatin1String("/etc/qnx/bin"));
-#elif defined Q_OS_UNIX
- environment.insert(QLatin1String("QNX_CONFIGURATION"), QLatin1String("/etc/qnx"));
- environment.insert(QLatin1String(Constants::QNX_TARGET_KEY), sdkPath() + QLatin1String("/target/qnx6"));
- environment.insert(QLatin1String(Constants::QNX_HOST_KEY), sdkPath() + QLatin1String("/host/linux/x86"));
+ // TODO:
+ //environment.insert(QLatin1String("PATH"), QLatin1String("/etc/qnx/bin"));
+ } else if (Utils::HostOsInfo::isAnyUnixHost()) {
+ environment.insert(QLatin1String("QNX_CONFIGURATION"), QLatin1String("/etc/qnx"));
+ environment.insert(QLatin1String(Constants::QNX_TARGET_KEY), sdkPath() + QLatin1String("/target/qnx6"));
+ environment.insert(QLatin1String(Constants::QNX_HOST_KEY), sdkPath() + QLatin1String("/host/linux/x86"));
- environment.insert(QLatin1String("PATH"), sdkPath() + QLatin1String("/host/linux/x86/usr/bin"));
- environment.insert(QLatin1String("PATH"), QLatin1String("/etc/qnx/bin"));
+ environment.insert(QLatin1String("PATH"), sdkPath() + QLatin1String("/host/linux/x86/usr/bin"));
+ environment.insert(QLatin1String("PATH"), QLatin1String("/etc/qnx/bin"));
- environment.insert(QLatin1String("LD_LIBRARY_PATH"), sdkPath() + QLatin1String("/host/linux/x86/usr/lib"));
-#endif
+ environment.insert(QLatin1String("LD_LIBRARY_PATH"), sdkPath() + QLatin1String("/host/linux/x86/usr/lib"));
+ }
environment.insert(QLatin1String("QNX_JAVAHOME"), sdkPath() + QLatin1String("/_jvm"));
environment.insert(QLatin1String("MAKEFLAGS"), QLatin1String("-I") + sdkPath() + QLatin1String("/target/qnx6/usr/include"));
diff --git a/src/plugins/qt4projectmanager/addlibrarywizard.cpp b/src/plugins/qt4projectmanager/addlibrarywizard.cpp
index 67711299e48..6955cb1cd5d 100644
--- a/src/plugins/qt4projectmanager/addlibrarywizard.cpp
+++ b/src/plugins/qt4projectmanager/addlibrarywizard.cpp
@@ -32,6 +32,8 @@
#include "ui_librarydetailswidget.h"
#include "librarydetailscontroller.h"
+#include <utils/hostosinfo.h>
+
#include <QVBoxLayout>
#include <QRadioButton>
#include <QLabel>
@@ -176,10 +178,10 @@ LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
packageLabel->setAttribute(Qt::WA_MacSmallSize, true);
layout->addWidget(packageLabel);
-#ifdef Q_OS_WIN
- m_packageRadio->setVisible(false);
- packageLabel->setVisible(false);
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ m_packageRadio->setVisible(false);
+ packageLabel->setVisible(false);
+ }
// select the default
m_internalRadio->setChecked(true);
diff --git a/src/plugins/qt4projectmanager/librarydetailscontroller.cpp b/src/plugins/qt4projectmanager/librarydetailscontroller.cpp
index 4344d2d6aeb..6b4a8584ca1 100644
--- a/src/plugins/qt4projectmanager/librarydetailscontroller.cpp
+++ b/src/plugins/qt4projectmanager/librarydetailscontroller.cpp
@@ -41,6 +41,7 @@
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/buildconfiguration.h>
+#include <utils/hostosinfo.h>
#include <QFileInfo>
#include <QDir>
@@ -67,27 +68,31 @@ LibraryDetailsController::LibraryDetailsController(
m_windowsGroupVisible(true),
m_libraryDetailsWidget(libraryDetails)
{
-#ifdef Q_OS_MAC
- m_creatorPlatform = CreatorMac;
-#endif
-#ifdef Q_OS_LINUX
- m_creatorPlatform = CreatorLinux;
-#endif
-#ifdef Q_OS_WIN
- m_creatorPlatform = CreatorWindows;
-#endif
-
-#ifndef Q_OS_LINUX
- // project for which we are going to insert the snippet
- const ProjectExplorer::Project *project =
- ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(proFile);
- // if its tool chain is maemo behave the same as we would be on linux
- ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(project->activeTarget()->profile());
- if (tc
- && (tc->targetAbi().osFlavor() == ProjectExplorer::Abi::HarmattanLinuxFlavor
- || tc->targetAbi().osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor))
+ switch (Utils::HostOsInfo::hostOs()) {
+ case Utils::HostOsInfo::HostOsMac:
+ m_creatorPlatform = CreatorMac;
+ break;
+ case Utils::HostOsInfo::HostOsLinux:
m_creatorPlatform = CreatorLinux;
-#endif
+ break;
+ case Utils::HostOsInfo::HostOsWindows:
+ m_creatorPlatform = CreatorWindows;
+ break;
+ default:
+ break;
+ }
+
+ if (!Utils::HostOsInfo::isLinuxHost()) {
+ // project for which we are going to insert the snippet
+ const ProjectExplorer::Project *project =
+ ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(proFile);
+ // if its tool chain is maemo behave the same as we would be on linux
+ ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(project->activeTarget()->profile());
+ if (tc
+ && (tc->targetAbi().osFlavor() == ProjectExplorer::Abi::HarmattanLinuxFlavor
+ || tc->targetAbi().osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor))
+ m_creatorPlatform = CreatorLinux;
+ }
setPlatformsVisible(true);
setLinkageGroupVisible(true);
diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp
index 39eaca11fd9..bf199d138a5 100644
--- a/src/plugins/qt4projectmanager/qmakestep.cpp
+++ b/src/plugins/qt4projectmanager/qmakestep.cpp
@@ -54,6 +54,7 @@
#include <qtsupport/qtprofileinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/debugginghelperbuildtask.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
@@ -66,6 +67,7 @@
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using namespace ProjectExplorer;
+using namespace Utils;
namespace {
const char * const QMAKE_BS_ID("QtProjectManager.QMakeBuildStep");
@@ -137,7 +139,7 @@ QString QMakeStep::allArguments(bool shorted)
arguments << QLatin1String("-r");
bool userProvidedMkspec = false;
- for (Utils::QtcProcess::ConstArgIterator ait(m_userArgs); ait.next(); ) {
+ for (QtcProcess::ConstArgIterator ait(m_userArgs); ait.next(); ) {
if (ait.value() == QLatin1String("-spec")) {
if (ait.next()) {
userProvidedMkspec = true;
@@ -145,7 +147,7 @@ QString QMakeStep::allArguments(bool shorted)
}
}
}
- Utils::FileName specArg = mkspec();
+ FileName specArg = mkspec();
if (!userProvidedMkspec && !specArg.isEmpty())
arguments << QLatin1String("-spec") << specArg.toUserOutput();
@@ -154,12 +156,12 @@ QString QMakeStep::allArguments(bool shorted)
arguments << deducedArguments();
- QString args = Utils::QtcProcess::joinArgs(arguments);
+ QString args = QtcProcess::joinArgs(arguments);
// User arguments
- Utils::QtcProcess::addArgs(&args, m_userArgs);
+ QtcProcess::addArgs(&args, m_userArgs);
// moreArgumentsAfter
foreach (const QString &arg, deducedArgumentsAfter())
- Utils::QtcProcess::addArg(&args, arg);
+ QtcProcess::addArg(&args, arg);
return args;
}
@@ -175,11 +177,11 @@ QStringList QMakeStep::deducedArguments()
ProjectExplorer::Abi targetAbi;
if (tc)
targetAbi = tc->targetAbi();
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
- if ((targetAbi.osFlavor() == ProjectExplorer::Abi::HarmattanLinuxFlavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor))
+ if ((HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost())
+ && (targetAbi.osFlavor() == ProjectExplorer::Abi::HarmattanLinuxFlavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor)) {
arguments << QLatin1String("-unix");
-#endif
+ }
// explicitly add architecture to CONFIG
if ((targetAbi.os() == ProjectExplorer::Abi::MacOS)
@@ -257,7 +259,7 @@ bool QMakeStep::init()
else
workingDirectory = qt4bc->buildDirectory();
- Utils::FileName program = qtVersion->qmakeCommand();
+ FileName program = qtVersion->qmakeCommand();
QString makefile = workingDirectory;
@@ -444,7 +446,7 @@ void QMakeStep::setLinkQmlDebuggingLibrary(bool enable)
QStringList QMakeStep::parserArguments()
{
QStringList result;
- for (Utils::QtcProcess::ConstArgIterator ait(allArguments()); ait.next(); )
+ for (QtcProcess::ConstArgIterator ait(allArguments()); ait.next(); )
if (ait.isSimple())
result << ait.value();
return result;
@@ -455,13 +457,13 @@ QString QMakeStep::userArguments()
return m_userArgs;
}
-Utils::FileName QMakeStep::mkspec()
+FileName QMakeStep::mkspec()
{
QString additionalArguments = m_userArgs;
- for (Utils::QtcProcess::ArgIterator ait(&additionalArguments); ait.next(); ) {
+ for (QtcProcess::ArgIterator ait(&additionalArguments); ait.next(); ) {
if (ait.value() == QLatin1String("-spec")) {
if (ait.next())
- return Utils::FileName::fromUserInput(ait.value());
+ return FileName::fromUserInput(ait.value());
}
}
diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
index ebbc882c792..75f6ca96b09 100644
--- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp
@@ -59,6 +59,7 @@
#include <qtsupport/baseqtversion.h>
#include <qtsupport/profilereader.h>
#include <qtsupport/qtprofileinformation.h>
+#include <utils/hostosinfo.h>
#include <QFormLayout>
#include <QInputDialog>
@@ -262,13 +263,13 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
toplayout->addRow(QString(), m_useTerminalCheck);
m_useTerminalCheck->setVisible(!m_qt4RunConfiguration->forcedGuiMode());
-#ifdef Q_OS_MAC
- m_usingDyldImageSuffix = new QCheckBox(tr("Use debug version of frameworks (DYLD_IMAGE_SUFFIX=_debug)"), this);
- m_usingDyldImageSuffix->setChecked(m_qt4RunConfiguration->isUsingDyldImageSuffix());
- toplayout->addRow(QString(), m_usingDyldImageSuffix);
- connect(m_usingDyldImageSuffix, SIGNAL(toggled(bool)),
- this, SLOT(usingDyldImageSuffixToggled(bool)));
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ m_usingDyldImageSuffix = new QCheckBox(tr("Use debug version of frameworks (DYLD_IMAGE_SUFFIX=_debug)"), this);
+ m_usingDyldImageSuffix->setChecked(m_qt4RunConfiguration->isUsingDyldImageSuffix());
+ toplayout->addRow(QString(), m_usingDyldImageSuffix);
+ connect(m_usingDyldImageSuffix, SIGNAL(toggled(bool)),
+ this, SLOT(usingDyldImageSuffixToggled(bool)));
+ }
QLabel *environmentLabel = new QLabel(this);
environmentLabel->setText(tr("Run Environment"));
diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp
index 33c9dea516e..0dbc990eb07 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.cpp
+++ b/src/plugins/qt4projectmanager/qt4nodes.cpp
@@ -58,6 +58,7 @@
#include <qtsupport/qtprofileinformation.h>
#include <qtsupport/qtsupportconstants.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/fileutils.h>
@@ -338,10 +339,8 @@ struct InternalNode
fileWithoutPrefix = file;
}
QStringList parts = fileWithoutPrefix.toString().split(separator, QString::SkipEmptyParts);
-#ifndef Q_OS_WIN
- if (!isRelative && parts.count() > 0)
+ if (!Utils::HostOsInfo::isWindowsHost() && !isRelative && parts.count() > 0)
parts[0].prepend(separator);
-#endif
QStringListIterator it(parts);
InternalNode *currentNode = this;
QString path = (isRelative ? (projectDirFileName.toString() + QLatin1Char('/')) : QString());
@@ -1397,13 +1396,8 @@ QString Qt4ProFileNode::makefile() const
QString Qt4ProFileNode::objectExtension() const
{
- if (m_varValues[ObjectExt].isEmpty()) {
-#ifdef Q_OS_WIN
- return QLatin1String(".obj");
-#else
- return QLatin1String(".o");
-#endif
- }
+ if (m_varValues[ObjectExt].isEmpty())
+ return Utils::HostOsInfo::isWindowsHost() ? QLatin1String(".obj") : QLatin1String(".o");
return m_varValues[ObjectExt].first();
}
@@ -2248,13 +2242,12 @@ TargetInformation Qt4ProFileNode::targetInformation(QtSupport::ProFileReader *re
if (result.target.isEmpty())
result.target = QFileInfo(m_projectFilePath).baseName();
-#if defined (Q_OS_MAC)
- if (reader->values(QLatin1String("CONFIG")).contains(QLatin1String("app_bundle"))) {
+ if (Utils::HostOsInfo::isMacHost()
+ && reader->values(QLatin1String("CONFIG")).contains(QLatin1String("app_bundle"))) {
result.workingDir += QLatin1Char('/')
+ result.target
+ QLatin1String(".app/Contents/MacOS");
}
-#endif
result.workingDir = QDir::cleanPath(result.workingDir);
@@ -2281,9 +2274,8 @@ TargetInformation Qt4ProFileNode::targetInformation(QtSupport::ProFileReader *re
result.executable = QDir::cleanPath(wd + QLatin1Char('/') + result.target);
//qDebug() << "##### updateTarget sets:" << result.workingDir << result.executable;
-#if defined (Q_OS_WIN)
- result.executable += QLatin1String(".exe");
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ result.executable += QLatin1String(".exe");
result.valid = true;
return result;
}
diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
index f59247e3c83..9a11b4838e8 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
+++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp
@@ -78,6 +78,7 @@
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
+#include <utils/hostosinfo.h>
#include <utils/parameteraction.h>
#ifdef WITH_TESTS
@@ -153,11 +154,10 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addAutoReleasedObject(new Qt4BuildConfigurationFactory);
addAutoReleasedObject(new Qt4RunConfigurationFactory);
-#ifdef Q_OS_MAC
- addAutoReleasedObject(new MacDesignerExternalEditor);
-#else
- addAutoReleasedObject(new DesignerExternalEditor);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ addAutoReleasedObject(new MacDesignerExternalEditor);
+ else
+ addAutoReleasedObject(new DesignerExternalEditor);
addAutoReleasedObject(new LinguistExternalEditor);
addAutoReleasedObject(new DesktopQtVersionFactory);
diff --git a/src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp b/src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp
index 0a66a9258d8..5fd071a3f23 100644
--- a/src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp
@@ -42,6 +42,7 @@
#include <utils/detailsbutton.h>
#include <utils/detailswidget.h>
+#include <utils/hostosinfo.h>
#include <utils/pathchooser.h>
#include <QCheckBox>
@@ -93,9 +94,8 @@ Qt4TargetSetupWidget::Qt4TargetSetupWidget(ProjectExplorer::Profile *p,
QWidget *w = new QWidget;
m_newBuildsLayout = new QGridLayout;
m_newBuildsLayout->setMargin(0);
-#ifdef Q_OS_MAC
- m_newBuildsLayout->setSpacing(0);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ m_newBuildsLayout->setSpacing(0);
w->setLayout(m_newBuildsLayout);
layout->addWidget(w);
diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp
index 92f55eaece8..966f02bc663 100644
--- a/src/plugins/qtsupport/baseqtversion.cpp
+++ b/src/plugins/qtsupport/baseqtversion.cpp
@@ -48,6 +48,7 @@
#include <utils/persistentsettings.h>
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <utils/synchronousprocess.h>
#include <QDir>
@@ -58,6 +59,7 @@
using namespace QtSupport;
using namespace QtSupport::Internal;
+using namespace Utils;
static const char QTVERSIONID[] = "Id";
static const char QTVERSIONNAME[] = "Name";
@@ -164,7 +166,7 @@ int BaseQtVersion::getUniqueId()
return QtVersionManager::instance()->getUniqueId();
}
-BaseQtVersion::BaseQtVersion(const Utils::FileName &qmakeCommand, bool isAutodetected, const QString &autodetectionSource)
+BaseQtVersion::BaseQtVersion(const FileName &qmakeCommand, bool isAutodetected, const QString &autodetectionSource)
: m_id(getUniqueId()),
m_isAutodetected(isAutodetected),
m_autodetectionSource(autodetectionSource),
@@ -204,10 +206,10 @@ BaseQtVersion::BaseQtVersion()
m_hasDocumentation(false),
m_qmakeIsExecutable(true)
{
- ctor(Utils::FileName());
+ ctor(FileName());
}
-void BaseQtVersion::ctor(const Utils::FileName &qmakePath)
+void BaseQtVersion::ctor(const FileName &qmakePath)
{
m_qmakeCommand = qmakePath;
m_designerCommand.clear();
@@ -225,7 +227,7 @@ BaseQtVersion::~BaseQtVersion()
{
}
-QString BaseQtVersion::defaultDisplayName(const QString &versionString, const Utils::FileName &qmakePath,
+QString BaseQtVersion::defaultDisplayName(const QString &versionString, const FileName &qmakePath,
bool fromPath)
{
QString location;
@@ -303,7 +305,7 @@ QList<ProjectExplorer::Task> BaseQtVersion::validateProfile(const ProjectExplore
if (!tc)
result << ProjectExplorer::Task(ProjectExplorer::Task::Error,
ProjectExplorer::ToolChainProfileInformation::msgNoToolChainInTarget(),
- Utils::FileName(), -1,
+ FileName(), -1,
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
@@ -322,7 +324,7 @@ QList<ProjectExplorer::Task> BaseQtVersion::validateProfile(const ProjectExplore
version->displayName(),
qtAbiString);
result << ProjectExplorer::Task(ProjectExplorer::Task::Error,
- message, Utils::FileName(), -1,
+ message, FileName(), -1,
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} // Abi mismatch
return result;
@@ -345,7 +347,7 @@ void BaseQtVersion::fromMap(const QVariantMap &map)
QString string = map.value(QLatin1String(QTVERSIONQMAKEPATH)).toString();
if (string.startsWith(QLatin1Char('~')))
string.remove(0, 1).prepend(QDir::homePath());
- ctor(Utils::FileName::fromUserInput(string));
+ ctor(FileName::fromUserInput(string));
}
QVariantMap BaseQtVersion::toMap() const
@@ -404,9 +406,9 @@ QStringList BaseQtVersion::warningReason() const
return ret;
}
-ProjectExplorer::ToolChain *BaseQtVersion::preferredToolChain(const Utils::FileName &ms) const
+ProjectExplorer::ToolChain *BaseQtVersion::preferredToolChain(const FileName &ms) const
{
- const Utils::FileName spec = ms.isEmpty() ? mkspec() : ms;
+ const FileName spec = ms.isEmpty() ? mkspec() : ms;
QList<ProjectExplorer::ToolChain *> tcList = ProjectExplorer::ToolChainManager::instance()->toolChains();
ProjectExplorer::ToolChain *possibleTc = 0;
foreach (ProjectExplorer::ToolChain *tc, tcList) {
@@ -419,7 +421,7 @@ ProjectExplorer::ToolChain *BaseQtVersion::preferredToolChain(const Utils::FileN
return possibleTc;
}
-Utils::FileName BaseQtVersion::qmakeCommand() const
+FileName BaseQtVersion::qmakeCommand() const
{
return m_qmakeCommand;
}
@@ -574,10 +576,10 @@ void BaseQtVersion::updateSourcePath() const
}
}
}
- m_sourcePath = Utils::FileName::fromUserInput(sourcePath);
+ m_sourcePath = FileName::fromUserInput(sourcePath);
}
-Utils::FileName BaseQtVersion::sourcePath() const
+FileName BaseQtVersion::sourcePath() const
{
updateSourcePath();
return m_sourcePath;
@@ -654,46 +656,43 @@ QString BaseQtVersion::findQtBinary(Binaries binary) const
QStringList possibleCommands;
switch (binary) {
case QmlScene: {
-#if defined(Q_OS_WIN)
- possibleCommands << QLatin1String("qmlscene.exe");
-#else
- possibleCommands << QLatin1String("qmlscene");
-#endif
+ if (HostOsInfo::isWindowsHost())
+ possibleCommands << QLatin1String("qmlscene.exe");
+ else
+ possibleCommands << QLatin1String("qmlscene");
}
case QmlViewer: {
-#if defined(Q_OS_WIN)
- possibleCommands << QLatin1String("qmlviewer.exe");
-#elif defined(Q_OS_MAC)
- possibleCommands << QLatin1String("QMLViewer.app/Contents/MacOS/QMLViewer");
-#else
- possibleCommands << QLatin1String("qmlviewer");
-#endif
+ if (HostOsInfo::isWindowsHost())
+ possibleCommands << QLatin1String("qmlviewer.exe");
+ else if (HostOsInfo::isMacHost())
+ possibleCommands << QLatin1String("QMLViewer.app/Contents/MacOS/QMLViewer");
+ else
+ possibleCommands << QLatin1String("qmlviewer");
}
break;
case Designer:
-#if defined(Q_OS_WIN)
- possibleCommands << QLatin1String("designer.exe");
-#elif defined(Q_OS_MAC)
- possibleCommands << QLatin1String("Designer.app/Contents/MacOS/Designer");
-#else
- possibleCommands << QLatin1String("designer");
-#endif
+ if (HostOsInfo::isWindowsHost())
+ possibleCommands << QLatin1String("designer.exe");
+ else if (HostOsInfo::isMacHost())
+ possibleCommands << QLatin1String("Designer.app/Contents/MacOS/Designer");
+ else
+ possibleCommands << QLatin1String("designer");
break;
case Linguist:
-#if defined(Q_OS_WIN)
- possibleCommands << QLatin1String("linguist.exe");
-#elif defined(Q_OS_MAC)
- possibleCommands << QLatin1String("Linguist.app/Contents/MacOS/Linguist");
-#else
- possibleCommands << QLatin1String("linguist");
-#endif
+ if (HostOsInfo::isWindowsHost())
+ possibleCommands << QLatin1String("linguist.exe");
+ else if (HostOsInfo::isMacHost())
+ possibleCommands << QLatin1String("Linguist.app/Contents/MacOS/Linguist");
+ else
+ possibleCommands << QLatin1String("linguist");
break;
case Uic:
-#ifdef Q_OS_WIN
- possibleCommands << QLatin1String("uic.exe");
-#else
- possibleCommands << QLatin1String("uic-qt4") << QLatin1String("uic4") << QLatin1String("uic");
-#endif
+ if (HostOsInfo::isWindowsHost()) {
+ possibleCommands << QLatin1String("uic.exe");
+ } else {
+ possibleCommands << QLatin1String("uic-qt4") << QLatin1String("uic4")
+ << QLatin1String("uic");
+ }
break;
default:
Q_ASSERT(false);
@@ -728,13 +727,13 @@ void BaseQtVersion::updateMkspec() const
if (m_mkspecFullPath.isEmpty())
return;
- Utils::FileName baseMkspecDir = mkspecDirectoryFromVersionInfo(versionInfo());
+ FileName baseMkspecDir = mkspecDirectoryFromVersionInfo(versionInfo());
if (m_mkspec.isChildOf(baseMkspecDir)) {
m_mkspec = m_mkspec.relativeChildPath(baseMkspecDir);
// qDebug() << "Setting mkspec to"<<mkspec;
} else {
- Utils::FileName sourceMkSpecPath = sourcePath().appendPath(QLatin1String("mkspecs"));
+ FileName sourceMkSpecPath = sourcePath().appendPath(QLatin1String("mkspecs"));
if (m_mkspec.isChildOf(sourceMkSpecPath)) {
m_mkspec = m_mkspec.relativeChildPath(sourceMkSpecPath);
} else {
@@ -786,19 +785,19 @@ void BaseQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
m_mkspecValues.insert(declarativeBins, evaluator->value(declarativeBins));
}
-Utils::FileName BaseQtVersion::mkspec() const
+FileName BaseQtVersion::mkspec() const
{
updateMkspec();
return m_mkspec;
}
-Utils::FileName BaseQtVersion::mkspecFor(ProjectExplorer::ToolChain *tc) const
+FileName BaseQtVersion::mkspecFor(ProjectExplorer::ToolChain *tc) const
{
if (!tc)
return mkspec();
- const QList<Utils::FileName> tcSpecList = tc->suggestedMkspecList();
- foreach (const Utils::FileName &tcSpec, tcSpecList) {
+ const QList<FileName> tcSpecList = tc->suggestedMkspecList();
+ foreach (const FileName &tcSpec, tcSpecList) {
if (hasMkspec(tcSpec))
return tcSpec;
}
@@ -806,13 +805,13 @@ Utils::FileName BaseQtVersion::mkspecFor(ProjectExplorer::ToolChain *tc) const
return mkspec();
}
-Utils::FileName BaseQtVersion::mkspecPath() const
+FileName BaseQtVersion::mkspecPath() const
{
updateMkspec();
return m_mkspecFullPath;
}
-bool BaseQtVersion::hasMkspec(const Utils::FileName &spec) const
+bool BaseQtVersion::hasMkspec(const FileName &spec) const
{
updateVersionInfo();
QFileInfo fi;
@@ -965,12 +964,11 @@ QString BaseQtVersion::demosPath() const
QString BaseQtVersion::frameworkInstallPath() const
{
-#ifdef Q_OS_MAC
- updateVersionInfo();
- return m_versionInfo.value(QLatin1String("QT_INSTALL_LIBS"));
-#else
+ if (HostOsInfo::isMacHost()) {
+ updateVersionInfo();
+ return m_versionInfo.value(QLatin1String("QT_INSTALL_LIBS"));
+ }
return QString();
-#endif
}
bool BaseQtVersion::hasExamples() const
@@ -993,7 +991,7 @@ QList<ProjectExplorer::HeaderPath> BaseQtVersion::systemHeaderPathes(const Proje
return result;
}
-void BaseQtVersion::addToEnvironment(const ProjectExplorer::Profile *p, Utils::Environment &env) const
+void BaseQtVersion::addToEnvironment(const ProjectExplorer::Profile *p, Environment &env) const
{
Q_UNUSED(p);
env.set(QLatin1String("QTDIR"), QDir::toNativeSeparators(qmakeProperty("QT_HOST_DATA")));
@@ -1037,10 +1035,10 @@ bool BaseQtVersion::hasQmlObserver() const
return m_hasQmlObserver;
}
-Utils::Environment BaseQtVersion::qmlToolsEnvironment() const
+Environment BaseQtVersion::qmlToolsEnvironment() const
{
// FIXME: This seems broken!
- Utils::Environment environment = Utils::Environment::systemEnvironment();
+ Environment environment = Environment::systemEnvironment();
#if 0 // FIXME: Fix this!
addToEnvironment(environment);
#endif
@@ -1126,7 +1124,7 @@ QList<ProjectExplorer::Task> BaseQtVersion::reportIssuesImpl(const QString &proF
if (!isValid()) {
//: %1: Reason for being invalid
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", "The Qt version is invalid: %1").arg(invalidReason());
- results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, Utils::FileName(), -1,
+ results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, FileName(), -1,
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
}
@@ -1136,7 +1134,7 @@ QList<ProjectExplorer::Task> BaseQtVersion::reportIssuesImpl(const QString &proF
//: %1: Path to qmake executable
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
"The qmake command \"%1\" was not found or is not executable.").arg(qmakeCommand().toUserOutput());
- results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, Utils::FileName(), -1,
+ results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, FileName(), -1,
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
}
@@ -1147,13 +1145,13 @@ QList<ProjectExplorer::Task> BaseQtVersion::reportIssuesImpl(const QString &proF
if ((tmpBuildDir.startsWith(sourcePath)) && (tmpBuildDir != sourcePath)) {
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
"Qmake does not support build directories below the source directory.");
- results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, Utils::FileName(), -1,
+ results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, FileName(), -1,
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
} else if (tmpBuildDir.count(slash) != sourcePath.count(slash) && qtVersion() < QtVersionNumber(4,8, 0)) {
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
"The build directory needs to be at the same level as the source directory.");
- results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, Utils::FileName(), -1,
+ results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, FileName(), -1,
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
}
@@ -1178,13 +1176,13 @@ QtConfigWidget *BaseQtVersion::createConfigurationWidget() const
return 0;
}
-bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QString, QString> *versionInfo)
+bool BaseQtVersion::queryQMakeVariables(const FileName &binary, QHash<QString, QString> *versionInfo)
{
bool qmakeIsExecutable;
return BaseQtVersion::queryQMakeVariables(binary, versionInfo, &qmakeIsExecutable);
}
-bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QString, QString> *versionInfo,
+bool BaseQtVersion::queryQMakeVariables(const FileName &binary, QHash<QString, QString> *versionInfo,
bool *qmakeIsExecutable)
{
const int timeOutMS = 30000; // Might be slow on some machines.
@@ -1194,14 +1192,14 @@ bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QSt
return false;
QProcess process;
- Utils::Environment env = Utils::Environment::systemEnvironment();
+ Environment env = Environment::systemEnvironment();
-#ifdef Q_OS_WIN
- // Add tool chain environments. This is necessary for non-static qmakes e.g. using mingw on windows
- QList<ProjectExplorer::ToolChain *> tcList = ProjectExplorer::ToolChainManager::instance()->toolChains();
- foreach (ProjectExplorer::ToolChain *tc, tcList)
- tc->addToEnvironment(env);
-#endif
+ if (HostOsInfo::isWindowsHost()) {
+ // Add tool chain environments. This is necessary for non-static qmakes e.g. using mingw on windows
+ QList<ProjectExplorer::ToolChain *> tcList = ProjectExplorer::ToolChainManager::instance()->toolChains();
+ foreach (ProjectExplorer::ToolChain *tc, tcList)
+ tc->addToEnvironment(env);
+ }
process.setEnvironment(env.toStringList());
process.start(qmake.absoluteFilePath(), QStringList(QLatin1String("-query")), QIODevice::ReadOnly);
@@ -1212,7 +1210,7 @@ bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QSt
return false;
}
if (!process.waitForFinished(timeOutMS)) {
- Utils::SynchronousProcess::stopProcess(process);
+ SynchronousProcess::stopProcess(process);
qWarning("Timeout running '%s' (%dms).", qPrintable(binary.toUserOutput()), timeOutMS);
return false;
}
@@ -1252,73 +1250,79 @@ bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash<QSt
return true;
}
-Utils::FileName BaseQtVersion::mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo)
+FileName BaseQtVersion::mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo)
{
QString dataDir = qmakeProperty(versionInfo, "QT_HOST_DATA");
if (dataDir.isEmpty())
- return Utils::FileName();
- return Utils::FileName::fromUserInput(dataDir + QLatin1String("/mkspecs"));
+ return FileName();
+ return FileName::fromUserInput(dataDir + QLatin1String("/mkspecs"));
}
-Utils::FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo)
+FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo)
{
- Utils::FileName baseMkspecDir = mkspecDirectoryFromVersionInfo(versionInfo);
+ FileName baseMkspecDir = mkspecDirectoryFromVersionInfo(versionInfo);
if (baseMkspecDir.isEmpty())
- return Utils::FileName();
+ return FileName();
- Utils::FileName mkspecFullPath = Utils::FileName::fromString(baseMkspecDir.toString() + QLatin1String("/default"));
+ FileName mkspecFullPath = FileName::fromString(baseMkspecDir.toString() + QLatin1String("/default"));
// qDebug() << "default mkspec is located at" << mkspecFullPath;
-#ifdef Q_OS_WIN
- QFile f2(mkspecFullPath.toString() + QLatin1String("/qmake.conf"));
- if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
- while (!f2.atEnd()) {
- QByteArray line = f2.readLine();
- if (line.startsWith("QMAKESPEC_ORIGINAL")) {
- const QList<QByteArray> &temp = line.split('=');
- if (temp.size() == 2) {
- QString possibleFullPath = QString::fromLocal8Bit(temp.at(1).trimmed().constData());
- // We sometimes get a mix of different slash styles here...
- possibleFullPath = possibleFullPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
- if (QFileInfo(possibleFullPath).exists()) // Only if the path exists
- mkspecFullPath = Utils::FileName::fromUserInput(possibleFullPath);
+ switch (HostOsInfo::hostOs()) {
+ case HostOsInfo::HostOsWindows: {
+ QFile f2(mkspecFullPath.toString() + QLatin1String("/qmake.conf"));
+ if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
+ while (!f2.atEnd()) {
+ QByteArray line = f2.readLine();
+ if (line.startsWith("QMAKESPEC_ORIGINAL")) {
+ const QList<QByteArray> &temp = line.split('=');
+ if (temp.size() == 2) {
+ QString possibleFullPath = QString::fromLocal8Bit(temp.at(1).trimmed().constData());
+ // We sometimes get a mix of different slash styles here...
+ possibleFullPath = possibleFullPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ if (QFileInfo(possibleFullPath).exists()) // Only if the path exists
+ mkspecFullPath = FileName::fromUserInput(possibleFullPath);
+ }
+ break;
}
- break;
}
+ f2.close();
}
- f2.close();
+ break;
}
-#elif defined(Q_OS_MAC)
- QFile f2(mkspecFullPath.toString() + QLatin1String("/qmake.conf"));
- if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
- while (!f2.atEnd()) {
- QByteArray line = f2.readLine();
- if (line.startsWith("MAKEFILE_GENERATOR")) {
- const QList<QByteArray> &temp = line.split('=');
- if (temp.size() == 2) {
- const QByteArray &value = temp.at(1);
- if (value.contains("XCODE")) {
- // we don't want to generate xcode projects...
-// qDebug() << "default mkspec is xcode, falling back to g++";
- mkspecFullPath = baseMkspecDir.appendPath(QLatin1String("macx-g++"));
+ case HostOsInfo::HostOsMac: {
+ QFile f2(mkspecFullPath.toString() + QLatin1String("/qmake.conf"));
+ if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
+ while (!f2.atEnd()) {
+ QByteArray line = f2.readLine();
+ if (line.startsWith("MAKEFILE_GENERATOR")) {
+ const QList<QByteArray> &temp = line.split('=');
+ if (temp.size() == 2) {
+ const QByteArray &value = temp.at(1);
+ if (value.contains("XCODE")) {
+ // we don't want to generate xcode projects...
+ // qDebug() << "default mkspec is xcode, falling back to g++";
+ mkspecFullPath = baseMkspecDir.appendPath(QLatin1String("macx-g++"));
+ }
+ //resolve mkspec link
+ mkspecFullPath = FileName::fromString(mkspecFullPath.toFileInfo().canonicalFilePath());
}
- //resolve mkspec link
- mkspecFullPath = Utils::FileName::fromString(mkspecFullPath.toFileInfo().canonicalFilePath());
+ break;
}
- break;
}
+ f2.close();
}
- f2.close();
+ break;
+ }
+ default:
+ mkspecFullPath = FileName::fromString(mkspecFullPath.toFileInfo().canonicalFilePath());
+ break;
}
-#else
- mkspecFullPath = Utils::FileName::fromString(mkspecFullPath.toFileInfo().canonicalFilePath());
-#endif
return mkspecFullPath;
}
-Utils::FileName BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionInfo, const QString &versionString)
+FileName BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionInfo, const QString &versionString)
{
QStringList dirs;
dirs << qmakeProperty(versionInfo, "QT_INSTALL_LIBS")
@@ -1336,7 +1340,7 @@ Utils::FileName BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionI
&& file.startsWith(QLatin1String("QtCore"))
&& file.endsWith(QLatin1String(".framework"))) {
// handle Framework
- Utils::FileName lib(info);
+ FileName lib(info);
lib.appendPath(file.left(file.lastIndexOf(QLatin1Char('.'))));
return lib;
}
@@ -1350,18 +1354,18 @@ Utils::FileName BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionI
|| file.endsWith(QString::fromLatin1(".so.") + versionString)
|| file.endsWith(QLatin1String(".so"))
|| file.endsWith(QLatin1Char('.') + versionString + QLatin1String(".dylib")))
- return Utils::FileName(info);
+ return FileName(info);
}
}
}
}
// Return path to first static library found:
if (!staticLibs.isEmpty())
- return Utils::FileName(staticLibs.at(0));
- return Utils::FileName();
+ return FileName(staticLibs.at(0));
+ return FileName();
}
-QList<ProjectExplorer::Abi> BaseQtVersion::qtAbisFromLibrary(const Utils::FileName &coreLibrary)
+QList<ProjectExplorer::Abi> BaseQtVersion::qtAbisFromLibrary(const FileName &coreLibrary)
{
return ProjectExplorer::Abi::abisOfBinary(coreLibrary);
}
diff --git a/src/plugins/qtsupport/qmldumptool.cpp b/src/plugins/qtsupport/qmldumptool.cpp
index 876591f66bf..47b06548d3d 100644
--- a/src/plugins/qtsupport/qmldumptool.cpp
+++ b/src/plugins/qtsupport/qmldumptool.cpp
@@ -42,6 +42,7 @@
#include <projectexplorer/runconfiguration.h>
#include <utils/runextensions.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDesktopServices>
#include <QCoreApplication>
@@ -245,9 +246,8 @@ static QStringList sourceFileNames()
files << QLatin1String("main.cpp") << QLatin1String("qmldump.pro")
<< QLatin1String("qmlstreamwriter.cpp") << QLatin1String("qmlstreamwriter.h")
<< QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT");
-#ifdef Q_OS_MAC
- files << QLatin1String("Info.plist");
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ files << QLatin1String("Info.plist");
return files;
}
diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp
index d677d1020b1..08c773ff76e 100644
--- a/src/plugins/qtsupport/qtoptionspage.cpp
+++ b/src/plugins/qtsupport/qtoptionspage.cpp
@@ -49,6 +49,7 @@
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorerconstants.h>
+#include <utils/hostosinfo.h>
#include <utils/runextensions.h>
#include <QDir>
@@ -617,10 +618,9 @@ static QString filterForQmakeFileDialog()
for (int i = 0; i < commands.size(); ++i) {
if (i)
filter += QLatin1Char(' ');
-#ifdef Q_OS_MAC
- // work around QTBUG-7739 that prohibits filters that don't start with *
- filter += QLatin1Char('*');
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ // work around QTBUG-7739 that prohibits filters that don't start with *
+ filter += QLatin1Char('*');
filter += commands.at(i);
}
filter += QLatin1Char(')');
diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp
index c2449051590..83a1696162c 100644
--- a/src/plugins/subversion/subversionplugin.cpp
+++ b/src/plugins/subversion/subversionplugin.cpp
@@ -46,6 +46,7 @@
#include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
#include <utils/fileutils.h>
+#include <utils/hostosinfo.h>
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
@@ -173,10 +174,9 @@ StatusList parseStatusOutput(const QString &output)
static inline QStringList svnDirectories()
{
QStringList rc(QLatin1String(".svn"));
-#ifdef Q_OS_WIN
- // Option on Windows systems to avoid hassle with some IDEs
- rc.push_back(QLatin1String("_svn"));
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ // Option on Windows systems to avoid hassle with some IDEs
+ rc.push_back(QLatin1String("_svn"));
return rc;
}
@@ -1192,11 +1192,9 @@ SubversionPlugin *SubversionPlugin::instance()
bool SubversionPlugin::vcsAdd(const QString &workingDir, const QString &rawFileName)
{
-#ifdef Q_OS_MAC // See below.
- return vcsAdd14(workingDir, rawFileName);
-#else
+ if (Utils::HostOsInfo::isMacHost()) // See below.
+ return vcsAdd14(workingDir, rawFileName);
return vcsAdd15(workingDir, rawFileName);
-#endif
}
// Post 1.4 add: Use "--parents" to add directories
diff --git a/src/plugins/subversion/subversionsettings.cpp b/src/plugins/subversion/subversionsettings.cpp
index 8ba54a5a053..11b2b6c6856 100644
--- a/src/plugins/subversion/subversionsettings.cpp
+++ b/src/plugins/subversion/subversionsettings.cpp
@@ -31,6 +31,7 @@
#include "subversionsettings.h"
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <QSettings>
@@ -49,11 +50,9 @@ enum { defaultTimeOutS = 30, defaultLogCount = 1000 };
static QString defaultCommand()
{
- QString rc;
- rc = QLatin1String("svn");
-#if defined(Q_OS_WIN32)
- rc.append(QLatin1String(".exe"));
-#endif
+ QString rc = QLatin1String("svn");
+ if (Utils::HostOsInfo::isWindowsHost())
+ rc.append(QLatin1String(".exe"));
return rc;
}
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 5c17d071609..dfa4ff27874 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -68,6 +68,7 @@
#include <extensionsystem/pluginmanager.h>
#include <find/basetextfind.h>
#include <utils/linecolumnlabel.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
@@ -117,6 +118,7 @@
using namespace TextEditor;
using namespace TextEditor::Internal;
+using namespace Utils;
namespace TextEditor {
namespace Internal {
@@ -1762,7 +1764,8 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
// fall through
case Qt::Key_Right:
case Qt::Key_Left:
-#ifndef Q_OS_MAC
+ if (HostOsInfo::isMacHost())
+ break;
if ((e->modifiers()
& (Qt::AltModifier | Qt::ShiftModifier)) == (Qt::AltModifier | Qt::ShiftModifier)) {
int diff_row = 0;
@@ -1786,7 +1789,6 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
viewport()->update();
}
}
-#endif
break;
case Qt::Key_PageUp:
case Qt::Key_PageDown:
@@ -1821,6 +1823,9 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
break;
}
+ const Qt::KeyboardModifiers modifiers
+ = HostOsInfo::isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
+
if (!ro && d->m_inBlockSelectionMode) {
QString text = e->text();
if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
@@ -1829,13 +1834,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
}
}
- if (e->key() == Qt::Key_H && e->modifiers() ==
-#ifdef Q_OS_DARWIN
- Qt::MetaModifier
-#else
- Qt::ControlModifier
-#endif
- ) {
+ if (e->key() == Qt::Key_H && e->modifiers() == modifiers) {
universalHelper();
e->accept();
return;
@@ -3390,11 +3389,8 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
cursor_pen = painter.pen();
}
-#ifndef Q_OS_MAC // no visible cursor on mac
- if (blockSelectionCursorRect.isValid())
+ if (!HostOsInfo::isMacHost() && blockSelectionCursorRect.isValid())
painter.fillRect(blockSelectionCursorRect, palette().text());
-#endif
-
}
offset.ry() += r.height();
@@ -4247,10 +4243,8 @@ void BaseTextEditorWidget::mousePressEvent(QMouseEvent *e)
}
}
-#ifdef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(e))
+ if (HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
return;
-#endif
QPlainTextEdit::mousePressEvent(e);
}
@@ -4270,10 +4264,8 @@ void BaseTextEditorWidget::mouseReleaseEvent(QMouseEvent *e)
}
}
-#ifndef Q_OS_LINUX
- if (handleForwardBackwardMouseButtons(e))
+ if (!HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
return;
-#endif
QPlainTextEdit::mouseReleaseEvent(e);
}
diff --git a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp
index 07f79b2b330..19eec6d06cb 100644
--- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp
+++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp
@@ -33,6 +33,7 @@
#include "codeassistant.h"
#include <utils/faketooltip.h>
+#include <utils/hostosinfo.h>
#include <QDebug>
#include <QApplication>
@@ -288,11 +289,9 @@ void FunctionHintProposalWidget::updateContent()
void FunctionHintProposalWidget::updatePosition()
{
const QDesktopWidget *desktop = QApplication::desktop();
-#ifdef Q_OS_MAC
- const QRect &screen = desktop->availableGeometry(desktop->screenNumber(d->m_underlyingWidget));
-#else
- const QRect &screen = desktop->screenGeometry(desktop->screenNumber(d->m_underlyingWidget));
-#endif
+ const QRect &screen = Utils::HostOsInfo::isMacHost()
+ ? desktop->availableGeometry(desktop->screenNumber(d->m_underlyingWidget))
+ : desktop->screenGeometry(desktop->screenNumber(d->m_underlyingWidget));
d->m_pager->setFixedWidth(d->m_pager->minimumSizeHint().width());
diff --git a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
index 439efaf5a03..e5e22772bbf 100644
--- a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
+++ b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
@@ -40,6 +40,7 @@
#include <texteditor/texteditorconstants.h>
#include <utils/faketooltip.h>
+#include <utils/hostosinfo.h>
#include <QRect>
#include <QLatin1String>
@@ -56,6 +57,7 @@
#include <QDesktopWidget>
#include <QLabel>
+using namespace Utils;
namespace TextEditor {
@@ -305,15 +307,15 @@ void GenericProposalWidgetPrivate::maybeShowInfoTip()
GenericProposalWidget::GenericProposalWidget()
: d(new GenericProposalWidgetPrivate(this))
{
-#ifdef Q_OS_MAC
- if (d->m_completionListView->horizontalScrollBar())
- d->m_completionListView->horizontalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
- if (d->m_completionListView->verticalScrollBar())
- d->m_completionListView->verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
-#else
- // This improves the look with QGTKStyle.
- setFrameStyle(d->m_completionListView->frameStyle());
-#endif
+ if (HostOsInfo::isMacHost()) {
+ if (d->m_completionListView->horizontalScrollBar())
+ d->m_completionListView->horizontalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
+ if (d->m_completionListView->verticalScrollBar())
+ d->m_completionListView->verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
+ } else {
+ // This improves the look with QGTKStyle.
+ setFrameStyle(d->m_completionListView->frameStyle());
+ }
d->m_completionListView->setFrameStyle(QFrame::NoFrame);
d->m_completionListView->setAttribute(Qt::WA_MacShowFocusRect, false);
d->m_completionListView->setUniformItemSizes(true);
@@ -492,11 +494,9 @@ void GenericProposalWidget::updatePositionAndSize()
// Determine the position, keeping the popup on the screen
const QDesktopWidget *desktop = QApplication::desktop();
-#ifdef Q_OS_MAC
- const QRect screen = desktop->availableGeometry(desktop->screenNumber(d->m_underlyingWidget));
-#else
- const QRect screen = desktop->screenGeometry(desktop->screenNumber(d->m_underlyingWidget));
-#endif
+ const QRect screen = HostOsInfo::isMacHost()
+ ? desktop->availableGeometry(desktop->screenNumber(d->m_underlyingWidget))
+ : desktop->screenGeometry(desktop->screenNumber(d->m_underlyingWidget));
QPoint pos = d->m_displayRect.bottomLeft();
pos.rx() -= 16 + fw; // Space for the icons
@@ -509,6 +509,8 @@ void GenericProposalWidget::updatePositionAndSize()
bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
{
+ const Qt::KeyboardModifiers modifier = HostOsInfo::isMacHost()
+ ? Qt::MetaModifier : Qt::ControlModifier;
if (e->type() == QEvent::FocusOut) {
abort();
#if (QT_VERSION < 0x050000) && defined(Q_OS_DARWIN) && ! defined(QT_MAC_USE_COCOA)
@@ -529,11 +531,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
switch (ke->key()) {
case Qt::Key_N:
case Qt::Key_P:
-#ifdef Q_OS_MAC
- if (ke->modifiers() == Qt::MetaModifier) {
-#else
- if (ke->modifiers() == Qt::ControlModifier) {
-#endif
+ if (ke->modifiers() == modifier) {
e->accept();
return true;
}
@@ -549,11 +547,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
case Qt::Key_P:
// select next/previous completion
d->m_explicitlySelected = true;
-#ifdef Q_OS_MAC
- if (ke->modifiers() == Qt::MetaModifier) {
-#else
- if (ke->modifiers() == Qt::ControlModifier) {
-#endif
+ if (ke->modifiers() == modifier) {
int change = (ke->key() == Qt::Key_N) ? 1 : -1;
int nrows = d->m_model->size();
int row = d->m_completionListView->currentIndex().row();
diff --git a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp
index ffa7b9c2493..e615e9816f3 100644
--- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp
+++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp
@@ -35,6 +35,7 @@
#include <valgrindprocess.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <ssh/sftpchannel.h>
@@ -135,11 +136,7 @@ void CallgrindController::run(Option option)
#if CALLGRIND_CONTROL_DEBUG
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
#endif
-#ifdef Q_OS_WIN
- int pid = 0;
-#else
- const int pid = m_valgrindProc->pid();
-#endif
+ const int pid = Utils::HostOsInfo::isWindowsHost() ? 0 : m_valgrindProc->pid();
m_process->run(CALLGRIND_CONTROL_BINARY,
QStringList() << optionString << QString::number(pid),
QString(), QString());
diff --git a/src/plugins/valgrind/valgrindconfigwidget.cpp b/src/plugins/valgrind/valgrindconfigwidget.cpp
index 6c1ca47945d..5aae417ce84 100644
--- a/src/plugins/valgrind/valgrindconfigwidget.cpp
+++ b/src/plugins/valgrind/valgrindconfigwidget.cpp
@@ -35,6 +35,7 @@
#include "ui_valgrindconfigwidget.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDebug>
@@ -65,12 +66,12 @@ ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings,
connect(m_settings, SIGNAL(valgrindExecutableChanged(QString)),
m_ui->valgrindExeChooser, SLOT(setPath(QString)));
-#ifdef Q_OS_WIN
- // FIXME: On Window we know that we don't have a local valgrind
- // executable, so having the "Browse" button in the path chooser
- // (which is needed for the remote executable) is confusing.
- m_ui->valgrindExeChooser->buttonAtIndex(0)->hide();
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ // FIXME: On Window we know that we don't have a local valgrind
+ // executable, so having the "Browse" button in the path chooser
+ // (which is needed for the remote executable) is confusing.
+ m_ui->valgrindExeChooser->buttonAtIndex(0)->hide();
+ }
//
// Callgrind
diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp
index 98c3caf978d..36cf226ec76 100644
--- a/src/plugins/valgrind/valgrindplugin.cpp
+++ b/src/plugins/valgrind/valgrindplugin.cpp
@@ -45,6 +45,7 @@
#include <projectexplorer/applicationrunconfiguration.h>
#include <projectexplorer/projectexplorer.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDebug>
@@ -93,9 +94,8 @@ void ValgrindPlugin::startValgrindTool(IAnalyzerTool *tool, StartMode mode)
bool ValgrindPlugin::initialize(const QStringList &, QString *)
{
StartModes modes;
-#ifndef Q_OS_WIN
- modes.append(StartMode(StartLocal));
-#endif
+ if (!Utils::HostOsInfo::isWindowsHost())
+ modes.append(StartMode(StartLocal));
modes.append(StartMode(StartRemote));
AnalyzerManager::addTool(new MemcheckTool(this), modes);
diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp
index 66b92c830a5..069ef349dee 100644
--- a/src/plugins/valgrind/valgrindrunner.cpp
+++ b/src/plugins/valgrind/valgrindrunner.cpp
@@ -33,9 +33,10 @@
#include "valgrindrunner.h"
#include "valgrindprocess.h"
+#include <utils/environment.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
-#include <utils/environment.h>
#include <ssh/sshconnection.h>
#include <ssh/sshremoteprocess.h>
@@ -93,10 +94,9 @@ void ValgrindRunner::Private::run(ValgrindProcess *_process)
QStringList valgrindArgs = valgrindArguments;
valgrindArgs << QString("--tool=%1").arg(q->tool());
-#ifdef Q_OS_MAC
- // May be slower to start but without it we get no filenames for symbols.
- valgrindArgs << QLatin1String("--dsymutil=yes");
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ // May be slower to start but without it we get no filenames for symbols.
+ valgrindArgs << QLatin1String("--dsymutil=yes");
QObject::connect(process, SIGNAL(processOutput(QByteArray,Utils::OutputFormat)),
q, SIGNAL(processOutputReceived(QByteArray,Utils::OutputFormat)));
diff --git a/src/plugins/vcsbase/commonvcssettings.cpp b/src/plugins/vcsbase/commonvcssettings.cpp
index 066ffa281d5..37ee4b54831 100644
--- a/src/plugins/vcsbase/commonvcssettings.cpp
+++ b/src/plugins/vcsbase/commonvcssettings.cpp
@@ -30,6 +30,8 @@
#include "commonvcssettings.h"
+#include <utils/hostosinfo.h>
+
#include <QSettings>
#include <QDebug>
@@ -52,11 +54,9 @@ static inline QString sshPasswordPromptDefault()
const QByteArray envSetting = qgetenv("SSH_ASKPASS");
if (!envSetting.isEmpty())
return QString::fromLocal8Bit(envSetting);
-#ifdef Q_OS_WIN
- return QLatin1String("win-ssh-askpass");
-#else
+ if (Utils::HostOsInfo::isWindowsHost())
+ return QLatin1String("win-ssh-askpass");
return QLatin1String("ssh-askpass");
-#endif
}
namespace VcsBase {
diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp
index c056611189f..87ec480e4b0 100644
--- a/src/plugins/welcome/welcomeplugin.cpp
+++ b/src/plugins/welcome/welcomeplugin.cpp
@@ -41,6 +41,7 @@
#include <projectexplorer/projectexplorer.h>
+#include <utils/hostosinfo.h>
#include <utils/styledbar.h>
#include <utils/iwelcomepage.h>
#include <utils/networkaccessmanager.h>
@@ -65,6 +66,7 @@
enum { debug = 0 };
using namespace ExtensionSystem;
+using namespace Utils;
static const char currentPageSettingsKeyC[] = "WelcomeTab";
@@ -240,11 +242,10 @@ void WelcomeMode::initPlugins()
engine->setOutputWarningsToStandardError(false);
engine->setNetworkAccessManagerFactory(m_networkAccessManagerFactory);
QString pluginPath = QCoreApplication::applicationDirPath();
-#ifdef Q_OS_MAC
- pluginPath += QLatin1String("/../PlugIns");
-#else
- pluginPath += QLatin1String("/../" IDE_LIBRARY_BASENAME "/qtcreator");
-#endif
+ if (HostOsInfo::isMacHost())
+ pluginPath += QLatin1String("/../PlugIns");
+ else
+ pluginPath += QLatin1String("/../" IDE_LIBRARY_BASENAME "/qtcreator");
engine->addImportPath(QDir::cleanPath(pluginPath));
facilitateQml(engine);
foreach (Utils::IWelcomePage *plugin, plugins) {
@@ -261,17 +262,13 @@ void WelcomeMode::initPlugins()
QString WelcomeMode::platform() const
{
-#if defined(Q_OS_WIN)
- return QLatin1String("windows");
-#elif defined(Q_OS_MAC)
- return QLatin1String("mac");
-#elif defined(Q_OS_LINUX)
- return QLatin1String("linux");
-#elif defined(Q_OS_UNIX)
- return QLatin1String("unix");
-#else
- return QLatin1String("other")
-#endif
+ switch (HostOsInfo::hostOs()) {
+ case HostOsInfo::HostOsWindows: return QLatin1String("windows");
+ case HostOsInfo::HostOsMac: return QLatin1String("mac");
+ case HostOsInfo::HostOsLinux: return QLatin1String("linux");
+ case HostOsInfo::HostOsOtherUnix: return QLatin1String("unix");
+ default: return QLatin1String("other");
+ }
}
void WelcomeMode::welcomePluginAdded(QObject *obj)