Qt: ignore double clicks unless they are left clicks

This commit is contained in:
Megamouse 2024-09-02 21:57:33 +02:00
parent e56164f1e3
commit fbebdc09b7
16 changed files with 152 additions and 11 deletions

View file

@ -8,6 +8,7 @@
#include <QHeaderView>
#include <QGuiApplication>
#include <QScreen>
#include <QMouseEvent>
constexpr auto qstr = QString::fromStdString;
@ -229,3 +230,18 @@ void save_data_list_dialog::UpdateList()
resize(preferred_size.boundedTo(max_size));
}
void save_data_list_dialog::mouseDoubleClickEvent(QMouseEvent* ev)
{
if (!ev) return;
// Qt's itemDoubleClicked signal doesn't distinguish between mouse buttons and there is no simple way to get the pressed button.
// So we have to ignore this event when another button is pressed.
if (ev->button() != Qt::LeftButton)
{
ev->ignore();
return;
}
QDialog::mouseDoubleClickEvent(ev);
}