Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -2342,6 +2342,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2341 unmodified lines | ||
| 2342 | 2342 | return viewFrustum.getPosition(); |
| 2343 | 2343 | }); |
| 2344 | 2344 | |
| 2345 | + DependencyManager::get<UsersScriptingInterface>()->setKickConfirmationOperator([this] (const QUuid& nodeID) { userKickConfirmation(nodeID); }); | |
| 2346 | + | |
| 2345 | 2347 | render::entities::WebEntityRenderer::setAcquireWebSurfaceOperator([this](const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) { |
| 2346 | 2348 | bool isTablet = url == TabletScriptingInterface::QML; |
| 2347 | 2349 | if (htmlContent) { |
| @@ -3287,6 +3289,40 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) { · 939 unmodified lines | ||
| 3287 | 3289 | #endif |
| 3288 | 3290 | } |
| 3289 | 3291 | |
| 3292 | +void Application::userKickConfirmation(const QUuid& nodeID) { | |
| 3293 | + auto avatarHashMap = DependencyManager::get<AvatarHashMap>(); | |
| 3294 | + auto avatar = avatarHashMap->getAvatarBySessionID(nodeID); | |
| 3295 | + | |
| 3296 | + QString userName; | |
| 3297 | + | |
| 3298 | + if (avatar) { | |
| 3299 | + userName = avatar->getSessionDisplayName(); | |
| 3300 | + } else { | |
| 3301 | + userName = nodeID.toString(); | |
| 3302 | + } | |
| 3303 | + | |
| 3304 | + QString kickMessage = "Do you wish to kick " + userName + " from your domain"; | |
| 3305 | + ModalDialogListener* dlg = OffscreenUi::asyncQuestion("Kick User", kickMessage, | |
| 3306 | + QMessageBox::Yes | QMessageBox::No); | |
| 3307 | + | |
| 3308 | + if (dlg->getDialogItem()) { | |
| 3309 | + | |
| 3310 | + QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) { | |
| 3311 | + QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 3312 | + | |
| 3313 | + bool yes = (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes); | |
| 3314 | + // ask the NodeList to kick the user with the given session ID | |
| 3315 | + | |
| 3316 | + if (yes) { | |
| 3317 | + DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID); | |
| 3318 | + } | |
| 3319 | + | |
| 3320 | + DependencyManager::get<UsersScriptingInterface>()->setWaitForKickResponse(false); | |
| 3321 | + }); | |
| 3322 | + DependencyManager::get<UsersScriptingInterface>()->setWaitForKickResponse(true); | |
| 3323 | + } | |
| 3324 | +} | |
| 3325 | + | |
| 3290 | 3326 | void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties) { |
| 3291 | 3327 | surfaceContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data()); |
| 3292 | 3328 | surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data()); |