mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 15:05:56 +00:00
Fixed mouse events in chats filters strip with inner padding.
This commit is contained in:
@@ -15,6 +15,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
[[nodiscard]] QMouseEvent TranslatedMouseEvent(QMouseEvent *e) {
|
||||||
|
return QMouseEvent(
|
||||||
|
e->type(),
|
||||||
|
e->pos() + QPoint(-st::dialogsSearchTabsPadding, 0),
|
||||||
|
e->button(),
|
||||||
|
e->buttons(),
|
||||||
|
e->modifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
ChatsFiltersTabs::ChatsFiltersTabs(
|
ChatsFiltersTabs::ChatsFiltersTabs(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
@@ -278,29 +290,32 @@ void ChatsFiltersTabs::paintEvent(QPaintEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatsFiltersTabs::mousePressEvent(QMouseEvent *e) {
|
void ChatsFiltersTabs::mousePressEvent(QMouseEvent *e) {
|
||||||
const auto mouseButton = e->button();
|
auto m = TranslatedMouseEvent(e);
|
||||||
|
const auto mouseButton = m.button();
|
||||||
if (mouseButton == Qt::MouseButton::LeftButton) {
|
if (mouseButton == Qt::MouseButton::LeftButton) {
|
||||||
_lockedPressed = (e->pos().x() >= _lockedFromX);
|
_lockedPressed = (m.pos().x() >= _lockedFromX);
|
||||||
if (_lockedPressed) {
|
if (_lockedPressed) {
|
||||||
Ui::RpWidget::mousePressEvent(e);
|
Ui::RpWidget::mousePressEvent(&m);
|
||||||
} else {
|
} else {
|
||||||
Ui::SettingsSlider::mousePressEvent(e);
|
Ui::SettingsSlider::mousePressEvent(&m);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ui::RpWidget::mousePressEvent(e);
|
Ui::RpWidget::mousePressEvent(&m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatsFiltersTabs::mouseMoveEvent(QMouseEvent *e) {
|
void ChatsFiltersTabs::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
auto m = TranslatedMouseEvent(e);
|
||||||
if (_reordering) {
|
if (_reordering) {
|
||||||
Ui::RpWidget::mouseMoveEvent(e);
|
Ui::RpWidget::mouseMoveEvent(&m);
|
||||||
} else {
|
} else {
|
||||||
Ui::SettingsSlider::mouseMoveEvent(e);
|
Ui::SettingsSlider::mouseMoveEvent(&m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatsFiltersTabs::mouseReleaseEvent(QMouseEvent *e) {
|
void ChatsFiltersTabs::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
const auto mouseButton = e->button();
|
auto m = TranslatedMouseEvent(e);
|
||||||
|
const auto mouseButton = m.button();
|
||||||
if (mouseButton == Qt::MouseButton::LeftButton) {
|
if (mouseButton == Qt::MouseButton::LeftButton) {
|
||||||
if (base::take(_lockedPressed)) {
|
if (base::take(_lockedPressed)) {
|
||||||
_lockedPressed = false;
|
_lockedPressed = false;
|
||||||
@@ -313,16 +328,16 @@ void ChatsFiltersTabs::mouseReleaseEvent(QMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ui::SettingsSlider::mouseReleaseEvent(e);
|
Ui::SettingsSlider::mouseReleaseEvent(&m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ui::RpWidget::mouseReleaseEvent(e);
|
Ui::RpWidget::mouseReleaseEvent(&m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatsFiltersTabs::contextMenuEvent(QContextMenuEvent *e) {
|
void ChatsFiltersTabs::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
const auto pos = e->pos();
|
const auto pos = e->pos() + QPoint(-st::dialogsSearchTabsPadding, 0);
|
||||||
if (pos.x() >= _lockedFromX) {
|
if (pos.x() >= _lockedFromX) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user