ScreenToolsController.h 3.25 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31


/// @file
///     @author Gus Grubba <mavlink@grubba.com>

#ifndef ScreenToolsController_H
#define ScreenToolsController_H

#include "QGCApplication.h"
#include <QQuickItem>
#include <QCursor>

/*!
    @brief Screen helper tools for QML widgets
*/

/// This Qml control is used to return screen parameters
class ScreenToolsController : public QQuickItem
{
    Q_OBJECT
public:
    ScreenToolsController();

32 33 34 35
    Q_PROPERTY(bool     isAndroid           READ isAndroid      CONSTANT)
    Q_PROPERTY(bool     isiOS               READ isiOS          CONSTANT)
    Q_PROPERTY(bool     isMobile            READ isMobile       CONSTANT)
    Q_PROPERTY(bool     testHighDPI         READ testHighDPI    CONSTANT)
36
    Q_PROPERTY(bool     isDebug             READ isDebug        CONSTANT)
37 38
    Q_PROPERTY(bool     isMacOS             READ isMacOS        CONSTANT)
    Q_PROPERTY(bool     isLinux             READ isLinux        CONSTANT)
39
    Q_PROPERTY(QString  iOSDevice           READ iOSDevice      CONSTANT)
Don Gagne's avatar
Don Gagne committed
40 41 42 43

    // Returns current mouse position
    Q_INVOKABLE int mouseX(void) { return QCursor::pos().x(); }
    Q_INVOKABLE int mouseY(void) { return QCursor::pos().y(); }
Don Gagne's avatar
Don Gagne committed
44

Don Gagne's avatar
Don Gagne committed
45 46 47 48
#if defined (__android__)
    bool    isAndroid           () { return true;  }
    bool    isiOS               () { return false; }
    bool    isMobile            () { return true;  }
49 50
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
Don Gagne's avatar
Don Gagne committed
51 52 53 54
#elif defined(__ios__)
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return true; }
    bool    isMobile            () { return true; }
55 56 57 58 59 60 61 62 63 64 65 66 67 68
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
#elif defined(__macos__)
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
    bool    isMobile            () { return qgcApp()->fakeMobile(); }
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return true; }
#elif defined(Q_OS_LINUX)
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
    bool    isMobile            () { return qgcApp()->fakeMobile(); }
    bool    isLinux             () { return true; }
    bool    isMacOS             () { return false; }
Don Gagne's avatar
Don Gagne committed
69 70 71
#else
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
72
    bool    isMobile            () { return qgcApp()->fakeMobile(); }
73 74
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
Don Gagne's avatar
Don Gagne committed
75
#endif
76

77
#ifdef QT_DEBUG
78 79
    bool testHighDPI            () { return qgcApp()->testHighDPI(); }
    bool isDebug                () { return true; }
80
#else
81 82
    bool isDebug                () { return false; }
    bool testHighDPI            () { return false; }
83
#endif
Don Gagne's avatar
Don Gagne committed
84

85 86
    QString  iOSDevice          ();

Don Gagne's avatar
Don Gagne committed
87 88 89
};

#endif