[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
This commit is contained in:
Leon Richardt 2020-08-22 23:10:10 +02:00 committed by GitHub
parent 6e6413da02
commit 505581ca65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View file

@ -1,5 +1,9 @@
# Changelog # 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 ## 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) - 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)

View file

@ -227,9 +227,15 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked,
Qt::CheckStateRole); Qt::CheckStateRole);
} }
} }
else if (clicked.column() == Column::Color && else if (clicked.column() == Column::Color)
clicked.row() != HighlightModel::WHISPER_ROW)
{ {
// Hacky (?) way to figure out what tab the cell was clicked in
const bool fromMessagesTab =
(dynamic_cast<HighlightModel *>(view->getModel()) != nullptr);
if (fromMessagesTab && clicked.row() == HighlightModel::WHISPER_ROW)
return;
auto initial = auto initial =
view->getModel()->data(clicked, Qt::DecorationRole).value<QColor>(); view->getModel()->data(clicked, Qt::DecorationRole).value<QColor>();
@ -244,11 +250,7 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked,
view->getModel()->setData(clicked, selected, view->getModel()->setData(clicked, selected,
Qt::DecorationRole); Qt::DecorationRole);
// Hacky (?) way to figure out what tab the cell was clicked in if (fromMessagesTab)
const bool fromMessages = (dynamic_cast<HighlightModel *>(
view->getModel()) != nullptr);
if (fromMessages)
{ {
/* /*
* For preset highlights in the "Messages" tab, we need to * For preset highlights in the "Messages" tab, we need to