Move major pages to the qml directory
This commit is contained in:
114
qml/RoomListPage.qml
Normal file
114
qml/RoomListPage.qml
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||||
|
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||||
|
*
|
||||||
|
* SPDX-LicenseIdentifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12 as QQC2
|
||||||
|
import QtQuick.Layouts 1.12
|
||||||
|
|
||||||
|
import org.kde.kirigami 2.13 as Kirigami
|
||||||
|
|
||||||
|
import org.kde.kitemmodels 1.0
|
||||||
|
import Spectral.Component 2.0
|
||||||
|
import Spectral 0.1
|
||||||
|
|
||||||
|
Kirigami.ScrollablePage {
|
||||||
|
id: page
|
||||||
|
|
||||||
|
property var roomListModel
|
||||||
|
property var enteredRoom
|
||||||
|
property var searchText: ""
|
||||||
|
|
||||||
|
onSearchTextChanged: sortedFilteredRoomListModel.invalidateFilter()
|
||||||
|
|
||||||
|
signal enterRoom(var room)
|
||||||
|
signal leaveRoom(var room)
|
||||||
|
|
||||||
|
title: i18n("Rooms")
|
||||||
|
|
||||||
|
titleDelegate: Kirigami.SearchField {
|
||||||
|
Layout.topMargin: Kirigami.Units.smallSpacing
|
||||||
|
Layout.bottomMargin: Kirigami.Units.smallSpacing
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onTextChanged: page.searchText = text
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: messageListView
|
||||||
|
|
||||||
|
model: KSortFilterProxyModel {
|
||||||
|
id: sortedFilteredRoomListModel
|
||||||
|
sourceModel: roomListModel
|
||||||
|
|
||||||
|
sortRole: "name"
|
||||||
|
sortOrder: Qt.AscendingOrder
|
||||||
|
filterRowCallback: function(row, parent) {
|
||||||
|
return (roomListModel.data(roomListModel.index(row, 0), RoomListModel.JoinStateRole) !== "upgraded") && roomListModel.data(roomListModel.index(row, 0), RoomListModel.NameRole).toLowerCase().includes(page.searchText.toLowerCase())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section.property: "categoryName"
|
||||||
|
section.delegate: Kirigami.ListSectionHeader {
|
||||||
|
label: section
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: Kirigami.AbstractListItem {
|
||||||
|
topPadding: Kirigami.Units.largeSpacing
|
||||||
|
bottomPadding: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
contentItem: RowLayout {
|
||||||
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
Kirigami.Avatar {
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
source: avatar ? "image://mxc/" + avatar : ""
|
||||||
|
name: model.name || "No Name"
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
|
QQC2.Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
text: name ?? ""
|
||||||
|
font.pixelSize: 15
|
||||||
|
font.bold: unreadCount >= 0
|
||||||
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
QQC2.Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
|
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
|
||||||
|
font.pixelSize: 12
|
||||||
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (enteredRoom) {
|
||||||
|
leaveRoom(enteredRoom)
|
||||||
|
}
|
||||||
|
|
||||||
|
enteredRoom = currentRoom
|
||||||
|
|
||||||
|
enterRoom(enteredRoom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,18 +15,18 @@ import Spectral.Effect 2.0
|
|||||||
import Spectral 0.1
|
import Spectral 0.1
|
||||||
|
|
||||||
Kirigami.ScrollablePage {
|
Kirigami.ScrollablePage {
|
||||||
property var currentRoom
|
|
||||||
|
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
title: "Messages"
|
property var currentRoom
|
||||||
|
|
||||||
|
title: i18n("Messages")
|
||||||
|
|
||||||
MessageEventModel {
|
MessageEventModel {
|
||||||
id: messageEventModel
|
id: messageEventModel
|
||||||
|
|
||||||
room: currentRoom
|
room: currentRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageClipboard {
|
ImageClipboard {
|
||||||
id: imageClipboard
|
id: imageClipboard
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
icon.name: 'mail-attachment'
|
icon.name: 'mail-attachment'
|
||||||
|
|
||||||
text: "Choose local file"
|
text: i18n("Choose local file")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
attachDialog.close()
|
attachDialog.close()
|
||||||
@@ -55,7 +55,7 @@ Kirigami.ScrollablePage {
|
|||||||
fileDialog.chosen.connect(function(path) {
|
fileDialog.chosen.connect(function(path) {
|
||||||
if (!path) return
|
if (!path) return
|
||||||
|
|
||||||
roomPanelInput.attach(path)
|
chatTextInput.attach(path)
|
||||||
})
|
})
|
||||||
|
|
||||||
fileDialog.open()
|
fileDialog.open()
|
||||||
@@ -71,11 +71,11 @@ Kirigami.ScrollablePage {
|
|||||||
padding: 16
|
padding: 16
|
||||||
|
|
||||||
icon.name: 'insert-image'
|
icon.name: 'insert-image'
|
||||||
text: "Clipboard image"
|
text: i18n("Clipboard image")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var localPath = StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/screenshots/" + (new Date()).getTime() + ".png"
|
var localPath = StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/screenshots/" + (new Date()).getTime() + ".png"
|
||||||
if (!imageClipboard.saveImage(localPath)) return
|
if (!imageClipboard.saveImage(localPath)) return
|
||||||
roomPanelInput.attach(localPath)
|
chatTextInput.attach(localPath)
|
||||||
attachDialog.close()
|
attachDialog.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,8 +289,8 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: RoomPanelInput {
|
footer: ChatTextInput {
|
||||||
id: roomPanelInput
|
id: chatTextInput
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
13
qml/main.qml
13
qml/main.qml
@@ -1,3 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
|
||||||
|
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
|
||||||
|
*
|
||||||
|
* SPDX-LicenseIdentifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
import QtQuick 2.14
|
import QtQuick 2.14
|
||||||
import QtQuick.Controls 2.14 as Controls
|
import QtQuick.Controls 2.14 as Controls
|
||||||
import QtQuick.Layouts 1.14
|
import QtQuick.Layouts 1.14
|
||||||
@@ -17,20 +23,20 @@ Kirigami.ApplicationWindow {
|
|||||||
id: contextDrawer
|
id: contextDrawer
|
||||||
enabled: roomList.enteredRoom !== null
|
enabled: roomList.enteredRoom !== null
|
||||||
room: root.currentRoom
|
room: root.currentRoom
|
||||||
|
handleVisible: enabled && (pageStack.currentItem instanceof RoomPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
pageStack.initialPage: LoadingPage {}
|
pageStack.initialPage: LoadingPage {}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: roomListComponent
|
id: roomListComponent
|
||||||
RoomListPanel {
|
RoomListPage {
|
||||||
id: roomList
|
id: roomList
|
||||||
roomListModel: spectralRoomListModel
|
roomListModel: spectralRoomListModel
|
||||||
|
|
||||||
onEnterRoom: {
|
onEnterRoom: {
|
||||||
applicationWindow().pageStack.push(roomPanelComponent, {"currentRoom": room});
|
applicationWindow().pageStack.push(roomPanelComponent, {"currentRoom": room});
|
||||||
root.currentRoom = room;
|
root.currentRoom = room;
|
||||||
|
|
||||||
}
|
}
|
||||||
onLeaveRoom: {
|
onLeaveRoom: {
|
||||||
var stack = applicationWindow().pageStack;
|
var stack = applicationWindow().pageStack;
|
||||||
@@ -49,6 +55,7 @@ Kirigami.ApplicationWindow {
|
|||||||
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
onErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||||
|
|
||||||
onInitiated: {
|
onInitiated: {
|
||||||
|
|
||||||
if (spectralController.accountCount === 0) {
|
if (spectralController.accountCount === 0) {
|
||||||
pageStack.replace("qrc:/qml/LoginPage.qml", {
|
pageStack.replace("qrc:/qml/LoginPage.qml", {
|
||||||
'spectralController': spectralController
|
'spectralController': spectralController
|
||||||
@@ -81,7 +88,7 @@ Kirigami.ApplicationWindow {
|
|||||||
Component {
|
Component {
|
||||||
id: roomPanelComponent
|
id: roomPanelComponent
|
||||||
|
|
||||||
RoomPanel {
|
RoomPage {
|
||||||
currentRoom: root.currentRoom
|
currentRoom: root.currentRoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
res.qrc
6
res.qrc
@@ -3,6 +3,9 @@
|
|||||||
<file>qml/main.qml</file>
|
<file>qml/main.qml</file>
|
||||||
<file>qml/LoginPage.qml</file>
|
<file>qml/LoginPage.qml</file>
|
||||||
<file>qml/LoadingPage.qml</file>
|
<file>qml/LoadingPage.qml</file>
|
||||||
|
<file>qml/RoomListPage.qml</file>
|
||||||
|
<file>qml/RoomPage.qml</file>
|
||||||
|
<file>qml/ChatTextInput.qml</file>
|
||||||
<file>imports/Spectral/Component/Emoji/EmojiPicker.qml</file>
|
<file>imports/Spectral/Component/Emoji/EmojiPicker.qml</file>
|
||||||
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
<file>imports/Spectral/Component/Emoji/qmldir</file>
|
||||||
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
<file>imports/Spectral/Component/Timeline/MessageDelegate.qml</file>
|
||||||
@@ -20,14 +23,11 @@
|
|||||||
<file>imports/Spectral/Setting/qmldir</file>
|
<file>imports/Spectral/Setting/qmldir</file>
|
||||||
<file>imports/Spectral/Panel/qmldir</file>
|
<file>imports/Spectral/Panel/qmldir</file>
|
||||||
<file>imports/Spectral/Panel/RoomDrawer.qml</file>
|
<file>imports/Spectral/Panel/RoomDrawer.qml</file>
|
||||||
<file>imports/Spectral/Panel/RoomListPanel.qml</file>
|
|
||||||
<file>imports/Spectral/Panel/RoomPanel.qml</file>
|
|
||||||
<file>imports/Spectral/Panel/RoomHeader.qml</file>
|
<file>imports/Spectral/Panel/RoomHeader.qml</file>
|
||||||
<file>imports/Spectral/Panel/SpectralSidebar.qml</file>
|
<file>imports/Spectral/Panel/SpectralSidebar.qml</file>
|
||||||
<file>imports/Spectral/Component/ScrollHelper.qml</file>
|
<file>imports/Spectral/Component/ScrollHelper.qml</file>
|
||||||
<file>imports/Spectral/Component/AutoListView.qml</file>
|
<file>imports/Spectral/Component/AutoListView.qml</file>
|
||||||
<file>imports/Spectral/Component/AutoTextField.qml</file>
|
<file>imports/Spectral/Component/AutoTextField.qml</file>
|
||||||
<file>imports/Spectral/Panel/RoomPanelInput.qml</file>
|
|
||||||
<file>imports/Spectral/Component/Timeline/SectionDelegate.qml</file>
|
<file>imports/Spectral/Component/Timeline/SectionDelegate.qml</file>
|
||||||
<file>assets/img/matrix.svg</file>
|
<file>assets/img/matrix.svg</file>
|
||||||
<file>imports/Spectral/Effect/RippleEffect.qml</file>
|
<file>imports/Spectral/Effect/RippleEffect.qml</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user