Utils: Replace macro usages with HostOsInfo

Change-Id: Iddec811b4b57a2a898ebdf319a3e2ec875febd6c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Orgad Shaneh
2016-09-10 22:57:46 +03:00
committed by Orgad Shaneh
parent 5305a58a51
commit ed68bda40d
3 changed files with 21 additions and 27 deletions

View File

@@ -25,6 +25,7 @@
#include "fileinprojectfinder.h"
#include "fileutils.h"
#include "hostosinfo.h"
#include "qtcassert.h"
#include <QDebug>
@@ -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)) {

View File

@@ -28,10 +28,6 @@
#include <QHeaderView>
#include <QFocusEvent>
#ifdef Q_OS_MAC
#include <QKeyEvent>
#endif
/*!
\class Utils::NavigationTreeView

View File

@@ -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<QKeyEvent *>(event)->key();
Qt::KeyboardModifiers mody = static_cast<QKeyEvent *>(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<QKeyEvent *>(event)->key();
Qt::KeyboardModifiers mody = static_cast<QKeyEvent *>(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();