Commit f49e117a authored by Leander Schulten's avatar Leander Schulten
Browse files

LoginView+UserManagment: remove Q_INVOKABLE from getDefaultUser....

LoginView+UserManagment: remove Q_INVOKABLE from getDefaultUser. UserManagment.defaultUser returns now the right User. Rename readUser to defaultUser.
parent 37d9fdbf
Pipeline #190381 passed with stage
in 4 minutes and 45 seconds
......@@ -68,7 +68,7 @@ Item{
x: parent.contentItem.x + 10
text: modelData.name
width: Math.max(implicitWidth+20,70)
enabled: (UserManagment.currentUser.havePermission(Permission.Admin) || modelData === UserManagment.currentUser)&&modelData!==UserManagment.getDefaultUser()
enabled: (UserManagment.currentUser.havePermission(Permission.Admin) || modelData === UserManagment.currentUser)&&modelData!==UserManagment.defaultUser
}
Button{
visible: UserManagment.currentUser.havePermission(Permission.Admin);
......@@ -100,7 +100,7 @@ Item{
anchors.bottom: parent.bottom
anchors.rightMargin: 5
onClicked: {
if(modelData===UserManagment.getDefaultUser()){
if(modelData===UserManagment.defaultUser){
UserManagment.logout();
}else if(modelData===UserManagment.currentUser){
UserManagment.logout()
......
......@@ -2,7 +2,7 @@
#include <QCryptographicHash>
#include <QJsonArray>
UserManagment::UserManagment():readUser(new User("Default","")),currentUser(readUser){
UserManagment::UserManagment() : defaultUser(new User(QStringLiteral("Default"), "")), currentUser(defaultUser.get()) {
/*auto pass = QCryptographicHash::hash(QString("12345").toUtf8(),QCryptographicHash::Sha3_256);
qDebug()<<pass;
auto admin = new User("Admin",pass);
......@@ -121,12 +121,12 @@ void UserManagment::autoLoginUser(){
void UserManagment::logout(User *user){
if(currentUser==user){
currentUser = readUser;
currentUser = getDefaultUser();
emit currentUserChanged();
}
}
void UserManagment::logout(){
currentUser = readUser;
currentUser = getDefaultUser();
emit currentUserChanged();
}
......
......@@ -18,11 +18,12 @@ class UserManagment : public QObject
{
Q_OBJECT
Q_PROPERTY(User* currentUser READ getCurrentUser NOTIFY currentUserChanged)
Q_PROPERTY(User* defaultUser READ getCurrentUser CONSTANT)
Q_PROPERTY(User *defaultUser READ getDefaultUser CONSTANT)
Q_PROPERTY(QAbstractItemModel * users READ getUserModel CONSTANT)
Q_PROPERTY(QString currentOsUserName READ getCurrentOsUserName CONSTANT)
private:
User * readUser;
// User is an incomplete type here
std::unique_ptr<User> defaultUser;
User * currentUser;
QString currentOsUserName;
ModelVector<std::unique_ptr<User>> users;
......@@ -36,7 +37,7 @@ public:
User * getUserById(ID id){return getUserById(id.value());}
User * getUserById(ID::value_type id);
Q_INVOKABLE User * getDefaultUser()const{return readUser;}
[[nodiscard]] User *getDefaultUser() const { return defaultUser.get(); }
/**
* @brief get Return the Singletone of the UserManagment
* @return
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment