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(login)
add_subdirectory(rooms)
add_subdirectory(roominfo)
add_subdirectory(timeline)
add_subdirectory(spaces)
add_subdirectory(chatbar)

View File

@@ -8,8 +8,6 @@ add_library(neochat STATIC
controller.h
roommanager.cpp
roommanager.h
models/userfiltermodel.cpp
models/userfiltermodel.h
models/userdirectorylistmodel.cpp
models/userdirectorylistmodel.h
notificationsmanager.cpp
@@ -79,26 +77,15 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
qml/EmojiSas.qml
qml/VerificationCanceled.qml
qml/MessageSourceSheet.qml
qml/RoomSearchPage.qml
qml/RoomPinnedMessagesPage.qml
qml/LocationChooser.qml
qml/InvitationView.qml
qml/AvatarTabButton.qml
qml/OsmLocationPlugin.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/RemoveChildDialog.qml
qml/QrCodeMaximizeComponent.qml
qml/NotificationsView.qml
qml/SearchPage.qml
qml/ServerComboBox.qml
qml/UserSearchPage.qml
qml/ManualUserDialog.qml
@@ -124,6 +111,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
IMPORTS
org.kde.neochat.libneochat
org.kde.neochat.rooms
org.kde.neochat.roominfo
org.kde.neochat.timeline
org.kde.neochat.spaces
org.kde.neochat.settings
@@ -189,7 +177,7 @@ else()
endif()
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
LibNeoChat
Timeline

View File

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

View File

@@ -149,9 +149,13 @@ Kirigami.ApplicationWindow {
}
function openRoomDrawer() {
pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomDrawerPage'), {
connection: root.connection
const page = pageStack.push(Qt.createComponent('org.kde.neochat', 'RoomDrawerPage'), {
connection: root.connection,
room: RoomManager.currentRoom,
userListModel: RoomManager.userListModel,
mediaMessageFilterModel: RoomManager.mediaMessageFilterModel
});
page.resolveResource.connect((idOrUri, action) => RoomManager.resolveResource(idOrUri, action))
}
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
property bool drawerUserState: NeoChatConfig.autoRoomInfoDrawer
room: RoomManager.currentRoom
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"
handleClosedToolTip: i18nc("@action:button", "Show Room Information")

View File

@@ -41,12 +41,17 @@ target_sources(LibNeoChat PRIVATE
models/locationsmodel.cpp
models/roomlistmodel.cpp
models/stickermodel.cpp
models/userfiltermodel.cpp
models/userlistmodel.cpp
)
ecm_add_qml_module(LibNeoChat GENERATE_PLUGIN_SOURCE
URI 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

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

View File

@@ -6,12 +6,13 @@ import QtLocation
import QtPositioning
import org.kde.kirigami as Kirigami
import org.kde.neochat
import org.kde.neochat.libneochat
Kirigami.Page {
id: root
required property var room
required property NeoChatRoom room
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.kitemmodels
import org.kde.neochat
import org.kde.neochat.settings
import org.kde.neochat.libneochat
import org.kde.neochat.timeline as Timeline
import org.kde.neochat.settings as Settings
Kirigami.OverlayDrawer {
id: root
readonly property NeoChatRoom room: RoomManager.currentRoom
required property NeoChatRoom room
required property NeoChatConnection connection
required property UserListModel userListModel
required property Timeline.MediaMessageFilterModel mediaMessageFilterModel
signal resolveResource(string idOrUri, string action)
width: actualWidth
interactive: modal
@@ -24,11 +29,12 @@ Kirigami.OverlayDrawer {
readonly property int minWidth: Kirigami.Units.gridUnit * 15
readonly property int maxWidth: Kirigami.Units.gridUnit * 25
readonly property int defaultWidth: Kirigami.Units.gridUnit * 20
property int roomDrawerWidth
property int actualWidth: {
if (NeoChatConfig.roomDrawerWidth === -1) {
if (root.roomDrawerWidth === -1) {
return Kirigami.Units.gridUnit * 20;
} else {
return NeoChatConfig.roomDrawerWidth;
return root.roomDrawerWidth;
}
}
@@ -46,8 +52,7 @@ Kirigami.OverlayDrawer {
visible: true
onPressed: _lastX = mapToGlobal(mouseX, mouseY).x
onReleased: {
NeoChatConfig.roomDrawerWidth = root.actualWidth;
NeoChatConfig.save();
root.roomDrawerWidth = root.actualWidth;
}
property real _lastX: -1
@@ -56,9 +61,9 @@ Kirigami.OverlayDrawer {
return;
}
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 {
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
onClicked: {
RoomSettingsView.openRoomSettings(root.room, RoomSettingsView.Room);
Settings.RoomSettingsView.openRoomSettings(root.room, Settings.RoomSettingsView.Room);
}
}
}
@@ -138,15 +143,17 @@ Kirigami.OverlayDrawer {
id: roomInformation
RoomInformation {
room: root.room
connection: root.connection
userListModel: root.userListModel
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
}
}
Component {
id: roomMedia
RoomMedia {
currentRoom: root.room
connection: root.connection
room: root.room
mediaMessageFilterModel: root.mediaMessageFilterModel
}
}

View File

@@ -7,7 +7,8 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami
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.
@@ -24,8 +25,12 @@ Kirigami.Page {
/**
* @brief The current room that user is viewing.
*/
readonly property NeoChatRoom room: RoomManager.currentRoom
required property NeoChatRoom room
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 : ""
@@ -61,15 +66,17 @@ Kirigami.Page {
id: roomInformation
RoomInformation {
room: root.room
connection: root.connection
userListModel: root.userListModel
onResolveResource: (idOrUri, action) => root.resolveResource(idOrUri, action)
}
}
Component {
id: roomMedia
RoomMedia {
currentRoom: root.room
connection: root.connection
room: root.room
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.kitemmodels
import org.kde.neochat
import org.kde.neochat.libneochat
/**
* @brief Component for visualising the room information.
@@ -34,13 +34,15 @@ QQC2.ScrollView {
*/
required property NeoChatRoom room
required property NeoChatConnection connection
required property UserListModel userListModel
/**
* @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")
signal resolveResource(string idOrUri, string action)
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
@@ -216,7 +218,7 @@ QQC2.ScrollView {
UserFilterModel {
id: userFilterModel
sourceModel: RoomManager.userListModel
sourceModel: root.userListModel
allowEmpty: true
}
@@ -249,7 +251,7 @@ QQC2.ScrollView {
KeyNavigation.backtab: index === 0 ? userList.headerItem.userListSearchField : null
onClicked: {
RoomManager.resolveResource(userDelegate.userId, "mention");
root.resolveResource(userDelegate.userId, "mention");
}
contentItem: RowLayout {
@@ -286,6 +288,8 @@ QQC2.ScrollView {
id: directChatDrawerHeader
DirectChatDrawerHeader {
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 Qt.labs.qmlmodels
import org.kde.neochat
import org.kde.neochat.timeline
import org.kde.neochat.libneochat
import org.kde.neochat.timeline as Timeline
/**
* @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.
*/
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)
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
@@ -42,26 +42,26 @@ QQC2.ScrollView {
clip: true
verticalLayoutDirection: ListView.BottomToTop
model: RoomManager.mediaMessageFilterModel
model: root.mediaMessageFilterModel
delegate: DelegateChooser {
role: "type"
DelegateChoice {
roleValue: MediaMessageFilterModel.Image
delegate: MessageDelegate {
roleValue: Timeline.MediaMessageFilterModel.Image
delegate: Timeline.MessageDelegate {
alwaysFillWidth: true
cardBackground: false
room: root.currentRoom
room: root.room
}
}
DelegateChoice {
roleValue: MediaMessageFilterModel.Video
delegate: MessageDelegate {
roleValue: Timeline.MediaMessageFilterModel.Video
delegate: Timeline.MessageDelegate {
alwaysFillWidth: true
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.neochat
import org.kde.neochat.libneochat
import org.kde.neochat.timeline
/**

View File

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