Changed edit method from double clicking to an edit button
This commit is contained in:
parent
87490c29cd
commit
b3f29f592b
@ -42,15 +42,23 @@ ApplicationWindow {
|
||||
color: TimelineManager.userColor(profile.userid, colors.window)
|
||||
font.bold: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
focus: true
|
||||
selectByMouse: true
|
||||
|
||||
onEditingFinished: profile.changeUsername(displayUsername.text)
|
||||
Keys.priority: Keys.BeforeItem
|
||||
Keys.onReturnPressed: profile.changeUsername(displayUsername.text)
|
||||
|
||||
MouseArea {
|
||||
enabled: !profile.isUsernameEditingAllowed
|
||||
anchors.fill: parent
|
||||
onDoubleClicked: {
|
||||
profile.allowUsernameEditing(true)
|
||||
ImageButton {
|
||||
anchors.leftMargin: 5
|
||||
anchors.left: displayUsername.right
|
||||
anchors.verticalCenter: displayUsername.verticalCenter
|
||||
image: profile.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png"
|
||||
|
||||
onClicked: {
|
||||
if(profile.isUsernameEditingAllowed) {
|
||||
profile.changeUsername(displayUsername.text)
|
||||
}else{
|
||||
profile.allowUsernameEditing(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "TimelineViewManager.h"
|
||||
#include "Utils.h"
|
||||
#include "dialogs/RawMessage.h"
|
||||
#include <mtx/responses.hpp>
|
||||
|
||||
Q_DECLARE_METATYPE(QModelIndex)
|
||||
|
||||
@ -260,6 +261,17 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||
connect(&events, &EventStore::updateFlowEventId, this, [this](std::string event_id) {
|
||||
this->updateFlowEventId(event_id);
|
||||
});
|
||||
|
||||
const auto userid = utils::localUser().toStdString();
|
||||
http::client()->get_profile(
|
||||
userid, [this](const mtx::responses::Profile &res, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
nhlog::net()->warn("failed to retrieve own profile info");
|
||||
return;
|
||||
}
|
||||
|
||||
globalUsername = QString::fromStdString(res.display_name);
|
||||
});
|
||||
}
|
||||
|
||||
QHash<int, QByteArray>
|
||||
@ -801,7 +813,12 @@ TimelineModel::viewDecryptedRawMessage(QString id) const
|
||||
void
|
||||
TimelineModel::openUserProfile(QString userid, bool global)
|
||||
{
|
||||
emit openProfile(new UserProfile(global ? "" : room_id_, global ? utils::localUser() : userid, manager_, this));
|
||||
if (global) {
|
||||
emit openProfile(new UserProfile("",utils::localUser(),
|
||||
manager_, this, globalUsername));
|
||||
} else {
|
||||
emit openProfile(new UserProfile(room_id_, userid, manager_, this));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -317,6 +317,7 @@ private:
|
||||
mutable EventStore events;
|
||||
|
||||
QString room_id_;
|
||||
QString globalUsername;
|
||||
|
||||
bool decryptDescription = true;
|
||||
bool m_paginationInProgress = false;
|
||||
|
@ -12,12 +12,14 @@
|
||||
UserProfile::UserProfile(QString roomid,
|
||||
QString userid,
|
||||
TimelineViewManager *manager_,
|
||||
TimelineModel *parent)
|
||||
TimelineModel *parent,
|
||||
QString globalUsername)
|
||||
: QObject(parent)
|
||||
, roomid_(roomid)
|
||||
, userid_(userid)
|
||||
, manager(manager_)
|
||||
, model(parent)
|
||||
, globalUsername(globalUsername)
|
||||
{
|
||||
fetchDeviceList(this->userid_);
|
||||
|
||||
@ -98,7 +100,7 @@ UserProfile::userid()
|
||||
QString
|
||||
UserProfile::displayName()
|
||||
{
|
||||
return cache::displayName(roomid_, userid_);
|
||||
return globalUserProfile() ? globalUsername : cache::displayName(roomid_, userid_);
|
||||
}
|
||||
|
||||
QString
|
||||
|
@ -94,7 +94,8 @@ public:
|
||||
UserProfile(QString roomid,
|
||||
QString userid,
|
||||
TimelineViewManager *manager_,
|
||||
TimelineModel *parent = nullptr);
|
||||
TimelineModel *parent = nullptr,
|
||||
QString globalUsername = "");
|
||||
|
||||
DeviceInfoModel *deviceList();
|
||||
|
||||
@ -119,11 +120,11 @@ public:
|
||||
|
||||
signals:
|
||||
void userStatusChanged();
|
||||
|
||||
void usernameEditingChanged();
|
||||
|
||||
private:
|
||||
QString roomid_, userid_;
|
||||
QString globalUsername;
|
||||
DeviceInfoModel deviceList_;
|
||||
bool isUserVerified = false;
|
||||
bool hasMasterKey = false;
|
||||
|
Loading…
Reference in New Issue
Block a user