ScreenToolsController.h 4.24 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * 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 36 37 38 39
    Q_PROPERTY(bool     isAndroid           READ isAndroid          CONSTANT)
    Q_PROPERTY(bool     isiOS               READ isiOS              CONSTANT)
    Q_PROPERTY(bool     isMobile            READ isMobile           CONSTANT)
    Q_PROPERTY(bool     isDebug             READ isDebug            CONSTANT)
    Q_PROPERTY(bool     isMacOS             READ isMacOS            CONSTANT)
    Q_PROPERTY(bool     isLinux             READ isLinux            CONSTANT)
    Q_PROPERTY(bool     isWindows           READ isWindows          CONSTANT)
    Q_PROPERTY(bool     isSerialAvailable   READ isSerialAvailable  CONSTANT)
40
    Q_PROPERTY(bool     hasTouch            READ hasTouch           CONSTANT)
41 42
    Q_PROPERTY(QString  iOSDevice           READ iOSDevice          CONSTANT)
    Q_PROPERTY(QString  fixedFontFamily     READ fixedFontFamily    CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
43 44
    Q_PROPERTY(QString  normalFontFamily    READ normalFontFamily   CONSTANT)
    Q_PROPERTY(QString  boldFontFamily      READ boldFontFamily     CONSTANT)
Don Gagne's avatar
Don Gagne committed
45 46 47 48

    // 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
49

50
#if defined(__mobile__)
51
    bool    isMobile            () const { return true;  }
52
#else
53
    bool    isMobile            () const { return qgcApp()->fakeMobile(); }
54 55
#endif

56
#if defined (Q_OS_ANDROID)
Don Gagne's avatar
Don Gagne committed
57 58
    bool    isAndroid           () { return true;  }
    bool    isiOS               () { return false; }
59 60
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
Gus Grubba's avatar
Gus Grubba committed
61
    bool    isWindows           () { return false; }
62
#elif defined(Q_OS_IOS)
Don Gagne's avatar
Don Gagne committed
63 64
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return true; }
65 66
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
Gus Grubba's avatar
Gus Grubba committed
67
    bool    isWindows           () { return false; }
68
#elif defined(Q_OS_MAC)
69 70 71 72
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return true; }
Gus Grubba's avatar
Gus Grubba committed
73
    bool    isWindows           () { return false; }
74 75 76 77 78
#elif defined(Q_OS_LINUX)
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
    bool    isLinux             () { return true; }
    bool    isMacOS             () { return false; }
Gus Grubba's avatar
Gus Grubba committed
79 80 81 82 83 84 85
    bool    isWindows           () { return false; }
#elif defined(Q_OS_WIN)
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
    bool    isWindows           () { return true; }
Don Gagne's avatar
Don Gagne committed
86 87 88
#else
    bool    isAndroid           () { return false; }
    bool    isiOS               () { return false; }
89 90
    bool    isLinux             () { return false; }
    bool    isMacOS             () { return false; }
Gus Grubba's avatar
Gus Grubba committed
91
    bool    isWindows           () { return false; }
Don Gagne's avatar
Don Gagne committed
92
#endif
93

94 95 96 97 98 99
#if defined(NO_SERIAL_LINK)
    bool    isSerialAvailable   () { return false; }
#else
    bool    isSerialAvailable   () { return true; }
#endif

100
#ifdef QT_DEBUG
101
    bool isDebug                () { return true; }
102
#else
103
    bool isDebug                () { return false; }
104
#endif
Don Gagne's avatar
Don Gagne committed
105

106 107
    bool    hasTouch() const;

108 109
    QString  iOSDevice          () const;
    QString  fixedFontFamily    () const;
Gus Grubba's avatar
Gus Grubba committed
110 111
    QString  normalFontFamily   () const;
    QString  boldFontFamily     () const;
Don Gagne's avatar
Don Gagne committed
112 113 114
};

#endif