-
Notifications
You must be signed in to change notification settings - Fork 0
/
Units.h
42 lines (34 loc) · 1.36 KB
/
Units.h
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
40
41
42
#ifndef UNITS_H
#define UNITS_H
#include <QObject>
#include <QScreen>
class Units : public QObject
{
Q_OBJECT
public:
explicit Units(QObject *parent = 0);
explicit Units(const QSize& screenSize, QObject *parent = 0);
explicit Units(const QSize& screenSize, const QSize &designedForSize, QObject *parent = 0);
explicit Units(const QSize& screenSize, const QSize &designedForSize, const qreal ratioMin, QObject *parent = 0);
explicit Units(const QSize& screenSize, const QSize &designedForSize, const qreal ratioMin, const qreal ratioMax, QObject *parent = 0);
explicit Units(const QSize& screenSize, const QSize &designedForSize, const qreal ratioMin, const qreal ratioMax, const bool roundUp, QObject *parent = 0);
Q_INVOKABLE qreal pt(int pixel);
Q_INVOKABLE int px(qreal point);
Q_INVOKABLE int scale(qreal point, qreal ratio);
Q_INVOKABLE qreal ratio();
Q_INVOKABLE QString size();
Q_INVOKABLE void roundUp(bool v);
protected slots:
void computeRatio();
signals:
void ratioChanged();
private:
bool mRoudUp;
QSize mCurrentSize;
QSize mIntendedSize;
qreal mRatio;
qreal mRatioMin;
qreal mRatioMax;
void init(const QSize& screenSize = QSize(1,1), const QSize &designedForSize = QSize(1,1), const qreal ratioMin = 0.0f, const qreal ratioMax = 99.0f, const bool roundUp = false);
};
#endif // UNIT_H