History

better implementation

danteruiz committed 7 years ago

Commit 2ab8eb91 parent 5f3e31b5 files · +52 −37Browse files

Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all

Unified · Split

interface/src/Application.cpp+36−0
@@ -2342,6 +2342,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2341 unmodified lines
23422342 return viewFrustum.getPosition();
23432343 });
23442344
2345+ DependencyManager::get<UsersScriptingInterface>()->setKickConfirmationOperator([this] (const QUuid& nodeID) { userKickConfirmation(nodeID); });
2346+
23452347 render::entities::WebEntityRenderer::setAcquireWebSurfaceOperator([this](const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
23462348 bool isTablet = url == TabletScriptingInterface::QML;
23472349 if (htmlContent) {
@@ -3287,6 +3289,40 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) { · 939 unmodified lines
32873289 #endif
32883290 }
32893291
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+
32903326 void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties) {
32913327 surfaceContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
32923328 surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t