mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 01:04:06 +02:00
Fix bad invocation, cleanup signatures
This commit is contained in:
parent
d50c448151
commit
341646c780
2 changed files with 27 additions and 40 deletions
|
@ -182,7 +182,7 @@ class TabletRootWindow : public QmlWindowClass {
|
|||
virtual QString qmlSource() const override { return "hifi/tablet/WindowRoot.qml"; }
|
||||
};
|
||||
|
||||
TabletProxy::TabletProxy(QObject* parent, QString name) : QObject(parent), _name(name) {
|
||||
TabletProxy::TabletProxy(QObject* parent, const QString& name) : QObject(parent), _name(name) {
|
||||
if (QThread::currentThread() != qApp->thread()) {
|
||||
qCWarning(uiLogging) << "Creating tablet proxy on wrong thread " << _name;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ bool TabletProxy::isMessageDialogOpen() {
|
|||
return result.toBool();
|
||||
}
|
||||
|
||||
void TabletProxy::emitWebEvent(QVariant msg) {
|
||||
void TabletProxy::emitWebEvent(const QVariant& msg) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitWebEvent", Q_ARG(QVariant, msg));
|
||||
return;
|
||||
|
@ -314,7 +314,7 @@ void TabletProxy::emitWebEvent(QVariant msg) {
|
|||
emit webEventReceived(msg);
|
||||
}
|
||||
|
||||
bool TabletProxy::isPathLoaded(QVariant path) {
|
||||
bool TabletProxy::isPathLoaded(const QVariant& path) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
bool result = false;
|
||||
QMetaObject::invokeMethod(this, "isPathLoaded", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, result), Q_ARG(QVariant, path));
|
||||
|
@ -620,8 +620,7 @@ TabletButtonProxy* TabletProxy::addButton(const QVariant& properties) {
|
|||
qCCritical(uiLogging) << "Could not find tablet in TabletRoot.qml";
|
||||
}
|
||||
} else if (_toolbarMode) {
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
auto toolbarProxy = tabletScriptingInterface->getSystemToolbarProxy();
|
||||
auto toolbarProxy = DependencyManager::get<TabletScriptingInterface>()->getSystemToolbarProxy();
|
||||
if (toolbarProxy) {
|
||||
// copy properties from tablet button proxy to toolbar button proxy.
|
||||
toolbarProxy->addButton(tabletButtonProxy->getProperties());
|
||||
|
@ -668,15 +667,16 @@ void TabletProxy::removeButton(TabletButtonProxy* tabletButtonProxy) {
|
|||
QMetaObject::invokeMethod(tablet, "removeButtonProxy", Qt::AutoConnection, Q_ARG(QVariant, buttonProxy->getProperties()));
|
||||
}
|
||||
} else if (_toolbarMode) {
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
QObject* toolbarProxy = tabletScriptingInterface->getSystemToolbarProxy();
|
||||
auto toolbarProxy = DependencyManager::get<TabletScriptingInterface>()->getSystemToolbarProxy();
|
||||
// remove button from toolbarProxy
|
||||
QMetaObject::invokeMethod(toolbarProxy, "removeButton", Qt::AutoConnection, Q_ARG(QVariant, buttonProxy->getUuid().toString()));
|
||||
buttonProxy->setToolbarButtonProxy(nullptr);
|
||||
if (toolbarProxy) {
|
||||
toolbarProxy->removeButton(buttonProxy->getUuid().toString());
|
||||
buttonProxy->setToolbarButtonProxy(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabletProxy::emitScriptEvent(QVariant msg) {
|
||||
void TabletProxy::emitScriptEvent(const QVariant& msg) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitScriptEvent", Q_ARG(QVariant, msg));
|
||||
return;
|
||||
|
@ -689,7 +689,7 @@ void TabletProxy::emitScriptEvent(QVariant msg) {
|
|||
}
|
||||
}
|
||||
|
||||
void TabletProxy::sendToQml(QVariant msg) {
|
||||
void TabletProxy::sendToQml(const QVariant& msg) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "sendToQml", Q_ARG(QVariant, msg));
|
||||
return;
|
||||
|
@ -707,8 +707,6 @@ void TabletProxy::addButtonsToHomeScreen() {
|
|||
if (!tablet || _toolbarMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
addButtonProxyToQmlTablet(tablet, buttonProxy.data());
|
||||
}
|
||||
|
@ -735,35 +733,23 @@ void TabletProxy::desktopWindowClosed() {
|
|||
}
|
||||
|
||||
void TabletProxy::addButtonsToToolbar() {
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
QObject* toolbarProxy = tabletScriptingInterface->getSystemToolbarProxy();
|
||||
|
||||
Qt::ConnectionType connectionType = Qt::AutoConnection;
|
||||
if (QThread::currentThread() != toolbarProxy->thread()) {
|
||||
connectionType = Qt::BlockingQueuedConnection;
|
||||
}
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
ToolbarProxy* toolbarProxy = DependencyManager::get<TabletScriptingInterface>()->getSystemToolbarProxy();
|
||||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
// copy properties from tablet button proxy to toolbar button proxy.
|
||||
QObject* toolbarButtonProxy = nullptr;
|
||||
bool hasResult = QMetaObject::invokeMethod(toolbarProxy, "addButton", connectionType, Q_RETURN_ARG(QObject*, toolbarButtonProxy), Q_ARG(QVariant, buttonProxy->getProperties()));
|
||||
if (hasResult) {
|
||||
buttonProxy->setToolbarButtonProxy(toolbarButtonProxy);
|
||||
} else {
|
||||
qCWarning(uiLogging) << "ToolbarProxy addButton has no result";
|
||||
}
|
||||
buttonProxy->setToolbarButtonProxy(toolbarProxy->addButton(buttonProxy->getProperties()));
|
||||
}
|
||||
|
||||
// make the toolbar visible
|
||||
QMetaObject::invokeMethod(toolbarProxy, "writeProperty", Qt::AutoConnection, Q_ARG(QString, "visible"), Q_ARG(QVariant, QVariant(true)));
|
||||
toolbarProxy->writeProperty("visible", QVariant(true));
|
||||
}
|
||||
|
||||
void TabletProxy::removeButtonsFromToolbar() {
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
QObject* toolbarProxy = tabletScriptingInterface->getSystemToolbarProxy();
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
ToolbarProxy* toolbarProxy = DependencyManager::get<TabletScriptingInterface>()->getSystemToolbarProxy();
|
||||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
// remove button from toolbarProxy
|
||||
QMetaObject::invokeMethod(toolbarProxy, "removeButton", Qt::AutoConnection, Q_ARG(QVariant, buttonProxy->getUuid().toString()));
|
||||
toolbarProxy->removeButton(buttonProxy->getUuid().toString());
|
||||
buttonProxy->setToolbarButtonProxy(nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -843,6 +829,7 @@ void TabletButtonProxy::setQmlButton(QQuickItem* qmlButton) {
|
|||
}
|
||||
|
||||
void TabletButtonProxy::setToolbarButtonProxy(QObject* toolbarButtonProxy) {
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
_toolbarButtonProxy = toolbarButtonProxy;
|
||||
if (_toolbarButtonProxy) {
|
||||
QObject::connect(_toolbarButtonProxy, SIGNAL(clicked()), this, SLOT(clickedSlot()));
|
||||
|
@ -859,9 +846,9 @@ QVariantMap TabletButtonProxy::getProperties() {
|
|||
return _properties;
|
||||
}
|
||||
|
||||
void TabletButtonProxy::editProperties(QVariantMap properties) {
|
||||
void TabletButtonProxy::editProperties(const QVariantMap& properties) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "editProperties", Qt::BlockingQueuedConnection, Q_ARG(QVariantMap, properties));
|
||||
QMetaObject::invokeMethod(this, "editProperties", Q_ARG(QVariantMap, properties));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class TabletProxy : public QObject {
|
|||
Q_PROPERTY(bool landscape READ getLandscape WRITE setLandscape)
|
||||
Q_PROPERTY(bool tabletShown MEMBER _tabletShown NOTIFY tabletShownChanged)
|
||||
public:
|
||||
TabletProxy(QObject* parent, QString name);
|
||||
TabletProxy(QObject* parent, const QString& name);
|
||||
~TabletProxy();
|
||||
|
||||
void setQmlTabletRoot(OffscreenQmlSurface* offscreenQmlSurface);
|
||||
|
@ -163,14 +163,14 @@ public:
|
|||
* @function TabletProxy#emitScriptEvent
|
||||
* @param msg {object|string}
|
||||
*/
|
||||
Q_INVOKABLE void emitScriptEvent(QVariant msg);
|
||||
Q_INVOKABLE void emitScriptEvent(const QVariant& msg);
|
||||
|
||||
/**jsdoc
|
||||
* Used to send an event to the qml embedded in the tablet
|
||||
* @function TabletProxy#sendToQml
|
||||
* @param msg {object|string}
|
||||
*/
|
||||
Q_INVOKABLE void sendToQml(QVariant msg);
|
||||
Q_INVOKABLE void sendToQml(const QVariant& msg);
|
||||
|
||||
/**jsdoc
|
||||
* Check if the tablet is on the homescreen
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
Q_INVOKABLE void setLandscape(bool landscape) { _landscape = landscape; }
|
||||
Q_INVOKABLE bool getLandscape() { return _landscape; }
|
||||
|
||||
Q_INVOKABLE bool isPathLoaded(QVariant path);
|
||||
Q_INVOKABLE bool isPathLoaded(const QVariant& path);
|
||||
|
||||
QQuickItem* getTabletRoot() const { return _qmlTabletRoot; }
|
||||
|
||||
|
@ -231,7 +231,7 @@ signals:
|
|||
protected slots:
|
||||
void addButtonsToHomeScreen();
|
||||
void desktopWindowClosed();
|
||||
void emitWebEvent(QVariant msg);
|
||||
void emitWebEvent(const QVariant& msg);
|
||||
protected:
|
||||
void removeButtonsFromHomeScreen();
|
||||
void loadHomeScreen(bool forceOntoHomeScreen);
|
||||
|
@ -284,7 +284,7 @@ public:
|
|||
* @function TabletButtonProxy#editProperties
|
||||
* @param {ButtonProperties} properties - set of properties to change
|
||||
*/
|
||||
Q_INVOKABLE void editProperties(QVariantMap properties);
|
||||
Q_INVOKABLE void editProperties(const QVariantMap& properties);
|
||||
|
||||
public slots:
|
||||
void clickedSlot() { emit clicked(); }
|
||||
|
|
Loading…
Reference in a new issue