mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 03:17:08 +02:00
Merge pull request #11209 from vladest/tablet_login_button
Added login button to Tablet
This commit is contained in:
commit
e69227aef8
6 changed files with 85 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
import "../../styles-uit"
|
import "../../styles-uit"
|
||||||
import "../audio" as HifiAudio
|
import "../audio" as HifiAudio
|
||||||
|
@ -109,16 +110,46 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RalewaySemiBold {
|
Item {
|
||||||
id: usernameText
|
width: 150
|
||||||
text: tabletRoot.username
|
height: 50
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 20
|
anchors.rightMargin: 30
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
text: Account.loggedIn ? qsTr("Log out") : qsTr("Log in")
|
||||||
horizontalAlignment: Text.AlignRight
|
horizontalAlignment: Text.AlignRight
|
||||||
|
anchors.right: parent.right
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
color: "#afafaf"
|
color: "#afafaf"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
visible: Account.loggedIn
|
||||||
|
height: Account.loggedIn ? parent.height/2 - parent.spacing/2 : 0
|
||||||
|
text: Account.loggedIn ? "[" + tabletRoot.usernameShort + "]" : ""
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
anchors.right: parent.right
|
||||||
|
font.pixelSize: 20
|
||||||
|
color: "#afafaf"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
if (!Account.loggedIn) {
|
||||||
|
DialogsManager.showLoginDialog()
|
||||||
|
} else {
|
||||||
|
Account.logOut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
|
@ -8,6 +8,7 @@ Item {
|
||||||
id: tabletRoot
|
id: tabletRoot
|
||||||
objectName: "tabletRoot"
|
objectName: "tabletRoot"
|
||||||
property string username: "Unknown user"
|
property string username: "Unknown user"
|
||||||
|
property string usernameShort: "Unknown user"
|
||||||
property var rootMenu;
|
property var rootMenu;
|
||||||
property var openModal: null;
|
property var openModal: null;
|
||||||
property var openMessage: null;
|
property var openMessage: null;
|
||||||
|
@ -157,6 +158,11 @@ Item {
|
||||||
|
|
||||||
function setUsername(newUsername) {
|
function setUsername(newUsername) {
|
||||||
username = newUsername;
|
username = newUsername;
|
||||||
|
usernameShort = newUsername.substring(0, 8);
|
||||||
|
|
||||||
|
if (newUsername.length > 8) {
|
||||||
|
usernameShort = usernameShort + "..."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
|
|
|
@ -18,6 +18,8 @@ AccountScriptingInterface* AccountScriptingInterface::getInstance() {
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
QObject::connect(accountManager.data(), &AccountManager::profileChanged,
|
QObject::connect(accountManager.data(), &AccountManager::profileChanged,
|
||||||
&sharedInstance, &AccountScriptingInterface::usernameChanged);
|
&sharedInstance, &AccountScriptingInterface::usernameChanged);
|
||||||
|
QObject::connect(accountManager.data(), &AccountManager::usernameChanged,
|
||||||
|
&sharedInstance, &AccountScriptingInterface::onUsernameChanged);
|
||||||
return &sharedInstance;
|
return &sharedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +33,21 @@ bool AccountScriptingInterface::checkAndSignalForAccessToken() {
|
||||||
return accountManager->checkAndSignalForAccessToken();
|
return accountManager->checkAndSignalForAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountScriptingInterface::logOut() {
|
||||||
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
|
return accountManager->logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountScriptingInterface::AccountScriptingInterface(QObject *parent): QObject(parent) {
|
||||||
|
m_loggedIn = isLoggedIn();
|
||||||
|
emit loggedInChanged(m_loggedIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountScriptingInterface::onUsernameChanged(QString username) {
|
||||||
|
m_loggedIn = (username != QString());
|
||||||
|
emit loggedInChanged(m_loggedIn);
|
||||||
|
}
|
||||||
|
|
||||||
QString AccountScriptingInterface::getUsername() {
|
QString AccountScriptingInterface::getUsername() {
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
if (accountManager->isLoggedIn()) {
|
if (accountManager->isLoggedIn()) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ class AccountScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString username READ getUsername NOTIFY usernameChanged)
|
Q_PROPERTY(QString username READ getUsername NOTIFY usernameChanged)
|
||||||
|
Q_PROPERTY(bool loggedIn READ loggedIn NOTIFY loggedInChanged)
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @namespace Account
|
* @namespace Account
|
||||||
|
@ -32,6 +33,7 @@ signals:
|
||||||
* @return {Signal}
|
* @return {Signal}
|
||||||
*/
|
*/
|
||||||
void usernameChanged();
|
void usernameChanged();
|
||||||
|
void loggedInChanged(bool loggedIn);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
static AccountScriptingInterface* getInstance();
|
static AccountScriptingInterface* getInstance();
|
||||||
|
@ -50,6 +52,20 @@ public slots:
|
||||||
*/
|
*/
|
||||||
bool isLoggedIn();
|
bool isLoggedIn();
|
||||||
bool checkAndSignalForAccessToken();
|
bool checkAndSignalForAccessToken();
|
||||||
|
void logOut();
|
||||||
|
|
||||||
|
public:
|
||||||
|
AccountScriptingInterface(QObject* parent = nullptr);
|
||||||
|
bool loggedIn() const {
|
||||||
|
return m_loggedIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onUsernameChanged(QString username);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_loggedIn { false };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AccountScriptingInterface_h
|
#endif // hifi_AccountScriptingInterface_h
|
||||||
|
|
|
@ -36,6 +36,11 @@ void DialogsManagerScriptingInterface::hideAddressBar() {
|
||||||
"hideAddressBar", Qt::QueuedConnection);
|
"hideAddressBar", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogsManagerScriptingInterface::showLoginDialog() {
|
||||||
|
QMetaObject::invokeMethod(DependencyManager::get<DialogsManager>().data(),
|
||||||
|
"showLoginDialog", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
void DialogsManagerScriptingInterface::showFeed() {
|
void DialogsManagerScriptingInterface::showFeed() {
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<DialogsManager>().data(),
|
QMetaObject::invokeMethod(DependencyManager::get<DialogsManager>().data(),
|
||||||
"showFeed", Qt::QueuedConnection);
|
"showFeed", Qt::QueuedConnection);
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void showAddressBar();
|
void showAddressBar();
|
||||||
void hideAddressBar();
|
void hideAddressBar();
|
||||||
|
void showLoginDialog();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addressBarShown(bool visible);
|
void addressBarShown(bool visible);
|
||||||
|
|
Loading…
Reference in a new issue