mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Add some Userprofile buttons
This commit is contained in:
parent
75efa5d3a2
commit
00e36b6068
5 changed files with 145 additions and 46 deletions
|
@ -12,7 +12,7 @@ ApplicationWindow{
|
|||
property var colors: currentActivePalette
|
||||
|
||||
id:userProfileDialog
|
||||
height: 500
|
||||
height: 650
|
||||
width: 420
|
||||
modality:Qt.WindowModal
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
@ -43,7 +43,7 @@ ApplicationWindow{
|
|||
width: userProfileDialog.width
|
||||
height: userProfileDialog.height
|
||||
|
||||
Layout.fillHeight : true
|
||||
// Layout.fillHeight : true
|
||||
|
||||
ColumnLayout{
|
||||
anchors.fill: userProfileItem
|
||||
|
@ -82,8 +82,62 @@ ApplicationWindow{
|
|||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
ImageButton{
|
||||
image:":/icons/icons/ui/do-not-disturb-rounded-sign.png"
|
||||
Layout.margins: {
|
||||
left: 5
|
||||
right: 5
|
||||
}
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Ban the user")
|
||||
onClicked : {
|
||||
userProfileList.banUser()
|
||||
}
|
||||
}
|
||||
// ImageButton{
|
||||
// image:":/icons/icons/ui/volume-off-indicator.png"
|
||||
// Layout.margins: {
|
||||
// left: 5
|
||||
// right: 5
|
||||
// }
|
||||
// ToolTip.visible: hovered
|
||||
// ToolTip.text: qsTr("Ignore messages from this user")
|
||||
// onClicked : {
|
||||
// userProfileList.ignoreUser()
|
||||
// }
|
||||
// }
|
||||
|
||||
ImageButton{
|
||||
image:":/icons/icons/ui/round-remove-button.png"
|
||||
Layout.margins: {
|
||||
left: 5
|
||||
right: 5
|
||||
}
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Kick the user")
|
||||
onClicked : {
|
||||
userProfileList.kickUser()
|
||||
}
|
||||
}
|
||||
|
||||
ImageButton{
|
||||
image:":/icons/icons/ui/black-bubble-speech.png"
|
||||
Layout.margins: {
|
||||
left: 5
|
||||
right: 5
|
||||
}
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Start a conversation")
|
||||
onClicked : {
|
||||
userProfileList.startChat()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
implicitHeight: userProfileDialog.height/2+20
|
||||
implicitHeight: userProfileDialog.height/2 + 20
|
||||
implicitWidth: userProfileDialog.width-20
|
||||
clip: true
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
@ -150,6 +204,8 @@ ApplicationWindow{
|
|||
id: okbutton
|
||||
text:"OK"
|
||||
onClicked: userProfileDialog.close()
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
||||
Layout.margins : {
|
||||
right : 10
|
||||
|
|
|
@ -82,8 +82,6 @@ ApplicationWindow {
|
|||
}
|
||||
onClicked: {
|
||||
dialog.close();
|
||||
flow.cancelVerification();
|
||||
deviceVerificationList.remove(flow.tranId);
|
||||
delete flow;
|
||||
}
|
||||
}
|
||||
|
@ -128,16 +126,26 @@ ApplicationWindow {
|
|||
|
||||
RowLayout {
|
||||
RadioButton {
|
||||
id: decimalRadio
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
text: qsTr("Decimal")
|
||||
contentItem: Text {
|
||||
text: decimalRadio.text
|
||||
color: colors.text
|
||||
}
|
||||
onClicked: { flow.method = DeviceVerificationFlow.Decimal }
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
RadioButton {
|
||||
id: emojiRadio
|
||||
Layout.alignment: Qt.AlignRight
|
||||
text: qsTr("Emoji")
|
||||
contentItem: Text {
|
||||
text: emojiRadio.text
|
||||
color: colors.text
|
||||
}
|
||||
onClicked: { flow.method = DeviceVerificationFlow.Emoji }
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +164,7 @@ ApplicationWindow {
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
onClicked: {
|
||||
dialog.close();
|
||||
dialog.close();
|
||||
flow.cancelVerification();
|
||||
deviceVerificationList.remove(flow.tranId);
|
||||
delete flow;
|
||||
|
@ -411,6 +419,7 @@ ApplicationWindow {
|
|||
text: col.emoji.emoji
|
||||
font.pixelSize: Qt.application.font.pixelSize * 2
|
||||
font.family: Settings.emojiFont
|
||||
color:colors.text
|
||||
}
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||
|
|
|
@ -13,7 +13,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *)
|
|||
{
|
||||
timeout = new QTimer(this);
|
||||
timeout->setSingleShot(true);
|
||||
this->sas = olm::client()->sas_init();
|
||||
this->sas = olm::client()->sas_init();
|
||||
this->isMacVerified = false;
|
||||
connect(timeout, &QTimer::timeout, this, [this]() {
|
||||
emit timedout();
|
||||
this->deleteLater();
|
||||
|
@ -134,45 +135,47 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *)
|
|||
}
|
||||
}
|
||||
});
|
||||
connect(ChatPage::instance(),
|
||||
&ChatPage::recievedDeviceVerificationMac,
|
||||
this,
|
||||
[this](const mtx::events::collections::DeviceEvents &message) {
|
||||
auto msg =
|
||||
std::get<mtx::events::DeviceEvent<msgs::KeyVerificationMac>>(message);
|
||||
if (msg.content.transaction_id == this->transaction_id) {
|
||||
std::string info =
|
||||
"MATRIX_KEY_VERIFICATION_MAC" + this->toClient.to_string() +
|
||||
this->deviceId.toStdString() +
|
||||
http::client()->user_id().to_string() +
|
||||
http::client()->device_id() + this->transaction_id;
|
||||
connect(
|
||||
ChatPage::instance(),
|
||||
&ChatPage::recievedDeviceVerificationMac,
|
||||
this,
|
||||
[this](const mtx::events::collections::DeviceEvents &message) {
|
||||
auto msg = std::get<mtx::events::DeviceEvent<msgs::KeyVerificationMac>>(message);
|
||||
if (msg.content.transaction_id == this->transaction_id) {
|
||||
std::string info =
|
||||
"MATRIX_KEY_VERIFICATION_MAC" + this->toClient.to_string() +
|
||||
this->deviceId.toStdString() + http::client()->user_id().to_string() +
|
||||
http::client()->device_id() + this->transaction_id;
|
||||
|
||||
std::vector<std::string> key_list;
|
||||
std::string key_string;
|
||||
for (auto mac : msg.content.mac) {
|
||||
if (mac.second ==
|
||||
this->sas->calculate_mac(this->device_keys[mac.first],
|
||||
info + mac.first)) {
|
||||
key_string += mac.first;
|
||||
} else {
|
||||
this->cancelVerification();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (msg.content.keys ==
|
||||
this->sas->calculate_mac(key_string, info + "KEY_IDS")) {
|
||||
// uncomment this in future to be compatible with the
|
||||
// MSC2366 this->sendVerificationDone(); and remoeve the
|
||||
// below line
|
||||
if (this->isMacVerified == true)
|
||||
emit this->deviceVerified();
|
||||
else
|
||||
this->isMacVerified = true;
|
||||
} else {
|
||||
this->cancelVerification();
|
||||
}
|
||||
}
|
||||
});
|
||||
std::vector<std::string> key_list;
|
||||
std::string key_string;
|
||||
for (auto mac : msg.content.mac) {
|
||||
key_string += mac.first + ",";
|
||||
if (device_keys[mac.first] != "") {
|
||||
if (mac.second ==
|
||||
this->sas->calculate_mac(this->device_keys[mac.first],
|
||||
info + mac.first)) {
|
||||
} else {
|
||||
this->cancelVerification();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
key_string = key_string.substr(0, key_string.length() - 1);
|
||||
if (msg.content.keys ==
|
||||
this->sas->calculate_mac(key_string, info + "KEY_IDS")) {
|
||||
// uncomment this in future to be compatible with the
|
||||
// MSC2366 this->sendVerificationDone(); and remove the
|
||||
// below line
|
||||
if (this->isMacVerified == true)
|
||||
emit this->deviceVerified();
|
||||
else
|
||||
this->isMacVerified = true;
|
||||
} else {
|
||||
this->cancelVerification();
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(ChatPage::instance(),
|
||||
&ChatPage::recievedDeviceVerificationReady,
|
||||
this,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "UserProfile.h"
|
||||
#include "ChatPage.h"
|
||||
#include "Logging.h"
|
||||
#include "Utils.h"
|
||||
#include "mtx/responses/crypto.hpp"
|
||||
|
@ -86,3 +87,30 @@ UserProfile::updateDeviceList()
|
|||
{
|
||||
fetchDeviceList(this->userId);
|
||||
}
|
||||
|
||||
void
|
||||
UserProfile::banUser()
|
||||
{
|
||||
ChatPage::instance()->banUser(this->userId, "");
|
||||
}
|
||||
|
||||
// void ignoreUser(){
|
||||
|
||||
// }
|
||||
|
||||
void
|
||||
UserProfile::kickUser()
|
||||
{
|
||||
ChatPage::instance()->kickUser(this->userId, "");
|
||||
}
|
||||
|
||||
void
|
||||
UserProfile::startChat()
|
||||
{
|
||||
mtx::requests::CreateRoom req;
|
||||
req.preset = mtx::requests::Preset::PrivateChat;
|
||||
req.visibility = mtx::requests::Visibility::Private;
|
||||
if (utils::localUser() != this->userId)
|
||||
req.invite = {this->userId.toStdString()};
|
||||
emit ChatPage::instance()->createRoom(req);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <QVector>
|
||||
|
||||
#include "MatrixClient.h"
|
||||
|
||||
class DeviceInfo
|
||||
{
|
||||
public:
|
||||
|
@ -36,6 +35,10 @@ public:
|
|||
|
||||
Q_INVOKABLE void fetchDeviceList(const QString &userID);
|
||||
Q_INVOKABLE void updateDeviceList();
|
||||
Q_INVOKABLE void banUser();
|
||||
// Q_INVOKABLE void ignoreUser();
|
||||
Q_INVOKABLE void kickUser();
|
||||
Q_INVOKABLE void startChat();
|
||||
|
||||
signals:
|
||||
void userIdChanged();
|
||||
|
|
Loading…
Reference in a new issue