mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Make users.js show QML window for edit friends
This commit is contained in:
parent
cede14fdc6
commit
f24f2749e1
7 changed files with 36 additions and 39 deletions
|
@ -235,7 +235,12 @@ var usersWindow = (function () {
|
|||
FRIENDS_BUTTON_HEIGHT = FRIENDS_BUTTON_SVG_HEIGHT,
|
||||
FRIENDS_BUTTON_COLOR = { red: 225, green: 225, blue: 225 },
|
||||
FRIENDS_BUTTON_ALPHA = 0.95,
|
||||
FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends",
|
||||
FRIENDS_WINDOW_WIDTH = 290,
|
||||
FRIENDS_WINDOW_HEIGHT = 500,
|
||||
FRIENDS_WINDOW_TITLE = "Add/Remove Friends",
|
||||
friendsButton,
|
||||
friendsWindow,
|
||||
|
||||
OPTION_BACKGROUND_COLOR = { red: 60, green: 60, blue: 60 },
|
||||
OPTION_BACKGROUND_ALPHA = 0.1,
|
||||
|
@ -643,7 +648,17 @@ var usersWindow = (function () {
|
|||
}
|
||||
|
||||
if (clickedOverlay === friendsButton) {
|
||||
GlobalServices.editFriends();
|
||||
if (!friendsWindow) {
|
||||
friendsWindow = new OverlayWebWindow({
|
||||
title: FRIENDS_WINDOW_TITLE,
|
||||
width: FRIENDS_WINDOW_WIDTH,
|
||||
height: FRIENDS_WINDOW_HEIGHT,
|
||||
visible: false
|
||||
});
|
||||
}
|
||||
friendsWindow.setURL(FRIENDS_WINDOW_URL);
|
||||
friendsWindow.setVisible(true);
|
||||
friendsWindow.raise();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4615,22 +4615,6 @@ void Application::activeChanged(Qt::ApplicationState state) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
void Application::showFriendsWindow() {
|
||||
const QString FRIENDS_WINDOW_OBJECT_NAME = "FriendsWindow";
|
||||
const QString FRIENDS_WINDOW_TITLE = "Add/Remove Friends";
|
||||
const QString FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends";
|
||||
const int FRIENDS_WINDOW_WIDTH = 290;
|
||||
const int FRIENDS_WINDOW_HEIGHT = 500;
|
||||
auto webWindowClass = _window->findChildren<WebWindowClass>(FRIENDS_WINDOW_OBJECT_NAME);
|
||||
if (webWindowClass.empty()) {
|
||||
auto friendsWindow = new WebWindowClass(FRIENDS_WINDOW_TITLE, FRIENDS_WINDOW_URL, FRIENDS_WINDOW_WIDTH,
|
||||
FRIENDS_WINDOW_HEIGHT);
|
||||
friendsWindow->setParent(_window);
|
||||
friendsWindow->setObjectName(FRIENDS_WINDOW_OBJECT_NAME);
|
||||
connect(friendsWindow, &WebWindowClass::closed, &WebWindowClass::deleteLater);
|
||||
friendsWindow->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::postLambdaEvent(std::function<void()> f) {
|
||||
if (this->thread() == QThread::currentThread()) {
|
||||
|
|
|
@ -245,8 +245,6 @@ public slots:
|
|||
void handleLocalServerConnection();
|
||||
void readArgumentsFromLocalSocket();
|
||||
|
||||
void showFriendsWindow();
|
||||
|
||||
void packageModel();
|
||||
|
||||
void openUrl(const QUrl& url);
|
||||
|
|
|
@ -144,6 +144,3 @@ void GlobalServicesScriptingInterface::updateDownloadInfo() {
|
|||
emit downloadInfoChanged(getDownloadInfo());
|
||||
}
|
||||
|
||||
void GlobalServicesScriptingInterface::editFriends() {
|
||||
QMetaObject::invokeMethod(qApp, "showFriendsWindow");
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ public:
|
|||
public slots:
|
||||
DownloadInfoResult getDownloadInfo();
|
||||
void updateDownloadInfo();
|
||||
void editFriends();
|
||||
|
||||
|
||||
private slots:
|
||||
void loggedOut();
|
||||
void checkDownloadInfo();
|
||||
|
|
|
@ -45,6 +45,20 @@ private:
|
|||
bool _navigationFocused { false };
|
||||
};
|
||||
|
||||
QString fixupHifiUrl(const QString& urlString) {
|
||||
static const QString ACCESS_TOKEN_PARAMETER = "access_token";
|
||||
static const QString ALLOWED_HOST = "metaverse.highfidelity.com";
|
||||
QUrl url(urlString);
|
||||
QUrlQuery query(url);
|
||||
if (url.host() == ALLOWED_HOST && query.allQueryItemValues(ACCESS_TOKEN_PARAMETER).empty()) {
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
query.addQueryItem(ACCESS_TOKEN_PARAMETER, accountManager.getAccountInfo().getAccessToken().token);
|
||||
url.setQuery(query.query());
|
||||
return url.toString();
|
||||
}
|
||||
return urlString;
|
||||
}
|
||||
|
||||
class UrlHandler : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -60,20 +74,7 @@ public:
|
|||
|
||||
// FIXME hack for authentication, remove when we migrate to Qt 5.6
|
||||
Q_INVOKABLE QString fixupUrl(const QString& originalUrl) {
|
||||
static const QString ACCESS_TOKEN_PARAMETER = "access_token";
|
||||
static const QString ALLOWED_HOST = "metaverse.highfidelity.com";
|
||||
QString result = originalUrl;
|
||||
QUrl url(originalUrl);
|
||||
QUrlQuery query(url);
|
||||
if (url.host() == ALLOWED_HOST && query.allQueryItemValues(ACCESS_TOKEN_PARAMETER).empty()) {
|
||||
qDebug() << "Updating URL with auth token";
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
query.addQueryItem(ACCESS_TOKEN_PARAMETER, accountManager.getAccountInfo().getAccessToken().token);
|
||||
url.setQuery(query.query());
|
||||
result = url.toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
return fixupHifiUrl(originalUrl);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -49,8 +49,11 @@ QString QmlWebWindowClass::getURL() const {
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
// HACK find a good place to declare and store this
|
||||
extern QString fixupHifiUrl(const QString& urlString);
|
||||
|
||||
void QmlWebWindowClass::setURL(const QString& urlString) {
|
||||
DependencyManager::get<OffscreenUi>()->executeOnUiThread([=] {
|
||||
_qmlWindow->setProperty(URL_PROPERTY, urlString);
|
||||
_qmlWindow->setProperty(URL_PROPERTY, fixupHifiUrl(urlString));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue