From 3aefc5aef44fb31c821ee225453b86b7eb93047e Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 24 Jun 2019 21:57:18 +0800 Subject: [PATCH] Implement #132. --- .../Spectral/Dialog/AccountDetailDialog.qml | 34 +++++++++++++++++++ src/messageeventmodel.cpp | 7 ++++ 2 files changed, 41 insertions(+) diff --git a/imports/Spectral/Dialog/AccountDetailDialog.qml b/imports/Spectral/Dialog/AccountDetailDialog.qml index 95c782de6..8e405fc42 100644 --- a/imports/Spectral/Dialog/AccountDetailDialog.qml +++ b/imports/Spectral/Dialog/AccountDetailDialog.qml @@ -201,6 +201,40 @@ Dialog { } } + Control { + width: parent.width + + contentItem: RowLayout { + MaterialIcon { + Layout.preferredWidth: 48 + Layout.preferredHeight: 48 + + color: MPalette.foreground + icon: "\ue8f8" + } + + Label { + Layout.fillWidth: true + + color: MPalette.foreground + text: "Show Join/Leave" + } + + Switch { + id: showJoinLeaveSwitch + + checked: MSettings.value("UI/show_joinleave", true) + onCheckedChanged: MSettings.setValue("UI/show_joinleave", checked) + } + } + + RippleEffect { + anchors.fill: parent + + onPrimaryClicked: showJoinLeaveSwitch.checked = !showJoinLeaveSwitch.checked + } + } + Control { width: parent.width diff --git a/src/messageeventmodel.cpp b/src/messageeventmodel.cpp index ffba3e569..75db8ed79 100644 --- a/src/messageeventmodel.cpp +++ b/src/messageeventmodel.cpp @@ -350,6 +350,13 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const { if (isPending) return pendingIt->deliveryStatus(); + auto* memberEvent = timelineIt->viewAs(); + if (memberEvent) { + if ((memberEvent->isJoin() || memberEvent->isLeave()) && + !Settings().value("UI/show_joinleave", true).toBool()) + return EventStatus::Hidden; + } + if (is(evt)) return EventStatus::Hidden; if (evt.isRedacted())