From 505581ca6598a58373619acef45303deec73f19a Mon Sep 17 00:00:00 2001 From: Leon Richardt Date: Sat, 22 Aug 2020 23:10:10 +0200 Subject: [PATCH] [Bug Fix] Color of second user highlight cannot be set (#1898) * Highlighting: Fix bug preventing user highlight from being set Before this commit, only the row of a clicked cell was checked, but not the tab it was clicked in. Since the "Whispers" row is the second row in the "Messages" tab on the highlighting page, the color picker was not opened for the second entry in the "Users" tab either. This commit fixes the bug by also checking tab the cell was clicked in. * Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ src/widgets/settingspages/HighlightingPage.cpp | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f953b82e9..1339c7317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unversioned + +- Bugfix: Fix bug preventing users from setting the highlight color of the second entry in the "User" highlights tab (#1898) + ## 2.2.0 - Major: We now support image thumbnails coming from the link resolver. This feature is off by default and can be enabled in the settings with the "Show link thumbnail" setting. This feature also requires the "Show link info when hovering" setting to be enabled (#1664) diff --git a/src/widgets/settingspages/HighlightingPage.cpp b/src/widgets/settingspages/HighlightingPage.cpp index f6076d6b7..f1364de7a 100644 --- a/src/widgets/settingspages/HighlightingPage.cpp +++ b/src/widgets/settingspages/HighlightingPage.cpp @@ -227,9 +227,15 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked, Qt::CheckStateRole); } } - else if (clicked.column() == Column::Color && - clicked.row() != HighlightModel::WHISPER_ROW) + else if (clicked.column() == Column::Color) { + // Hacky (?) way to figure out what tab the cell was clicked in + const bool fromMessagesTab = + (dynamic_cast(view->getModel()) != nullptr); + + if (fromMessagesTab && clicked.row() == HighlightModel::WHISPER_ROW) + return; + auto initial = view->getModel()->data(clicked, Qt::DecorationRole).value(); @@ -244,11 +250,7 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked, view->getModel()->setData(clicked, selected, Qt::DecorationRole); - // Hacky (?) way to figure out what tab the cell was clicked in - const bool fromMessages = (dynamic_cast( - view->getModel()) != nullptr); - - if (fromMessages) + if (fromMessagesTab) { /* * For preset highlights in the "Messages" tab, we need to