mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +02:00
Added username to tablet header
This commit is contained in:
parent
d2f024e84d
commit
bff0eeef75
3 changed files with 48 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
import "../../styles-uit"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: tablet
|
id: tablet
|
||||||
|
@ -98,8 +99,10 @@ Item {
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: item1
|
id: item1
|
||||||
width: 225
|
width: 170
|
||||||
height: 10
|
height: 10
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 50
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: audioBarBase
|
id: audioBarBase
|
||||||
|
@ -123,18 +126,18 @@ Item {
|
||||||
anchors.fill: audioBarMask
|
anchors.fill: audioBarMask
|
||||||
source: audioBarMask
|
source: audioBarMask
|
||||||
start: Qt.point(0, 0)
|
start: Qt.point(0, 0)
|
||||||
end: Qt.point(225, 0)
|
end: Qt.point(170, 0)
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0
|
position: 0
|
||||||
color: "#2c8e72"
|
color: "#2c8e72"
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.9
|
position: 0.8
|
||||||
color: "#1fc6a6"
|
color: "#1fc6a6"
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.91
|
position: 0.81
|
||||||
color: "#ea4c5f"
|
color: "#ea4c5f"
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
|
@ -144,6 +147,17 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: usernameText
|
||||||
|
text: tablet.parent.parent.username
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 0
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
font.pixelSize: 20
|
||||||
|
color: "#afafaf"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +243,7 @@ Item {
|
||||||
};
|
};
|
||||||
setCurrentItemState("hover state");
|
setCurrentItemState("hover state");
|
||||||
}
|
}
|
||||||
|
|
||||||
function previousItem() {
|
function previousItem() {
|
||||||
setCurrentItemState("base state");
|
setCurrentItemState("base state");
|
||||||
var prevIndex = (columnIndex + 3 - 1) % 3;
|
var prevIndex = (columnIndex + 3 - 1) % 3;
|
||||||
|
@ -238,7 +252,7 @@ Item {
|
||||||
}
|
}
|
||||||
setCurrentItemState("hover state");
|
setCurrentItemState("hover state");
|
||||||
}
|
}
|
||||||
|
|
||||||
function upItem() {
|
function upItem() {
|
||||||
setCurrentItemState("base state");
|
setCurrentItemState("base state");
|
||||||
rowIndex = rowIndex - 3;
|
rowIndex = rowIndex - 3;
|
||||||
|
@ -251,7 +265,7 @@ Item {
|
||||||
}
|
}
|
||||||
setCurrentItemState("hover state");
|
setCurrentItemState("hover state");
|
||||||
}
|
}
|
||||||
|
|
||||||
function downItem() {
|
function downItem() {
|
||||||
setCurrentItemState("base state");
|
setCurrentItemState("base state");
|
||||||
rowIndex = rowIndex + 3;
|
rowIndex = rowIndex + 3;
|
||||||
|
@ -275,4 +289,3 @@ Item {
|
||||||
Keys.onUpPressed: upItem();
|
Keys.onUpPressed: upItem();
|
||||||
Keys.onReturnPressed: selectItem();
|
Keys.onReturnPressed: selectItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Hifi 1.0
|
||||||
Item {
|
Item {
|
||||||
id: tabletRoot
|
id: tabletRoot
|
||||||
objectName: "tabletRoot"
|
objectName: "tabletRoot"
|
||||||
|
property string username: "Unknown user"
|
||||||
property var eventBridge;
|
property var eventBridge;
|
||||||
|
|
||||||
signal showDesktop();
|
signal showDesktop();
|
||||||
|
@ -30,6 +31,10 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setUsername(newUsername) {
|
||||||
|
username = newUsername;
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: loader
|
id: loader
|
||||||
objectName: "loader"
|
objectName: "loader"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
#include <AudioInjector.h>
|
#include <AudioInjector.h>
|
||||||
|
#include <AccountManager.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
#include <RegisteredMetaTypes.h>
|
#include <RegisteredMetaTypes.h>
|
||||||
#include "ScriptEngineLogging.h"
|
#include "ScriptEngineLogging.h"
|
||||||
|
@ -166,6 +167,16 @@ static void addButtonProxyToQmlTablet(QQuickItem* qmlTablet, TabletButtonProxy*
|
||||||
buttonProxy->setQmlButton(qobject_cast<QQuickItem*>(qmlButton));
|
buttonProxy->setQmlButton(qobject_cast<QQuickItem*>(qmlButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString getUsername() {
|
||||||
|
QString username = "Unknown user";
|
||||||
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
|
if (accountManager->isLoggedIn()) {
|
||||||
|
return accountManager->getAccountInfo().getUsername();
|
||||||
|
} else {
|
||||||
|
return "Unknown user";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
|
void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
|
||||||
std::lock_guard<std::mutex> guard(_mutex);
|
std::lock_guard<std::mutex> guard(_mutex);
|
||||||
_qmlOffscreenSurface = qmlOffscreenSurface;
|
_qmlOffscreenSurface = qmlOffscreenSurface;
|
||||||
|
@ -173,6 +184,16 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr
|
||||||
if (_qmlTabletRoot && _qmlOffscreenSurface) {
|
if (_qmlTabletRoot && _qmlOffscreenSurface) {
|
||||||
QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant)));
|
QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant)));
|
||||||
gotoHomeScreen();
|
gotoHomeScreen();
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(_qmlTabletRoot, "setUsername", Q_ARG(const QVariant&, QVariant(getUsername())));
|
||||||
|
|
||||||
|
// hook up username changed signal.
|
||||||
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
|
QObject::connect(accountManager.data(), &AccountManager::profileChanged, [this]() {
|
||||||
|
if (_qmlTabletRoot) {
|
||||||
|
QMetaObject::invokeMethod(_qmlTabletRoot, "setUsername", Q_ARG(const QVariant&, QVariant(getUsername())));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
removeButtonsFromHomeScreen();
|
removeButtonsFromHomeScreen();
|
||||||
_state = State::Uninitialized;
|
_state = State::Uninitialized;
|
||||||
|
@ -196,7 +217,7 @@ void TabletProxy::gotoHomeScreen() {
|
||||||
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
|
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
|
||||||
QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
|
QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()));
|
||||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL)));
|
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL)));
|
||||||
QMetaObject::invokeMethod(_qmlTabletRoot, "playButtonClickSound");
|
QMetaObject::invokeMethod(_qmlTabletRoot, "playButtonClickSound");
|
||||||
_state = State::Home;
|
_state = State::Home;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue