BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
deviceprofile_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 //
43 // W A R N I N G
44 // -------------
45 //
46 // This file is not part of the Qt API. It exists for the convenience
47 // of Qt Designer. This header
48 // file may change from version to version without notice, or even be removed.
49 //
50 // We mean it.
51 //
52 
53 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_DEVICEPROFILE_P_H
54 #define BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_DEVICEPROFILE_P_H
55 
57 
58 #include <QtCore/QSharedDataPointer>
59 #include <QtCore/QString>
60 
61 QT_BEGIN_NAMESPACE
62 
63 class QDesignerFormEditorInterface;
64 class QWidget;
65 class QStyle;
66 
67 namespace qdesigner_internal {
68 
69 class DeviceProfileData;
70 
71 /* DeviceProfile for embedded design. They influence
72  * default properties (for example, fonts), dpi and
73  * style of the form. This class represents a device
74  * profile. */
75 
77 public:
79 
83 
84  void clear();
85 
86  // Device name
87  QString name() const;
88  void setName(const QString&);
89 
90  // System settings active
91  bool isEmpty() const;
92 
93  // Default font family of the embedded system
94  QString fontFamily() const;
95  void setFontFamily(const QString&);
96 
97  // Default font size of the embedded system
98  int fontPointSize() const;
99  void setFontPointSize(int p);
100 
101  // Display resolution of the embedded system
102  int dpiX() const;
103  void setDpiX(int d);
104  int dpiY() const;
105  void setDpiY(int d);
106 
107  // Style
108  QString style() const;
109  void setStyle(const QString&);
110 
111  // Initialize from desktop system
112  void fromSystem();
113 
114  static void systemResolution(int* dpiX, int* dpiY);
115  static void widgetResolution(const QWidget* w, int* dpiX, int* dpiY);
116 
117  bool equals(const DeviceProfile& rhs) const;
118 
119  // Apply to form/preview (using font inheritance)
120  enum ApplyMode {
121  /* Pre-Apply to parent widget of form being edited: Apply font
122  * and make use of property inheritance to be able to modify the
123  * font property freely. */
125  /* Post-Apply to preview widget: Change only inherited font
126  * sub properties. */
127  ApplyPreview
128  };
129  void apply(const QDesignerFormEditorInterface* core, QWidget* widget, ApplyMode am) const;
130 
131  static void applyDPI(int dpiX, int dpiY, QWidget* widget);
132 
133  QString toString() const;
134 
135  QString toXml() const;
136  bool fromXml(const QString& xml, QString* errorMessage);
137 
138 private:
139  QSharedDataPointer<DeviceProfileData> m_d;
140 };
141 
142 inline bool operator==(const DeviceProfile& s1, const DeviceProfile& s2)
143 {
144  return s1.equals(s2);
145 }
146 inline bool operator!=(const DeviceProfile& s1, const DeviceProfile& s2)
147 {
148  return !s1.equals(s2);
149 }
150 
151 } // namespace qdesigner_internal
152 
153 QT_END_NAMESPACE
154 
155 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_DEVICEPROFILE_P_H
void apply(const QDesignerFormEditorInterface *core, QWidget *widget, ApplyMode am) const
DeviceProfile(const DeviceProfile &)
static void systemResolution(int *dpiX, int *dpiY)
bool equals(const DeviceProfile &rhs) const
DeviceProfile & operator=(const DeviceProfile &)
bool fromXml(const QString &xml, QString *errorMessage)
void setFontFamily(const QString &)
QSharedDataPointer< DeviceProfileData > m_d
static void widgetResolution(const QWidget *w, int *dpiX, int *dpiY)
void setName(const QString &)
static void applyDPI(int dpiX, int dpiY, QWidget *widget)
void setStyle(const QString &)
bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2)
bool operator==(const DeviceProfile &s1, const DeviceProfile &s2)
#define QDESIGNER_SHARED_EXPORT