Browse Source

Activate desktop invite links on clicks while preserving drag selection

master
evgeny 1 week ago
parent
commit
b7821121c3
  1. 13
      tools/chatgui/src/chatview.cpp
  2. 1
      tools/chatgui/src/chatview.h
  3. 2
      tools/chatgui/src/messagelist.cpp

13
tools/chatgui/src/chatview.cpp

@ -180,6 +180,19 @@ void ChatView::mouseMoveEvent(QMouseEvent *event) {
}
void ChatView::mouseReleaseEvent(QMouseEvent *event) {
const QModelIndex pressed(m_pressIndex);
if (event->button() == Qt::LeftButton && !m_selecting && pressed.isValid() &&
(event->pos() - m_pressPos).manhattanLength() < 5 && indexAt(event->pos()) == pressed) {
auto* delegate = qobject_cast<MessageDelegate*>(itemDelegate(pressed));
QStyleOptionViewItem option; option.initFrom(this); option.widget = this; option.rect = visualRect(pressed);
const QString link = delegate ? delegate->inviteLinkAt(option, pressed, event->pos()) : QString();
if (!link.isEmpty()) {
m_pressIndex = QPersistentModelIndex();
GUI_INFO("invite link: activated row=%d bytes=%d", pressed.row(), link.size());
emit inviteLinkActivated(link);
event->accept(); return;
}
}
if (event->button() == Qt::LeftButton && m_selecting) {
m_selecting = false;
viewport()->update();

1
tools/chatgui/src/chatview.h

@ -35,6 +35,7 @@ public:
signals:
void animationTriggered();
void inviteLinkActivated(const QString& link);
protected:
bool viewportEvent(QEvent *event) override;

2
tools/chatgui/src/messagelist.cpp

@ -344,6 +344,8 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
connect(m_view, &ChatView::inviteLinkActivated, this, &MessageList::inviteLinkActivated);
/* ── шапка чата: название канала + переключатель рации ── */
{
auto* header = new QWidget(this);

Loading…
Cancel
Save