mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
better implementation
This commit is contained in:
parent
5f3e31b119
commit
2ab8eb98e8
5 changed files with 52 additions and 37 deletions
|
@ -2342,6 +2342,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return viewFrustum.getPosition();
|
return viewFrustum.getPosition();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DependencyManager::get<UsersScriptingInterface>()->setKickConfirmationOperator([this] (const QUuid& nodeID) { userKickConfirmation(nodeID); });
|
||||||
|
|
||||||
render::entities::WebEntityRenderer::setAcquireWebSurfaceOperator([this](const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
|
render::entities::WebEntityRenderer::setAcquireWebSurfaceOperator([this](const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
|
||||||
bool isTablet = url == TabletScriptingInterface::QML;
|
bool isTablet = url == TabletScriptingInterface::QML;
|
||||||
if (htmlContent) {
|
if (htmlContent) {
|
||||||
|
@ -3287,6 +3289,40 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::userKickConfirmation(const QUuid& nodeID) {
|
||||||
|
auto avatarHashMap = DependencyManager::get<AvatarHashMap>();
|
||||||
|
auto avatar = avatarHashMap->getAvatarBySessionID(nodeID);
|
||||||
|
|
||||||
|
QString userName;
|
||||||
|
|
||||||
|
if (avatar) {
|
||||||
|
userName = avatar->getSessionDisplayName();
|
||||||
|
} else {
|
||||||
|
userName = nodeID.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString kickMessage = "Do you wish to kick " + userName + " from your domain";
|
||||||
|
ModalDialogListener* dlg = OffscreenUi::asyncQuestion("Kick User", kickMessage,
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
if (dlg->getDialogItem()) {
|
||||||
|
|
||||||
|
QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) {
|
||||||
|
QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr);
|
||||||
|
|
||||||
|
bool yes = (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes);
|
||||||
|
// ask the NodeList to kick the user with the given session ID
|
||||||
|
|
||||||
|
if (yes) {
|
||||||
|
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
DependencyManager::get<UsersScriptingInterface>()->setWaitForKickResponse(false);
|
||||||
|
});
|
||||||
|
DependencyManager::get<UsersScriptingInterface>()->setWaitForKickResponse(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties) {
|
void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties) {
|
||||||
surfaceContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
surfaceContext->setContextProperty("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
||||||
|
|
|
@ -593,6 +593,7 @@ private:
|
||||||
void toggleTabletUI(bool shouldOpen = false) const;
|
void toggleTabletUI(bool shouldOpen = false) const;
|
||||||
|
|
||||||
static void setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties);
|
static void setupQmlSurface(QQmlContext* surfaceContext, bool setAdditionalContextProperties);
|
||||||
|
void userKickConfirmation(const QUuid& nodeID);
|
||||||
|
|
||||||
MainWindow* _window;
|
MainWindow* _window;
|
||||||
QElapsedTimer& _sessionRunTimer;
|
QElapsedTimer& _sessionRunTimer;
|
||||||
|
|
|
@ -17,6 +17,6 @@ if (NOT ANDROID)
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
link_hifi_libraries(shared networking octree shaders gpu procedural graphics material-networking model-networking ktx recording avatars fbx hfm entities controllers animation audio physics image midi ui qml)
|
link_hifi_libraries(shared networking octree shaders gpu procedural graphics material-networking model-networking ktx recording avatars fbx hfm entities controllers animation audio physics image midi)
|
||||||
# ui includes gl, but link_hifi_libraries does not use transitive includes, so gl must be explicit
|
# ui includes gl, but link_hifi_libraries does not use transitive includes, so gl must be explicit
|
||||||
include_hifi_library_headers(gl)
|
include_hifi_library_headers(gl)
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include "UsersScriptingInterface.h"
|
#include "UsersScriptingInterface.h"
|
||||||
|
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <AvatarHashMap.h>
|
|
||||||
#include <OffscreenUi.h>
|
|
||||||
|
|
||||||
UsersScriptingInterface::UsersScriptingInterface() {
|
UsersScriptingInterface::UsersScriptingInterface() {
|
||||||
// emit a signal when kick permissions have changed
|
// emit a signal when kick permissions have changed
|
||||||
|
@ -54,43 +52,15 @@ float UsersScriptingInterface::getAvatarGain(const QUuid& nodeID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsersScriptingInterface::kick(const QUuid& nodeID) {
|
void UsersScriptingInterface::kick(const QUuid& nodeID) {
|
||||||
|
|
||||||
|
if (_kickConfirmationOperator) {
|
||||||
bool waitingForKickResponse = _kickResponseLock.resultWithReadLock<bool>([&] { return _waitingForKickResponse; });
|
bool waitingForKickResponse = _kickResponseLock.resultWithReadLock<bool>([&] { return _waitingForKickResponse; });
|
||||||
if (getCanKick() && !waitingForKickResponse) {
|
if (getCanKick() && !waitingForKickResponse) {
|
||||||
|
_kickConfirmationOperator(nodeID);
|
||||||
|
}
|
||||||
auto avatarHashMap = DependencyManager::get<AvatarHashMap>();
|
|
||||||
auto avatar = avatarHashMap->getAvatarBySessionID(nodeID);
|
|
||||||
|
|
||||||
QString userName;
|
|
||||||
|
|
||||||
if (avatar) {
|
|
||||||
userName = avatar->getSessionDisplayName();
|
|
||||||
} else {
|
} else {
|
||||||
userName = nodeID.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString kickMessage = "Do you wish to kick " + userName + " from your domain";
|
|
||||||
ModalDialogListener* dlg = OffscreenUi::asyncQuestion("Kick User", kickMessage,
|
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
|
||||||
|
|
||||||
if (dlg->getDialogItem()) {
|
|
||||||
|
|
||||||
QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) {
|
|
||||||
QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr);
|
|
||||||
|
|
||||||
bool yes = (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes);
|
|
||||||
// ask the NodeList to kick the user with the given session ID
|
|
||||||
|
|
||||||
if (yes) {
|
|
||||||
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);
|
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
_kickResponseLock.withWriteLock([&] { _waitingForKickResponse = false; });
|
|
||||||
});
|
|
||||||
|
|
||||||
_kickResponseLock.withWriteLock([&] { _waitingForKickResponse = true; });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsersScriptingInterface::mute(const QUuid& nodeID) {
|
void UsersScriptingInterface::mute(const QUuid& nodeID) {
|
||||||
|
|
|
@ -39,6 +39,12 @@ class UsersScriptingInterface : public QObject, public Dependency {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UsersScriptingInterface();
|
UsersScriptingInterface();
|
||||||
|
void setKickConfirmationOperator(std::function<void(const QUuid& nodeID)> kickConfirmationOperator) {
|
||||||
|
_kickConfirmationOperator = kickConfirmationOperator;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getWaitForKickResponse() { return _kickResponseLock.resultWithReadLock<bool>([&] { return _waitingForKickResponse; }); }
|
||||||
|
void setWaitForKickResponse(bool waitForKickResponse) { _kickResponseLock.withWriteLock([&] { _waitingForKickResponse = waitForKickResponse; }); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -197,6 +203,8 @@ private:
|
||||||
bool getRequestsDomainListData();
|
bool getRequestsDomainListData();
|
||||||
void setRequestsDomainListData(bool requests);
|
void setRequestsDomainListData(bool requests);
|
||||||
|
|
||||||
|
std::function<void(const QUuid& nodeID)> _kickConfirmationOperator;
|
||||||
|
|
||||||
ReadWriteLockable _kickResponseLock;
|
ReadWriteLockable _kickResponseLock;
|
||||||
bool _waitingForKickResponse { false };
|
bool _waitingForKickResponse { false };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue