From ed68bda40da8a515a6f51ffdaf3ca4be82d699e1 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 10 Sep 2016 22:57:46 +0300 Subject: [PATCH] Utils: Replace macro usages with HostOsInfo Change-Id: Iddec811b4b57a2a898ebdf319a3e2ec875febd6c Reviewed-by: Eike Ziller --- src/libs/utils/fileinprojectfinder.cpp | 25 ++++++++++++------------- src/libs/utils/navigationtreeview.cpp | 4 ---- src/libs/utils/tooltip/tooltip.cpp | 19 +++++++++---------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/libs/utils/fileinprojectfinder.cpp b/src/libs/utils/fileinprojectfinder.cpp index ff6a7c36ccc..5729b03b8e8 100644 --- a/src/libs/utils/fileinprojectfinder.cpp +++ b/src/libs/utils/fileinprojectfinder.cpp @@ -25,6 +25,7 @@ #include "fileinprojectfinder.h" #include "fileutils.h" +#include "hostosinfo.h" #include "qtcassert.h" #include @@ -141,25 +142,23 @@ QString FileInProjectFinder::findFile(const QUrl &fileUrl, bool *success) const int prefixToIgnore = -1; const QChar separator = QLatin1Char('/'); if (originalPath.startsWith(m_projectDir + separator)) { - -#ifdef Q_OS_MAC - // starting with the project path is not sufficient if the file was - // copied in an insource build, e.g. into MyApp.app/Contents/Resources - static const QString appResourcePath = QString::fromLatin1(".app/Contents/Resources"); - if (originalPath.contains(appResourcePath)) { - // the path is inside the project, but most probably as a resource of an insource build - // so ignore that path - prefixToIgnore = originalPath.indexOf(appResourcePath) + appResourcePath.length(); - } else { -#endif + if (Utils::HostOsInfo::isMacHost()) { + // starting with the project path is not sufficient if the file was + // copied in an insource build, e.g. into MyApp.app/Contents/Resources + static const QString appResourcePath = QString::fromLatin1(".app/Contents/Resources"); + if (originalPath.contains(appResourcePath)) { + // the path is inside the project, but most probably as a resource of an insource build + // so ignore that path + prefixToIgnore = originalPath.indexOf(appResourcePath) + appResourcePath.length(); + } + } + if (prefixToIgnore == -1) { if (debug) qDebug() << "FileInProjectFinder: found" << originalPath << "in project directory"; if (success) *success = true; return originalPath; -#ifdef Q_OS_MAC } -#endif } if (m_cache.contains(originalPath)) { diff --git a/src/libs/utils/navigationtreeview.cpp b/src/libs/utils/navigationtreeview.cpp index 4806ec9e344..87037356cc9 100644 --- a/src/libs/utils/navigationtreeview.cpp +++ b/src/libs/utils/navigationtreeview.cpp @@ -28,10 +28,6 @@ #include #include -#ifdef Q_OS_MAC -#include -#endif - /*! \class Utils::NavigationTreeView diff --git a/src/libs/utils/tooltip/tooltip.cpp b/src/libs/utils/tooltip/tooltip.cpp index 9fdca7b7e84..c9be1f99f35 100644 --- a/src/libs/utils/tooltip/tooltip.cpp +++ b/src/libs/utils/tooltip/tooltip.cpp @@ -304,18 +304,17 @@ bool ToolTip::eventFilter(QObject *o, QEvent *event) return false; switch (event->type()) { -#ifdef Q_OS_MAC case QEvent::KeyPress: - case QEvent::KeyRelease: { - int key = static_cast(event)->key(); - Qt::KeyboardModifiers mody = static_cast(event)->modifiers(); - if (!(mody & Qt::KeyboardModifierMask) - && key != Qt::Key_Shift && key != Qt::Key_Control - && key != Qt::Key_Alt && key != Qt::Key_Meta) - hideTipWithDelay(); + case QEvent::KeyRelease: + if (HostOsInfo::isMacHost()) { + int key = static_cast(event)->key(); + Qt::KeyboardModifiers mody = static_cast(event)->modifiers(); + if (!(mody & Qt::KeyboardModifierMask) + && key != Qt::Key_Shift && key != Qt::Key_Control + && key != Qt::Key_Alt && key != Qt::Key_Meta) + hideTipWithDelay(); + } break; - } -#endif case QEvent::Leave: if (o == m_tip && !m_tip->isAncestorOf(qApp->focusWidget())) hideTipWithDelay();