Create a new module for the room info drawer QML.

Create a new module for the room info drawer QML. This also requires moving some QML to LibNeoChat common with other modules. Finally all QML in roominfo is modifed to not depend on app.
This commit is contained in:
James Graham
2025-05-17 14:27:38 +01:00
parent 495f7194ac
commit e7040a518a
19 changed files with 104 additions and 55 deletions

View File

@@ -8,6 +8,7 @@ endif()
add_subdirectory(libneochat) add_subdirectory(libneochat)
add_subdirectory(login) add_subdirectory(login)
add_subdirectory(rooms) add_subdirectory(rooms)
add_subdirectory(roominfo)
add_subdirectory(timeline) add_subdirectory(timeline)
add_subdirectory(spaces) add_subdirectory(spaces)
add_subdirectory(chatbar) add_subdirectory(chatbar)

View File

@@ -8,8 +8,6 @@ add_library(neochat STATIC
controller.h controller.h
roommanager.cpp roommanager.cpp
roommanager.h roommanager.h
models/userfiltermodel.cpp
models/userfiltermodel.h
models/userdirectorylistmodel.cpp models/userdirectorylistmodel.cpp
models/userdirectorylistmodel.h models/userdirectorylistmodel.h
notificationsmanager.cpp notificationsmanager.cpp
@@ -79,26 +77,15 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
qml/EmojiSas.qml qml/EmojiSas.qml
qml/VerificationCanceled.qml qml/VerificationCanceled.qml
qml/MessageSourceSheet.qml qml/MessageSourceSheet.qml
qml/RoomSearchPage.qml
qml/RoomPinnedMessagesPage.qml
qml/LocationChooser.qml qml/LocationChooser.qml
qml/InvitationView.qml qml/InvitationView.qml
qml/AvatarTabButton.qml qml/AvatarTabButton.qml
qml/OsmLocationPlugin.qml qml/OsmLocationPlugin.qml
qml/FullScreenMap.qml qml/FullScreenMap.qml
qml/LocationsPage.qml
qml/LocationMapItem.qml
qml/RoomDrawer.qml
qml/RoomDrawerPage.qml
qml/DirectChatDrawerHeader.qml
qml/GroupChatDrawerHeader.qml
qml/RoomInformation.qml
qml/RoomMedia.qml
qml/ChooseRoomDialog.qml qml/ChooseRoomDialog.qml
qml/RemoveChildDialog.qml qml/RemoveChildDialog.qml
qml/QrCodeMaximizeComponent.qml qml/QrCodeMaximizeComponent.qml
qml/NotificationsView.qml qml/NotificationsView.qml
qml/SearchPage.qml
qml/ServerComboBox.qml qml/ServerComboBox.qml
qml/UserSearchPage.qml qml/UserSearchPage.qml
qml/ManualUserDialog.qml qml/ManualUserDialog.qml
@@ -124,6 +111,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
IMPORTS IMPORTS
org.kde.neochat.libneochat org.kde.neochat.libneochat
org.kde.neochat.rooms org.kde.neochat.rooms
org.kde.neochat.roominfo
org.kde.neochat.timeline org.kde.neochat.timeline
org.kde.neochat.spaces org.kde.neochat.spaces
org.kde.neochat.settings org.kde.neochat.settings
@@ -189,7 +177,7 @@ else()
endif() endif()
target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models) target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
target_link_libraries(neochat PRIVATE Loginplugin Roomsplugin Timelineplugin Spacesplugin Chatbarplugin Settingsplugin Devtoolsplugin) target_link_libraries(neochat PRIVATE Loginplugin Roomsplugin RoomInfoplugin Timelineplugin Spacesplugin Chatbarplugin Settingsplugin Devtoolsplugin)
target_link_libraries(neochat PUBLIC target_link_libraries(neochat PUBLIC
LibNeoChat LibNeoChat
Timeline Timeline

View File

@@ -8,6 +8,8 @@ import QtPositioning
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.neochat.libneochat
ApplicationWindow { ApplicationWindow {
id: root id: root

View File

@@ -149,9 +149,13 @@ Kirigami.ApplicationWindow {
} }
function openRoomDrawer() { function openRoomDrawer() {
pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomDrawerPage'), { const page = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomDrawerPage'), {
connection: root.connection connection: root.connection,
room: RoomManager.currentRoom,
userListModel: RoomManager.userListModel,
mediaMessageFilterModel: RoomManager.mediaMessageFilterModel
}); });
page.resolveResource.connect((idOrUri, action) => RoomManager.resolveResource(idOrUri, action))
} }
contextDrawer: RoomDrawer { contextDrawer: RoomDrawer {
@@ -161,7 +165,18 @@ Kirigami.ApplicationWindow {
// It is used to ensure that user choice is remembered when changing pages and expanding and contracting the window width // It is used to ensure that user choice is remembered when changing pages and expanding and contracting the window width
property bool drawerUserState: NeoChatConfig.autoRoomInfoDrawer property bool drawerUserState: NeoChatConfig.autoRoomInfoDrawer
room: RoomManager.currentRoom
connection: root.connection connection: root.connection
userListModel: RoomManager.userListModel
mediaMessageFilterModel: RoomManager.mediaMessageFilterModel
onResolveResource: (idOrUri, action) => RoomManager.resolveResource(idOrUri, action)
roomDrawerWidth: NeoChatConfig.roomDrawerWidth
onRoomDrawerWidthChanged: {
NeoChatConfig.roomDrawerWidth = actualWidth;
NeoChatConfig.save();
}
handleClosedIcon.source: "documentinfo-symbolic" handleClosedIcon.source: "documentinfo-symbolic"
handleClosedToolTip: i18nc("@action:button", "Show Room Information") handleClosedToolTip: i18nc("@action:button", "Show Room Information")

View File

@@ -41,12 +41,17 @@ target_sources(LibNeoChat PRIVATE
models/locationsmodel.cpp models/locationsmodel.cpp
models/roomlistmodel.cpp models/roomlistmodel.cpp
models/stickermodel.cpp models/stickermodel.cpp
models/userfiltermodel.cpp
models/userlistmodel.cpp models/userlistmodel.cpp
) )
ecm_add_qml_module(LibNeoChat GENERATE_PLUGIN_SOURCE ecm_add_qml_module(LibNeoChat GENERATE_PLUGIN_SOURCE
URI org.kde.neochat.libneochat URI org.kde.neochat.libneochat
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/libneochat OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/libneochat
QML_FILES
qml/GroupChatDrawerHeader.qml
qml/LocationMapItem.qml
qml/SearchPage.qml
) )
ecm_qt_declare_logging_category(LibNeoChat ecm_qt_declare_logging_category(LibNeoChat

View File

@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2025 James Graham <james.h.graham@protonmail.com>
# SPDX-License-Identifier: BSD-2-Clause
qt_add_library(RoomInfo STATIC)
ecm_add_qml_module(RoomInfo GENERATE_PLUGIN_SOURCE
URI org.kde.neochat.roominfo
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/roominfo
QML_FILES
RoomDrawer.qml
RoomDrawerPage.qml
RoomInformation.qml
RoomMedia.qml
DirectChatDrawerHeader.qml
LocationsPage.qml
RoomPinnedMessagesPage.qml
RoomSearchPage.qml
)

View File

@@ -8,7 +8,7 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.labs.components as KirigamiComponents import org.kde.kirigamiaddons.labs.components as KirigamiComponents
import org.kde.neochat import org.kde.neochat.libneochat
ColumnLayout { ColumnLayout {
id: root id: root
@@ -18,6 +18,8 @@ ColumnLayout {
*/ */
required property NeoChatRoom room required property NeoChatRoom room
signal resolveResource(string idOrUri, string action)
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
spacing: 0 spacing: 0
@@ -33,7 +35,7 @@ ColumnLayout {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
onClicked: { onClicked: {
RoomManager.resolveResource(root.room.directChatRemoteMember.uri) root.resolveResource(root.room.directChatRemoteMember.uri, "")
} }
contentItem: KirigamiComponents.Avatar { contentItem: KirigamiComponents.Avatar {

View File

@@ -6,12 +6,13 @@ import QtLocation
import QtPositioning import QtPositioning
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.neochat
import org.kde.neochat.libneochat
Kirigami.Page { Kirigami.Page {
id: root id: root
required property var room required property NeoChatRoom room
title: i18nc("Locations on a map", "Locations") title: i18nc("Locations on a map", "Locations")

View File

@@ -9,14 +9,19 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kitemmodels import org.kde.kitemmodels
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.settings import org.kde.neochat.timeline as Timeline
import org.kde.neochat.settings as Settings
Kirigami.OverlayDrawer { Kirigami.OverlayDrawer {
id: root id: root
readonly property NeoChatRoom room: RoomManager.currentRoom required property NeoChatRoom room
required property NeoChatConnection connection required property NeoChatConnection connection
required property UserListModel userListModel
required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
signal resolveResource(string idOrUri, string action)
width: actualWidth width: actualWidth
interactive: modal interactive: modal
@@ -24,11 +29,12 @@ Kirigami.OverlayDrawer {
readonly property int minWidth: Kirigami.Units.gridUnit * 15 readonly property int minWidth: Kirigami.Units.gridUnit * 15
readonly property int maxWidth: Kirigami.Units.gridUnit * 25 readonly property int maxWidth: Kirigami.Units.gridUnit * 25
readonly property int defaultWidth: Kirigami.Units.gridUnit * 20 readonly property int defaultWidth: Kirigami.Units.gridUnit * 20
property int roomDrawerWidth
property int actualWidth: { property int actualWidth: {
if (NeoChatConfig.roomDrawerWidth === -1) { if (root.roomDrawerWidth === -1) {
return Kirigami.Units.gridUnit * 20; return Kirigami.Units.gridUnit * 20;
} else { } else {
return NeoChatConfig.roomDrawerWidth; return root.roomDrawerWidth;
} }
} }
@@ -46,8 +52,7 @@ Kirigami.OverlayDrawer {
visible: true visible: true
onPressed: _lastX = mapToGlobal(mouseX, mouseY).x onPressed: _lastX = mapToGlobal(mouseX, mouseY).x
onReleased: { onReleased: {
NeoChatConfig.roomDrawerWidth = root.actualWidth; root.roomDrawerWidth = root.actualWidth;
NeoChatConfig.save();
} }
property real _lastX: -1 property real _lastX: -1
@@ -56,9 +61,9 @@ Kirigami.OverlayDrawer {
return; return;
} }
if (Qt.application.layoutDirection === Qt.RightToLeft) { if (Qt.application.layoutDirection === Qt.RightToLeft) {
root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, NeoChatConfig.roomDrawerWidth - _lastX + mapToGlobal(mouseX, mouseY).x)); root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, root.roomDrawerWidth - _lastX + mapToGlobal(mouseX, mouseY).x));
} else { } else {
root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, NeoChatConfig.roomDrawerWidth + _lastX - mapToGlobal(mouseX, mouseY).x)); root.actualWidth = Math.min(root.maxWidth, Math.max(root.minWidth, root.roomDrawerWidth + _lastX - mapToGlobal(mouseX, mouseY).x));
} }
} }
} }
@@ -121,7 +126,7 @@ Kirigami.OverlayDrawer {
QQC2.ToolTip.visible: hovered QQC2.ToolTip.visible: hovered
onClicked: { onClicked: {
RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Room); Settings.RoomSettingsView.openRoomSettings(root.room, Settings.RoomSettingsView.Room);
} }
} }
} }
@@ -138,15 +143,17 @@ Kirigami.OverlayDrawer {
id: roomInformation id: roomInformation
RoomInformation { RoomInformation {
room: root.room room: root.room
connection: root.connection userListModel: root.userListModel
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
} }
} }
Component { Component {
id: roomMedia id: roomMedia
RoomMedia { RoomMedia {
currentRoom: root.room room: root.room
connection: root.connection mediaMessageFilterModel: root.mediaMessageFilterModel
} }
} }

View File

@@ -7,7 +7,8 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kitemmodels import org.kde.kitemmodels
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.timeline as Timeline
/** /**
* @brief Page for holding a room drawer component. * @brief Page for holding a room drawer component.
@@ -24,8 +25,12 @@ Kirigami.Page {
/** /**
* @brief The current room that user is viewing. * @brief The current room that user is viewing.
*/ */
readonly property NeoChatRoom room: RoomManager.currentRoom required property NeoChatRoom room
required property NeoChatConnection connection required property NeoChatConnection connection
required property UserListModel userListModel
required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
signal resolveResource(string idOrUri, string action)
title: drawerItemLoader.item ? drawerItemLoader.item.title : "" title: drawerItemLoader.item ? drawerItemLoader.item.title : ""
@@ -61,15 +66,17 @@ Kirigami.Page {
id: roomInformation id: roomInformation
RoomInformation { RoomInformation {
room: root.room room: root.room
connection: root.connection userListModel: root.userListModel
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
} }
} }
Component { Component {
id: roomMedia id: roomMedia
RoomMedia { RoomMedia {
currentRoom: root.room room: root.room
connection: root.connection mediaMessageFilterModel: root.mediaMessageFilterModel
} }
} }

View File

@@ -12,7 +12,7 @@ import org.kde.kirigamiaddons.delegates as Delegates
import org.kde.kirigamiaddons.labs.components as KirigamiComponents import org.kde.kirigamiaddons.labs.components as KirigamiComponents
import org.kde.kitemmodels import org.kde.kitemmodels
import org.kde.neochat import org.kde.neochat.libneochat
/** /**
* @brief Component for visualising the room information. * @brief Component for visualising the room information.
@@ -34,13 +34,15 @@ QQC2.ScrollView {
*/ */
required property NeoChatRoom room required property NeoChatRoom room
required property NeoChatConnection connection required property UserListModel userListModel
/** /**
* @brief The title that should be displayed for this component if available. * @brief The title that should be displayed for this component if available.
*/ */
readonly property string title: root.room.isSpace ? i18nc("@action:title", "Space Members") : i18nc("@action:title", "Room Information") readonly property string title: root.room.isSpace ? i18nc("@action:title", "Space Members") : i18nc("@action:title", "Room Information")
signal resolveResource(string idOrUri, string action)
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890) // HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
@@ -216,7 +218,7 @@ QQC2.ScrollView {
UserFilterModel { UserFilterModel {
id: userFilterModel id: userFilterModel
sourceModel: RoomManager.userListModel sourceModel: root.userListModel
allowEmpty: true allowEmpty: true
} }
@@ -249,7 +251,7 @@ QQC2.ScrollView {
KeyNavigation.backtab: index === 0 ? userList.headerItem.userListSearchField : null KeyNavigation.backtab: index === 0 ? userList.headerItem.userListSearchField : null
onClicked: { onClicked: {
RoomManager.resolveResource(userDelegate.userId, "mention"); root.resolveResource(userDelegate.userId, "mention");
} }
contentItem: RowLayout { contentItem: RowLayout {
@@ -286,6 +288,8 @@ QQC2.ScrollView {
id: directChatDrawerHeader id: directChatDrawerHeader
DirectChatDrawerHeader { DirectChatDrawerHeader {
room: root.room room: root.room
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
} }
} }

View File

@@ -6,8 +6,8 @@ import QtQuick.Controls as QQC2
import QtQuick.Layouts import QtQuick.Layouts
import Qt.labs.qmlmodels import Qt.labs.qmlmodels
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.timeline import org.kde.neochat.timeline as Timeline
/** /**
* @brief Component for visualising the loaded media items in the room. * @brief Component for visualising the loaded media items in the room.
@@ -31,9 +31,9 @@ QQC2.ScrollView {
/** /**
* @brief The current room that user is viewing. * @brief The current room that user is viewing.
*/ */
required property NeoChatRoom currentRoom required property NeoChatRoom room
required property NeoChatConnection connection required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890) // HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
@@ -42,26 +42,26 @@ QQC2.ScrollView {
clip: true clip: true
verticalLayoutDirection: ListView.BottomToTop verticalLayoutDirection: ListView.BottomToTop
model: RoomManager.mediaMessageFilterModel model: root.mediaMessageFilterModel
delegate: DelegateChooser { delegate: DelegateChooser {
role: "type" role: "type"
DelegateChoice { DelegateChoice {
roleValue: MediaMessageFilterModel.Image roleValue: Timeline.MediaMessageFilterModel.Image
delegate: MessageDelegate { delegate: Timeline.MessageDelegate {
alwaysFillWidth: true alwaysFillWidth: true
cardBackground: false cardBackground: false
room: root.currentRoom room: root.room
} }
} }
DelegateChoice { DelegateChoice {
roleValue: MediaMessageFilterModel.Video roleValue: Timeline.MediaMessageFilterModel.Video
delegate: MessageDelegate { delegate: Timeline.MessageDelegate {
alwaysFillWidth: true alwaysFillWidth: true
cardBackground: false cardBackground: false
room: root.currentRoom room: root.room
} }
} }
} }

View File

@@ -6,7 +6,7 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.timeline import org.kde.neochat.timeline
/** /**

View File

@@ -3,7 +3,7 @@
import QtQuick import QtQuick
import org.kde.neochat import org.kde.neochat.libneochat
import org.kde.neochat.timeline import org.kde.neochat.timeline
/** /**