diff options
author | Bernd Weimer <bernd.weimer@pelagicore.com> | 2017-11-23 17:56:38 +0100 |
---|---|---|
committer | Bernd Weimer <bernd.weimer@pelagicore.com> | 2017-11-28 09:23:35 +0000 |
commit | 75c32dd0f21913b4777a12cc1d5d9fd805a58d17 (patch) | |
tree | 6145c868d365961a6d597fe84c6e07fba7c471a1 | |
parent | 8f8b4078bd2adcf6963b5a5c248cfa7251b7b299 (diff) | |
download | qtapplicationmanager-75c32dd0f21913b4777a12cc1d5d9fd805a58d17.tar.gz |
Hide more properties in FakeApplicationManagerWindow
A decission had to be made whether the logging output (warnings)
should closely resemble the ones in multi-process mode or whether the
termination on error behavior should be the same. The latter has
been favored. For instance binding a none-existent property leads to
an abort, whereas assignment doesn't.
Task-number: AUTOSUITE-143
Change-Id: Id7b0f6eea77236855066281835ec6293ccc4850c
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r-- | src/manager-lib/fakeapplicationmanagerwindow.cpp | 54 | ||||
-rw-r--r-- | src/manager-lib/fakeapplicationmanagerwindow.h | 46 |
2 files changed, 95 insertions, 5 deletions
diff --git a/src/manager-lib/fakeapplicationmanagerwindow.cpp b/src/manager-lib/fakeapplicationmanagerwindow.cpp index 6a8c6b87..ffa65051 100644 --- a/src/manager-lib/fakeapplicationmanagerwindow.cpp +++ b/src/manager-lib/fakeapplicationmanagerwindow.cpp @@ -256,24 +256,68 @@ void FakeApplicationManagerWindow::onVisibleChanged() m_runtime->addWindow(this); } +/* The rest of the code is merely to hide properties and functions that + * are derived from QQuickItem, but are not available in real QWindows. */ + QJSValue FakeApplicationManagerWindow::getUndefined() const { return QJSValue(); } -void FakeApplicationManagerWindow::connectNotify(const QMetaMethod &signal) +void FakeApplicationManagerWindow::referenceError(const char *symbol) const { - static int parentMetaIdx = FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("parentChanged(QQuickItem*)"); +#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) + qWarning().noquote() << "ReferenceError:" << symbol << "is not defined"; +#else + qmlWarning(this) << "ReferenceError: " << symbol << " is not defined"; +#endif +} + +void FakeApplicationManagerWindow::grabToImage() const { referenceError("grabToImage"); } +void FakeApplicationManagerWindow::contains() const { referenceError("contains"); } +void FakeApplicationManagerWindow::mapFromItem() const { referenceError("mapFromItem"); } +void FakeApplicationManagerWindow::mapToItem() const { referenceError("mapToItem"); } +void FakeApplicationManagerWindow::mapFromGlobal() const { referenceError("mapFromGlobal"); } +void FakeApplicationManagerWindow::mapToGlobal() const { referenceError("mapToGlobal"); } +void FakeApplicationManagerWindow::forceActiveFocus() const { referenceError("forceActiveFocus"); } +void FakeApplicationManagerWindow::nextItemInFocusChain() const { referenceError("nextItemInFocusChain"); } +void FakeApplicationManagerWindow::childAt() const { referenceError("childAt"); } - if (signal.methodIndex() == parentMetaIdx) { +void FakeApplicationManagerWindow::connectNotify(const QMetaMethod &signal) +{ + // array of signal indices that should not be connected to + static const QVector<int> metaIndices = { + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("parentChanged(QQuickItem*)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("childrenChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("childrenRectChanged(QRectF)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("zChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("enabledChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("visibleChildrenChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("stateChanged(QString)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("clipChanged(bool)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("focusChanged(bool)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("activeFocusChanged(bool)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("activeFocusOnTabChanged(bool)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("rotationChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("scaleChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("transformOriginChanged(TransformOrigin)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("smoothChanged(bool)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("antialiasingChanged(bool)"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("implicitWidthChanged()"), + FakeApplicationManagerWindow::staticMetaObject.indexOfSignal("implicitHeightChanged()") + }; + + if (metaIndices.contains(signal.methodIndex())) { determineRuntime(); if (m_runtime) m_runtime->m_componentError = true; + QString name = qSL("on") + QString::fromUtf8(signal.name()); + name[2] = name[2].toUpper(); #if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - qWarning() << "QML ApplicationManagerWindow: Cannot assign to non-existent property \"onParentChanged\""; + qWarning() << "QML ApplicationManagerWindow: Cannot assign to non-existent property" << name; #else - qmlWarning(this) << "Cannot assign to non-existent property \"onParentChanged\""; + qmlWarning(this) << "Cannot assign to non-existent property \"" << name << "\""; #endif } } diff --git a/src/manager-lib/fakeapplicationmanagerwindow.h b/src/manager-lib/fakeapplicationmanagerwindow.h index 4a0b41d6..7b300717 100644 --- a/src/manager-lib/fakeapplicationmanagerwindow.h +++ b/src/manager-lib/fakeapplicationmanagerwindow.h @@ -68,7 +68,40 @@ class FakeApplicationManagerWindow : public QQuickItem Q_PROPERTY(bool inputEventsEnabled READ dummyGetter WRITE dummySetter) Q_PROPERTY(bool focusOnClick READ dummyGetter WRITE dummySetter) + // Hide the following properties (from QQuickIem), + // since they are not available in multi-process mode (QWindow): Q_PROPERTY(QJSValue parent READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue children READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue resources READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue z READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue enabled READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue visibleChildren READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue states READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue transitions READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue state READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue childrenRect READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue anchors READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue left READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue right READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue horizontalCenter READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue top READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue bottom READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue verticalCenter READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue baseline READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue clip READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue focus READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue activeFocus READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue activeFocusOnTab READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue rotation READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue scale READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue transformOrigin READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue transformOriginPoint READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue transform READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue smooth READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue antialiasing READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue implicitWidth READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue implicitHeight READ getUndefined CONSTANT) + Q_PROPERTY(QJSValue layer READ getUndefined CONSTANT) public: explicit FakeApplicationManagerWindow(QQuickItem *parent = nullptr); @@ -111,6 +144,18 @@ public slots: // void show() // void showMinimized() + // Hide the following functions (from QQuickIem), + // since they are not available in multi-process mode (QWindow): + Q_INVOKABLE void grabToImage() const; + Q_INVOKABLE void contains() const; + Q_INVOKABLE void mapFromItem() const; + Q_INVOKABLE void mapToItem() const; + Q_INVOKABLE void mapFromGlobal() const; + Q_INVOKABLE void mapToGlobal() const; + Q_INVOKABLE void forceActiveFocus() const; + Q_INVOKABLE void nextItemInFocusChain() const; + Q_INVOKABLE void childAt() const; + signals: void fakeCloseSignal(); void fakeFullScreenSignal(); @@ -133,6 +178,7 @@ private: void determineRuntime(); void onVisibleChanged(); QJSValue getUndefined() const; + void referenceError(const char *symbol) const; InProcessSurfaceItem *m_surfaceItem = nullptr; QSharedPointer<QObject> m_windowProperties; |