Implement searching in rooms

BUG: 457839
This commit is contained in:
Tobias Fella
2022-11-15 23:12:39 +01:00
parent 7f27056a34
commit 51e0023384
8 changed files with 361 additions and 3 deletions

View File

@@ -20,7 +20,7 @@ ColumnLayout {
default property alias innerObject : column.children
property Item hoverComponent: hoverActions
property Item hoverComponent: hoverActions ?? null
property bool isEmote: false
property bool cardBackground: true
property bool showUserMessageOnRight: Config.showLocalMessagesOnRight && model.author.isLocalUser && !Config.compactLayout
@@ -106,6 +106,9 @@ ColumnLayout {
// Show hover actions by updating the global hover component to this delegate
function updateHoverComponent() {
if (!hoverComponent) {
return;
}
if (hovered && !Kirigami.Settings.isMobile) {
hoverComponent.delegate = root
hoverComponent.bubble = bubble
@@ -229,10 +232,10 @@ ColumnLayout {
QQC2.Label {
id: timeLabel
text: visible ? time.toLocaleTimeString(Qt.locale(), Locale.ShortFormat) : ""
text: visible ? model.time.toLocaleTimeString(Qt.locale(), Locale.ShortFormat) : ""
color: Kirigami.Theme.disabledTextColor
QQC2.ToolTip.visible: hoverHandler.hovered
QQC2.ToolTip.text: time.toLocaleString(Qt.locale(), Locale.LongFormat)
QQC2.ToolTip.text: model.time.toLocaleString(Qt.locale(), Locale.LongFormat)
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
HoverHandler {
@@ -268,6 +271,7 @@ ColumnLayout {
id: bubbleBackground
visible: cardBackground && !Config.compactLayout
anchors.fill: parent
Kirigami.Theme.colorSet: Kirigami.Theme.View
color: {
if (model.author.isLocalUser) {
return Kirigami.ColorUtils.tintWithAlpha(Kirigami.Theme.backgroundColor, Kirigami.Theme.highlightColor, 0.15)

View File

@@ -0,0 +1,75 @@
// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami
import org.kde.neochat 1.0
Kirigami.ScrollablePage {
id: searchPage
property var currentRoom
title: i18nc("@action:title", "Search Messages")
Kirigami.Theme.colorSet: Kirigami.Theme.Window
SearchModel {
id: searchModel
connection: Controller.activeConnection
searchText: searchField.text
room: searchPage.currentRoom
}
header: RowLayout {
Kirigami.SearchField {
id: searchField
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.leftMargin: Kirigami.Units.smallSpacing
Layout.fillWidth: true
Keys.onEnterPressed: searchButton.clicked()
Keys.onReturnPressed: searchButton.clicked()
}
QQC2.Button {
id: searchButton
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.smallSpacing
onClicked: searchModel.search()
icon.name: "search"
}
}
ListView {
id: messageListView
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 0
verticalLayoutDirection: ListView.BottomToTop
section.property: "section"
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
visible: searchField.text.length === 0 && messageListView.count === 0
text: i18n("Enter a text to start searching")
}
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
visible: searchField.text.length > 0 && messageListView.count === 0 && !searchModel.searching
text: i18n("No results found")
}
Kirigami.LoadingPlaceholder {
anchors.centerIn: parent
visible: searchModel.searching
}
model: searchModel
delegate: EventDelegate {}
}
}

View File

@@ -111,6 +111,23 @@ Kirigami.OverlayDrawer {
text: devtoolsButton.text
}
}
QQC2.ToolButton {
id: searchButton
Layout.alignment: Qt.AlignRight
icon.name: "search"
text: i18n("Search in this room")
display: QQC2.AbstractButton.IconOnly
visible: Controller.quotientMinorVersion > 6
onClicked: {
pageStack.pushDialogLayer("qrc:/SearchPage.qml", {
currentRoom: room
}, {
title: i18nc("@action:title", "Search")
})
}
}
QQC2.ToolButton {
id: inviteButton