diff --git a/src/libs/qmleditorwidgets/contextpanewidget.cpp b/src/libs/qmleditorwidgets/contextpanewidget.cpp index 4ef37f3cea49f00193f173f4a67dd14a6a965e93..6fe788357a2a398d24f04a10b50ffdba0679783a 100644 --- a/src/libs/qmleditorwidgets/contextpanewidget.cpp +++ b/src/libs/qmleditorwidgets/contextpanewidget.cpp @@ -29,6 +29,9 @@ **************************************************************************/ #include "contextpanewidget.h" + +#include + #include #include #include @@ -49,6 +52,8 @@ #include "customcolordialog.h" #include "colorbutton.h" +using namespace Utils; + namespace QmlEditorWidgets { /* XPM */ @@ -102,12 +107,12 @@ DragWidget::DragWidget(QWidget *parent) : QFrame(parent) // TODO: The following code should be enabled for OSX // when QTBUG-23205 is fixed -#ifndef Q_OS_MAC - m_dropShadowEffect = new QGraphicsDropShadowEffect; - m_dropShadowEffect->setBlurRadius(6); - m_dropShadowEffect->setOffset(2, 2); - setGraphicsEffect(m_dropShadowEffect); -#endif + if (!HostOsInfo::isMacHost()) { + m_dropShadowEffect = new QGraphicsDropShadowEffect; + m_dropShadowEffect->setBlurRadius(6); + m_dropShadowEffect->setOffset(2, 2); + setGraphicsEffect(m_dropShadowEffect); + } } void DragWidget::mousePressEvent(QMouseEvent * event) @@ -127,12 +132,12 @@ void DragWidget::mouseReleaseEvent(QMouseEvent *event) m_startPos = QPoint(-1, -1); // TODO: The following code should be enabled for OSX // when QTBUG-23205 is fixed -#ifndef Q_OS_MAC - m_dropShadowEffect = new QGraphicsDropShadowEffect; - m_dropShadowEffect->setBlurRadius(6); - m_dropShadowEffect->setOffset(2, 2); - setGraphicsEffect(m_dropShadowEffect); -#endif + if (!HostOsInfo::isMacHost()) { + m_dropShadowEffect = new QGraphicsDropShadowEffect; + m_dropShadowEffect->setBlurRadius(6); + m_dropShadowEffect->setOffset(2, 2); + setGraphicsEffect(m_dropShadowEffect); + } } QFrame::mouseReleaseEvent(event); } @@ -177,16 +182,14 @@ void DragWidget::protectedMoved() void DragWidget::leaveEvent(QEvent *) { -#ifdef Q_OS_MAC - unsetCursor(); -#endif + if (HostOsInfo::isMacHost()) + unsetCursor(); } void DragWidget::enterEvent(QEvent *) { -#ifdef Q_OS_MAC - setCursor(Qt::ArrowCursor); -#endif + if (HostOsInfo::isMacHost()) + setCursor(Qt::ArrowCursor); } ContextPaneWidget::ContextPaneWidget(QWidget *parent) : DragWidget(parent), m_currentWidget(0) @@ -232,9 +235,8 @@ ContextPaneWidget::ContextPaneWidget(QWidget *parent) : DragWidget(parent), m_cu m_disableAction->setCheckable(true); connect(m_disableAction.data(), SIGNAL(toggled(bool)), this, SLOT(onDisable(bool))); m_pinned = false; -#ifdef Q_OS_MAC - setCursor(Qt::ArrowCursor); -#endif + if (HostOsInfo::isMacHost()) + setCursor(Qt::ArrowCursor); } ContextPaneWidget::~ContextPaneWidget() diff --git a/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp b/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp index c0d7ed8768853c1f0cffdce36592b4281cc932f2..e50f24c6e0d4888f85610149f92eba523e4bdfe8 100644 --- a/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp +++ b/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp @@ -29,6 +29,9 @@ **************************************************************************/ #include "contextpanewidgetimage.h" + +#include + #include "ui_contextpanewidgetimage.h" #include "ui_contextpanewidgetborderimage.h" #include @@ -611,12 +614,12 @@ PreviewLabel::PreviewLabel(QWidget *parent) // TODO: The following code should be enabled for OSX // when QTBUG-23205 is fixed -#ifndef Q_OS_MAC - QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect; - dropShadowEffect->setBlurRadius(4); - dropShadowEffect->setOffset(2, 2); - m_hooverInfo->setGraphicsEffect(dropShadowEffect); -#endif + if (!Utils::HostOsInfo::isMacHost()) { + QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect; + dropShadowEffect->setBlurRadius(4); + dropShadowEffect->setOffset(2, 2); + m_hooverInfo->setGraphicsEffect(dropShadowEffect); + } m_hooverInfo->setAutoFillBackground(true); m_hooverInfo->raise(); } diff --git a/src/libs/qmleditorwidgets/customcolordialog.cpp b/src/libs/qmleditorwidgets/customcolordialog.cpp index f9bbb8137109c2252994da340a58ec944bf9e940..dbeb7a27315c657925dd756d2bb4af5589e688e2 100644 --- a/src/libs/qmleditorwidgets/customcolordialog.cpp +++ b/src/libs/qmleditorwidgets/customcolordialog.cpp @@ -32,6 +32,8 @@ #include "huecontrol.h" #include "colorbox.h" +#include + #include #include #include @@ -41,6 +43,8 @@ #include #include +using namespace Utils; + namespace QmlEditorWidgets { CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent ) @@ -52,12 +56,12 @@ CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent ) // TODO: The following code should be enabled for OSX // when QTBUG-23205 is fixed -#ifndef Q_OS_MAC - QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect; - dropShadowEffect->setBlurRadius(6); - dropShadowEffect->setOffset(2, 2); - setGraphicsEffect(dropShadowEffect); -#endif + if (!HostOsInfo::isMacHost()) { + QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect; + dropShadowEffect->setBlurRadius(6); + dropShadowEffect->setOffset(2, 2); + setGraphicsEffect(dropShadowEffect); + } setAutoFillBackground(true); m_hueControl = new HueControl(this); @@ -184,16 +188,14 @@ void CustomColorDialog::setupWidgets() void CustomColorDialog::leaveEvent(QEvent *) { -#ifdef Q_OS_MAC - unsetCursor(); -#endif + if (HostOsInfo::isMacHost()) + unsetCursor(); } void CustomColorDialog::enterEvent(QEvent *) { -#ifdef Q_OS_MAC - setCursor(Qt::ArrowCursor); -#endif + if (HostOsInfo::isMacHost()) + setCursor(Qt::ArrowCursor); } diff --git a/src/libs/qmleditorwidgets/qmleditorwidgets.pro b/src/libs/qmleditorwidgets/qmleditorwidgets.pro index c449baac7197a30fdae163bf3306e2f628bef884..99eced9375620573ed1d5596129c76b9b05e970a 100644 --- a/src/libs/qmleditorwidgets/qmleditorwidgets.pro +++ b/src/libs/qmleditorwidgets/qmleditorwidgets.pro @@ -7,5 +7,6 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3 include(../../qtcreatorlibrary.pri) include(../qmljs/qmljs.pri) +include(../utils/utils.pri) include(qmleditorwidgets-lib.pri) diff --git a/src/libs/qmleditorwidgets/qmleditorwidgets.qbs b/src/libs/qmleditorwidgets/qmleditorwidgets.qbs index e0b057e759de299ad7c9bc60455950ccea100dd6..b88bdf71482db720d1c07682c72c4a700831b9fc 100644 --- a/src/libs/qmleditorwidgets/qmleditorwidgets.qbs +++ b/src/libs/qmleditorwidgets/qmleditorwidgets.qbs @@ -19,6 +19,7 @@ QtcLibrary { Depends { name: "cpp" } Depends { name: "Qt"; submodules: ["widgets", "quick1", "script"] } Depends { name: "QmlJS" } + Depends { name: "Utils" } files: [ "resources.qrc", diff --git a/src/libs/utils/buildablehelperlibrary.cpp b/src/libs/utils/buildablehelperlibrary.cpp index 485895d863892a96f8fb95e2dafb307fe1d1a0bd..21f9b91ef3f1cb0459aacc9d5a1d917ba06e7904 100644 --- a/src/libs/utils/buildablehelperlibrary.cpp +++ b/src/libs/utils/buildablehelperlibrary.cpp @@ -38,8 +38,9 @@ #include #include -#include #include +#include +#include #include #include @@ -121,14 +122,13 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath, bool QStringList BuildableHelperLibrary::possibleQMakeCommands() { // On windows no one has renamed qmake, right? -#ifdef Q_OS_WIN - return QStringList(QLatin1String("qmake.exe")); -#else + if (HostOsInfo::isWindowsHost()) + return QStringList(QLatin1String("qmake.exe")); + // On unix some distributions renamed qmake to avoid clashes QStringList result; result << QLatin1String("qmake-qt4") << QLatin1String("qmake4") << QLatin1String("qmake"); return result; -#endif } // Copy helper source files to a target directory, replacing older files. diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp index 4c5144556769e4a80f52f42309c65348becd6a7d..9e000eb2bc8ff457d3846f52884de11a47f9453b 100644 --- a/src/libs/utils/consoleprocess_unix.cpp +++ b/src/libs/utils/consoleprocess_unix.cpp @@ -33,6 +33,8 @@ #include "environment.h" #include "qtcprocess.h" +#include + #include #include #include @@ -134,12 +136,14 @@ bool ConsoleProcess::start(const QString &program, const QString &args) } } + if (Utils::HostOsInfo::isMacHost()) { + xtermArgs << (QCoreApplication::applicationDirPath() + + QLatin1String("/../Resources/qtcreator_process_stub")); + } else { + xtermArgs << (QCoreApplication::applicationDirPath() + + QLatin1String("/qtcreator_process_stub")); + } xtermArgs -#ifdef Q_OS_MAC - << (QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/qtcreator_process_stub")) -#else - << (QCoreApplication::applicationDirPath() + QLatin1String("/qtcreator_process_stub")) -#endif << modeOption(d->m_mode) << d->m_stubServer.fullServerName() << msgPromptToClose() @@ -279,11 +283,9 @@ void ConsoleProcess::stubExited() QString ConsoleProcess::defaultTerminalEmulator() { -#ifdef Q_OS_MAC - return QLatin1String("/usr/X11/bin/xterm"); -#else + if (Utils::HostOsInfo::isMacHost()) + return QLatin1String("/usr/X11/bin/xterm"); return QLatin1String("xterm"); -#endif } QString ConsoleProcess::terminalEmulator(const QSettings *settings) diff --git a/src/libs/utils/detailsbutton.cpp b/src/libs/utils/detailsbutton.cpp index aa95ea284888be71377eb82a703043c30c446efc..178f22a585a5d1490c2be1cf8209d160014adf29 100644 --- a/src/libs/utils/detailsbutton.cpp +++ b/src/libs/utils/detailsbutton.cpp @@ -30,6 +30,7 @@ #include "detailsbutton.h" +#include #include #include @@ -83,11 +84,9 @@ QSize DetailsButton::sizeHint() const { // TODO: Adjust this when icons become available! const int w = fontMetrics().width(text()) + 32; -#ifdef Q_OS_MAC - return QSize(w, 34); -#else + if (HostOsInfo::isMacHost()) + return QSize(w, 34); return QSize(w, 22); -#endif } bool DetailsButton::event(QEvent *e) @@ -120,11 +119,10 @@ void DetailsButton::paintEvent(QPaintEvent *e) QWidget::paintEvent(e); QPainter p(this); -#ifndef Q_OS_MAC + // draw hover animation - if (!isDown() && m_fader > 0) + if (!HostOsInfo::isMacHost() && !isDown() && m_fader > 0) p.fillRect(rect().adjusted(1, 1, -2, -2), QColor(255, 255, 255, int(m_fader*180))); -#endif if (isChecked()) { if (m_checkedPixmap.isNull() || m_checkedPixmap.size() != contentsRect().size()) diff --git a/src/libs/utils/detailswidget.cpp b/src/libs/utils/detailswidget.cpp index ff5b8ca08376be57ab5650f547b847c67f45df95..e0e40f6127c0e5698b9e7c7504d7566a152926b7 100644 --- a/src/libs/utils/detailswidget.cpp +++ b/src/libs/utils/detailswidget.cpp @@ -30,6 +30,7 @@ #include "detailswidget.h" #include "detailsbutton.h" +#include "hostosinfo.h" #include #include @@ -143,10 +144,10 @@ QPixmap DetailsWidgetPrivate::cacheBackground(const QSize &size) QRect topRect(0, 0, size.width(), topHeight); QRect fullRect(0, 0, size.width(), size.height()); -#ifdef Q_OS_MAC - p.fillRect(fullRect, qApp->palette().window().color()); -#endif - p.fillRect(fullRect, QColor(255, 255, 255, 40)); + if (HostOsInfo::isMacHost()) + p.fillRect(fullRect, qApp->palette().window().color()); + else + p.fillRect(fullRect, QColor(255, 255, 255, 40)); QLinearGradient lg(topRect.topLeft(), topRect.bottomLeft()); lg.setColorAt(0, QColor(255, 255, 255, 130)); @@ -188,11 +189,10 @@ void DetailsWidgetPrivate::changeHoverState(bool hovered) { if (!m_toolWidget) return; -#ifdef Q_OS_MAC - m_toolWidget->setOpacity(hovered ? 1.0 : 0); -#else - m_toolWidget->fadeTo(hovered ? 1.0 : 0); -#endif + if (HostOsInfo::isMacHost()) + m_toolWidget->setOpacity(hovered ? 1.0 : 0); + else + m_toolWidget->fadeTo(hovered ? 1.0 : 0); m_hovered = hovered; } @@ -381,9 +381,8 @@ void DetailsWidget::setToolWidget(Utils::FadingPanel *widget) d->m_toolWidget->adjustSize(); d->m_grid->addWidget(d->m_toolWidget, 0, 1, 1, 1, Qt::AlignRight); -#ifdef Q_OS_MAC - d->m_toolWidget->setOpacity(1.0); -#endif + if (HostOsInfo::isMacHost()) + d->m_toolWidget->setOpacity(1.0); d->changeHoverState(d->m_hovered); } diff --git a/src/libs/utils/environment.cpp b/src/libs/utils/environment.cpp index 97650cb2bbdd9df805f1684780fb6fd783c6755e..03eb5c72a7772c8e5aa12beb6d1128d9524539ba 100644 --- a/src/libs/utils/environment.cpp +++ b/src/libs/utils/environment.cpp @@ -30,6 +30,8 @@ #include "environment.h" +#include "hostosinfo.h" + #include #include #include @@ -41,18 +43,18 @@ public: SystemEnvironment() : Environment(QProcess::systemEnvironment()) { -#ifdef Q_OS_LINUX - QString ldLibraryPath = value(QLatin1String("LD_LIBRARY_PATH")); - QDir lib(QCoreApplication::applicationDirPath()); - lib.cd("../lib"); - QString toReplace = lib.path(); - lib.cd("qtcreator"); - toReplace.append(QLatin1String(":")); - toReplace.append(lib.path()); - - if (ldLibraryPath.startsWith(toReplace)) - set(QLatin1String("LD_LIBRARY_PATH"), ldLibraryPath.remove(0, toReplace.length())); -#endif + if (Utils::HostOsInfo::isLinuxHost()) { + QString ldLibraryPath = value(QLatin1String("LD_LIBRARY_PATH")); + QDir lib(QCoreApplication::applicationDirPath()); + lib.cd("../lib"); + QString toReplace = lib.path(); + lib.cd("qtcreator"); + toReplace.append(QLatin1String(":")); + toReplace.append(lib.path()); + + if (ldLibraryPath.startsWith(toReplace)) + set(QLatin1String("LD_LIBRARY_PATH"), ldLibraryPath.remove(0, toReplace.length())); + } } }; @@ -60,6 +62,11 @@ Q_GLOBAL_STATIC(SystemEnvironment, staticSystemEnvironment) namespace Utils { +static QChar varSeparator() +{ + return HostOsInfo::isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':'); +} + static bool sortEnvironmentItem(const EnvironmentItem &a, const EnvironmentItem &b) { return a.name < b.name; @@ -104,11 +111,10 @@ Environment::Environment(const QStringList &env) foreach (const QString &s, env) { int i = s.indexOf(QLatin1Char('=')); if (i >= 0) { -#ifdef Q_OS_WIN - m_values.insert(s.left(i).toUpper(), s.mid(i+1)); -#else - m_values.insert(s.left(i), s.mid(i+1)); -#endif + if (HostOsInfo::isWindowsHost()) + m_values.insert(s.left(i).toUpper(), s.mid(i+1)); + else + m_values.insert(s.left(i), s.mid(i+1)); } } } @@ -128,32 +134,18 @@ QStringList Environment::toStringList() const void Environment::set(const QString &key, const QString &value) { -#ifdef Q_OS_WIN - QString _key = key.toUpper(); -#else - const QString &_key = key; -#endif - m_values.insert(_key, value); + m_values.insert(HostOsInfo::isWindowsHost() ? key.toUpper() : key, value); } void Environment::unset(const QString &key) { -#ifdef Q_OS_WIN - QString _key = key.toUpper(); -#else - const QString &_key = key; -#endif - m_values.remove(_key); + m_values.remove(HostOsInfo::isWindowsHost() ? key.toUpper() : key); } void Environment::appendOrSet(const QString &key, const QString &value, const QString &sep) { -#ifdef Q_OS_WIN - QString _key = key.toUpper(); -#else - const QString &_key = key; -#endif - QMap::iterator it = m_values.find(key); + const QString &_key = HostOsInfo::isWindowsHost() ? key.toUpper() : key; + QMap::iterator it = m_values.find(_key); if (it == m_values.end()) { m_values.insert(_key, value); } else { @@ -166,12 +158,8 @@ void Environment::appendOrSet(const QString &key, const QString &value, const QS void Environment::prependOrSet(const QString&key, const QString &value, const QString &sep) { -#ifdef Q_OS_WIN - QString _key = key.toUpper(); -#else - const QString &_key = key; -#endif - QMap::iterator it = m_values.find(key); + const QString &_key = HostOsInfo::isWindowsHost() ? key.toUpper() : key; + QMap::iterator it = m_values.find(_key); if (it == m_values.end()) { m_values.insert(_key, value); } else { @@ -184,38 +172,33 @@ void Environment::prependOrSet(const QString&key, const QString &value, const QS void Environment::appendOrSetPath(const QString &value) { -#ifdef Q_OS_WIN - const QChar sep = QLatin1Char(';'); -#else - const QChar sep = QLatin1Char(':'); -#endif - appendOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(sep)); + appendOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(varSeparator())); } void Environment::prependOrSetPath(const QString &value) { -#ifdef Q_OS_WIN - const QChar sep = QLatin1Char(';'); -#else - const QChar sep = QLatin1Char(':'); -#endif - prependOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(sep)); + prependOrSet(QLatin1String("PATH"), QDir::toNativeSeparators(value), QString(varSeparator())); } void Environment::prependOrSetLibrarySearchPath(const QString &value) { -#ifdef Q_OS_MAC - Q_UNUSED(value); - // we could set DYLD_LIBRARY_PATH on Mac but it is unnecessary in practice -#elif defined(Q_OS_WIN) - const QChar sep = QLatin1Char(';'); - const QLatin1String path("PATH"); - prependOrSet(path, QDir::toNativeSeparators(value), QString(sep)); -#elif defined(Q_OS_UNIX) - const QChar sep = QLatin1Char(':'); - const QLatin1String path("LD_LIBRARY_PATH"); - prependOrSet(path, QDir::toNativeSeparators(value), QString(sep)); -#endif + switch (HostOsInfo::hostOs()) { + case HostOsInfo::HostOsWindows: { + const QChar sep = QLatin1Char(';'); + const QLatin1String path("PATH"); + prependOrSet(path, QDir::toNativeSeparators(value), QString(sep)); + break; + } + case HostOsInfo::HostOsLinux: + case HostOsInfo::HostOsOtherUnix: { + const QChar sep = QLatin1Char(':'); + const QLatin1String path("LD_LIBRARY_PATH"); + prependOrSet(path, QDir::toNativeSeparators(value), QString(sep)); + break; + } + default: // we could set DYLD_LIBRARY_PATH on Mac but it is unnecessary in practice + break; + } } Environment Environment::systemEnvironment() @@ -233,14 +216,15 @@ QString Environment::searchInPath(const QString &executable, { QStringList execs; execs << executable; -#ifdef Q_OS_WIN - // Check all the executable extensions on windows: - QStringList extensions = value(QLatin1String("PATHEXT")).split(QLatin1Char(';')); - - // .exe.bat is legal (and run when starting new.exe), so always go through the complete list once: - foreach (const QString &ext, extensions) - execs << executable + ext.toLower(); -#endif + if (HostOsInfo::isWindowsHost()) { + // Check all the executable extensions on windows: + QStringList extensions = value(QLatin1String("PATHEXT")).split(QLatin1Char(';')); + + // .exe.bat is legal (and run when starting new.exe), so always go through the + // complete list once: + foreach (const QString &ext, extensions) + execs << executable + ext.toLower(); + } return searchInPath(execs, additionalDirs); } @@ -287,12 +271,7 @@ QString Environment::searchInPath(const QStringList &executables, QStringList Environment::path() const { -#ifdef Q_OS_WIN - const QChar sep = QLatin1Char(';'); -#else - const QChar sep = QLatin1Char(':'); -#endif - return m_values.value(QLatin1String("PATH")).split(sep, QString::SkipEmptyParts); + return m_values.value(QLatin1String("PATH")).split(varSeparator(), QString::SkipEmptyParts); } QString Environment::value(const QString &key) const @@ -425,68 +404,68 @@ QString Environment::expandVariables(const QString &input) const { QString result = input; -#ifdef Q_OS_WIN - for (int vStart = -1, i = 0; i < result.length(); ) { - if (result.at(i++) == QLatin1Char('%')) { - if (vStart > 0) { - const_iterator it = m_values.constFind(result.mid(vStart, i - vStart - 1).toUpper()); - if (it != m_values.constEnd()) { - result.replace(vStart - 1, i - vStart + 1, *it); - i = vStart - 1 + it->length(); - vStart = -1; + if (HostOsInfo::isWindowsHost()) { + for (int vStart = -1, i = 0; i < result.length(); ) { + if (result.at(i++) == QLatin1Char('%')) { + if (vStart > 0) { + const_iterator it = m_values.constFind(result.mid(vStart, i - vStart - 1).toUpper()); + if (it != m_values.constEnd()) { + result.replace(vStart - 1, i - vStart + 1, *it); + i = vStart - 1 + it->length(); + vStart = -1; + } else { + vStart = i; + } } else { vStart = i; } - } else { - vStart = i; } } - } -#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('}')) { - const_iterator it = m_values.constFind(result.mid(vStart, i - 1 - vStart)); - if (it != constEnd()) { - result.replace(vStart - 2, i - vStart + 2, *it); - i = vStart - 2 + it->length(); + } 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; } - state = BASE; - } - } else if (state == VARIABLE) { - if (!c.isLetterOrNumber() && c != QLatin1Char('_')) { - const_iterator it = m_values.constFind(result.mid(vStart, i - vStart - 1)); - if (it != constEnd()) { - result.replace(vStart - 1, i - vStart, *it); - i = vStart - 1 + it->length(); + } else if (state == BRACEDVARIABLE) { + if (c == QLatin1Char('}')) { + const_iterator it = m_values.constFind(result.mid(vStart, i - 1 - vStart)); + if (it != constEnd()) { + result.replace(vStart - 2, i - vStart + 2, *it); + i = vStart - 2 + it->length(); + } + state = BASE; + } + } else if (state == VARIABLE) { + if (!c.isLetterOrNumber() && c != QLatin1Char('_')) { + const_iterator it = m_values.constFind(result.mid(vStart, i - vStart - 1)); + if (it != constEnd()) { + result.replace(vStart - 1, i - vStart, *it); + i = vStart - 1 + it->length(); + } + state = BASE; } - state = BASE; } } + if (state == VARIABLE) { + const_iterator it = m_values.constFind(result.mid(vStart)); + if (it != constEnd()) + result.replace(vStart - 1, result.length() - vStart + 1, *it); + } } - if (state == VARIABLE) { - const_iterator it = m_values.constFind(result.mid(vStart)); - if (it != constEnd()) - result.replace(vStart - 1, result.length() - vStart + 1, *it); - } -#endif return result; } diff --git a/src/libs/utils/environmentmodel.cpp b/src/libs/utils/environmentmodel.cpp index dd1ac90ba8ca0128500aa0a93b552c3c8d921e05..c3f129498df43e742c352ef088456f3febe443e6 100644 --- a/src/libs/utils/environmentmodel.cpp +++ b/src/libs/utils/environmentmodel.cpp @@ -31,6 +31,7 @@ #include "environmentmodel.h" #include +#include #include @@ -202,11 +203,8 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, if (index.column() == 0) { //fail if a variable with the same name already exists -#if defined(Q_OS_WIN) - const QString &newName = value.toString().toUpper(); -#else - const QString &newName = value.toString(); -#endif + const QString &newName = HostOsInfo::isWindowsHost() + ? value.toString().toUpper() : value.toString(); // Does the new name exist already? if (d->m_resultEnvironment.hasKey(newName) || newName.isEmpty()) return false; diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index fc539b044172b18eb40d9bd259aa0b1317cccbe8..3ef845514ea5a8a774fd85db0cb4e0a39eceb528 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -31,6 +31,7 @@ #include "fileutils.h" #include "savefile.h" +#include "hostosinfo.h" #include "qtcassert.h" #include @@ -412,12 +413,8 @@ TempFileSaver::~TempFileSaver() On windows filenames are compared case insensitively. */ - -#ifdef Q_OS_WIN -Qt::CaseSensitivity FileName::cs = Qt::CaseInsensitive; -#else -Qt::CaseSensitivity FileName::cs = Qt::CaseSensitive; -#endif +const Qt::CaseSensitivity FileName::cs + = HostOsInfo::isWindowsHost() ? Qt::CaseInsensitive : Qt::CaseSensitive; FileName::FileName() : QString() @@ -581,10 +578,8 @@ FileName &FileName::append(QChar str) QT_BEGIN_NAMESPACE uint qHash(const Utils::FileName &a) { -#ifdef Q_OS_WIN - return qHash(a.toString().toUpper()); -#else + if (Utils::HostOsInfo::isWindowsHost()) + return qHash(a.toString().toUpper()); return qHash(a.toString()); -#endif } QT_END_NAMESPACE diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 34227753c43152b00c4c5c5b62948bd7b7e0df83..2047d911931690e95d0d4662cfeb9200d2d0e79d 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -175,7 +175,7 @@ public: using QString::isNull; using QString::clear; private: - static Qt::CaseSensitivity cs; + static const Qt::CaseSensitivity cs; FileName(const QString &string); }; diff --git a/src/libs/utils/filewizarddialog.cpp b/src/libs/utils/filewizarddialog.cpp index 50521b2e20cc81d00f404d6e2d401e0b405eebfe..bc52de6097ac5d49213b54d871835eb77fc9dad4 100644 --- a/src/libs/utils/filewizarddialog.cpp +++ b/src/libs/utils/filewizarddialog.cpp @@ -31,6 +31,8 @@ #include "filewizarddialog.h" #include "filewizardpage.h" +#include "hostosinfo.h" + #include /*! @@ -49,15 +51,15 @@ FileWizardDialog::FileWizardDialog(QWidget *parent) : setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setOption(QWizard::NoCancelButton, false); setOption(QWizard::NoDefaultButton, false); -#ifdef Q_OS_MAC - setButtonLayout(QList() - << QWizard::CancelButton - << QWizard::Stretch - << QWizard::BackButton - << QWizard::NextButton - << QWizard::CommitButton - << QWizard::FinishButton); -#endif + if (HostOsInfo::isMacHost()) { + setButtonLayout(QList() + << QWizard::CancelButton + << QWizard::Stretch + << QWizard::BackButton + << QWizard::NextButton + << QWizard::CommitButton + << QWizard::FinishButton); + } const int filePageId = addPage(m_filePage); wizardProgress()->item(filePageId)->setTitle(tr("Location")); connect(m_filePage, SIGNAL(activated()), button(QWizard::FinishButton), SLOT(animateClick())); diff --git a/src/libs/utils/hostosinfo.cpp b/src/libs/utils/hostosinfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d00887f719dd953ead501c144044f20833e226ae --- /dev/null +++ b/src/libs/utils/hostosinfo.cpp @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: http://www.qt-project.org/ +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +**************************************************************************/ +#include "hostosinfo.h" + +namespace Utils { + +HostOsInfo::HostOs HostOsInfo::hostOs() +{ +#if defined(Q_OS_WIN) + return HostOsWindows; +#elif defined(Q_OS_LINUX) + return HostOsLinux; +#elif defined(Q_OS_MAC) + return HostOsMac; +#elif defined(Q_OS_UNIX) + return HostOsOtherUnix; +#else + return HostOsOther; +#endif +} + +bool HostOsInfo::isAnyUnixHost() +{ +#ifdef Q_OS_UNIX + return true; +#else + return false; +#endif +} + +} // namespace Utils diff --git a/src/libs/utils/hostosinfo.h b/src/libs/utils/hostosinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..e456ff7e73f38c37c433cd2c034b75062d256485 --- /dev/null +++ b/src/libs/utils/hostosinfo.h @@ -0,0 +1,53 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: http://www.qt-project.org/ +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +**************************************************************************/ +#ifndef HOSTOSINFO_H +#define HOSTOSINFO_H + +#include "utils_global.h" + +namespace Utils { + +class QTCREATOR_UTILS_EXPORT HostOsInfo +{ +public: + // Add more as needed. + enum HostOs { HostOsWindows, HostOsLinux, HostOsMac, HostOsOtherUnix, HostOsOther }; + + static HostOs hostOs(); + + static bool isWindowsHost() { return hostOs() == HostOsWindows; } + static bool isLinuxHost() { return hostOs() == HostOsLinux; } + static bool isMacHost() { return hostOs() == HostOsMac; } + static bool isAnyUnixHost(); +}; + +} // namespace Utils + +#endif // HOSTOSINFO_H diff --git a/src/libs/utils/pathlisteditor.cpp b/src/libs/utils/pathlisteditor.cpp index ba1e85238ccbf7da3098dab54f295dbabbcda77c..df4c64652c83099ecbcbd2629024257361bec9e3 100644 --- a/src/libs/utils/pathlisteditor.cpp +++ b/src/libs/utils/pathlisteditor.cpp @@ -30,6 +30,8 @@ #include "pathlisteditor.h" +#include "hostosinfo.h" + #include #include #include @@ -254,12 +256,7 @@ void PathListEditor::slotInsert() QChar PathListEditor::separator() { -#ifdef Q_OS_WIN - static const QChar rc(QLatin1Char(';')); -#else - static const QChar rc(QLatin1Char(':')); -#endif - return rc; + return HostOsInfo::isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':'); } // Add a button "Import from 'Path'" diff --git a/src/libs/utils/stringutils.cpp b/src/libs/utils/stringutils.cpp index 7d06ed9a8ca1c465bc3b41228f7212c3efa7101c..c6ddb87c18e243898d58f5125839c67410cba2fe 100644 --- a/src/libs/utils/stringutils.cpp +++ b/src/libs/utils/stringutils.cpp @@ -30,6 +30,8 @@ #include "stringutils.h" +#include "hostosinfo.h" + #include #include #include @@ -95,19 +97,17 @@ QTCREATOR_UTILS_EXPORT QString commonPath(const QStringList &files) lastSeparatorPos = common.lastIndexOf(QLatin1Char('\\')); if (lastSeparatorPos == -1) return QString(); -#ifdef Q_OS_UNIX - if (lastSeparatorPos == 0) // Unix: "/a", "/b" -> '/' + if (HostOsInfo::isAnyUnixHost() && lastSeparatorPos == 0) // Unix: "/a", "/b" -> '/' lastSeparatorPos = 1; -#endif common.truncate(lastSeparatorPos); return common; } QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path) { -#ifdef Q_OS_WIN - QString outPath = path; -#else + if (HostOsInfo::isWindowsHost()) + return path; + static const QString homePath = QDir::homePath(); QFileInfo fi(QDir::cleanPath(path)); @@ -116,7 +116,6 @@ QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path) outPath = QLatin1Char('~') + outPath.mid(homePath.size()); else outPath = path; -#endif return outPath; } diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index af2e0dd8fdbb58f79a343684cfe5699dd844b34f..bd5ec37dda0f5bf8d68eb564f65c9257f478aadf 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -30,6 +30,8 @@ #include "stylehelper.h" +#include "hostosinfo.h" + #include #include #include @@ -69,11 +71,7 @@ QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int qreal StyleHelper::sidebarFontSize() { -#if defined(Q_OS_MAC) - return 10; -#else - return 7.5; -#endif + return HostOsInfo::isMacHost() ? 10 : 7.5; } QPalette StyleHelper::sidebarFontPalette(const QPalette &original) diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index 1017693581d14f436f6c4f4a48ef045709da8081..b2b540cae17685a210c3568583722296a2cd7d3f 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -29,6 +29,8 @@ **************************************************************************/ #include "synchronousprocess.h" + +#include "hostosinfo.h" #include #include @@ -599,18 +601,6 @@ bool SynchronousProcess::stopProcess(QProcess &p) // Path utilities -enum OS_Type { OS_Mac, OS_Windows, OS_Unix }; - -#ifdef Q_OS_WIN -static const OS_Type pathOS = OS_Windows; -#else -# ifdef Q_OS_MAC -static const OS_Type pathOS = OS_Mac; -# else -static const OS_Type pathOS = OS_Unix; -# endif -#endif - // Locate a binary in a directory, applying all kinds of // extensions the operating system supports. static QString checkBinary(const QDir &dir, const QString &binary) @@ -622,16 +612,18 @@ static QString checkBinary(const QDir &dir, const QString &binary) // Does the OS have some weird extension concept or does the // binary have a 3 letter extension? - if (pathOS == OS_Unix) + if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) return QString(); const int dotIndex = binary.lastIndexOf(QLatin1Char('.')); if (dotIndex != -1 && dotIndex == binary.size() - 4) return QString(); - switch (pathOS) { - case OS_Unix: + switch (HostOsInfo::hostOs()) { + case HostOsInfo::HostOsLinux: + case HostOsInfo::HostOsOtherUnix: + case HostOsInfo::HostOsOther: break; - case OS_Windows: { + case HostOsInfo::HostOsWindows: { static const char *windowsExtensions[] = {".cmd", ".bat", ".exe", ".com" }; // Check the Windows extensions using the order const int windowsExtensionCount = sizeof(windowsExtensions)/sizeof(const char*); @@ -642,7 +634,7 @@ static QString checkBinary(const QDir &dir, const QString &binary) } } break; - case OS_Mac: { + case HostOsInfo::HostOsMac: { // Check for Mac app folders const QFileInfo appFolder(dir.filePath(binary + QLatin1String(".app"))); if (appFolder.isDir()) { @@ -667,7 +659,7 @@ QString SynchronousProcess::locateBinary(const QString &path, const QString &bin return checkBinary(absInfo.dir(), absInfo.fileName()); // Windows finds binaries in the current directory - if (pathOS == OS_Windows) { + if (HostOsInfo::isWindowsHost()) { const QString currentDirBinary = checkBinary(QDir::current(), binary); if (!currentDirBinary.isEmpty()) return currentDirBinary; @@ -694,9 +686,7 @@ QString SynchronousProcess::locateBinary(const QString &binary) QChar SynchronousProcess::pathSeparator() { - if (pathOS == OS_Windows) - return QLatin1Char(';'); - return QLatin1Char(':'); + return HostOsInfo::isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':'); } } // namespace Utils diff --git a/src/libs/utils/utils.pro b/src/libs/utils/utils.pro index 7829c45097d5b0ab91d758d59f7eb256ebfcbffd..fa2d8ccc7165fa31cb9ece68f292ef7eb72ed9e6 100644 --- a/src/libs/utils/utils.pro +++ b/src/libs/utils/utils.pro @@ -13,10 +13,12 @@ lessThan(QT_MAJOR_VERSION, 5) { } HEADERS += \ - proxyaction.h + proxyaction.h \ + hostosinfo.h SOURCES += \ - proxyaction.cpp + proxyaction.cpp \ + hostosinfo.cpp win32: LIBS += -lUser32 # PortsGatherer diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 10e8d284225e0628902a814d10c2619a194a6fdb..10775ce8a9e3cb7427fdafdb7765b83ff75b4769 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -154,6 +154,8 @@ QtcLibrary { "utils_global.h", "wizard.cpp", "wizard.h", + "hostosinfo.cpp", + "hostosinfo.h", "persistentsettings.h", "settingsselector.h", "buildablehelperlibrary.cpp", diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 256c1f68ba3fb9eb1af5e57f7d46be8dd6e00ea5..453c4b57462e00c9449a940d10699c79c6ddf382 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -33,6 +33,7 @@ #include "ui_addnewavddialog.h" #include +#include #include #include @@ -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 ae6b7ac2294d359dc8010861d60529af3ecb570d..259fee43f7865523ec790e272bf379dbba9eaa5e 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -36,6 +36,8 @@ #include "androidconstants.h" +#include + #include #include #include @@ -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 6b0a7e94f10fecbf84de770b069b0c5dc99cc32a..07ba1ecd8690551b3c4b1ae98572c0fd0a36514f 100644 --- a/src/plugins/android/androidtoolchain.cpp +++ b/src/plugins/android/androidtoolchain.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -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 AndroidToolChain::suggestedMkspecList() const +QList AndroidToolChain::suggestedMkspecList() const { - return QList()<< Utils::FileName::fromString(QLatin1String("android-g++")); + return QList()<< 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 26953cab7152dcf9275b6e736f21e30018b574ab..c6526bfc56ace088f0b3b264308a81a00859e0cd 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -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 313d081fe4b800865faf06abf38d7abdda6c33e7..f47dacba72476b2f5925b2c034c9f4d7de12e100 100644 --- a/src/plugins/clearcase/clearcasesettings.cpp +++ b/src/plugins/clearcase/clearcasesettings.cpp @@ -33,6 +33,7 @@ #include "clearcasesettings.h" #include +#include #include @@ -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 b320e43dced20d0320b41600b6b6f3982b125b45..bab9fed6284ec507c72fcbbdac98a5c60bdab6e7 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 + #include #include @@ -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 5d9ebc24c36e024263c05f5c3b78243ceb5c8583..08d2632e7ca37563fdba05206667458628609c32 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 #include #include @@ -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 d7a8eaaf1aaaf511b9e408589482d4652f8c82b2..4f93a27d4dd92cbfd7caa9b0aa84b96d10b68322 100644 --- a/src/plugins/coreplugin/basefilewizard.cpp +++ b/src/plugins/coreplugin/basefilewizard.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -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::CancelButton - << QWizard::Stretch - << QWizard::BackButton - << QWizard::NextButton - << QWizard::CommitButton - << QWizard::FinishButton); -#endif + if (Utils::HostOsInfo::isMacHost()) { + w->setButtonLayout(QList() + << 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 1d9ea58c033eda7e3803e7fdb7783ec9c813fe74..31d8bbc91c3116868ddbc0584efe178b639b5d4f 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 #include #include @@ -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 89cedb58ab6c49ecfd7e71c7f34d360cd0d6c9e9..bbd8ee8f8f6dbb78e69d4b0534902908aec16386 100644 --- a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -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 ba6c8c72925dc84c50154e17f0adf92b6da0f6b3..eea0b197dcba7d47dc693cffa28673a7175264ea 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -33,6 +33,7 @@ #include #include "icore.h" +#include #include #include @@ -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()); diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 7a1b0c5ab35d5bd1619e36ec863399d6b9bb0a25..a604f00974cb77563fa2d7cf11cd0cf38be37f68 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -42,6 +42,7 @@ #include "vcsmanager.h" #include "coreconstants.h" +#include #include #include #include @@ -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 c0d9eeced8aa0e5efb54bbe579e7e4cec817d37d..06c7d1d825464a0f3ddf829d4a089e13c01d913e 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -61,6 +61,7 @@ #include #include +#include #include #include @@ -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 460c46acf6d6ad43dc63bc95390482a3f0b72927..7ebe2662a76364cca644f8c8d3ac387766b74183 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 #include #include @@ -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 d44006c4f34f3a8c1081338b4390155761c48f64..368b25dba6357d546e374e7e9106b719e75d71ec 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -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 2517bfc27340ff2292923035250e3c703ace966b..2bed5a079af36e0b39a1b6c86ba584a4c9ca1452 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -29,6 +29,7 @@ **************************************************************************/ #include "fancytabwidget.h" +#include #include #include @@ -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 3541027cd0a48a82aa37b9d6ca28ec6d8b34ebec..ffc94139a9bb3285c8c87f4a258c356fc680877d 100644 --- a/src/plugins/coreplugin/fileiconprovider.cpp +++ b/src/plugins/coreplugin/fileiconprovider.cpp @@ -31,6 +31,7 @@ #include "fileiconprovider.h" #include "mimedatabase.h" +#include #include #include @@ -44,6 +45,8 @@ #include #include +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 7d7cf98cdec9749764bd20a30e0b23d62375d3cf..7996768fe934e15211362cb307d291a42b995ebd 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -48,6 +48,7 @@ #include +#include #include #include @@ -198,11 +199,7 @@ QWidget *OutputPaneManager::buttonsWidget() // Return shortcut as Ctrl+ 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 427a8bdd195d05a33616aecf21c7ab828c0c4cce..8e3679f23b81501943fd647d79a9dea4411fb9ce 100644 --- a/src/plugins/cpaster/codepasterprotocol.cpp +++ b/src/plugins/cpaster/codepasterprotocol.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -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 aa67a49ed948b280ed75478fbe463676cc0800ea..f4058190065a30a23d51cb85b16986cfb4177c66 100644 --- a/src/plugins/cpaster/pasteselectdialog.cpp +++ b/src/plugins/cpaster/pasteselectdialog.cpp @@ -31,6 +31,7 @@ #include "pasteselectdialog.h" #include "protocol.h" +#include #include #include @@ -56,9 +57,8 @@ PasteSelectDialog::PasteSelectDialog(const QList &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 1ca72725c78eb2f9be983fac4704c91a7caf8a7c..d943147a8c7d694738809c1c053e197ca6422955 100644 --- a/src/plugins/cpaster/settings.cpp +++ b/src/plugins/cpaster/settings.cpp @@ -31,6 +31,8 @@ #include "settings.h" #include "pastebindotcomprotocol.h" +#include + #include #include @@ -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 264f3b9f25ebe1750578ac7c9da9436ecd9d4d7e..8225a8010659968f770913b484f8919ff1ffcfef 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -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 d2c01d01d6319a8b095dd06e3fcc0a0a87fbb454..2f11b68387d64917789e6ee4d99a17a45e6d9bb0 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -39,6 +39,7 @@ #include +#include #include #include @@ -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 5cb7fd873079dabd3599717530efefdd3c11f09b..853658a93629ff4428d0799b378478a8aabb521e 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -62,6 +62,7 @@ # include #endif +#include #include #include @@ -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 e22a7bb8985d058fa2dac92e5e6f51412ce5da22..7a00c132a5eb69554ba3b367354a90c156b980bb 100644 --- a/src/plugins/cvs/cvssettings.cpp +++ b/src/plugins/cvs/cvssettings.cpp @@ -31,6 +31,7 @@ #include "cvssettings.h" #include +#include #include #include @@ -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 86acab94c44bc91d9da07d311f049aa898349b25..191f2218a6a39bde0948db7176726d480ce3aa09 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -38,6 +38,7 @@ #include "debuggerstringutils.h" #include "stackframe.h" +#include #include #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 495f28af0fb5a2b97d07b5c1413e5a00288f4175..1b94f7c22f3badcd447b669e0672775ad9de982c 100644 --- a/src/plugins/debugger/commonoptionspage.cpp +++ b/src/plugins/debugger/commonoptionspage.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -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 87ae97d8ee09315514bf4d34da319e48be0ac530..0e820d241a4f78a7e742ab8ff1f91a730ca12bc3 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -115,6 +115,7 @@ #include #include +#include #include #include #include @@ -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 161d48c424a9a6e95f347dbfbb3a5e0ca9b507fd..2ad658598abc52f9c15658907e7fe98dedcd3882 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -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 59a02f59673be36e7ea2030adeadb66df8c15e0e..de0b736bc7da00ab5c5a86fa6d6fa584e5b27363 100644 --- a/src/plugins/debugger/gdb/localplaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/localplaingdbadapter.cpp @@ -38,6 +38,7 @@ #include +#include #include #include @@ -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 f41ec430743f6dafada5a72c8c6e027bdea1387b..8714786a98326933e7f21a2bfbe35e1d15289bb9 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 #include #include @@ -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 4451c13100e69b4ebfc95b4cfd0c759487bd84c1..31ce3ae3c6f61c562220d49b5266dfc189d32ef4 100644 --- a/src/plugins/debugger/moduleswindow.cpp +++ b/src/plugins/debugger/moduleswindow.cpp @@ -35,6 +35,7 @@ #include "debuggercore.h" #include "debuggerengine.h" +#include #include #include @@ -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 5da22a6f8c623a25de881ec4af24b6c6aab65ab3..ab78588c9998eb0d0f55dd98995c5abadf84c9e5 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -60,6 +60,7 @@ #include "fakevimhandler.h" +#include #include #include @@ -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 c9e8bf9c0ecd281f77acb80859711ef07ed1b7bc..73b6195c46dbe823fac9bb3533641166178260c1 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -44,6 +44,7 @@ #include +#include #include #include @@ -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(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 db28b564f2f0ed71cf2ab5eb9a5404cbf6186d88..340e4ed7130173f28d5a086f94943d74867017fa 100644 --- a/src/plugins/git/gerrit/gerritparameters.cpp +++ b/src/plugins/git/gerrit/gerritparameters.cpp @@ -36,6 +36,7 @@ #else # include #endif +#include #include #include #include @@ -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 1ae8a662ff40c326c99bb5757a8ca9218329ec3e..1c60966bffc7674d7415f369923486e93447d6ee 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -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 53810909683f20683e05f5dd1d3a263a1ff753a1..5ec9297a86ac64fd667844d76ee1da084bb72ac3 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -30,6 +30,7 @@ #include "gitsettings.h" +#include #include #include @@ -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 01fd37abd0c5fea4da61ace5f1d33075e7d4e966..82c2f111324fec3d75fb965e44531413f3a0ae21 100644 --- a/src/plugins/git/settingspage.cpp +++ b/src/plugins/git/settingspage.cpp @@ -34,6 +34,7 @@ #include "gitclient.h" #include +#include #include #include @@ -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 df328832e958c55c0e5d803de908e1ac8f95539e..5c77d01bf0cbc9b29ac173d5638062c4f18a8af0 100644 --- a/src/plugins/help/externalhelpwindow.cpp +++ b/src/plugins/help/externalhelpwindow.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -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 2af6e437e1edb753e4f1412d2175bf1da33c0cea..e6d7bc11d30e2601ef629c576ddd5b45eab383e4 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -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 4b60c422596914c5f4908e66eed7f7cda0f06e23..0c72233396ea6b45dce0783f2adae9bb7cb6d070 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 + #include #include #include @@ -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 76baa1ad4968eaf4bd8e4a7369f1d0abaa0b5ec3..52573bf105f1a7ebdb90239716e638b328fb213b 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 + #include #include #include @@ -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 (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 c20f8e37cf7e5ba592bed9b6623454f267512d4c..b0d4303104ae95218452069be8bbbb958acf89e9 100644 --- a/src/plugins/help/openpagesswitcher.cpp +++ b/src/plugins/help/openpagesswitcher.cpp @@ -34,6 +34,8 @@ #include "openpagesmodel.h" #include "openpageswidget.h" +#include + #include #include @@ -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 7d5b84f844c46d03c00b3b3a4b59a7ebca056af7..910f64cac44648b49eadf60c07acd5e60f660f92 100644 --- a/src/plugins/locator/locatorwidget.cpp +++ b/src/plugins/locator/locatorwidget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -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(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(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 0967ae9f25b4f9a4dbce98ea8f5142704522c744..70b460ca9d6f94bccb4826cfe6b625d77049e550 100644 --- a/src/plugins/madde/maemodeploybymountsteps.cpp +++ b/src/plugins/madde/maemodeploybymountsteps.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -345,29 +346,31 @@ bool MaemoMountAndCopyFilesService::isDeploymentNecessary() const QList MaemoMountAndCopyFilesService::mountSpecifications() const { QList 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 7ae076e62157bafa23fe963f61907eecb54ab0de..fe4635f9b9377dbfd02333d722c25019f4e540c6 100644 --- a/src/plugins/madde/maemoglobal.cpp +++ b/src/plugins/madde/maemoglobal.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -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 16789d70118b07bfc8e7238f40611693f22a9f9d..36cc0bae4beeb6a5bb4a3e5c7b1254a064c27115 100644 --- a/src/plugins/madde/maemopackagecreationstep.cpp +++ b/src/plugins/madde/maemopackagecreationstep.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -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 f1191255ad92b4b6dc1d067e588f4ee450b7cee2..c1709152fc71e1a88022ab8607342d3c95d27cc1 100644 --- a/src/plugins/madde/maemoqemuruntimeparser.cpp +++ b/src/plugins/madde/maemoqemuruntimeparser.cpp @@ -33,6 +33,7 @@ #include "maemoqemusettings.h" #include +#include #include #include @@ -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 21e1309f089176d26156ac9bc52d96ede64d6b52..bc6acb400b606e21dc3be49b944573035e5f705f 100644 --- a/src/plugins/madde/maemoqtversion.cpp +++ b/src/plugins/madde/maemoqtversion.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -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 7292f55cc188cb157406cfb404245c87c03214a2..283b9100f7f36a91387f9691707dc31c2a0950ec 100644 --- a/src/plugins/madde/maemoremotecopyfacility.cpp +++ b/src/plugins/madde/maemoremotecopyfacility.cpp @@ -33,6 +33,7 @@ #include #include +#include #include @@ -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 2dcd24f9e5c9c371a575a5154175be8f49247685..bb659b81eceba1ca0ace0042e622a1580ff7765d 100644 --- a/src/plugins/perforce/perforcesettings.cpp +++ b/src/plugins/perforce/perforcesettings.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -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 e0f3d96d4f253ceca6cef47a22c77025b3db4faa..c8b9f45a1467f760369c13010110655994855c80 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -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 8acb23033ece0a30808158b3b8a695a367ff414e..0cdb7e6e50d278b73a26f99c853d2d820639573d 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 #include #include @@ -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 b503e74e9268c36fc05ce5101aa952f28c7e9e35..ecc3b11f48dc8cca093fc17ffa20dbbc8eb559cd 100644 --- a/src/plugins/projectexplorer/environmentitemswidget.cpp +++ b/src/plugins/projectexplorer/environmentitemswidget.cpp @@ -31,6 +31,7 @@ #include "environmentitemswidget.h" #include +#include #include #include @@ -54,9 +55,8 @@ QList EnvironmentItemsWidgetPrivate::cleanUp( QSet 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 cdae6badcd427d7069554456b51417e55ecf2231..92aef556098699c434fcbe8c190c7bdbc539be5f 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -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 Internal::GccToolChainFactory::autoDetect() { QList 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 ClangToolChain::suggestedMkspecList() const @@ -865,29 +864,26 @@ QString MingwToolChain::typeDisplayName() const QList MingwToolChain::suggestedMkspecList() const { -#if defined(Q_OS_WIN) - return QList() << FileName::fromString(QLatin1String("win32-g++")); -#elif defined(Q_OS_LINUX) - if (version().startsWith("4.6.")) - return QList() - << FileName::fromString(QLatin1String("win32-g++-4.6-cross")) - << FileName::fromString(QLatin1String("unsupported/win32-g++-4.6-cross")); - else - return QList() - << FileName::fromString(QLatin1String("win32-g++-cross")) - << FileName::fromString(QLatin1String("unsupported/win32-g++-cross")); -#else + if (Utils::HostOsInfo::isWindowsHost()) + return QList() << FileName::fromString(QLatin1String("win32-g++")); + if (Utils::HostOsInfo::isLinuxHost()) { + if (version().startsWith("4.6.")) + return QList() + << FileName::fromString(QLatin1String("win32-g++-4.6-cross")) + << FileName::fromString(QLatin1String("unsupported/win32-g++-4.6-cross")); + else + return QList() + << FileName::fromString(QLatin1String("win32-g++-cross")) + << FileName::fromString(QLatin1String("unsupported/win32-g++-cross")); + } return QList(); -#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 efac70bc7581124ea336039a79b1923c520b7985..f5b6fc4b5011f0f575efb398290f1dc2ab701560 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -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 1816a9bb3c78aaa324590ce87e3264787fc46434..63cd30181e4784939e6e4365a12abcf02da5bc7a 100644 --- a/src/plugins/projectexplorer/settingsaccessor.cpp +++ b/src/plugins/projectexplorer/settingsaccessor.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -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 33100e411a13413f566e35eda06ef6983ee047af..3e95ba74738524ce4040ae3423d9b58313ff9ef2 100644 --- a/src/plugins/qmldesigner/components/integration/xuifiledialog.cpp +++ b/src/plugins/qmldesigner/components/integration/xuifiledialog.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#include + #include #include #include @@ -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 b5a73d953270ed119138ca9aa5a13abc1778c055..e4f33136db1dee3af2db11302ebf23e234355bb7 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 + #include @@ -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 3e949364d6d486b2454c35d01a46e226d9f111d8..be56367eca189df4db3a1d0dc362e38ab221cd8c 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 + #include #include #include @@ -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 378d2dc9e3692df181d682d7e777f8cb9cdde069..40c5788cc6e204f1aaf4e669b0afcf0911d422db 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -55,6 +55,7 @@ #include +#include #include #include @@ -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 45ebc6f3f8e553e92875345a10b2a01cf1859d6f..abbd051f1389c80774bfd6105fb454f99261ddd4 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -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 259bc32ca03f71d7d5a8d2d5f1c7dc9d410e22aa..3e86121d4cb7febdbb0b0aa5ff82339f0405a914 100644 --- a/src/plugins/qnx/blackberryqtversion.cpp +++ b/src/plugins/qnx/blackberryqtversion.cpp @@ -35,6 +35,7 @@ #include "qnxconstants.h" +#include #include #include @@ -72,11 +73,8 @@ QMultiMap parseEnvironmentFile(const QString &fileName) QMapIterator 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 BlackBerryQtVersion::environment() const if (sdkPath().isEmpty()) return QMultiMap(); -#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 fff076867f15831e5e6199b3b6557614bd55cd1d..bc5169f836503946002a9902da0801047114bd80 100644 --- a/src/plugins/qnx/qnxqtversion.cpp +++ b/src/plugins/qnx/qnxqtversion.cpp @@ -35,6 +35,8 @@ #include "qnxconstants.h" +#include + using namespace Qnx; using namespace Qnx::Internal; @@ -96,26 +98,26 @@ QMultiMap QnxQtVersion::environment() const QMultiMap 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 67711299e48c0381aadbb0a379f0a840b75acbeb..6955cb1cd5d57e137b5e6baacfeefecf8392ee58 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 + #include #include #include @@ -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 4344d2d6aebd4649cc8de0c3029ac750d341a994..6b4a8584ca1020de3ad6fc46da5c3b7ae01a5e62 100644 --- a/src/plugins/qt4projectmanager/librarydetailscontroller.cpp +++ b/src/plugins/qt4projectmanager/librarydetailscontroller.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -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 39eaca11fd9392d8be3c5915c93924ac87a925d3..bf199d138a599a60faddc51566cd68a9116e759d 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -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 ebbc882c7922ed867670a731ffd0bed261235f22..75f6ca96b0903c5893d99e73ebbf2f9984535168 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -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 33c9dea516e421214c5608bff2d64433cb71d5b3..0dbc990eb072638beee8e53b8e21193b4cf5f91c 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -58,6 +58,7 @@ #include #include +#include #include #include #include @@ -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 f59247e3c83cacba625b95a2e1c09a70a41e7dd3..9a11b4838e8f810385ecdb2d6ae0bcc49f1e55a6 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -78,6 +78,7 @@ #include #include #include +#include #include #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 0a66a9258d8c78aa92466dd495a99510adb36928..5fd071a3f2306a5133e0827eab7fd60ca1f15778 100644 --- a/src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4targetsetupwidget.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -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 92f55eaece8c1819ff4f51acd38caf6cb2890022..966f02bc663ee0779b75e2ad5af6fbe9699c362f 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -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 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 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 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"<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 tcSpecList = tc->suggestedMkspecList(); - foreach (const Utils::FileName &tcSpec, tcSpecList) { + const QList 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 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 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 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 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 *versionInfo) +bool BaseQtVersion::queryQMakeVariables(const FileName &binary, QHash *versionInfo) { bool qmakeIsExecutable; return BaseQtVersion::queryQMakeVariables(binary, versionInfo, &qmakeIsExecutable); } -bool BaseQtVersion::queryQMakeVariables(const Utils::FileName &binary, QHash *versionInfo, +bool BaseQtVersion::queryQMakeVariables(const FileName &binary, QHash *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 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 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 &versionInfo) +FileName BaseQtVersion::mkspecDirectoryFromVersionInfo(const QHash &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 &versionInfo) +FileName BaseQtVersion::mkspecFromVersionInfo(const QHash &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 &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 &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 &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 &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 &versionInfo, const QString &versionString) +FileName BaseQtVersion::qtCorePath(const QHash &versionInfo, const QString &versionString) { QStringList dirs; dirs << qmakeProperty(versionInfo, "QT_INSTALL_LIBS") @@ -1336,7 +1340,7 @@ Utils::FileName BaseQtVersion::qtCorePath(const QHash &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 &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 BaseQtVersion::qtAbisFromLibrary(const Utils::FileName &coreLibrary) +QList 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 876591f66bfc25a59b6694ec3f270673c23de227..47b06548d3db2b9f33026e8e0d5c001181cf8fdf 100644 --- a/src/plugins/qtsupport/qmldumptool.cpp +++ b/src/plugins/qtsupport/qmldumptool.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -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 d677d1020b1f41d51842ea2f9def722b677089d9..08c773ff76e7e8e03cf684d07b288c7becd2aac0 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -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 c24490515909fa70785b2dcd56300d59d8b794c6..83a1696162c3d43304b27b406a84f697f0cffa5e 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -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 8ba54a5a053ff1c3242c8af0e9f07680b33622e4..11b2b6c6856c4447a19e31bcbd7ef0dec49c029b 100644 --- a/src/plugins/subversion/subversionsettings.cpp +++ b/src/plugins/subversion/subversionsettings.cpp @@ -31,6 +31,7 @@ #include "subversionsettings.h" #include +#include #include @@ -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 5c17d0716099235f0ee0bb5240f59f3fcd469d9c..dfa4ff27874ae6da92853fd1cfee525f17236dce 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -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 07f79b2b3301ddd3075fde860779cfbe95740ca2..19eec6d06cba151e0acf94554e0c2b67821b2b17 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp @@ -33,6 +33,7 @@ #include "codeassistant.h" #include +#include #include #include @@ -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 439efaf5a03329de8750238c894c60e854960eb4..e5e22772bbf385b3199bfee3b662db1df9202d86 100644 --- a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -56,6 +57,7 @@ #include #include +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 ffa7b9c24931fe3af28146d1dad8f5fc09d58e32..e615e9816f3cc6039cf7cfdede42517fcd9aeb18 100644 --- a/src/plugins/valgrind/callgrind/callgrindcontroller.cpp +++ b/src/plugins/valgrind/callgrind/callgrindcontroller.cpp @@ -35,6 +35,7 @@ #include +#include #include #include @@ -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 6c1ca47945dd7be4b369d0e15976bb3ac67a450d..5aae417ce8457d37fe9787e9479e45dcc202eb28 100644 --- a/src/plugins/valgrind/valgrindconfigwidget.cpp +++ b/src/plugins/valgrind/valgrindconfigwidget.cpp @@ -35,6 +35,7 @@ #include "ui_valgrindconfigwidget.h" +#include #include #include @@ -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 98c3caf978d1dcd0abfd7263f31223f8348e79a5..36cf226ec7664765623d4b86de758928282473b2 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -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 66b92c830a5f00b741973c99bfad0ff7b0b98f10..069ef349deec4eba6f33e7d11a2284871c0562ce 100644 --- a/src/plugins/valgrind/valgrindrunner.cpp +++ b/src/plugins/valgrind/valgrindrunner.cpp @@ -33,9 +33,10 @@ #include "valgrindrunner.h" #include "valgrindprocess.h" +#include +#include #include -#include #include #include @@ -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 066ffa281d59dd10cebb9ba861cf85c2b128d4a9..37ee4b54831e3bf4b734eacca3fce16570bd8093 100644 --- a/src/plugins/vcsbase/commonvcssettings.cpp +++ b/src/plugins/vcsbase/commonvcssettings.cpp @@ -30,6 +30,8 @@ #include "commonvcssettings.h" +#include + #include #include @@ -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 c056611189f311e6c375ae3effedff3f71c29bd5..87ec480e4b02bf3c5a8370a207e5e017cc30347a 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -41,6 +41,7 @@ #include +#include #include #include #include @@ -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) diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp index ba6d8fd15541af9b8184bd11cafe9ab999119413..8f3677786f55808ebc9267d09a2cb89ea14e3221 100644 --- a/src/shared/help/indexwindow.cpp +++ b/src/shared/help/indexwindow.cpp @@ -37,6 +37,7 @@ #include "topicchooser.h" #include +#include #include #include @@ -165,13 +166,12 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e) } } } -#ifdef Q_OS_MAC - else if (obj == m_indexWidget && e->type() == QEvent::KeyPress) { + else if (Utils::HostOsInfo::isMacHost() && obj == m_indexWidget + && e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) m_indexWidget->activateCurrentItem(); } -#endif return QWidget::eventFilter(obj, e); } diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 2b8e5e46511e20de82100c25f6509eb14181b170..9bf6ff17bb3824a72799533a82d32022b3a4e636 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -33,6 +33,8 @@ #include "qmakeglobals.h" #include "ioutils.h" +#include + #include using namespace ProFileEvaluatorInternal; @@ -93,11 +95,8 @@ QStringList ProFileEvaluator::values(const QString &variableName, const ProFile QString ProFileEvaluator::sysrootify(const QString &path, const QString &baseDir) const { -#ifdef Q_OS_WIN - Qt::CaseSensitivity cs = Qt::CaseInsensitive; -#else - Qt::CaseSensitivity cs = Qt::CaseSensitive; -#endif + const Qt::CaseSensitivity cs = Utils::HostOsInfo::isWindowsHost() + ? Qt::CaseInsensitive : Qt::CaseSensitive; const bool isHostSystemPath = d->m_option->sysroot.isEmpty() || path.startsWith(d->m_option->sysroot, cs) || path.startsWith(baseDir, cs) || path.startsWith(d->m_outputDir, cs);