Use ItemDelegate in RoomList instead of a Rectangle with handlers

fixes #683
relates to #571
This commit is contained in:
Nicolas Werner 2021-11-03 23:01:36 +01:00
parent 1a163f49e2
commit 1e22274d8c
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
9 changed files with 1895 additions and 498 deletions

View file

@ -114,10 +114,10 @@ Page {
}
delegate: Rectangle {
delegate: ItemDelegate {
id: roomItem
property color background: Nheko.colors.window
property color backgroundColor: Nheko.colors.window
property color importantText: Nheko.colors.text
property color unimportantText: Nheko.colors.buttonText
property color bubbleBackground: Nheko.colors.highlight
@ -136,20 +136,31 @@ Page {
required property bool isDirect
required property string directChatOtherUserId
color: background
height: avatarSize + 2 * Nheko.paddingMedium
width: ListView.view.width
state: "normal"
ToolTip.visible: hovered.hovered && collapsed
ToolTip.visible: hovered && collapsed
ToolTip.text: roomName
onClicked: {
console.log("tapped " + roomId);
if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
Rooms.setCurrentRoom(roomId);
else
Rooms.resetCurrentRoom();
}
onPressAndHold: {
if (!isInvite)
roomContextMenu.show(roomId, tags);
}
states: [
State {
name: "highlight"
when: hovered.hovered && !((Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId)
when: roomItem.hovered && !((Rooms.currentRoom && roomId == Rooms.currentRoom.roomId) || Rooms.currentRoomPreview.roomid == roomId)
PropertyChanges {
target: roomItem
background: Nheko.colors.dark
backgroundColor: Nheko.colors.dark
importantText: Nheko.colors.brightText
unimportantText: Nheko.colors.brightText
bubbleBackground: Nheko.colors.highlight
@ -163,7 +174,7 @@ Page {
PropertyChanges {
target: roomItem
background: Nheko.colors.highlight
backgroundColor: Nheko.colors.highlight
importantText: Nheko.colors.highlightedText
unimportantText: Nheko.colors.highlightedText
bubbleBackground: Nheko.colors.highlightedText
@ -189,28 +200,6 @@ Page {
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
}
TapHandler {
margin: -Nheko.paddingSmall
onSingleTapped: {
console.log("tapped "+roomId);
if (!Rooms.currentRoom || Rooms.currentRoom.roomId !== roomId)
Rooms.setCurrentRoom(roomId);
else
Rooms.resetCurrentRoom();
}
onLongPressed: {
if (!isInvite)
roomContextMenu.show(roomId, tags);
}
}
HoverHandler {
id: hovered
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
}
}
RowLayout {
@ -362,6 +351,10 @@ Page {
visible: hasUnreadMessages
}
background: Rectangle {
color: backgroundColor
}
}
}
@ -505,24 +498,28 @@ Page {
Rectangle {
id: unverifiedStuffBubble
color: Qt.lighter(Nheko.theme.orange, verifyButtonHovered.hovered ? 1.2 : 1.0)
color: Qt.lighter(Nheko.theme.orange, verifyButtonHovered.hovered ? 1.2 : 1)
Layout.fillWidth: true
implicitHeight: explanation.height + Nheko.paddingMedium * 2
visible: SelfVerificationStatus.status != SelfVerificationStatus.AllVerified
RowLayout {
id: unverifiedStuffBubbleContainer
width: parent.width
height: explanation.height + Nheko.paddingMedium * 2
spacing: 0
Label {
id: explanation
Layout.margins: Nheko.paddingMedium
Layout.rightMargin: Nheko.paddingSmall
color: Nheko.colors.buttonText
Layout.fillWidth: true
text: switch(SelfVerificationStatus.status) {
text: {
switch (SelfVerificationStatus.status) {
case SelfVerificationStatus.NoMasterKey:
//: Cross-signing setup has not run yet.
return qsTr("Encryption not set up");
@ -533,7 +530,8 @@ Page {
//: There are unverified devices signed in to this account.
return qsTr("Please verify your other devices");
default:
return ""
return "";
}
}
textFormat: Text.PlainText
wrapMode: Text.Wrap
@ -558,8 +556,8 @@ Page {
HoverHandler {
id: verifyButtonHovered
enabled: !closeUnverifiedBubble.hovered
enabled: !closeUnverifiedBubble.hovered
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
}
@ -567,13 +565,13 @@ Page {
enabled: !closeUnverifiedBubble.hovered
acceptedButtons: Qt.LeftButton
onSingleTapped: {
if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedDevices) {
if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedDevices)
SelfVerificationStatus.verifyUnverifiedDevices();
} else {
else
SelfVerificationStatus.statusChanged();
}
}
}
}
Rectangle {

View file

@ -116,6 +116,7 @@ Page {
LogoutDialog {
}
}
Component {
@ -123,6 +124,7 @@ Page {
JoinRoomDialog {
}
}
Component {
@ -130,6 +132,7 @@ Page {
LeaveRoomDialog {
}
}
Shortcut {
@ -296,28 +299,31 @@ Page {
buttons: Platform.MessageDialog.Ok
text: qsTr("Wait for the confirmation link to arrive, then continue.")
onAccepted: UIA.continue3pidReceived()
}
Connections {
function onPassword() {
console.log("UIA: password needed");
uiaPassPrompt.show();
}
function onEmail() {
uiaEmailPrompt.show();
}
function onPhoneNumber() {
uiaPhoneNumberPrompt.show();
}
function onPrompt3pidToken() {
uiaTokenPrompt.show();
}
function onConfirm3pidToken() {
uiaConfirmationLinkDialog.open();
}
function onError(msg) {
uiaErrorDialog.text = msg;
uiaErrorDialog.open();

View file

@ -2,12 +2,12 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
import "./components/"
import Qt.labs.platform 1.1 as P
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.3
import im.nheko 1.0
import "./components/"
Item {
visible: false
@ -208,7 +208,6 @@ Item {
}
background: Rectangle {
color: Nheko.colors.window
border.color: Nheko.theme.separator
@ -258,30 +257,32 @@ Item {
verifyMasterKey.close();
}
}
FlatButton {
visible: SelfVerificationStatus.hasSSSS
Layout.alignment: Qt.AlignHCenter
text: qsTr("enter passphrase")
onClicked: {
SelfVerificationStatus.verifyMasterKeyWithPassphrase()
SelfVerificationStatus.verifyMasterKeyWithPassphrase();
verifyMasterKey.close();
}
}
}
}
Connections {
function onStatusChanged() {
console.log("STATUS CHANGED: " + SelfVerificationStatus.status);
if (SelfVerificationStatus.status == SelfVerificationStatus.NoMasterKey)
if (SelfVerificationStatus.status == SelfVerificationStatus.NoMasterKey) {
bootstrapCrosssigning.open();
else if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedMasterKey)
} else if (SelfVerificationStatus.status == SelfVerificationStatus.UnverifiedMasterKey) {
verifyMasterKey.open();
else {
} else {
bootstrapCrosssigning.close();
verifyMasterKey.close();
}
}
function onShowRecoveryKey(key) {

View file

@ -9,6 +9,9 @@ import QtQuick.Layouts 1.3
import im.nheko 1.0
Dialog {
default property alias inner: scroll.data
property int useableWidth: scroll.width - scroll.ScrollBar.vertical.width
parent: Overlay.overlay
anchors.centerIn: parent
height: (Math.floor(parent.height / 2) - Nheko.paddingLarge) * 2
@ -17,10 +20,6 @@ Dialog {
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
closePolicy: Popup.NoAutoClose
default property alias inner: scroll.data
property int useableWidth: scroll.width - scroll.ScrollBar.vertical.width
contentChildren: [
ScrollView {
id: scroll

View file

@ -45,6 +45,7 @@ ApplicationWindow {
onAccepted: {
if (input.text.match("#.+?:.{3,}"))
dbb.accepted();
}
}
@ -71,6 +72,7 @@ ApplicationWindow {
text: "Cancel"
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
}
}
}

View file

@ -2,9 +2,9 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
import Qt.labs.platform 1.1
import QtQuick 2.15
import QtQuick.Controls 2.15
import Qt.labs.platform 1.1
import im.nheko 1.0
MessageDialog {

View file

@ -2,9 +2,9 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
import Qt.labs.platform 1.1
import QtQuick 2.15
import QtQuick.Controls 2.15
import Qt.labs.platform 1.1
import im.nheko 1.0
MessageDialog {

File diff suppressed because it is too large Load diff

View file

@ -327,14 +327,17 @@ ApplicationWindow {
onClicked: profile.signOutDevice(deviceId)
visible: profile.isSelf
}
}
RowLayout {
id: deviceNameRow
property bool isEditingAllowed
TextInput {
id: deviceNameField
readOnly: !deviceNameRow.isEditingAllowed
text: deviceName
color: Nheko.colors.text
@ -409,8 +412,6 @@ ApplicationWindow {
}
}
}
footer: DialogButtonBox {