[SMS App] Add highlighting to ConversationList view
Summary: Let the ListView use its default highlighting (did I not notice before?) and keep the currently-selected chat highlighted at all times Test Plan: - Launch app - Use mouse or arrow keys to select a conversation. The highlight should follow the selected conversation Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: apol, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D17612
This commit is contained in:
parent
1d3368532a
commit
1ec20886a8
4 changed files with 19 additions and 4 deletions
|
@ -67,6 +67,7 @@ void ConversationListModel::setDeviceId(const QString& deviceId)
|
|||
}
|
||||
|
||||
m_deviceId = deviceId;
|
||||
Q_EMIT deviceIdChanged();
|
||||
|
||||
// This method still gets called *with a valid deviceID* when the device is not connected while the component is setting up
|
||||
// Detect that case and don't do anything.
|
||||
|
|
|
@ -68,7 +68,7 @@ class ConversationListModel
|
|||
: public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId)
|
||||
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
|
||||
|
||||
public:
|
||||
ConversationListModel(QObject* parent = nullptr);
|
||||
|
@ -92,6 +92,9 @@ public Q_SLOTS:
|
|||
void createRowFromMessage(const QVariantMap& message);
|
||||
void printDBusError(const QDBusError& error);
|
||||
|
||||
Q_SIGNALS:
|
||||
void deviceIdChanged();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Get all conversations currently known by the conversationsInterface, if any
|
||||
|
|
|
@ -51,7 +51,8 @@ void ConversationModel::setThreadId(const qint64& threadId)
|
|||
|
||||
m_threadId = threadId;
|
||||
clear();
|
||||
if (threadId != INVALID_THREAD_ID) {
|
||||
knownMessageIDs.clear();
|
||||
if (m_threadId != INVALID_THREAD_ID && m_deviceId != "") {
|
||||
requestMoreMessages();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ Kirigami.ScrollablePage
|
|||
readonly property QtObject device: devicesCombo.currentIndex >= 0 ? devicesModel.data(devicesModel.index(devicesCombo.currentIndex, 0), DevicesModel.DeviceRole) : null
|
||||
readonly property alias lastDeviceId: conversationListModel.deviceId
|
||||
|
||||
Component {
|
||||
ConversationDisplay {
|
||||
id: chatView
|
||||
ConversationDisplay {
|
||||
deviceId: page.lastDeviceId
|
||||
|
@ -122,7 +122,17 @@ Kirigami.ScrollablePage
|
|||
conversationId: model.conversationId,
|
||||
})
|
||||
}
|
||||
onClicked: { startChat(); }
|
||||
onClicked: {
|
||||
startChat();
|
||||
view.currentIndex = index
|
||||
}
|
||||
// Keep the currently-open chat highlighted even if this element is not focused
|
||||
highlighted: chatView.conversationId == model.conversationId
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
currentIndex = -1
|
||||
focus = true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue