Enroute Flight Navigation
A navigation app for VFR pilots
ScaleQuickItem.h
1/***************************************************************************
2 * Copyright (C) 2019-2020 by Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include <QQmlEngine>
24#include <QtQuick/QQuickPaintedItem>
25
26namespace Ui {
27
37
38class ScaleQuickItem : public QQuickPaintedItem
39{
40 Q_OBJECT
41 QML_NAMED_ELEMENT(Scale)
42
43public:
48 explicit ScaleQuickItem(QQuickItem *parent = nullptr);
49
50 // Default destructor
51 ~ScaleQuickItem() override = default;
52
54 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged REQUIRED)
55
56
60 [[nodiscard]] QColor color() const {return m_color;}
61
66 void setColor(QColor _color);
67
70
71
75 [[nodiscard]] auto pixelPer10km() const -> qreal {return m_pixelPer10km;}
76
81 void setPixelPer10km(qreal _pxp10k);
82
87 void paint(QPainter* painter) override;
88
93 Q_PROPERTY(bool vertical READ vertical WRITE setVertical NOTIFY verticalChanged)
94
95
99 [[nodiscard]] auto vertical() const -> bool {return m_vertical;}
100
105 void setVertical(bool newVertical);
106
107signals:
110
113
116
117private:
118 Q_DISABLE_COPY_MOVE(ScaleQuickItem)
119
120 qreal m_pixelPer10km {0.0};
121 bool m_vertical {false};
122 QColor m_color {Qt::black};
123};
124
125} // namespace Ui
void setPixelPer10km(qreal _pxp10k)
Setter function for the property with the same name.
qreal pixelPer10km
Number of pixel that represent a distance of 10km on the map.
void setColor(QColor _color)
Setter function for the property with the same name.
void verticalChanged()
Notification signal for property with the same name.
void setVertical(bool newVertical)
Setter function for the property with the same name.
auto vertical() const -> bool
Getter function for the property with the same name.
void colorChanged()
Notification signal for property with the same name.
QColor color
Foreground color.
void paint(QPainter *painter) override
Re-implemented from QQuickPaintedItem to implement painting.
bool vertical
Determines whether the scale should be drawn vertically or horizontally.
void pixelPer10kmChanged()
Notification signal for property with the same name.
auto pixelPer10km() const -> qreal
Getter function for the property with the same name.
QColor color() const
Getter function for the property with the same name.
ScaleQuickItem(QQuickItem *parent=nullptr)
Standard constructor.