| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the Qt Designer of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 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 DEVICEPROFILE_H
|
|---|
| 54 | #define DEVICEPROFILE_H
|
|---|
| 55 |
|
|---|
| 56 | #include "shared_global_p.h"
|
|---|
| 57 |
|
|---|
| 58 | #include <QtCore/QString>
|
|---|
| 59 | #include <QtCore/QSharedDataPointer>
|
|---|
| 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 |
|
|---|
| 76 | class QDESIGNER_SHARED_EXPORT DeviceProfile {
|
|---|
| 77 | public:
|
|---|
| 78 | DeviceProfile();
|
|---|
| 79 |
|
|---|
| 80 | DeviceProfile(const DeviceProfile&);
|
|---|
| 81 | DeviceProfile& operator=(const DeviceProfile&);
|
|---|
| 82 | ~DeviceProfile();
|
|---|
| 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. */
|
|---|
| 124 | ApplyFormParent,
|
|---|
| 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 | { return s1.equals(s2); }
|
|---|
| 144 | inline bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2)
|
|---|
| 145 | { return !s1.equals(s2); }
|
|---|
| 146 |
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | QT_END_NAMESPACE
|
|---|
| 151 |
|
|---|
| 152 | #endif // DEVICEPROFILE_H
|
|---|