Implement devtoool to show hidden timeline messages
This commit is contained in:
@@ -15,6 +15,12 @@ FormCard.FormCardPage {
|
|||||||
FormCard.FormCard {
|
FormCard.FormCard {
|
||||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
FormCard.FormCheckDelegate {
|
||||||
|
text: i18nc("@option:check", "Show hidden events in the timeline")
|
||||||
|
checked: Config.showAllEvents
|
||||||
|
|
||||||
|
onToggled: Config.showAllEvents = checked
|
||||||
|
}
|
||||||
FormCard.FormCheckDelegate {
|
FormCard.FormCheckDelegate {
|
||||||
id: roomAccountDataVisibleCheck
|
id: roomAccountDataVisibleCheck
|
||||||
text: i18nc("@option:check Enable the matrix 'threads' feature", "Always allow device verification")
|
text: i18nc("@option:check Enable the matrix 'threads' feature", "Always allow device verification")
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ MessageFilterModel::MessageFilterModel(QObject *parent, TimelineModel *sourceMod
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MessageFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
bool MessageFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
|
{
|
||||||
|
if (NeoChatConfig::self()->showAllEvents()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return eventIsVisible(sourceRow, sourceParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MessageFilterModel::eventIsVisible(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
{
|
{
|
||||||
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
|
|
||||||
@@ -59,9 +67,8 @@ bool MessageFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sour
|
|||||||
// Don't show state events that are not the first in a consecutive group on the
|
// Don't show state events that are not the first in a consecutive group on the
|
||||||
// same day as they will be grouped as a single delegate.
|
// same day as they will be grouped as a single delegate.
|
||||||
const bool notLastRow = sourceRow < sourceModel()->rowCount() - 1;
|
const bool notLastRow = sourceRow < sourceModel()->rowCount() - 1;
|
||||||
const bool previousEventIsState = notLastRow
|
const bool previousEventIsState =
|
||||||
? sourceModel()->data(sourceModel()->index(sourceRow + 1, 0), MessageEventModel::DelegateTypeRole) == DelegateType::State
|
notLastRow ? sourceModel()->data(sourceModel()->index(sourceRow + 1, 0), MessageEventModel::DelegateTypeRole) == DelegateType::State : false;
|
||||||
: false;
|
|
||||||
const bool newDay = sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageEventModel::ShowSectionRole).toBool();
|
const bool newDay = sourceModel()->data(sourceModel()->index(sourceRow, 0), MessageEventModel::ShowSectionRole).toBool();
|
||||||
if (eventType == DelegateType::State && notLastRow && previousEventIsState && !newDay) {
|
if (eventType == DelegateType::State && notLastRow && previousEventIsState && !newDay) {
|
||||||
return false;
|
return false;
|
||||||
@@ -72,7 +79,11 @@ bool MessageFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sour
|
|||||||
|
|
||||||
QVariant MessageFilterModel::data(const QModelIndex &index, int role) const
|
QVariant MessageFilterModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (role == AggregateDisplayRole) {
|
if (role == MessageEventModel::DelegateTypeRole) {
|
||||||
|
if (!eventIsVisible(index.row(), index.parent())) {
|
||||||
|
return DelegateType::Other;
|
||||||
|
}
|
||||||
|
} else if (role == AggregateDisplayRole) {
|
||||||
return aggregateEventToString(mapToSource(index).row());
|
return aggregateEventToString(mapToSource(index).row());
|
||||||
} else if (role == StateEventsRole) {
|
} else if (role == StateEventsRole) {
|
||||||
return stateEventsList(mapToSource(index).row());
|
return stateEventsList(mapToSource(index).row());
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public:
|
|||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool eventIsVisible(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Aggregation of the text of consecutive state events starting at row.
|
* @brief Aggregation of the text of consecutive state events starting at row.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -157,6 +157,10 @@
|
|||||||
</entry>
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
<group name="Debug">
|
<group name="Debug">
|
||||||
|
<entry name="ShowAllEvents" type="bool">
|
||||||
|
<label>Don't hide any events in the timeline</label>
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
<entry name="AlwaysVerifyDevice" type="bool">
|
<entry name="AlwaysVerifyDevice" type="bool">
|
||||||
<label>Always allow device verification</label>
|
<label>Always allow device verification</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ qt_add_qml_module(timeline
|
|||||||
QML_FILES
|
QML_FILES
|
||||||
EventDelegate.qml
|
EventDelegate.qml
|
||||||
TimelineDelegate.qml
|
TimelineDelegate.qml
|
||||||
|
HiddenDelegate.qml
|
||||||
MessageDelegate.qml
|
MessageDelegate.qml
|
||||||
LoadingDelegate.qml
|
LoadingDelegate.qml
|
||||||
ReadMarkerDelegate.qml
|
ReadMarkerDelegate.qml
|
||||||
|
|||||||
@@ -50,6 +50,17 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: DelegateType.Other
|
roleValue: DelegateType.Other
|
||||||
delegate: Item {}
|
delegate: Config.showAllEvents ? hiddenDelegate : emptyDelegate
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: hiddenDelegate
|
||||||
|
HiddenDelegate {
|
||||||
|
room: root.room
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: emptyDelegate
|
||||||
|
Item {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
94
src/timeline/HiddenDelegate.qml
Normal file
94
src/timeline/HiddenDelegate.qml
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls as QQC2
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import org.kde.kirigami as Kirigami
|
||||||
|
import org.kde.kirigamiaddons.components as KirigamiComponents
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
|
TimelineDelegate {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The NeoChatRoom the delegate is being displayed in.
|
||||||
|
*/
|
||||||
|
required property NeoChatRoom room
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The matrix ID of the message event.
|
||||||
|
*/
|
||||||
|
required property string eventId
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The message author.
|
||||||
|
*
|
||||||
|
* This should consist of the following:
|
||||||
|
* - id - The matrix ID of the author.
|
||||||
|
* - isLocalUser - Whether the author is the local user.
|
||||||
|
* - avatarSource - The mxc URL for the author's avatar in the current room.
|
||||||
|
* - avatarMediaId - The media ID of the author's avatar.
|
||||||
|
* - avatarUrl - The mxc URL for the author's avatar.
|
||||||
|
* - displayName - The display name of the author.
|
||||||
|
* - display - The name of the author.
|
||||||
|
* - color - The color for the author.
|
||||||
|
* - object - The Quotient::User object for the author.
|
||||||
|
*
|
||||||
|
* @sa Quotient::User
|
||||||
|
*/
|
||||||
|
required property var author
|
||||||
|
|
||||||
|
contentItem: QQC2.Control {
|
||||||
|
id: contentControl
|
||||||
|
contentItem: RowLayout {
|
||||||
|
KirigamiComponents.Avatar {
|
||||||
|
Layout.leftMargin: Kirigami.Units.largeSpacing * 1.5
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.small
|
||||||
|
implicitHeight: Kirigami.Units.iconSizes.small
|
||||||
|
|
||||||
|
name: root.author.displayName
|
||||||
|
source: root.author.avatarSource
|
||||||
|
color: root.author.color
|
||||||
|
}
|
||||||
|
QQC2.Label {
|
||||||
|
text: root.author.displayName + " : " + root.eventId
|
||||||
|
color: Kirigami.Theme.disabledTextColor
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
Kirigami.Icon {
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.small
|
||||||
|
implicitHeight: Kirigami.Units.iconSizes.small
|
||||||
|
source: "view-hidden"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TapHandler {
|
||||||
|
acceptedButtons: Qt.RightButton
|
||||||
|
onTapped: _private.showMessageMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
TapHandler {
|
||||||
|
acceptedButtons: Qt.LeftButton
|
||||||
|
onLongPressed: _private.showMessageMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: Kirigami.Theme.backgroundColor
|
||||||
|
radius: Kirigami.Units.smallSpacing
|
||||||
|
border {
|
||||||
|
width: contentControl.hovered ? 1 : 0
|
||||||
|
color: Kirigami.Theme.highlightColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: _private
|
||||||
|
function showMessageMenu() {
|
||||||
|
RoomManager.viewEventMenu(root.eventId, root.room, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user