Skip to content

Commit a0ba291

Browse files
committed
Remove deprecated usage of setUserData
This removes the usage of QObjectUserData, setUserData and userData. Fixes #1305
1 parent 8c60ba6 commit a0ba291

4 files changed

Lines changed: 155 additions & 147 deletions

File tree

libraries/ui/src/OffscreenUi.cpp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
* <p><em>This API currently has no effect and is not used.</em></p>
3939
*
4040
* @namespace OffscreenFlags
41-
*
41+
*
4242
* @hifi-interface
4343
* @hifi-client-entity
4444
* @hifi-avatar
4545
*
46-
* @property {boolean} navigationFocused - <code>true</code> if UI has joystick navigation focus, <code>false</code> if it
46+
* @property {boolean} navigationFocused - <code>true</code> if UI has joystick navigation focus, <code>false</code> if it
4747
* doesn't.
48-
* @property {boolean} navigationFocusDisabled - <code>true</code> if UI joystick navigation focus is disabled,
48+
* @property {boolean} navigationFocusDisabled - <code>true</code> if UI joystick navigation focus is disabled,
4949
* <code>false</code> if it isn't.
5050
*/
5151

@@ -75,7 +75,7 @@ class OffscreenFlags : public QObject {
7575
emit navigationFocusDisabledChanged();
7676
}
7777
}
78-
78+
7979
signals:
8080

8181
/*@jsdoc
@@ -99,9 +99,9 @@ class OffscreenFlags : public QObject {
9999

100100
static OffscreenFlags* offscreenFlags { nullptr };
101101

102-
// This hack allows the QML UI to work with keys that are also bound as
103-
// shortcuts at the application level. However, it seems as though the
104-
// bound actions are still getting triggered. At least for backspace.
102+
// This hack allows the QML UI to work with keys that are also bound as
103+
// shortcuts at the application level. However, it seems as though the
104+
// bound actions are still getting triggered. At least for backspace.
105105
// Not sure why.
106106
//
107107
// However, the problem may go away once we switch to the new menu system,
@@ -168,7 +168,7 @@ void OffscreenUi::onRootContextCreated(QQmlContext* qmlContext) {
168168
qmlContext->setContextProperty("fileDialogHelper", new FileDialogHelper());
169169
#ifdef DEBUG
170170
qmlContext->setContextProperty("DebugQML", QVariant(true));
171-
#else
171+
#else
172172
qmlContext->setContextProperty("DebugQML", QVariant(false));
173173
#endif
174174

@@ -284,7 +284,7 @@ QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const
284284
map.insert("buttons", buttons.operator int());
285285
map.insert("defaultButton", defaultButton);
286286
QVariant result;
287-
bool invokeResult;
287+
bool invokeResult = false;
288288
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
289289
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
290290
if (tablet->getToolbarMode() && _desktop) {
@@ -309,7 +309,7 @@ int OffscreenUi::waitForMessageBoxResult(QQuickItem* messageBox) {
309309
if (!messageBox) {
310310
return QMessageBox::NoButton;
311311
}
312-
312+
313313
return MessageBoxListener(messageBox).waitForButtonResult();
314314
}
315315

@@ -424,8 +424,8 @@ QString OffscreenUi::getText(const Icon icon, const QString& title, const QStrin
424424
QString OffscreenUi::getItem(const Icon icon, const QString& title, const QString& label, const QStringList& items,
425425
int current, bool editable, bool* ok) {
426426

427-
if (ok) {
428-
*ok = false;
427+
if (ok) {
428+
*ok = false;
429429
}
430430

431431
auto offscreenUi = DependencyManager::get<OffscreenUi>();
@@ -580,7 +580,7 @@ QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title
580580
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
581581
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
582582

583-
bool invokeResult;
583+
bool invokeResult = false;
584584
if (tablet->getToolbarMode() && _desktop) {
585585
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
586586
Q_RETURN_ARG(QVariant, result),
@@ -608,7 +608,7 @@ QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString&
608608
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
609609
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
610610

611-
bool invokeResult;
611+
bool invokeResult = false;
612612
if (tablet->getToolbarMode() && _desktop) {
613613
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
614614
Q_RETURN_ARG(QVariant, result),
@@ -619,7 +619,7 @@ QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString&
619619
Q_ARG(QVariant, QVariant::fromValue(map)));
620620
emit tabletScriptingInterface->tabletNotification();
621621
}
622-
622+
623623
if (!invokeResult) {
624624
qWarning() << "Failed to create custom message box";
625625
return nullptr;
@@ -648,13 +648,13 @@ void OffscreenUi::setNavigationFocused(bool focused) {
648648
// FIXME HACK....
649649
// This hack is an attempt to work around the 'offscreen UI can't gain keyboard focus' bug
650650
// https://app.asana.com/0/27650181942747/83176475832393
651-
// The problem seems related to https://bugreports.qt.io/browse/QTBUG-50309
651+
// The problem seems related to https://bugreports.qt.io/browse/QTBUG-50309
652652
//
653653
// The workaround seems to be to give some other window (same process or another process doesn't seem to matter)
654-
// focus and then put focus back on the interface main window.
654+
// focus and then put focus back on the interface main window.
655655
//
656-
// If I could reliably reproduce this bug I could eventually track down what state change is occuring
657-
// during the process of the main window losing and then gaining focus, but failing that, here's a
656+
// If I could reliably reproduce this bug I could eventually track down what state change is occuring
657+
// during the process of the main window losing and then gaining focus, but failing that, here's a
658658
// brute force way of triggering that state change at application start in a way that should be nearly
659659
// imperceptible to the user.
660660
class KeyboardFocusHack : public QObject {
@@ -754,7 +754,7 @@ private slots:
754754

755755
QString OffscreenUi::fileDialog(const QVariantMap& properties) {
756756
QVariant buildDialogResult;
757-
bool invokeResult;
757+
bool invokeResult = false;
758758
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
759759
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
760760
if (tablet->getToolbarMode() && _desktop) {
@@ -783,7 +783,7 @@ QString OffscreenUi::fileDialog(const QVariantMap& properties) {
783783

784784
ModalDialogListener* OffscreenUi::fileDialogAsync(const QVariantMap& properties) {
785785
QVariant buildDialogResult;
786-
bool invokeResult;
786+
bool invokeResult = false;
787787
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
788788
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
789789
if (tablet->getToolbarMode() && _desktop) {
@@ -1003,7 +1003,7 @@ class AssetDialogListener : public ModalDialogListener {
10031003
QString OffscreenUi::assetDialog(const QVariantMap& properties) {
10041004
// ATP equivalent of fileDialog().
10051005
QVariant buildDialogResult;
1006-
bool invokeResult;
1006+
bool invokeResult = false;
10071007
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
10081008
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
10091009
if (tablet->getToolbarMode() && _desktop) {
@@ -1033,7 +1033,7 @@ QString OffscreenUi::assetDialog(const QVariantMap& properties) {
10331033
ModalDialogListener *OffscreenUi::assetDialogAsync(const QVariantMap& properties) {
10341034
// ATP equivalent of fileDialog().
10351035
QVariant buildDialogResult;
1036-
bool invokeResult;
1036+
bool invokeResult = false;
10371037
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
10381038
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
10391039
if (tablet->getToolbarMode() && _desktop) {
@@ -1165,7 +1165,7 @@ bool OffscreenUi::eventFilter(QObject* originalDestination, QEvent* event) {
11651165
}
11661166

11671167
// QML input elements absorb key press, but apparently not key release.
1168-
// therefore we want to ensure that key release events for key presses that were
1168+
// therefore we want to ensure that key release events for key presses that were
11691169
// accepted by the QML layer are suppressed
11701170
if (type == QEvent::KeyRelease && pressed) {
11711171
pressed = false;
@@ -1175,10 +1175,6 @@ bool OffscreenUi::eventFilter(QObject* originalDestination, QEvent* event) {
11751175
return result;
11761176
}
11771177

1178-
unsigned int OffscreenUi::getMenuUserDataId() const {
1179-
return _vrMenu->_userDataId;
1180-
}
1181-
11821178
ModalDialogListener::ModalDialogListener(QQuickItem *dialog) : _dialog(dialog) {
11831179
if (!dialog) {
11841180
_finished = true;

libraries/ui/src/OffscreenUi.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class OffscreenUi : public OffscreenQmlSurface, public Dependency {
7474

7575
// Setting pinned to true will hide all overlay elements on the desktop that don't have a pinned flag
7676
void setPinned(bool pinned = true);
77-
77+
7878
void togglePinned();
7979
void setConstrainToolbarToCenterX(bool constrained);
8080

@@ -237,7 +237,6 @@ class OffscreenUi : public OffscreenQmlSurface, public Dependency {
237237
static ModalDialogListener* getTextAsync(const Icon icon, const QString & title, const QString & label, const QString & text = QString());
238238
static ModalDialogListener* getItemAsync(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true);
239239

240-
unsigned int getMenuUserDataId() const;
241240
QList<QObject *> &getModalDialogListeners();
242241

243242
signals:
@@ -270,7 +269,7 @@ private slots:
270269
QList<QObject*> _modalDialogListeners;
271270
std::unordered_map<int, bool> _pressedKeys;
272271
VrMenu* _vrMenu { nullptr };
273-
QQueue<std::function<void(VrMenu*)>> _queuedMenuInitializers;
272+
QQueue<std::function<void(VrMenu*)>> _queuedMenuInitializers;
274273
};
275274

276275
#endif

0 commit comments

Comments
 (0)