Showing the changes to libraries/script-engine/src/TabletScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <QtCore/QThread> |
| 12 | 12 | |
| 13 | 13 | #include <AudioInjector.h> |
| 14 | +#include <AccountManager.h> | |
| 14 | 15 | #include <PathUtils.h> |
| 15 | 16 | #include <RegisteredMetaTypes.h> |
| 16 | 17 | #include "ScriptEngineLogging.h" |
| @@ -166,6 +167,16 @@ static void addButtonProxyToQmlTablet(QQuickItem* qmlTablet, TabletButtonProxy* · 149 unmodified lines | ||
| 166 | 167 | buttonProxy->setQmlButton(qobject_cast<QQuickItem*>(qmlButton)); |
| 167 | 168 | } |
| 168 | 169 | |
| 170 | +static QString getUsername() { | |
| 171 | + QString username = "Unknown user"; | |
| 172 | + auto accountManager = DependencyManager::get<AccountManager>(); | |
| 173 | + if (accountManager->isLoggedIn()) { | |
| 174 | + return accountManager->getAccountInfo().getUsername(); | |
| 175 | + } else { | |
| 176 | + return "Unknown user"; | |
| 177 | + } | |
| 178 | +} | |
| 179 | + | |
| 169 | 180 | void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) { |
| 170 | 181 | std::lock_guard<std::mutex> guard(_mutex); |
| 171 | 182 | _qmlOffscreenSurface = qmlOffscreenSurface; |
| @@ -173,6 +184,16 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr · 1 unmodified line | ||
| 173 | 184 | if (_qmlTabletRoot && _qmlOffscreenSurface) { |
| 174 | 185 | QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant))); |
| 175 | 186 | gotoHomeScreen(); |
| 187 | + | |
| 188 | + QMetaObject::invokeMethod(_qmlTabletRoot, "setUsername", Q_ARG(const QVariant&, QVariant(getUsername()))); | |
| 189 | + | |
| 190 | + // hook up username changed signal. | |
| 191 | + auto accountManager = DependencyManager::get<AccountManager>(); | |
| 192 | + QObject::connect(accountManager.data(), &AccountManager::profileChanged, [this]() { | |
| 193 | + if (_qmlTabletRoot) { | |
| 194 | + QMetaObject::invokeMethod(_qmlTabletRoot, "setUsername", Q_ARG(const QVariant&, QVariant(getUsername()))); | |
| 195 | + } | |
| 196 | + }); | |
| 176 | 197 | } else { |
| 177 | 198 | removeButtonsFromHomeScreen(); |
| 178 | 199 | _state = State::Uninitialized; |
| @@ -196,7 +217,7 @@ void TabletProxy::gotoHomeScreen() { · 17 unmodified lines | ||
| 196 | 217 | auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader"); |
| 197 | 218 | QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen())); |
| 198 | 219 | QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL))); |
| 199 | − QMetaObject::invokeMethod(_qmlTabletRoot, "playButtonClickSound"); | |
| 220 | + QMetaObject::invokeMethod(_qmlTabletRoot, "playButtonClickSound"); | |
| 200 | 221 | _state = State::Home; |
| 201 | 222 | } |
| 202 | 223 | } |