add ui to kick api

This commit is contained in:
danteruiz 2019-03-15 18:15:18 -07:00
parent 98eec6b74d
commit 5f3e31b119
8 changed files with 56 additions and 6 deletions

View file

@ -28,7 +28,7 @@ TabletModalWindow {
id: mouse;
anchors.fill: parent
}
function click(button) {
clickedButton = button;
selected(button);

View file

@ -117,7 +117,6 @@ Rectangle {
if (loader.item.hasOwnProperty("gotoPreviousApp")) {
loader.item.gotoPreviousApp = true;
}
screenChanged("Web", url)
});
}

View file

@ -17,6 +17,6 @@ if (NOT ANDROID)
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)
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)
# ui includes gl, but link_hifi_libraries does not use transitive includes, so gl must be explicit
include_hifi_library_headers(gl)

View file

@ -12,6 +12,8 @@
#include "UsersScriptingInterface.h"
#include <NodeList.h>
#include <AvatarHashMap.h>
#include <OffscreenUi.h>
UsersScriptingInterface::UsersScriptingInterface() {
// emit a signal when kick permissions have changed
@ -52,8 +54,43 @@ float UsersScriptingInterface::getAvatarGain(const QUuid& nodeID) {
}
void UsersScriptingInterface::kick(const QUuid& nodeID) {
// ask the NodeList to kick the user with the given session ID
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);
bool waitingForKickResponse = _kickResponseLock.resultWithReadLock<bool>([&] { return _waitingForKickResponse; });
if (getCanKick() && !waitingForKickResponse) {
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);
}
_kickResponseLock.withWriteLock([&] { _waitingForKickResponse = false; });
});
_kickResponseLock.withWriteLock([&] { _waitingForKickResponse = true; });
}
}
}
void UsersScriptingInterface::mute(const QUuid& nodeID) {

View file

@ -15,6 +15,7 @@
#define hifi_UsersScriptingInterface_h
#include <DependencyManager.h>
#include <shared/ReadWriteLockable.h>
/**jsdoc
* @namespace Users
@ -195,6 +196,9 @@ signals:
private:
bool getRequestsDomainListData();
void setRequestsDomainListData(bool requests);
ReadWriteLockable _kickResponseLock;
bool _waitingForKickResponse { false };
};

View file

@ -240,6 +240,12 @@ class MessageBoxListener : public ModalDialogListener {
return static_cast<QMessageBox::StandardButton>(_result.toInt());
}
protected slots:
virtual void onDestroyed() override {
ModalDialogListener::onDestroyed();
onSelected(QMessageBox::NoButton);
}
private slots:
void onSelected(int button) {
_result = button;

View file

@ -34,6 +34,9 @@ class ModalDialogListener : public QObject {
Q_OBJECT
friend class OffscreenUi;
public:
QQuickItem* getDialogItem() { return _dialog; };
protected:
ModalDialogListener(QQuickItem* dialog);
virtual ~ModalDialogListener();
@ -43,7 +46,7 @@ signals:
void response(const QVariant& value);
protected slots:
void onDestroyed();
virtual void onDestroyed();
protected:
QQuickItem* _dialog;

View file

@ -368,6 +368,7 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
if (toolbarMode) {
#if !defined(DISABLE_QML)
closeDialog();
// create new desktop window
auto tabletRootWindow = new TabletRootWindow();
tabletRootWindow->initQml(QVariantMap());