From 87490c29cd8af7c17b5a4591798f1f0ebfa9023c Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Thu, 28 Jan 2021 20:03:50 +0530 Subject: Username can be edited by double clicking on text, added global user profile menu action in user info widget --- src/ChatPage.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ChatPage.cpp') diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 4e472a3a..0d3c98a8 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -112,6 +112,10 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(sidebarActions_, &SideBarActions::createRoom, this, &ChatPage::createRoom); user_info_widget_ = new UserInfoWidget(sideBar_); + connect(user_info_widget_, &UserInfoWidget::openGlobalUserProfile, this, [this]() { + view_manager_->activeTimeline()->openUserProfile("", true); + }); + user_mentions_popup_ = new popups::UserMentions(); room_list_ = new RoomList(userSettings, sideBar_); connect(room_list_, &RoomList::joinRoom, this, &ChatPage::joinRoom); -- cgit 1.5.1 From 3b82b2ff972e4f74904e315008b996202473570c Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Thu, 28 Jan 2021 23:53:56 +0530 Subject: fix linting --- src/ChatPage.cpp | 2 +- src/timeline/TimelineModel.cpp | 4 ++-- src/ui/UserProfile.cpp | 4 ++-- src/ui/UserProfile.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ChatPage.cpp') diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 0d3c98a8..cf50e62a 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -111,7 +111,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(sidebarActions_, &SideBarActions::joinRoom, this, &ChatPage::joinRoom); connect(sidebarActions_, &SideBarActions::createRoom, this, &ChatPage::createRoom); - user_info_widget_ = new UserInfoWidget(sideBar_); + user_info_widget_ = new UserInfoWidget(sideBar_); connect(user_info_widget_, &UserInfoWidget::openGlobalUserProfile, this, [this]() { view_manager_->activeTimeline()->openUserProfile("", true); }); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 41c0b40e..a25e77fd 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -814,8 +814,8 @@ void TimelineModel::openUserProfile(QString userid, bool global) { if (global) { - emit openProfile(new UserProfile("",utils::localUser(), - manager_, this, globalUsername)); + emit openProfile( + new UserProfile("", utils::localUser(), manager_, this, globalUsername)); } else { emit openProfile(new UserProfile(room_id_, userid, manager_, this)); } diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index a53d25f4..28757b72 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -4,10 +4,10 @@ #include "DeviceVerificationFlow.h" #include "Logging.h" #include "Utils.h" -#include #include "mtx/responses/crypto.hpp" #include "timeline/TimelineModel.h" #include "timeline/TimelineViewManager.h" +#include UserProfile::UserProfile(QString roomid, QString userid, @@ -228,7 +228,7 @@ UserProfile::changeUsername(QString username) if (globalUserProfile()) { // change global http::client()->set_displayname( - username.toStdString(), [this]( mtx::http::RequestErr err) { + username.toStdString(), [this](mtx::http::RequestErr err) { if (err) { nhlog::net()->warn("could not change username"); return; diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h index 04317766..b1172077 100644 --- a/src/ui/UserProfile.h +++ b/src/ui/UserProfile.h @@ -94,7 +94,7 @@ public: UserProfile(QString roomid, QString userid, TimelineViewManager *manager_, - TimelineModel *parent = nullptr, + TimelineModel *parent = nullptr, QString globalUsername = ""); DeviceInfoModel *deviceList(); @@ -126,8 +126,8 @@ private: QString roomid_, userid_; QString globalUsername; DeviceInfoModel deviceList_; - bool isUserVerified = false; - bool hasMasterKey = false; + bool isUserVerified = false; + bool hasMasterKey = false; bool usernameEditing = false; TimelineViewManager *manager; TimelineModel *model; -- cgit 1.5.1 From 9b5a287d14a18b1bef012a348dd77350fdb70ba3 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Fri, 29 Jan 2021 11:55:24 +0530 Subject: made requeste changes --- resources/qml/UserProfile.qml | 10 +++++----- src/ChatPage.cpp | 2 +- src/timeline/TimelineModel.cpp | 6 +----- src/ui/UserProfile.cpp | 8 ++++---- src/ui/UserProfile.h | 4 ++-- 5 files changed, 13 insertions(+), 17 deletions(-) (limited to 'src/ChatPage.cpp') diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml index 5e577099..79e2b665 100644 --- a/resources/qml/UserProfile.qml +++ b/resources/qml/UserProfile.qml @@ -15,7 +15,7 @@ ApplicationWindow { minimumHeight: 420 palette: colors color: colors.window - title: profile.globalUserProfile ? "Global User Profile" : "Room User Profile" + title: profile.isGlobalUserProfile ? "Global User Profile" : "Room User Profile" ColumnLayout { id: contentL @@ -44,19 +44,19 @@ ApplicationWindow { Layout.alignment: Qt.AlignHCenter selectByMouse: true - Keys.priority: Keys.BeforeItem - Keys.onReturnPressed: profile.changeUsername(displayUsername.text) + onAccepted: profile.changeUsername(displayUsername.text) ImageButton { + visible: profile.isSelf 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) { + if (profile.isUsernameEditingAllowed) { profile.changeUsername(displayUsername.text) - }else{ + } else { profile.allowUsernameEditing(true) } } diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index cf50e62a..07ed3941 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -113,7 +113,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) user_info_widget_ = new UserInfoWidget(sideBar_); connect(user_info_widget_, &UserInfoWidget::openGlobalUserProfile, this, [this]() { - view_manager_->activeTimeline()->openUserProfile("", true); + view_manager_->activeTimeline()->openUserProfile(utils::localUser(), true); }); user_mentions_popup_ = new popups::UserMentions(); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 73077508..79cf5184 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -801,11 +801,7 @@ TimelineModel::viewDecryptedRawMessage(QString id) const void TimelineModel::openUserProfile(QString userid, bool global) { - if (global) { - emit openProfile(new UserProfile("", utils::localUser(), manager_, this)); - } else { - emit openProfile(new UserProfile(room_id_, userid, manager_, this)); - } + emit openProfile(new UserProfile(global ? "" : room_id_, userid, manager_, this)); } void diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index e2adffcd..9e8d45b5 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -116,7 +116,7 @@ UserProfile::userid() QString UserProfile::displayName() { - return globalUserProfile() ? globalUsername : cache::displayName(roomid_, userid_); + return isGlobalUserProfile() ? globalUsername : cache::displayName(roomid_, userid_); } QString @@ -126,9 +126,9 @@ UserProfile::avatarUrl() } bool -UserProfile::globalUserProfile() const +UserProfile::isGlobalUserProfile() const { - return (roomid_ == "") && isSelf(); + return roomid_ == ""; } bool @@ -241,7 +241,7 @@ UserProfile::startChat() void UserProfile::changeUsername(QString username) { - if (globalUserProfile()) { + if (isGlobalUserProfile()) { // change global http::client()->set_displayname( username.toStdString(), [this](mtx::http::RequestErr err) { diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h index 5ccb54b3..d450d58f 100644 --- a/src/ui/UserProfile.h +++ b/src/ui/UserProfile.h @@ -83,7 +83,7 @@ class UserProfile : public QObject Q_PROPERTY(QString userid READ userid CONSTANT) Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT) Q_PROPERTY(DeviceInfoModel *deviceList READ deviceList CONSTANT) - Q_PROPERTY(bool globalUserProfile READ globalUserProfile CONSTANT) + Q_PROPERTY(bool isGlobalUserProfile READ isGlobalUserProfile CONSTANT) Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged) Q_PROPERTY( bool userVerificationEnabled READ userVerificationEnabled NOTIFY userStatusChanged) @@ -101,7 +101,7 @@ public: QString userid(); QString displayName(); QString avatarUrl(); - bool globalUserProfile() const; + bool isGlobalUserProfile() const; bool getUserStatus(); bool userVerificationEnabled() const; bool isSelf() const; -- cgit 1.5.1