Open desktop message avatars only after a completed click
This commit is contained in:
1 parent
7d69404532
commit
1f9dbd9dea
2 files changed
+12
-2
No files matched your search
@@ -131,14 +131,21 @@ static void ensureVoiceTimer() {
|
||||
bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) {
|
||||
if (event->type() != QEvent::MouseButtonRelease) return false;
|
||||
if (event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseButtonRelease) return false;
|
||||
Layout L = calcLayout(option, index);
|
||||
|
||||
const auto* mouse = static_cast<QMouseEvent*>(event);
|
||||
if (mouse->button() == Qt::LeftButton && !L.narrow && L.avatarRect.contains(mouse->pos() - option.rect.topLeft())) {
|
||||
const bool onAvatar=mouse->button()==Qt::LeftButton && !L.narrow && L.avatarRect.contains(mouse->pos()-option.rect.topLeft());
|
||||
if (event->type()==QEvent::MouseButtonPress) {
|
||||
m_avatarPress=onAvatar ? index : QModelIndex(); m_avatarPressPosition=mouse->pos(); return onAvatar;
|
||||
}
|
||||
const bool activateAvatar=onAvatar && m_avatarPress==index && (mouse->pos()-m_avatarPressPosition).manhattanLength()<5;
|
||||
m_avatarPress=QPersistentModelIndex();
|
||||
if (activateAvatar) {
|
||||
emit avatarRequested(index.data(MsgChannelIdRole).toString(), index.data(MsgAuthorNodeIdRole).toULongLong());
|
||||
return true;
|
||||
}
|
||||
if (onAvatar) return true;
|
||||
|
||||
if (L.isVideo) {
|
||||
int dlState = index.data(MsgFileDownloadStateRole).toInt();
|
||||
|
||||
Reference in new issue
Block a user