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
Layout.rightMargin: Nheko.paddingMedium
Layout.topMargin: Nheko.paddingMedium
Layout.alignment: Qt.AlignRight | Qt.AlignCenter
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
hoverEnabled: true
width: fontMetrics.font.pixelSize
height: fontMetrics.font.pixelSize

View file

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

View file

@ -99,8 +99,23 @@ ApplicationWindow {
Layout.fillHeight: true
model: invitees
delegate: RowLayout {
delegate: ItemDelegate {
id: del
hoverEnabled: true
width: ListView.view.width
height: layout.implicitHeight + Nheko.paddingSmall * 2
onClicked: TimelineManager.openGlobalUserProfile(model.mxid)
background: Rectangle {
color: del.hovered ? Nheko.colors.dark : inviteDialogRoot.color
}
RowLayout {
id: layout
spacing: Nheko.paddingMedium
anchors.centerIn: parent
width: del.width - Nheko.paddingSmall * 2
Avatar {
width: Nheko.avatarSize
@ -108,7 +123,7 @@ ApplicationWindow {
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
onClicked: TimelineManager.openGlobalUserProfile(model.mxid)
enabled: false
}
ColumnLayout {
@ -116,21 +131,32 @@ ApplicationWindow {
Label {
text: model.displayName
color: TimelineManager.userColor(model ? model.mxid : "", Nheko.colors.window)
color: TimelineManager.userColor(model ? model.mxid : "", del.background.color)
font.pointSize: fontMetrics.font.pointSize
}
Label {
text: model.mxid
color: Nheko.colors.buttonText
color: del.hovered ? Nheko.colors.brightText : Nheko.colors.buttonText
font.pointSize: fontMetrics.font.pointSize * 0.9
}
}
Item {
Layout.fillHeight: 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
clip: true
spacing: Nheko.paddingMedium
boundsBehavior: Flickable.StopAtBounds
model: readReceipts
delegate: ItemDelegate {
id: del
onClicked: room.openUserProfile(model.mxid)
padding: Nheko.paddingMedium
width: receiptLayout.implicitWidth
height: receiptLayout.implicitHeight
width: ListView.view.width
height: receiptLayout.implicitHeight + Nheko.paddingSmall * 2
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: model.mxid
background: Rectangle {
color: del.hovered ? Nheko.colors.dark : readReceiptsRoot.color
}
RowLayout {
id: receiptLayout
spacing: Nheko.paddingMedium
anchors.fill: parent
anchors.margins: Nheko.paddingSmall
Avatar {
width: Nheko.avatarSize
@ -96,11 +102,10 @@ ApplicationWindow {
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
}
background: Rectangle {
color: readReceiptsRoot.color
}
}
}

View file

@ -75,7 +75,6 @@ ApplicationWindow {
id: memberList
clip: true
spacing: Nheko.paddingMedium
boundsBehavior: Flickable.StopAtBounds
model: members
@ -85,11 +84,24 @@ ApplicationWindow {
enabled: !Settings.mobileMode
}
delegate: RowLayout {
delegate: ItemDelegate {
id: del
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
padding: Nheko.paddingMedium
width: ListView.view.width
height: memberLayout.implicitHeight + Nheko.paddingSmall * 2
hoverEnabled: true
background: Rectangle {
color: del.hovered ? Nheko.colors.dark : roomMembersRoot.color
}
RowLayout {
id: memberLayout
spacing: Nheko.paddingMedium
anchors.centerIn: parent
width: parent.width - Nheko.paddingSmall * 2
Avatar {
id: avatar
@ -99,7 +111,7 @@ ApplicationWindow {
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
enabled: false
}
ColumnLayout {
@ -107,23 +119,22 @@ ApplicationWindow {
ElidedLabel {
fullText: model.displayName
color: TimelineManager.userColor(model ? model.mxid : "", Nheko.colors.window)
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: Nheko.colors.buttonText
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 {
Layout.fillHeight: true
Layout.fillWidth: true
}
Item {
Layout.fillWidth: true
}
EncryptionIndicator {
@ -150,6 +161,13 @@ ApplicationWindow {
}
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
}
footer: Item {
width: parent.width
visible: (members.numUsersLoaded < members.memberCount) && members.loadingMoreMembers

View file

@ -16,6 +16,10 @@ InviteesModel::InviteesModel(QObject *parent)
void
InviteesModel::addUser(QString mxid)
{
for (const auto &invitee : invitees_)
if (invitee->mxid_ == mxid)
return;
beginInsertRows(QModelIndex(), invitees_.count(), invitees_.count());
auto invitee = new Invitee{mxid, this};
@ -30,6 +34,20 @@ InviteesModel::addUser(QString mxid)
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>
InviteesModel::roleNames() const
{

View file

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

View file

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

View file

@ -147,7 +147,7 @@ private:
CallManager *callManager_ = 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::KeyVerificationCancel)