Reorder QML files to follow coding conventions

https://doc.qt.io/qt-5/qml-codingconventions.html#qml-object-declarations
This commit is contained in:
miruka
2020-07-12 00:25:57 -04:00
parent 229fbee298
commit 3c7b78d4ca
131 changed files with 1022 additions and 1122 deletions

View File

@@ -7,14 +7,13 @@ import "../Base"
import "../Base/HTile"
Rectangle {
implicitHeight: accountList.count >= 2 ? accountList.contentHeight : 0
color: theme.mainPane.accountBar.background
property RoomList roomList
readonly property alias accountList: accountList
implicitHeight: accountList.count >= 2 ? accountList.contentHeight : 0
color: theme.mainPane.accountBar.background
Behavior on implicitHeight { HNumberAnimation {} }
HGridView {

View File

@@ -13,10 +13,8 @@ HMenu {
property string presence
property string statusMsg
signal wentToAccountPage()
function setPresence(presence, statusMsg=undefined) {
py.callClientCoro(userId, "set_presence", [presence, statusMsg])
}
@@ -24,7 +22,6 @@ HMenu {
onOpened: statusText.forceActiveFocus()
HLabeledItem {
id: statusMsgLabel
enabled: presence && presence !== "offline"

View File

@@ -7,6 +7,39 @@ import "../Base/HTile"
HTile {
id: account
property bool enableKeybinds: false
property bool filterActive: false
readonly property bool collapsed:
(window.uiState.collapseAccounts[model.id] || false) &&
! filterActive
readonly property alias avatar: title
readonly property alias totalMessageIndicator: totalMessageIndicator
readonly property alias title: title
readonly property alias addChat: addChat
readonly property alias expand: expand
signal wentToAccountPage()
function setCollapse(collapse) {
window.uiState.collapseAccounts[model.id] = collapse
window.uiStateChanged()
py.callCoro("set_account_collapse", [model.id, collapse])
}
function toggleCollapse() {
setCollapse(! collapsed)
}
function togglePresence(presence) {
if (model.presence === presence) presence = "online"
py.callClientCoro(model.id, "set_presence", [presence])
}
backgroundColor: theme.mainPane.listView.account.background
contentItem: ContentRow {
@@ -171,40 +204,6 @@ HTile {
onWentToAccountPage: account.wentToAccountPage()
}
property bool enableKeybinds: false
property bool filterActive: false
readonly property bool collapsed:
(window.uiState.collapseAccounts[model.id] || false) &&
! filterActive
readonly property alias avatar: title
readonly property alias totalMessageIndicator: totalMessageIndicator
readonly property alias title: title
readonly property alias addChat: addChat
readonly property alias expand: expand
signal wentToAccountPage()
function setCollapse(collapse) {
window.uiState.collapseAccounts[model.id] = collapse
window.uiStateChanged()
py.callCoro("set_account_collapse", [model.id, collapse])
}
function toggleCollapse() {
setCollapse(! collapsed)
}
function togglePresence(presence) {
if (model.presence === presence) presence = "online"
py.callClientCoro(model.id, "set_presence", [presence])
}
HShortcut {
enabled: enableKeybinds
sequences: window.settings.keys.accountSettings

View File

@@ -5,17 +5,16 @@ import QtQuick.Layouts 1.12
import "../Base"
Rectangle {
// Hide filter field overflowing for a sec on size changes
clip: true
implicitHeight: theme.baseElementsHeight
color: theme.mainPane.bottomBar.background
property RoomList roomList
readonly property alias addAccountButton: addAccountButton
readonly property alias filterField: filterField
// Hide filter field overflowing for a sec on size changes
clip: true
implicitHeight: theme.baseElementsHeight
color: theme.mainPane.bottomBar.background
HRowLayout {
anchors.fill: parent

View File

@@ -6,15 +6,11 @@ import "../Base"
HDrawer {
id: mainPane
saveName: "mainPane"
background: Rectangle { color: theme.mainPane.background }
minimumSize: theme.mainPane.minimumSize
readonly property alias accountBar: accountBar
readonly property alias roomList: roomList
readonly property alias bottomBar: bottomBar
function toggleFocus() {
if (bottomBar.filterField.activeFocus) {
pageLoader.takeFocus()
@@ -26,6 +22,10 @@ HDrawer {
}
saveName: "mainPane"
background: Rectangle { color: theme.mainPane.background }
minimumSize: theme.mainPane.minimumSize
Behavior on opacity { HNumberAnimation {} }
Binding on visible {

View File

@@ -4,6 +4,13 @@ import QtQuick 2.12
import "../Base"
HLabel {
property QtObject indicatorTheme
property int unreads: 0
property int highlights: 0
property bool localUnreads: false
property bool localHighlights: false
text:
unreads >= 1000000 ? Math.floor(unreads / 1000000) + "M" :
unreads >= 1000 ? Math.floor(unreads / 1000) + "K" :
@@ -31,13 +38,5 @@ HLabel {
Behavior on color { HColorAnimation {} }
}
property QtObject indicatorTheme
property int unreads: 0
property int highlights: 0
property bool localUnreads: false
property bool localHighlights: false
Behavior on scale { HNumberAnimation {} }
}

View File

@@ -9,6 +9,22 @@ import "../Base/HTile"
HTile {
id: room
readonly property bool joined: ! invited && ! parted
readonly property bool invited: model.inviter_id && ! parted
readonly property bool parted: model.left
readonly property ListModel eventModel:
ModelStore.get(model.for_account, model.id, "events")
// FIXME: binding loop
readonly property QtObject accountModel:
ModelStore.get("accounts").find(model.for_account)
readonly property QtObject lastEvent:
eventModel.count > 0 ? eventModel.get(0) : null
backgroundColor: theme.mainPane.listView.room.background
leftPadding: theme.spacing * 2
rightPadding: theme.spacing
@@ -179,19 +195,4 @@ HTile {
})
}
}
readonly property bool joined: ! invited && ! parted
readonly property bool invited: model.inviter_id && ! parted
readonly property bool parted: model.left
readonly property ListModel eventModel:
ModelStore.get(model.for_account, model.id, "events")
// FIXME: binding loop
readonly property QtObject accountModel:
ModelStore.get("accounts").find(model.for_account)
readonly property QtObject lastEvent:
eventModel.count > 0 ? eventModel.get(0) : null
}

View File

@@ -8,83 +8,19 @@ import "../Base"
HListView {
id: roomList
model: ModelStore.get("all_rooms")
delegate: DelegateChooser {
role: "type"
DelegateChoice {
roleValue: "Account"
AccountDelegate {
width: roomList.width
leftPadding: theme.spacing
rightPadding: 0 // the right buttons have padding
filterActive: Boolean(filter)
enableKeybinds: Boolean(
roomList.model.get(currentIndex) && (
roomList.model.get(currentIndex).for_account ||
roomList.model.get(currentIndex).id
) === model.id
)
totalMessageIndicator.visible: false
onLeftClicked: showItemAtIndex(model.index)
onCollapsedChanged:
if (wantedUserId === model.id) startCorrectItemSearch()
onWentToAccountPage: roomList.currentIndex = model.index
}
}
DelegateChoice {
roleValue: "Room"
RoomDelegate {
width: roomList.width
onLeftClicked: showItemAtIndex(model.index)
}
}
}
onFilterChanged: {
py.callCoro("set_substring_filter", ["all_rooms", filter], () => {
if (filter) {
currentIndex = 1 // highlight the first matching room
return
}
const item = model.get(currentIndex)
if (
! filter &&
item && (
currentIndex === 1 || // required, related to the if above
(
currentShouldBeAccount &&
wantedUserId !== item.id
) || (
currentShouldBeRoom && (
wantedUserId !== item.for_account ||
wantedRoomId !== item.id
)
)
)
)
startCorrectItemSearch()
})
}
property string filter: ""
readonly property bool currentShouldBeAccount:
window.uiState.page === "Pages/AccountSettings/AccountSettings.qml" ||
window.uiState.page === "Pages/AddChat/AddChat.qml"
readonly property bool currentShouldBeRoom:
window.uiState.page === "Pages/Chat/Chat.qml"
readonly property string wantedUserId:
window.uiState.pageProperties.userId || ""
readonly property string wantedRoomId:
window.uiState.pageProperties.roomId || ""
@@ -99,7 +35,6 @@ HListView {
return accounts
}
function goToAccount(userId) {
accountIndice[userId] + 1 <= model.count -1 &&
model.get(accountIndice[userId] + 1).type === "Room" ?
@@ -200,6 +135,73 @@ HListView {
}
model: ModelStore.get("all_rooms")
delegate: DelegateChooser {
role: "type"
DelegateChoice {
roleValue: "Account"
AccountDelegate {
width: roomList.width
leftPadding: theme.spacing
rightPadding: 0 // the right buttons have padding
filterActive: Boolean(filter)
enableKeybinds: Boolean(
roomList.model.get(currentIndex) && (
roomList.model.get(currentIndex).for_account ||
roomList.model.get(currentIndex).id
) === model.id
)
totalMessageIndicator.visible: false
onLeftClicked: showItemAtIndex(model.index)
onCollapsedChanged:
if (wantedUserId === model.id) startCorrectItemSearch()
onWentToAccountPage: roomList.currentIndex = model.index
}
}
DelegateChoice {
roleValue: "Room"
RoomDelegate {
width: roomList.width
onLeftClicked: showItemAtIndex(model.index)
}
}
}
onFilterChanged: {
py.callCoro("set_substring_filter", ["all_rooms", filter], () => {
if (filter) {
currentIndex = 1 // highlight the first matching room
return
}
const item = model.get(currentIndex)
if (
! filter &&
item && (
currentIndex === 1 || // required, related to the if above
(
currentShouldBeAccount &&
wantedUserId !== item.id
) || (
currentShouldBeRoom && (
wantedUserId !== item.for_account ||
wantedRoomId !== item.id
)
)
)
)
startCorrectItemSearch()
})
}
Connections {
target: pageLoader