ScreenTools.h 1.99 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1
/*=====================================================================
2

Don Gagne's avatar
Don Gagne committed
3
 QGroundControl Open Source Ground Control Station
4

Don Gagne's avatar
Don Gagne committed
5
 (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
6

Don Gagne's avatar
Don Gagne committed
7
 This file is part of the QGROUNDCONTROL project
8

Don Gagne's avatar
Don Gagne committed
9 10 11 12
 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
13

Don Gagne's avatar
Don Gagne committed
14 15 16 17
 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
18

Don Gagne's avatar
Don Gagne committed
19 20
 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
21

Don Gagne's avatar
Don Gagne committed
22 23 24
 ======================================================================*/

/// @file
25
///     @author Gus Grubba <mavlink@grubba.com>
Don Gagne's avatar
Don Gagne committed
26

27 28
#ifndef SCREENTOOLS_H
#define SCREENTOOLS_H
Don Gagne's avatar
Don Gagne committed
29 30 31 32

#include <QObject>
#include <QCursor>

33 34
/// This Qml control is used to return screen parameters
class ScreenTools : public QObject
Don Gagne's avatar
Don Gagne committed
35 36 37
{
    Q_OBJECT
public:
38 39
    ScreenTools();

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    Q_PROPERTY(double   screenDPI           READ screenDPI CONSTANT)
    Q_PROPERTY(double   dpiFactor           READ dpiFactor CONSTANT)
    Q_PROPERTY(int      mouseX              READ mouseX)
    Q_PROPERTY(int      mouseY              READ mouseY)
    Q_PROPERTY(bool     repaintRequested    READ repaintRequested   NOTIFY repaintRequestedChanged)

    double  screenDPI           () { return _dotsPerInch; }
    double  dpiFactor           () { return _dpiFactor; }
    int     mouseX              () { return QCursor::pos().x(); }
    int     mouseY              () { return QCursor::pos().y(); }
    bool    repaintRequested    () { return true; }

signals:
    void repaintRequestedChanged();

private slots:
    void _updateCanvas();
57 58 59 60 61

private:
    double _dotsPerInch;
    double _dpiFactor;

Don Gagne's avatar
Don Gagne committed
62 63 64
};

#endif