Highlight account and room delegates

This commit is contained in:
miruka 2019-07-12 17:06:37 -04:00
parent 4b45c119ff
commit cb0d7e8a77
11 changed files with 151 additions and 94 deletions

View File

@ -1,3 +1,11 @@
- Qt 5.12
- New input handlers
- ECMAScript 7
- .mjs modules
- inset properties
- `ToolTip.hide()`/`show()`
- horizontal & vertical padding props
- Refactoring - Refactoring
- Don't bake in size properties for components - Don't bake in size properties for components

View File

@ -6,7 +6,7 @@ import QtQuick.Controls 2.0
import "../Base" import "../Base"
import "../utils.js" as Utils import "../utils.js" as Utils
Rectangle { HRectangle {
property string name: "" property string name: ""
property var imageUrl: null property var imageUrl: null
property var toolTipImageUrl: imageUrl property var toolTipImageUrl: imageUrl

View File

@ -0,0 +1,26 @@
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.12
HRectangle {
property bool checkable: false // TODO
property bool checked: false
property color normalColor: theme.controls.listEntry.background
property color hoveredColor: theme.controls.listEntry.hoveredBackground
property color pressedColor: theme.controls.listEntry.pressedBackground
property color checkedColor: theme.controls.listEntry.checkedBackground
color: checked ? checkedColor :
// tap.pressed ? pressedColor :
hover.hovered ? hoveredColor :
normalColor
Behavior on color {
ColorAnimation { duration: theme.animationDuration / 1.5 }
}
HoverHandler { id: hover }
TapHandler { id: tap }
}

View File

@ -24,11 +24,5 @@ HLabel {
mouse.accepted = Boolean(link) mouse.accepted = Boolean(link)
if (link) { Qt.openUrlExternally(link) } if (link) { Qt.openUrlExternally(link) }
} }
onPressAndHold: mouse.accepted = false
onDoubleClicked: mouse.accepted = false
onPressed: mouse.accepted = false
onReleased: mouse.accepted = false
onWheel: mouse.accepted = false
} }
} }

View File

@ -13,53 +13,60 @@ Column {
property bool expanded: true property bool expanded: true
HRowLayout { HHighlightRectangle {
width: parent.width width: parent.width
height: childrenRect.height height: childrenRect.height
id: row
HUserAvatar { normalColor: theme.sidePane.account.background
id: avatar
// Need to do this because conflict with the model property
Component.onCompleted: userId = model.userId
}
HColumnLayout { HRowLayout {
Layout.fillWidth: true id: row
Layout.fillHeight: true width: parent.width
HLabel { HUserAvatar {
id: accountLabel id: avatar
text: userInfo.displayName || model.userId // Need to do this because conflict with the model property
elide: HLabel.ElideRight Component.onCompleted: userId = model.userId
maximumLineCount: 1
Layout.fillWidth: true
leftPadding: 6
rightPadding: leftPadding
} }
HTextField { HColumnLayout {
id: statusEdit
text: userInfo.statusMessage
placeholderText: qsTr("Set status message")
font.pixelSize: theme.fontSize.small
background: null
padding: 0
leftPadding: accountLabel.leftPadding
rightPadding: leftPadding
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true
onEditingFinished: { HLabel {
//Backend.setStatusMessage(model.userId, text) TODO id: accountLabel
pageStack.forceActiveFocus() text: userInfo.displayName || model.userId
elide: HLabel.ElideRight
maximumLineCount: 1
Layout.fillWidth: true
leftPadding: sidePane.currentSpacing
rightPadding: leftPadding
}
HTextField {
id: statusEdit
text: userInfo.statusMessage
placeholderText: qsTr("Set status message")
font.pixelSize: theme.fontSize.small
background: null
padding: 0
leftPadding: accountLabel.leftPadding
rightPadding: leftPadding
Layout.fillWidth: true
onEditingFinished: {
//Backend.setStatusMessage(model.userId, text) TODO
pageStack.forceActiveFocus()
}
} }
} }
}
ExpandButton { ExpandButton {
expandableItem: accountDelegate id: expandButton
Layout.preferredHeight: row.height expandableItem: accountDelegate
Layout.preferredHeight: row.height
}
} }
} }

View File

@ -30,6 +30,7 @@ Column {
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
Layout.leftMargin: sidePane.currentSpacing
Layout.fillWidth: true Layout.fillWidth: true
} }

View File

@ -1,71 +1,82 @@
// Copyright 2019 miruka // Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3. // This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.7 import QtQuick 2.12
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "../Base" import "../Base"
import "../utils.js" as Utils import "../utils.js" as Utils
MouseArea { HHighlightRectangle {
id: roomDelegate id: roomDelegate
width: roomList.width width: roomList.width
height: childrenRect.height height: childrenRect.height
onClicked: TapHandler {
pageStack.showRoom(roomList.userId, roomList.category, model.roomId) onTapped: pageStack.showRoom(
roomList.userId, roomList.category, model.roomId
)
}
HRowLayout { Row {
width: parent.width width: parent.width - sidePane.currentSpacing * 2
spacing: sidePane.collapsed ? 0 : sidePane.normalSpacing padding: sidePane.currentSpacing / 2
leftPadding: sidePane.currentSpacing
rightPadding: 0
HRoomAvatar { HRowLayout {
id: roomAvatar width: parent.width
roomId: model.roomId spacing: sidePane.currentSpacing
}
HColumnLayout { HRoomAvatar {
Layout.fillWidth: true id: roomAvatar
Layout.maximumWidth: roomId: model.roomId
parent.width - parent.totalSpacing - roomAvatar.width
HLabel {
id: roomLabel
text: model.displayName || "<i>Empty room</i>"
textFormat: model.displayName? Text.PlainText : Text.StyledText
elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Qt.AlignVCenter
Layout.maximumWidth: parent.width
} }
HRichLabel { HColumnLayout {
function getText(ev) { Layout.fillWidth: true
if (! ev) { return "" } Layout.maximumWidth:
parent.width - parent.totalSpacing - roomAvatar.width
if (! Utils.eventIsMessage(ev)) { HLabel {
return Utils.translatedEventContent(ev) id: roomLabel
} text: model.displayName || "<i>Empty room</i>"
textFormat:
model.displayName? Text.PlainText : Text.StyledText
elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Qt.AlignVCenter
return Utils.coloredNameHtml( Layout.maximumWidth: parent.width
users.find(ev.senderId).displayName,
ev.senderId
) + ": " + py.callSync("inlinify", [ev.content])
} }
// Have to do it like this to avoid binding loop HRichLabel {
property var lastEv: timelines.lastEventOf(model.roomId) function getText(ev) {
onLastEvChanged: text = getText(lastEv) if (! ev) { return "" }
id: subtitleLabel if (! Utils.eventIsMessage(ev)) {
visible: Boolean(text) return Utils.translatedEventContent(ev)
textFormat: Text.StyledText }
font.pixelSize: theme.fontSize.small return Utils.coloredNameHtml(
elide: Text.ElideRight users.find(ev.senderId).displayName,
maximumLineCount: 1 ev.senderId
) + ": " + py.callSync("inlinify", [ev.content])
}
Layout.maximumWidth: parent.width // Have to do it like this to avoid binding loop
property var lastEv: timelines.lastEventOf(model.roomId)
onLastEvChanged: text = getText(lastEv)
id: subtitleLabel
visible: Boolean(text)
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: parent.width
}
} }
} }
} }

View File

@ -8,12 +8,11 @@ import "../Base"
import "../utils.js" as Utils import "../utils.js" as Utils
HListView { HListView {
id: roomList
property string userId: "" property string userId: ""
property string category: "" property string category: ""
id: roomList
spacing: sidePane.collapsed ? 0 : sidePane.normalSpacing
model: SortFilterProxyModel { model: SortFilterProxyModel {
sourceModel: rooms sourceModel: rooms
filters: AllOf { filters: AllOf {

View File

@ -12,6 +12,7 @@ HRectangle {
clip: true clip: true
property int normalSpacing: 8 property int normalSpacing: 8
property int currentSpacing: collapsed ? 0 : normalSpacing
property bool collapsed: false property bool collapsed: false
HColumnLayout { HColumnLayout {
@ -21,10 +22,8 @@ HRectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
spacing: collapsed ? 0 : normalSpacing * 3 spacing: currentSpacing
topMargin: collapsed ? 0 : normalSpacing bottomMargin: currentSpacing
bottomMargin: topMargin
Layout.leftMargin: topMargin
Behavior on spacing { HNumberAnimation {} } Behavior on spacing { HNumberAnimation {} }
} }

View File

@ -41,6 +41,13 @@ QtObject {
property color background: colors.background2 property color background: colors.background2
} }
property QtObject listEntry: QtObject {
property color background: "transparent"
property color hoveredBackground: Qt.hsla(0, 0, 0, 0.2)
property color pressedBackground: Qt.hsla(0, 0, 0, 0.4)
property color checkedBackground: Qt.hsla(0, 0, 0, 0.4)
}
property QtObject textField: QtObject { property QtObject textField: QtObject {
property color background: colors.background2 property color background: colors.background2
} }
@ -53,6 +60,10 @@ QtObject {
property QtObject sidePane: QtObject { property QtObject sidePane: QtObject {
property color background: colors.background2 property color background: colors.background2
property QtObject account: QtObject {
property color background: Qt.lighter(colors.background2, 1.05)
}
property QtObject settingsButton: QtObject { property QtObject settingsButton: QtObject {
property color background: colors.background2 property color background: colors.background2
} }

View File

@ -28,6 +28,7 @@ ApplicationWindow {
Python { id: py } Python { id: py }
// Models
Accounts { id: accounts } Accounts { id: accounts }
Devices { id: devices } Devices { id: devices }
RoomCategories { id: roomCategories } RoomCategories { id: roomCategories }