From 87c72e32db995cb1efcb1a11777d0c07fdee61d3 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 28 Apr 2019 12:40:18 -0400 Subject: [PATCH] Update SidePane componants, add Base.HColumnLayout --- .../AccountDelegate.qml | 34 +++++++------------ .../{sidePane => SidePane}/AccountList.qml | 11 ++++-- .../HToolBar.qml => SidePane/PaneToolBar.qml} | 0 .../RoomCategoryDelegate.qml | 0 .../{sidePane => SidePane}/RoomDelegate.qml | 22 +++++++----- .../{sidePane => SidePane}/RoomList.qml | 4 +-- .../Root.qml => SidePane/SidePane.qml} | 5 ++- .../{sidePane => SidePane}/utils.js | 0 harmonyqml/components/base/HColumnLayout.qml | 11 ++++++ harmonyqml/components/base/HTextField.qml | 1 + 10 files changed, 50 insertions(+), 38 deletions(-) rename harmonyqml/components/{sidePane => SidePane}/AccountDelegate.qml (74%) rename harmonyqml/components/{sidePane => SidePane}/AccountList.qml (59%) rename harmonyqml/components/{sidePane/HToolBar.qml => SidePane/PaneToolBar.qml} (100%) rename harmonyqml/components/{sidePane => SidePane}/RoomCategoryDelegate.qml (100%) rename harmonyqml/components/{sidePane => SidePane}/RoomDelegate.qml (80%) rename harmonyqml/components/{sidePane => SidePane}/RoomList.qml (91%) rename harmonyqml/components/{sidePane/Root.qml => SidePane/SidePane.qml} (87%) rename harmonyqml/components/{sidePane => SidePane}/utils.js (100%) create mode 100644 harmonyqml/components/base/HColumnLayout.qml diff --git a/harmonyqml/components/sidePane/AccountDelegate.qml b/harmonyqml/components/SidePane/AccountDelegate.qml similarity index 74% rename from harmonyqml/components/sidePane/AccountDelegate.qml rename to harmonyqml/components/SidePane/AccountDelegate.qml index 0219f1e7..f6e44edb 100644 --- a/harmonyqml/components/sidePane/AccountDelegate.qml +++ b/harmonyqml/components/SidePane/AccountDelegate.qml @@ -3,21 +3,20 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.4 import "../base" as Base -ColumnLayout { +Base.HColumnLayout { id: accountDelegate - spacing: 0 width: parent.width - RowLayout { + property string roomListUserId: userId + + Base.HRowLayout { id: row - spacing: 0 Base.HAvatar { id: avatar; name: displayName; dimension: 36 } - ColumnLayout { + Base.HColumnLayout { Layout.fillWidth: true Layout.fillHeight: true - spacing: 0 Base.HLabel { id: accountLabel @@ -29,22 +28,20 @@ ColumnLayout { rightPadding: leftPadding } - TextField { + Base.HTextField { id: statusEdit text: statusMessage || "" placeholderText: qsTr("Set status message") + font.pixelSize: Base.HStyle.fontSize.small background: null - color: "black" - selectByMouse: true - font.family: "Roboto" - font.pixelSize: 12 - Layout.fillWidth: true + padding: 0 leftPadding: accountLabel.leftPadding rightPadding: leftPadding + Layout.fillWidth: true onEditingFinished: { - Backend.setStatusMessage(userId, text) + //Backend.setStatusMessage(userId, text) pageStack.forceActiveFocus() } } @@ -65,17 +62,12 @@ ColumnLayout { id: roomList visible: true interactive: false // no scrolling - forUserId: userId + userId: roomListUserId - Layout.minimumHeight: - roomList.visible ? - roomList.contentHeight : - 0 - Layout.maximumHeight: Layout.minimumHeight + Layout.preferredHeight: roomList.visible ? roomList.contentHeight : 0 - Layout.minimumWidth: + Layout.preferredWidth: parent.width - Layout.leftMargin - Layout.rightMargin - Layout.maximumWidth: Layout.minimumWidth Layout.margins: accountList.spacing Layout.leftMargin: diff --git a/harmonyqml/components/sidePane/AccountList.qml b/harmonyqml/components/SidePane/AccountList.qml similarity index 59% rename from harmonyqml/components/sidePane/AccountList.qml rename to harmonyqml/components/SidePane/AccountList.qml index 7aae9041..caa074c4 100644 --- a/harmonyqml/components/sidePane/AccountList.qml +++ b/harmonyqml/components/SidePane/AccountList.qml @@ -4,8 +4,13 @@ import QtQuick.Layouts 1.4 ListView { id: accountList - spacing: 8 - model: Backend.models.accounts - delegate: AccountDelegate {} clip: true + + spacing: 8 + Layout.leftMargin: spacing + topMargin: spacing + bottomMargin: spacing + + model: Backend.models.accounts + delegate: AccountDelegate {} } diff --git a/harmonyqml/components/sidePane/HToolBar.qml b/harmonyqml/components/SidePane/PaneToolBar.qml similarity index 100% rename from harmonyqml/components/sidePane/HToolBar.qml rename to harmonyqml/components/SidePane/PaneToolBar.qml diff --git a/harmonyqml/components/sidePane/RoomCategoryDelegate.qml b/harmonyqml/components/SidePane/RoomCategoryDelegate.qml similarity index 100% rename from harmonyqml/components/sidePane/RoomCategoryDelegate.qml rename to harmonyqml/components/SidePane/RoomCategoryDelegate.qml diff --git a/harmonyqml/components/sidePane/RoomDelegate.qml b/harmonyqml/components/SidePane/RoomDelegate.qml similarity index 80% rename from harmonyqml/components/sidePane/RoomDelegate.qml rename to harmonyqml/components/SidePane/RoomDelegate.qml index 623892b7..0bda3b2b 100644 --- a/harmonyqml/components/sidePane/RoomDelegate.qml +++ b/harmonyqml/components/SidePane/RoomDelegate.qml @@ -5,29 +5,32 @@ import "../base" as Base import "utils.js" as SidePaneJS MouseArea { - id: root + id: roomDelegate width: roomList.width height: roomList.childrenHeight - onClicked: pageStack.showRoom(roomList.forUserId, roomId) + onClicked: pageStack.showRoom(roomList.userId, roomId) - RowLayout { + Base.HRowLayout { anchors.fill: parent id: row spacing: 1 - Base.HAvatar { id: avatar; name: displayName; dimension: root.height } - - ColumnLayout { - spacing: 0 + Base.HAvatar { + id: roomAvatar + name: displayName + dimension: roomDelegate.height + } + Base.HColumnLayout { Base.HLabel { id: roomLabel text: displayName ? displayName : "Empty room" textFormat: Text.StyledText elide: Text.ElideRight maximumLineCount: 1 - Layout.maximumWidth: row.width - row.spacing - avatar.width + Layout.maximumWidth: + row.width - row.totalSpacing - roomAvatar.width verticalAlignment: Qt.AlignVCenter topPadding: -2 @@ -35,10 +38,11 @@ MouseArea { leftPadding: 5 rightPadding: leftPadding } + Base.HLabel { function getText() { return SidePaneJS.getLastRoomEventText( - roomId, roomList.forUserId + roomId, roomList.userId ) } diff --git a/harmonyqml/components/sidePane/RoomList.qml b/harmonyqml/components/SidePane/RoomList.qml similarity index 91% rename from harmonyqml/components/sidePane/RoomList.qml rename to harmonyqml/components/SidePane/RoomList.qml index aa96443b..cb4096e3 100644 --- a/harmonyqml/components/sidePane/RoomList.qml +++ b/harmonyqml/components/SidePane/RoomList.qml @@ -4,7 +4,7 @@ import QtQuick.Layouts 1.4 import "../base" as Base ListView { - property var forUserId: null + property var userId: null property int childrenHeight: 36 property int sectionHeight: 16 + spacing @@ -31,7 +31,7 @@ ListView { id: roomList spacing: 8 - model: Backend.models.rooms.get(forUserId) + model: Backend.models.rooms.get(userId) delegate: RoomDelegate {} section.property: "category" diff --git a/harmonyqml/components/sidePane/Root.qml b/harmonyqml/components/SidePane/SidePane.qml similarity index 87% rename from harmonyqml/components/sidePane/Root.qml rename to harmonyqml/components/SidePane/SidePane.qml index bd6b5730..e6876751 100644 --- a/harmonyqml/components/sidePane/Root.qml +++ b/harmonyqml/components/SidePane/SidePane.qml @@ -10,15 +10,14 @@ Base.HGlassRectangle { isPageStackDescendant: false - ColumnLayout { + Base.HColumnLayout { anchors.fill: parent - spacing: 0 AccountList { Layout.fillWidth: true Layout.fillHeight: true } - HToolBar {} + PaneToolBar {} } } diff --git a/harmonyqml/components/sidePane/utils.js b/harmonyqml/components/SidePane/utils.js similarity index 100% rename from harmonyqml/components/sidePane/utils.js rename to harmonyqml/components/SidePane/utils.js diff --git a/harmonyqml/components/base/HColumnLayout.qml b/harmonyqml/components/base/HColumnLayout.qml new file mode 100644 index 00000000..fd56fe36 --- /dev/null +++ b/harmonyqml/components/base/HColumnLayout.qml @@ -0,0 +1,11 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.4 + +ColumnLayout { + id: columnLayout + spacing: 0 + + property int totalSpacing: + spacing * Math.max(0, (columnLayout.visibleChildren.length - 1)) +} diff --git a/harmonyqml/components/base/HTextField.qml b/harmonyqml/components/base/HTextField.qml index 098a9fd1..c300cd86 100644 --- a/harmonyqml/components/base/HTextField.qml +++ b/harmonyqml/components/base/HTextField.qml @@ -4,6 +4,7 @@ import QtQuick.Controls 2.0 TextField { font.family: HStyle.fontFamily.sans font.pixelSize: HStyle.fontSize.normal + color: HStyle.colors.foreground selectByMouse: true }