mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-12 01:19:46 +00:00
added base ligin functions
This commit is contained in:
parent
bae5ab5d48
commit
ffe4f228e1
SnakeClient/SnakeApp
back-end/ProfileViewItems
front-end
@ -37,6 +37,10 @@ void MainClient::handleReceivePackage(ClientProtocol::Command cmd, const QByteAr
|
||||
|
||||
_users [playerData->id()] = playerData;
|
||||
|
||||
if (playerData->id() == _currentUserId) {
|
||||
emit currentUserDataChanged(_users [playerData->id()]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: return;
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
signals:
|
||||
void sigOnlineStatusChanged(OnlineStatus);
|
||||
void currentUserDataChanged(QSharedPointer<PlayerClientData>);
|
||||
};
|
||||
|
||||
#endif // MAINCLIENT_H
|
||||
|
@ -22,6 +22,8 @@ MainMenuModel::MainMenuModel(QObject *ptr): QObject (ptr) {
|
||||
connect(_client, &MainClient::sigOnlineStatusChanged,
|
||||
this , &MainMenuModel::onlineStatusChanged);
|
||||
|
||||
connect(_client, &MainClient::currentUserDataChanged,
|
||||
_userViewModel , &UserView::setSource);
|
||||
}
|
||||
|
||||
QObject *MainMenuModel::userViewModel() const {
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "userview.h"
|
||||
|
||||
const PlayerClientData *UserView::getSource() const {
|
||||
return _source;
|
||||
return _source.data();
|
||||
}
|
||||
|
||||
void UserView::setSource(const PlayerClientData *value) {
|
||||
void UserView::setSource(QSharedPointer<PlayerClientData> data) {
|
||||
|
||||
_offline = value == nullptr;
|
||||
_offline = data == nullptr;
|
||||
|
||||
if (value->id() != _source->id()) {
|
||||
_source = value;
|
||||
if (data->id() != _source->id()) {
|
||||
_source = data;
|
||||
emit sourceChanged();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class UserView : public QObject
|
||||
Q_PROPERTY(bool offline READ offline NOTIFY offlineChanged)
|
||||
|
||||
private:
|
||||
const PlayerClientData *_source = nullptr;
|
||||
QSharedPointer<PlayerClientData> _source = nullptr;
|
||||
|
||||
bool _offline = false;
|
||||
|
||||
@ -35,7 +35,6 @@ public:
|
||||
int id() const;
|
||||
|
||||
const PlayerClientData *getSource() const;
|
||||
void setSource(const PlayerClientData *value);
|
||||
bool offline() const;
|
||||
void setOffline(bool offline);
|
||||
|
||||
@ -46,6 +45,8 @@ signals:
|
||||
void offlineChanged(bool offline);
|
||||
|
||||
public slots:
|
||||
void setSource(QSharedPointer<PlayerClientData> data);
|
||||
|
||||
};
|
||||
|
||||
#endif // USERVIEW_H
|
||||
|
@ -6,6 +6,8 @@ import QtQuick.Layouts 1.3
|
||||
BasePopUp {
|
||||
id : popup
|
||||
|
||||
autoClose: true;
|
||||
closeInterval: 5000
|
||||
function show(title_, message_, img_) {
|
||||
title.text = title_;
|
||||
message.text = message_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user