6#include <QtCore/qiodevice.h>
7#include <QtGui/qwindow.h>
8#include <QtGui/qscreen.h>
9#include <QtGui/qguiapplication.h>
10#include <QtCore/QIODevice>
11#include <private/qhighdpiscaling_p.h>
55 : m_settings(
"QtProject",
"QtQmlPreview")
79 m_savePositionTimer.
start();
85void QQmlPreviewPosition::saveWindowPosition()
88 const QByteArray positionAsByteArray = fromPositionToByteArray(m_lastWindowPosition);
89 if (!m_settingsKey.
isNull())
90 m_settings.
setValue(m_settingsKey, positionAsByteArray);
100 if (m_settings.
contains(m_settingsKey)) {
101 m_hasPosition =
true;
102 readLastPositionFromByteArray(m_settings.
value(m_settingsKey).
toByteArray());
110 if (m_currentInitScreensData.isEmpty())
113 if (!m_hasPosition) {
122QByteArray QQmlPreviewPosition::fromPositionToByteArray(
129 const quint16 majorVersion = 1;
130 const quint16 minorVersion = 0;
132 stream << majorVersion << minorVersion << m_currentInitScreensData <<
position.screenName
137void QQmlPreviewPosition::readLastPositionFromByteArray(
const QByteArray &
array)
147 stream >> majorVersion >> minorVersion;
164 if (nativePosition.
isNull())
170 m_lastWindowPosition = { nameOfScreen, nativePosition,
size };
176 if (
position.nativePosition.isNull())
185 window->setFramePosition(point);
187 qWarning(
"preview position is out of screen");
\inmodule QtCore\reentrant
static QList< QScreen * > screens()
Returns a list of all the screens associated with the windowing system the application is connected t...
static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen)
void append(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
bool operator==(const QQmlPreviewPosition::ScreenData &other) const
void loadWindowPositionSettings(const QUrl &url)
void takePosition(QWindow *window, InitializeState state=PositionInitialized)
void initLastSavedWindowPosition(QWindow *window)
\inmodule QtCore\reentrant
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QScreen class is used to query screen properties. \inmodule QtGui.
QRect geometry
the screen's geometry in pixels
QRect virtualGeometry
the pixel geometry of the virtual desktop to which this screen belongs
QString name
a user presentable string representing the screen
QPlatformScreen * handle() const
Get the platform screen handle.
bool contains(QAnyStringView key) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(QAnyStringView key, const QVariant &value)
Sets the value of setting key to value.
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isNull() const
Returns true if this string is null; otherwise returns false.
void setSingleShot(bool singleShot)
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
void setInterval(int msec)
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
Combined button and popup list for selecting options.
n void setPosition(void) \n\
GLenum GLuint GLintptr GLsizeiptr size
[1]
static QT_BEGIN_NAMESPACE QVector< QQmlPreviewPosition::ScreenData > initScreensData()
static QDataStream & operator<<(QDataStream &out, const QQmlPreviewPosition::ScreenData &screenData)
static QScreen * findScreen(const QString &nameOfScreen)
static QDataStream & operator>>(QDataStream &in, QQmlPreviewPosition::ScreenData &screenData)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QLatin1StringView QLatin1String
QTextStream out(stdout)
[7]
QUrl url("example.com")
[constructor-url-reference]