Merge pull request #806 from LorenDB/dialogFixes

Dialog fixes and improvements
This commit is contained in:
DeepBlueV7.X 2021-11-18 22:34:48 +01:00 committed by GitHub
commit 229d7be868
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 156 additions and 83 deletions

View file

@ -543,8 +543,7 @@ Page {
id: closeUnverifiedBubble id: closeUnverifiedBubble
Layout.rightMargin: Nheko.paddingMedium Layout.rightMargin: Nheko.paddingMedium
Layout.topMargin: Nheko.paddingMedium Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.alignment: Qt.AlignRight | Qt.AlignCenter
hoverEnabled: true hoverEnabled: true
width: fontMetrics.font.pixelSize width: fontMetrics.font.pixelSize
height: fontMetrics.font.pixelSize height: fontMetrics.font.pixelSize

View file

@ -21,6 +21,11 @@ ApplicationWindow {
width: 350 width: 350
height: fontMetrics.lineSpacing * 7 height: fontMetrics.lineSpacing * 7
Shortcut {
sequence: StandardKey.Cancel
onActivated: dbb.rejected()
}
ColumnLayout { ColumnLayout {
spacing: Nheko.paddingMedium spacing: Nheko.paddingMedium
anchors.margins: Nheko.paddingMedium anchors.margins: Nheko.paddingMedium
@ -36,11 +41,15 @@ ApplicationWindow {
id: statusInput id: statusInput
Layout.fillWidth: true Layout.fillWidth: true
onAccepted: dbb.accepted()
focus: true
} }
} }
footer: DialogButtonBox { footer: DialogButtonBox {
id: dbb
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
onAccepted: { onAccepted: {
if (inputDialog.onAccepted) if (inputDialog.onAccepted)

View file

@ -99,38 +99,64 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
model: invitees model: invitees
delegate: RowLayout { delegate: ItemDelegate {
spacing: Nheko.paddingMedium id: del
Avatar { hoverEnabled: true
width: Nheko.avatarSize width: ListView.view.width
height: Nheko.avatarSize height: layout.implicitHeight + Nheko.paddingSmall * 2
userid: model.mxid onClicked: TimelineManager.openGlobalUserProfile(model.mxid)
url: model.avatarUrl.replace("mxc://", "image://MxcImage/") background: Rectangle {
displayName: model.displayName color: del.hovered ? Nheko.colors.dark : inviteDialogRoot.color
onClicked: TimelineManager.openGlobalUserProfile(model.mxid)
} }
ColumnLayout { RowLayout {
spacing: Nheko.paddingSmall id: layout
Label { spacing: Nheko.paddingMedium
text: model.displayName anchors.centerIn: parent
color: TimelineManager.userColor(model ? model.mxid : "", Nheko.colors.window) width: del.width - Nheko.paddingSmall * 2
font.pointSize: fontMetrics.font.pointSize
Avatar {
width: Nheko.avatarSize
height: Nheko.avatarSize
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
enabled: false
} }
Label { ColumnLayout {
text: model.mxid spacing: Nheko.paddingSmall
color: Nheko.colors.buttonText
font.pointSize: fontMetrics.font.pointSize * 0.9 Label {
text: model.displayName
color: TimelineManager.userColor(model ? model.mxid : "", del.background.color)
font.pointSize: fontMetrics.font.pointSize
}
Label {
text: model.mxid
color: del.hovered ? Nheko.colors.brightText : Nheko.colors.buttonText
font.pointSize: fontMetrics.font.pointSize * 0.9
}
} }
Item { Item {
Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
} }
ImageButton {
image: ":/icons/icons/ui/dismiss.svg"
onClicked: invitees.removeUser(model.mxid)
}
}
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
} }
} }

View file

@ -54,23 +54,29 @@ ApplicationWindow {
id: readReceiptsList id: readReceiptsList
clip: true clip: true
spacing: Nheko.paddingMedium
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
model: readReceipts model: readReceipts
delegate: ItemDelegate { delegate: ItemDelegate {
id: del
onClicked: room.openUserProfile(model.mxid) onClicked: room.openUserProfile(model.mxid)
padding: Nheko.paddingMedium padding: Nheko.paddingMedium
width: receiptLayout.implicitWidth width: ListView.view.width
height: receiptLayout.implicitHeight height: receiptLayout.implicitHeight + Nheko.paddingSmall * 2
hoverEnabled: true hoverEnabled: true
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: model.mxid ToolTip.text: model.mxid
background: Rectangle {
color: del.hovered ? Nheko.colors.dark : readReceiptsRoot.color
}
RowLayout { RowLayout {
id: receiptLayout id: receiptLayout
spacing: Nheko.paddingMedium spacing: Nheko.paddingMedium
anchors.fill: parent
anchors.margins: Nheko.paddingSmall
Avatar { Avatar {
width: Nheko.avatarSize width: Nheko.avatarSize
@ -96,11 +102,10 @@ ApplicationWindow {
font.pointSize: fontMetrics.font.pointSize * 0.9 font.pointSize: fontMetrics.font.pointSize * 0.9
} }
Item { }
Layout.fillHeight: true
Layout.fillWidth: true
}
Item {
Layout.fillWidth: true
} }
} }
@ -110,10 +115,6 @@ ApplicationWindow {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
} }
background: Rectangle {
color: readReceiptsRoot.color
}
} }
} }

View file

@ -75,7 +75,6 @@ ApplicationWindow {
id: memberList id: memberList
clip: true clip: true
spacing: Nheko.paddingMedium
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
model: members model: members
@ -85,67 +84,86 @@ ApplicationWindow {
enabled: !Settings.mobileMode enabled: !Settings.mobileMode
} }
delegate: RowLayout { delegate: ItemDelegate {
id: del id: del
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
padding: Nheko.paddingMedium
width: ListView.view.width width: ListView.view.width
spacing: Nheko.paddingMedium height: memberLayout.implicitHeight + Nheko.paddingSmall * 2
hoverEnabled: true
Avatar { background: Rectangle {
id: avatar color: del.hovered ? Nheko.colors.dark : roomMembersRoot.color
width: Nheko.avatarSize
height: Nheko.avatarSize
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
} }
ColumnLayout { RowLayout {
spacing: Nheko.paddingSmall id: memberLayout
ElidedLabel { spacing: Nheko.paddingMedium
fullText: model.displayName anchors.centerIn: parent
color: TimelineManager.userColor(model ? model.mxid : "", Nheko.colors.window) width: parent.width - Nheko.paddingSmall * 2
font.pixelSize: fontMetrics.font.pixelSize
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width Avatar {
id: avatar
width: Nheko.avatarSize
height: Nheko.avatarSize
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
enabled: false
} }
ElidedLabel { ColumnLayout {
fullText: model.mxid spacing: Nheko.paddingSmall
color: Nheko.colors.buttonText
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9) ElidedLabel {
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width fullText: model.displayName
color: TimelineManager.userColor(model ? model.mxid : "", del.background.color)
font.pixelSize: fontMetrics.font.pixelSize
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
}
ElidedLabel {
fullText: model.mxid
color: del.hovered ? Nheko.colors.brightText : Nheko.colors.buttonText
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9)
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
}
} }
Item { Item {
Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
} }
EncryptionIndicator {
id: encryptInd
Layout.alignment: Qt.AlignRight
visible: room.isEncrypted
encrypted: room.isEncrypted
trust: encrypted ? model.trustlevel : Crypto.Unverified
ToolTip.text: {
if (!encrypted)
return qsTr("This room is not encrypted!");
switch (trust) {
case Crypto.Verified:
return qsTr("This user is verified.");
case Crypto.TOFU:
return qsTr("This user isn't verified, but is still using the same master key from the first time you met.");
default:
return qsTr("This user has unverified devices!");
}
}
}
} }
EncryptionIndicator { CursorShape {
id: encryptInd anchors.fill: parent
cursorShape: Qt.PointingHandCursor
Layout.alignment: Qt.AlignRight
visible: room.isEncrypted
encrypted: room.isEncrypted
trust: encrypted ? model.trustlevel : Crypto.Unverified
ToolTip.text: {
if (!encrypted)
return qsTr("This room is not encrypted!");
switch (trust) {
case Crypto.Verified:
return qsTr("This user is verified.");
case Crypto.TOFU:
return qsTr("This user isn't verified, but is still using the same master key from the first time you met.");
default:
return qsTr("This user has unverified devices!");
}
}
} }
} }

View file

@ -16,6 +16,10 @@ InviteesModel::InviteesModel(QObject *parent)
void void
InviteesModel::addUser(QString mxid) InviteesModel::addUser(QString mxid)
{ {
for (const auto &invitee : invitees_)
if (invitee->mxid_ == mxid)
return;
beginInsertRows(QModelIndex(), invitees_.count(), invitees_.count()); beginInsertRows(QModelIndex(), invitees_.count(), invitees_.count());
auto invitee = new Invitee{mxid, this}; auto invitee = new Invitee{mxid, this};
@ -30,6 +34,20 @@ InviteesModel::addUser(QString mxid)
emit countChanged(); emit countChanged();
} }
void
InviteesModel::removeUser(QString mxid)
{
for (int i = 0; i < invitees_.length(); ++i) {
if (invitees_[i]->mxid_ == mxid) {
beginRemoveRows(QModelIndex(), i, i);
invitees_.removeAt(i);
endRemoveRows();
emit countChanged();
break;
}
}
}
QHash<int, QByteArray> QHash<int, QByteArray>
InviteesModel::roleNames() const InviteesModel::roleNames() const
{ {

View file

@ -43,6 +43,7 @@ public:
InviteesModel(QObject *parent = nullptr); InviteesModel(QObject *parent = nullptr);
Q_INVOKABLE void addUser(QString mxid); Q_INVOKABLE void addUser(QString mxid);
Q_INVOKABLE void removeUser(QString mxid);
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex & = QModelIndex()) const override int rowCount(const QModelIndex & = QModelIndex()) const override

View file

@ -116,9 +116,10 @@ TimelineViewManager::updateColorPalette()
QColor QColor
TimelineViewManager::userColor(QString id, QColor background) TimelineViewManager::userColor(QString id, QColor background)
{ {
if (!userColors.contains(id)) QPair<QString, quint64> idx{id, background.rgba64()};
userColors.insert(id, QColor(utils::generateContrastingHexColor(id, background))); if (!userColors.contains(idx))
return userColors.value(id); userColors.insert(idx, QColor(utils::generateContrastingHexColor(id, background)));
return userColors.value(idx);
} }
QString QString

View file

@ -147,7 +147,7 @@ private:
CallManager *callManager_ = nullptr; CallManager *callManager_ = nullptr;
VerificationManager *verificationManager_ = nullptr; VerificationManager *verificationManager_ = nullptr;
QHash<QString, QColor> userColors; QHash<QPair<QString, quint64>, QColor> userColors;
}; };
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationAccept) Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationAccept)
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationCancel) Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationCancel)