Some more changes

- remove unnecessary field sender in userprofile.qml
    - cover user facing string with qsTr to get picked by translations
    - add spacing and fix theming issue
    - increase and add color to username
    - change back to QVector from QLinkedList cause I have mistaken
    better time complexity to give better benchmark

red
This commit is contained in:
CH Chethan Reddy 2020-06-24 23:05:32 +05:30
parent d49ab15656
commit 1633650303
5 changed files with 193 additions and 63 deletions

View file

@ -112,7 +112,7 @@ Page {
flow.tranId = transactionId; flow.tranId = transactionId;
deviceVerificationList.add(flow.tranId); deviceVerificationList.add(flow.tranId);
var dialog = deviceVerificationDialog.createObject(timelineRoot, var dialog = deviceVerificationDialog.createObject(timelineRoot,
{flow: flow,sender: false}); {flow: flow});
dialog.show(); dialog.show();
} }
} }

View file

@ -13,7 +13,7 @@ ApplicationWindow{
id:userProfileDialog id:userProfileDialog
height: 500 height: 500
width: 500 width: 400
modality:Qt.WindowModal modality:Qt.WindowModal
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
palette: colors palette: colors
@ -64,6 +64,9 @@ ApplicationWindow{
id: userProfileName id: userProfileName
text: user_data.userName text: user_data.userName
fontSizeMode: Text.HorizontalFit fontSizeMode: Text.HorizontalFit
font.pixelSize: 16
color:timelineManager.userColor(modelData.userId, colors.window)
font.bold: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
@ -71,6 +74,8 @@ ApplicationWindow{
id: matrixUserID id: matrixUserID
text: user_data.userId text: user_data.userId
fontSizeMode: Text.HorizontalFit fontSizeMode: Text.HorizontalFit
font.pixelSize: 16
color:colors.text
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
@ -79,8 +84,6 @@ ApplicationWindow{
implicitWidth: userProfileDialog.width-20 implicitWidth: userProfileDialog.width-20
clip: true clip: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
ScrollBar.horizontal.policy: ScrollBar.AlwaysOn
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ListView{ ListView{
id: deviceList id: deviceList
@ -98,6 +101,7 @@ ApplicationWindow{
Text{ Text{
Layout.fillWidth: true Layout.fillWidth: true
color: colors.text color: colors.text
font.bold: true
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: deviceID text: deviceID
} }
@ -116,12 +120,15 @@ ApplicationWindow{
{userId : user_data.userId,sender: true,deviceId : model.deviceID}); {userId : user_data.userId,sender: true,deviceId : model.deviceID});
deviceVerificationList.add(newFlow.tranId); deviceVerificationList.add(newFlow.tranId);
var dialog = deviceVerificationDialog.createObject(userProfileDialog, var dialog = deviceVerificationDialog.createObject(userProfileDialog,
{flow: newFlow,sender: true}); {flow: newFlow});
dialog.show(); dialog.show();
} }
palette {
button: "white"
}
contentItem: Text { contentItem: Text {
text: verifyButton.text text: verifyButton.text
color: colors.background color: "black"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -134,19 +141,26 @@ ApplicationWindow{
id: okbutton id: okbutton
text:"OK" text:"OK"
onClicked: userProfileDialog.close() onClicked: userProfileDialog.close()
anchors.margins: { anchors {
right:10 right: parent.right
bottom:10 bottom: parent.bottom
}
anchors.margins : {
right : 10
bottom : 10
}
palette {
button: "white"
} }
contentItem: Text { contentItem: Text {
text: okbutton.text text: okbutton.text
color: colors.background color: "black"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
} }
} }

View file

@ -7,7 +7,6 @@ import Qt.labs.settings 1.0
import im.nheko 1.0 import im.nheko 1.0
ApplicationWindow { ApplicationWindow {
property bool sender: true
title: stack.currentItem.title title: stack.currentItem.title
id: dialog id: dialog
@ -25,7 +24,7 @@ ApplicationWindow {
width: stack.implicitWidth width: stack.implicitWidth
StackView { StackView {
id: stack id: stack
initialItem: sender == true?newVerificationRequest:acceptNewVerificationRequest initialItem: flow.sender == true?newVerificationRequest:acceptNewVerificationRequest
implicitWidth: currentItem.implicitWidth implicitWidth: currentItem.implicitWidth
implicitHeight: currentItem.implicitHeight implicitHeight: currentItem.implicitHeight
} }
@ -52,7 +51,7 @@ ApplicationWindow {
Component { Component {
id: newVerificationRequest id: newVerificationRequest
Pane { Pane {
property string title: "Sending Device Verification Request" property string title: qsTr("Sending Device Verification Request")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -60,8 +59,8 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: "A new device was added." text: qsTr("A new device was added.")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -70,15 +69,24 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: "The device may have been added by you signing in from another client or physical device. To ensure that no malicious user can eavesdrop on your encrypted communications, you should verify the new device." text: qsTr("The device may have been added by you signing in from another client or physical device. To ensure that no malicious user can eavesdrop on your encrypted communications, you should verify the new device.")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
RowLayout { RowLayout {
Button { Button {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "Cancel" text: qsTr("Cancel")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
flow.cancelVerification(); flow.cancelVerification();
@ -91,7 +99,16 @@ ApplicationWindow {
} }
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "Start verification" text: qsTr("Start verification")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { stack.replace(awaitingVerificationRequestAccept); flow.startVerificationRequest(); } onClicked: { stack.replace(awaitingVerificationRequestAccept); flow.startVerificationRequest(); }
} }
} }
@ -102,7 +119,7 @@ ApplicationWindow {
Component { Component {
id: acceptNewVerificationRequest id: acceptNewVerificationRequest
Pane { Pane {
property string title: "Recieving Device Verification Request" property string title: qsTr("Recieving Device Verification Request")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
@ -111,15 +128,15 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: "The device was requested to be verified" text: qsTr("The device was requested to be verified")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
RowLayout { RowLayout {
RadioButton { RadioButton {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "Decimal" text: qsTr("Decimal")
onClicked: { flow.method = DeviceVerificationFlow.Decimal } onClicked: { flow.method = DeviceVerificationFlow.Decimal }
} }
Item { Item {
@ -127,7 +144,7 @@ ApplicationWindow {
} }
RadioButton { RadioButton {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "Emoji" text: qsTr("Emoji")
onClicked: { flow.method = DeviceVerificationFlow.Emoji } onClicked: { flow.method = DeviceVerificationFlow.Emoji }
} }
} }
@ -135,7 +152,16 @@ ApplicationWindow {
RowLayout { RowLayout {
Button { Button {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "Deny" text: qsTr("Deny")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
flow.cancelVerification(); flow.cancelVerification();
@ -148,7 +174,16 @@ ApplicationWindow {
} }
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "Accept" text: qsTr("Accept")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { stack.replace(awaitingVerificationRequestAccept); flow.acceptVerificationRequest(); } onClicked: { stack.replace(awaitingVerificationRequestAccept); flow.acceptVerificationRequest(); }
} }
} }
@ -159,7 +194,7 @@ ApplicationWindow {
Component { Component {
id: awaitingVerificationRequestAccept id: awaitingVerificationRequestAccept
Pane { Pane {
property string title: "Waiting for other party" property string title: qsTr("Waiting for other party")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -168,8 +203,8 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
id: content id: content
text: "Waiting for other side to accept the verification request." text: qsTr("Waiting for other side to accept the verification request.")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -179,7 +214,16 @@ ApplicationWindow {
RowLayout { RowLayout {
Button { Button {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "Cancel" text: qsTr("Cancel")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
flow.cancelVerification(); flow.cancelVerification();
@ -198,7 +242,7 @@ ApplicationWindow {
Component { Component {
id: digitVerification id: digitVerification
Pane { Pane {
property string title: "Verification Code" property string title: qsTr("Verification Code")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -206,8 +250,8 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: "Please verify the following digits. You should see the same numbers on both sides. If they differ, please press 'They do not match!' to abort verification!" text: qsTr("Please verify the following digits. You should see the same numbers on both sides. If they differ, please press 'They do not match!' to abort verification!")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -230,7 +274,16 @@ ApplicationWindow {
RowLayout { RowLayout {
Button { Button {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "They do not match!" text: qsTr("They do not match!")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
flow.cancelVerification(); flow.cancelVerification();
@ -243,7 +296,16 @@ ApplicationWindow {
} }
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "They match." text: qsTr("They match!")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { stack.replace(awaitingVerificationConfirmation); flow.sendVerificationMac(); } onClicked: { stack.replace(awaitingVerificationConfirmation); flow.sendVerificationMac(); }
} }
} }
@ -254,7 +316,7 @@ ApplicationWindow {
Component { Component {
id: emojiVerification id: emojiVerification
Pane { Pane {
property string title: "Verification Code" property string title: qsTr("Verification Code")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -262,8 +324,8 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: "Please verify the following emoji. You should see the same emoji on both sides. If they differ, please press 'They do not match!' to abort verification!" text: qsTr("Please verify the following emoji. You should see the same emoji on both sides. If they differ, please press 'They do not match!' to abort verification!")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -369,7 +431,16 @@ ApplicationWindow {
RowLayout { RowLayout {
Button { Button {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "They do not match!" text: qsTr("They do not match!")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
flow.cancelVerification(); flow.cancelVerification();
@ -382,7 +453,16 @@ ApplicationWindow {
} }
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "They match." text: qsTr("They match!")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { stack.replace(awaitingVerificationConfirmation); flow.sendVerificationMac(); } onClicked: { stack.replace(awaitingVerificationConfirmation); flow.sendVerificationMac(); }
} }
} }
@ -393,7 +473,7 @@ ApplicationWindow {
Component { Component {
id: awaitingVerificationConfirmation id: awaitingVerificationConfirmation
Pane { Pane {
property string title: "Awaiting Confirmation" property string title: qsTr("Awaiting Confirmation")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -402,8 +482,8 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
id: content id: content
text: "Waiting for other side to complete verification." text: qsTr("Waiting for other side to complete verification.")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -413,7 +493,16 @@ ApplicationWindow {
RowLayout { RowLayout {
Button { Button {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
text: "Cancel" text: qsTr("Cancel")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
flow.cancelVerification(); flow.cancelVerification();
@ -432,7 +521,7 @@ ApplicationWindow {
Component { Component {
id: verificationSuccess id: verificationSuccess
Pane { Pane {
property string title: "Successful Verification" property string title: qsTr("Successful Verification")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -441,8 +530,8 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
id: content id: content
text: "Verification successful! Both sides verified their devices!" text: qsTr("Verification successful! Both sides verified their devices!")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -452,7 +541,16 @@ ApplicationWindow {
} }
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "Close" text: qsTr("Close")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close() dialog.close()
deviceVerificationList.remove(flow.tranId); deviceVerificationList.remove(flow.tranId);
@ -467,7 +565,7 @@ ApplicationWindow {
Component { Component {
id: partnerAborted id: partnerAborted
Pane { Pane {
property string title: "Verification aborted!" property string title: qsTr("Verification aborted!")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Label { Label {
@ -476,8 +574,8 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
id: content id: content
text: "Verification canceled by the other party!" text: qsTr("Verification canceled by the other party!")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -487,7 +585,16 @@ ApplicationWindow {
} }
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "Close" text: qsTr("Close")
palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
dialog.close(); dialog.close();
deviceVerificationList.remove(flow.tranId); deviceVerificationList.remove(flow.tranId);
@ -502,7 +609,7 @@ ApplicationWindow {
Component { Component {
id: timedout id: timedout
Pane { Pane {
property string title: "Verification timed out" property string title: qsTr("Verification timed out")
ColumnLayout { ColumnLayout {
spacing: 16 spacing: 16
Text { Text {
@ -511,8 +618,8 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
id: content id: content
text: "Device verification timed out." text: qsTr("Device verification timed out.")
color:colors.text
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -521,8 +628,18 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
} }
Button { Button {
id: timedOutCancel
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
text: "Close" palette {
button: "white"
}
contentItem: Text {
text: parent.text
color: "black"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
text: qsTr("Close")
onClicked: { onClicked: {
dialog.close() dialog.close()
deviceVerificationList.remove(flow.tranId); deviceVerificationList.remove(flow.tranId);

View file

@ -26,17 +26,17 @@ namespace msgs = mtx::events::msg;
void void
DeviceVerificationList::add(QString tran_id) DeviceVerificationList::add(QString tran_id)
{ {
this->dv_list.append(tran_id); this->deviceVerificationList.push_back(tran_id);
} }
void void
DeviceVerificationList::remove(QString tran_id) DeviceVerificationList::remove(QString tran_id)
{ {
this->dv_list.removeOne(tran_id); this->deviceVerificationList.removeOne(tran_id);
} }
bool bool
DeviceVerificationList::exist(QString tran_id) DeviceVerificationList::exist(QString tran_id)
{ {
return this->dv_list.contains(tran_id); return this->deviceVerificationList.contains(tran_id);
} }
void void

View file

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <QHash> #include <QHash>
#include <QLinkedList>
#include <QQuickView> #include <QQuickView>
#include <QQuickWidget> #include <QQuickWidget>
#include <QSharedPointer> #include <QSharedPointer>
@ -32,7 +31,7 @@ public:
Q_INVOKABLE bool exist(QString tran_id); Q_INVOKABLE bool exist(QString tran_id);
private: private:
QLinkedList<QString> dv_list; QVector<QString> deviceVerificationList;
}; };
class TimelineViewManager : public QObject class TimelineViewManager : public QObject