From 9b93eb44d5b6864f89d43556b9f7b73bf8614e7a Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 6 Apr 2024 14:19:38 +0000 Subject: [PATCH] Show a verified icon for verified devices rather than a verify option --- src/models/devicesmodel.cpp | 9 +++++++++ src/settings/DeviceDelegate.qml | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/models/devicesmodel.cpp b/src/models/devicesmodel.cpp index f44692b0a..01b4cb3f2 100644 --- a/src/models/devicesmodel.cpp +++ b/src/models/devicesmodel.cpp @@ -19,6 +19,15 @@ using namespace Quotient; DevicesModel::DevicesModel(QObject *parent) : QAbstractListModel(parent) { + connect(m_connection, &Connection::sessionVerified, this, [this](const QString &, const QString &deviceId) { + const auto it = std::find_if(m_devices.begin(), m_devices.end(), [deviceId](const Quotient::Device &device) { + return device.deviceId == deviceId; + }); + if (it != m_devices.end()) { + const auto index = this->index(it - m_devices.begin()); + Q_EMIT dataChanged(index, index, {Type}); + } + }); } void DevicesModel::fetchDevices() diff --git a/src/settings/DeviceDelegate.qml b/src/settings/DeviceDelegate.qml index 001e399cc..46d607488 100644 --- a/src/settings/DeviceDelegate.qml +++ b/src/settings/DeviceDelegate.qml @@ -17,6 +17,7 @@ FormCard.AbstractFormDelegate { required property string id required property string timestamp required property string displayName + required property int type property bool editDeviceName: false property bool showVerifyButton @@ -98,7 +99,7 @@ FormCard.AbstractFormDelegate { } QQC2.ToolButton { display: QQC2.AbstractButton.IconOnly - visible: root.showVerifyButton + visible: root.showVerifyButton && root.type !== DevicesModel.Verified action: Kirigami.Action { id: verifyDeviceAction text: i18n("Verify device") @@ -112,6 +113,21 @@ FormCard.AbstractFormDelegate { delay: Kirigami.Units.toolTipDelay } } + Kirigami.Icon { + visible: root.showVerifyButton && root.type === DevicesModel.Verified + implicitWidth: Kirigami.Units.iconSizes.smallMedium + implicitHeight: Kirigami.Units.iconSizes.smallMedium + source: "security-high" + + HoverHandler { + id: verifyHover + } + QQC2.ToolTip { + text: i18nc("This device is verified", "Verified") + delay: Kirigami.Units.toolTipDelay + visible: verifyHover.hovered + } + } QQC2.ToolButton { display: QQC2.AbstractButton.IconOnly action: Kirigami.Action {