1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the Qt API. It exists for the convenience |
9 | // of Qt Designer. This header |
10 | // file may change from version to version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | // |
14 | |
15 | #ifndef DEVICEPROFILE_H |
16 | #define DEVICEPROFILE_H |
17 | |
18 | #include "shared_global_p.h" |
19 | |
20 | #include <QtCore/qstring.h> |
21 | #include <QtCore/qshareddata.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QDesignerFormEditorInterface; |
26 | class QWidget; |
27 | class QStyle; |
28 | |
29 | namespace qdesigner_internal { |
30 | |
31 | class DeviceProfileData; |
32 | |
33 | /* DeviceProfile for embedded design. They influence |
34 | * default properties (for example, fonts), dpi and |
35 | * style of the form. This class represents a device |
36 | * profile. */ |
37 | |
38 | class QDESIGNER_SHARED_EXPORT DeviceProfile { |
39 | public: |
40 | DeviceProfile(); |
41 | |
42 | DeviceProfile(const DeviceProfile&); |
43 | DeviceProfile& operator=(const DeviceProfile&); |
44 | ~DeviceProfile(); |
45 | |
46 | void clear(); |
47 | |
48 | // Device name |
49 | QString name() const; |
50 | void setName(const QString &); |
51 | |
52 | // System settings active |
53 | bool isEmpty() const; |
54 | |
55 | // Default font family of the embedded system |
56 | QString fontFamily() const; |
57 | void setFontFamily(const QString &); |
58 | |
59 | // Default font size of the embedded system |
60 | int fontPointSize() const; |
61 | void setFontPointSize(int p); |
62 | |
63 | // Display resolution of the embedded system |
64 | int dpiX() const; |
65 | void setDpiX(int d); |
66 | int dpiY() const; |
67 | void setDpiY(int d); |
68 | |
69 | // Style |
70 | QString style() const; |
71 | void setStyle(const QString &); |
72 | |
73 | // Initialize from desktop system |
74 | void fromSystem(); |
75 | |
76 | static void systemResolution(int *dpiX, int *dpiY); |
77 | static void widgetResolution(const QWidget *w, int *dpiX, int *dpiY); |
78 | |
79 | bool equals(const DeviceProfile& rhs) const; |
80 | |
81 | // Apply to form/preview (using font inheritance) |
82 | enum ApplyMode { |
83 | /* Pre-Apply to parent widget of form being edited: Apply font |
84 | * and make use of property inheritance to be able to modify the |
85 | * font property freely. */ |
86 | ApplyFormParent, |
87 | /* Post-Apply to preview widget: Change only inherited font |
88 | * sub properties. */ |
89 | ApplyPreview |
90 | }; |
91 | void apply(const QDesignerFormEditorInterface *core, QWidget *widget, ApplyMode am) const; |
92 | |
93 | static void applyDPI(int dpiX, int dpiY, QWidget *widget); |
94 | |
95 | QString toString() const; |
96 | |
97 | QString toXml() const; |
98 | bool fromXml(const QString &xml, QString *errorMessage); |
99 | |
100 | private: |
101 | QSharedDataPointer<DeviceProfileData> m_d; |
102 | }; |
103 | |
104 | inline bool operator==(const DeviceProfile &s1, const DeviceProfile &s2) |
105 | { return s1.equals(rhs: s2); } |
106 | inline bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2) |
107 | { return !s1.equals(rhs: s2); } |
108 | |
109 | } |
110 | |
111 | |
112 | QT_END_NAMESPACE |
113 | |
114 | #endif // DEVICEPROFILE_H |
115 | |