mirror of
https://github.com/QuasarApp/Hanoi-Towers.git
synced 2025-05-14 18:39:33 +00:00
fix online status bar
This commit is contained in:
parent
b7c75fa471
commit
da89633f3e
HanoiTowers/client
@ -78,6 +78,9 @@ BackEnd::BackEnd(QQmlApplicationEngine *engine):
|
||||
connect(_client , &HanoiClient::profileChanged,
|
||||
this, &BackEnd::handleProfileChanged);
|
||||
|
||||
connect(_client , &HanoiClient::statusChanged,
|
||||
this, &BackEnd::setOnlineStatus);
|
||||
|
||||
connect(&_profile, &LocalUser::nameChanged,
|
||||
this, &BackEnd::handleChangeName);
|
||||
|
||||
@ -399,7 +402,7 @@ void BackEnd::setGameState(GameState *gameState) {
|
||||
emit gameStateChanged(gameState);
|
||||
}
|
||||
|
||||
void BackEnd::setOnlineStatus(int onlineStatus) {
|
||||
void BackEnd::setOnlineStatus(QH::ClientStatus onlineStatus) {
|
||||
if (_onlineStatus == static_cast<OnlineStatus>(onlineStatus))
|
||||
return;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class BackEnd: public QObject
|
||||
Q_PROPERTY(QObject* profileObject READ profileObject NOTIFY profileChanged)
|
||||
|
||||
Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
|
||||
Q_PROPERTY(int onlineStatus READ onlineStatus WRITE setOnlineStatus NOTIFY onlineStatusChanged)
|
||||
Q_PROPERTY(int onlineStatus READ onlineStatus NOTIFY onlineStatusChanged)
|
||||
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ private slots:
|
||||
void handleOnlineRequestError(QH::ErrorCodes::Code, const QString&Errr);
|
||||
|
||||
void handleProfileChanged(QSharedPointer<LocalUser> profileId);
|
||||
void setOnlineStatus(int onlineStatus);
|
||||
void setOnlineStatus(QH::ClientStatus onlineStatus);
|
||||
|
||||
private:
|
||||
void init();
|
||||
@ -189,7 +189,7 @@ private:
|
||||
SettingsData _settingsData;
|
||||
HanoiImageProvider *_imageProvider = nullptr;
|
||||
DataConverter *_dataConverter = nullptr;
|
||||
OnlineStatus _onlineStatus = OnlineStatus::Offline;
|
||||
OnlineStatus _onlineStatus = OnlineStatus::Dissconnected;
|
||||
};
|
||||
|
||||
|
||||
|
@ -7,8 +7,7 @@ import "./../base" as Base
|
||||
ToolBar {
|
||||
id: root
|
||||
|
||||
property var client: (backEnd)? backEnd.onlineStatus: null;
|
||||
property int onlineStatus: (client)? client.status : 0
|
||||
property int onlineStatus: (backEnd)? backEnd.onlineStatus: 0
|
||||
property bool returnButton: false
|
||||
property bool gameStateWidget: false
|
||||
|
||||
@ -21,9 +20,12 @@ ToolBar {
|
||||
function getStatusColor(status) {
|
||||
switch(status) {
|
||||
|
||||
case 0: return theme.headerColorOffline;
|
||||
case 1: return theme.headerColorOnline;
|
||||
case 2: return theme.headerColorLogined;
|
||||
case OnlineStatusQml.connecting: return theme.headerColorOffline;
|
||||
case OnlineStatusQml.connected: return theme.headerColorOnline;
|
||||
case OnlineStatusQml.loginning: return theme.headerColorOnline;
|
||||
case OnlineStatusQml.loggined: return theme.headerColorLogined;
|
||||
default:
|
||||
return theme.headerColorOffline
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,13 +109,14 @@ GridLayout {
|
||||
id: eonline
|
||||
text: ""
|
||||
checked: privateRoot.onlieUser
|
||||
visible: privateRoot.onlineStatus === OnlineStatusQml.offline || privateRoot.onlineStatus === OnlineStatusQml.loggined
|
||||
visible: !bonline.visible
|
||||
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
id: bonline
|
||||
running: true;
|
||||
visible: !eonline.visible
|
||||
visible: privateRoot.onlineStatus === OnlineStatusQml.loginning || privateRoot.onlineStatus === OnlineStatusQml.loggined
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ OnlineStatusQml::OnlineStatusQml()
|
||||
}
|
||||
|
||||
int OnlineStatusQml::offline() const {
|
||||
return static_cast<int>(OnlineStatus::Offline);
|
||||
return static_cast<int>(OnlineStatus::Dissconnected);
|
||||
}
|
||||
|
||||
int OnlineStatusQml::connecting() const {
|
||||
@ -25,6 +25,6 @@ int OnlineStatusQml::loginning() const {
|
||||
}
|
||||
|
||||
int OnlineStatusQml::loggined() const {
|
||||
return static_cast<int>(OnlineStatus::Loggined);
|
||||
return static_cast<int>(OnlineStatus::Logined);
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
#ifndef ONLINESTATUSQML_H
|
||||
#define ONLINESTATUSQML_H
|
||||
#include <QObject>
|
||||
#include <singleserverclient.h>
|
||||
|
||||
|
||||
enum class OnlineStatus: int {
|
||||
Offline,
|
||||
Connecting,
|
||||
Connected,
|
||||
Loginning,
|
||||
Loggined
|
||||
};
|
||||
typedef QH::ClientStatus OnlineStatus;
|
||||
|
||||
class OnlineStatusQml
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user