summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/audio-visualizer-qml/touchsettings.cpp
blob: 83fce63924eb4a41b4aaae2f821185b056dd83ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "touchsettings.h"

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#define DEVICE QInputDevice
#include <QtGui/QInputDevice>
#else
#define DEVICE QTouchDevice
#include <QtGui/QTouchDevice>
#endif

#include <QDebug>

TouchSettings::TouchSettings(QObject *parent)
    : QObject(parent)
{
}

bool TouchSettings::isHoverEnabled() const
{
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID) || defined(Q_OS_QNX) || defined(Q_OS_WINRT)
    return false;
#else
    const auto devices = DEVICE::devices();
    bool isTouch = false;
    for (const DEVICE *dev : devices)
        if (dev->type() == DEVICE::DeviceType::TouchScreen) {
            isTouch = true;
            break;
        }
    bool isMobile = false;
    if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE")) {
        isMobile = true;
    }
    return !isTouch && !isMobile;
#endif
}