mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 21:18:48 +03:00
shifted isUsernameEditingAllowed to qml from c++
This commit is contained in:
parent
9b5a287d14
commit
e09e587796
3 changed files with 14 additions and 28 deletions
|
@ -36,7 +36,10 @@ ApplicationWindow {
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: displayUsername
|
id: displayUsername
|
||||||
readOnly: !profile.isUsernameEditingAllowed
|
|
||||||
|
property bool isUsernameEditingAllowed
|
||||||
|
|
||||||
|
readOnly: !isUsernameEditingAllowed
|
||||||
text: profile.displayName
|
text: profile.displayName
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
color: TimelineManager.userColor(profile.userid, colors.window)
|
color: TimelineManager.userColor(profile.userid, colors.window)
|
||||||
|
@ -44,20 +47,24 @@ ApplicationWindow {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
|
|
||||||
onAccepted: profile.changeUsername(displayUsername.text)
|
onAccepted: {
|
||||||
|
profile.changeUsername(displayUsername.text)
|
||||||
|
displayUsername.isUsernameEditingAllowed = false
|
||||||
|
}
|
||||||
|
|
||||||
ImageButton {
|
ImageButton {
|
||||||
visible: profile.isSelf
|
visible: profile.isSelf
|
||||||
anchors.leftMargin: 5
|
anchors.leftMargin: 5
|
||||||
anchors.left: displayUsername.right
|
anchors.left: displayUsername.right
|
||||||
anchors.verticalCenter: displayUsername.verticalCenter
|
anchors.verticalCenter: displayUsername.verticalCenter
|
||||||
image: profile.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png"
|
image: displayUsername.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (profile.isUsernameEditingAllowed) {
|
if (displayUsername.isUsernameEditingAllowed) {
|
||||||
profile.changeUsername(displayUsername.text)
|
profile.changeUsername(displayUsername.text)
|
||||||
|
displayUsername.isUsernameEditingAllowed = false
|
||||||
} else {
|
} else {
|
||||||
profile.allowUsernameEditing(true)
|
displayUsername.isUsernameEditingAllowed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,8 +270,6 @@ UserProfile::changeUsername(QString username)
|
||||||
err->matrix_error.error);
|
err->matrix_error.error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
allowUsernameEditing(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -290,19 +288,6 @@ UserProfile::unverify(QString device)
|
||||||
cache::markDeviceUnverified(userid_.toStdString(), device.toStdString());
|
cache::markDeviceUnverified(userid_.toStdString(), device.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
UserProfile::allowUsernameEditing(bool allow)
|
|
||||||
{
|
|
||||||
usernameEditing = allow;
|
|
||||||
emit usernameEditingChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
UserProfile::isUsernameEditingAllowed() const
|
|
||||||
{
|
|
||||||
return usernameEditing;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UserProfile::setGlobalUsername(const QString &globalUser)
|
UserProfile::setGlobalUsername(const QString &globalUser)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,8 +88,6 @@ class UserProfile : public QObject
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
bool userVerificationEnabled READ userVerificationEnabled NOTIFY userStatusChanged)
|
bool userVerificationEnabled READ userVerificationEnabled NOTIFY userStatusChanged)
|
||||||
Q_PROPERTY(bool isSelf READ isSelf CONSTANT)
|
Q_PROPERTY(bool isSelf READ isSelf CONSTANT)
|
||||||
Q_PROPERTY(
|
|
||||||
bool isUsernameEditingAllowed READ isUsernameEditingAllowed NOTIFY usernameEditingChanged)
|
|
||||||
public:
|
public:
|
||||||
UserProfile(QString roomid,
|
UserProfile(QString roomid,
|
||||||
QString userid,
|
QString userid,
|
||||||
|
@ -105,7 +103,6 @@ public:
|
||||||
bool getUserStatus();
|
bool getUserStatus();
|
||||||
bool userVerificationEnabled() const;
|
bool userVerificationEnabled() const;
|
||||||
bool isSelf() const;
|
bool isSelf() const;
|
||||||
bool isUsernameEditingAllowed() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void verify(QString device = "");
|
Q_INVOKABLE void verify(QString device = "");
|
||||||
Q_INVOKABLE void unverify(QString device = "");
|
Q_INVOKABLE void unverify(QString device = "");
|
||||||
|
@ -115,11 +112,9 @@ public:
|
||||||
Q_INVOKABLE void kickUser();
|
Q_INVOKABLE void kickUser();
|
||||||
Q_INVOKABLE void startChat();
|
Q_INVOKABLE void startChat();
|
||||||
Q_INVOKABLE void changeUsername(QString username);
|
Q_INVOKABLE void changeUsername(QString username);
|
||||||
Q_INVOKABLE void allowUsernameEditing(bool allow);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void userStatusChanged();
|
void userStatusChanged();
|
||||||
void usernameEditingChanged();
|
|
||||||
void displayNameChanged();
|
void displayNameChanged();
|
||||||
void globalUsernameRetrieved(const QString &globalUser);
|
void globalUsernameRetrieved(const QString &globalUser);
|
||||||
|
|
||||||
|
@ -132,7 +127,6 @@ private:
|
||||||
DeviceInfoModel deviceList_;
|
DeviceInfoModel deviceList_;
|
||||||
bool isUserVerified = false;
|
bool isUserVerified = false;
|
||||||
bool hasMasterKey = false;
|
bool hasMasterKey = false;
|
||||||
bool usernameEditing = false;
|
|
||||||
TimelineViewManager *manager;
|
TimelineViewManager *manager;
|
||||||
TimelineModel *model;
|
TimelineModel *model;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue