Removed Q_SLOTS from HistoryInner.

This commit is contained in:
23rd 2021-09-29 03:00:11 +03:00
parent cb8f49aea0
commit ececdcb9c0
2 changed files with 17 additions and 21 deletions

View file

@ -168,6 +168,8 @@ HistoryInner::HistoryInner(
HistoryView::MakePathShiftGradient( HistoryView::MakePathShiftGradient(
controller->chatStyle(), controller->chatStyle(),
[=] { update(); })) [=] { update(); }))
, _touchSelectTimer([=] { onTouchSelect(); })
, _touchScrollTimer([=] { onTouchScrollTimer(); })
, _scrollDateCheck([this] { scrollDateCheck(); }) , _scrollDateCheck([this] { scrollDateCheck(); })
, _scrollDateHideTimer([this] { scrollDateHideByTimer(); }) { , _scrollDateHideTimer([this] { scrollDateHideByTimer(); }) {
Instance = this; Instance = this;
@ -180,13 +182,7 @@ HistoryInner::HistoryInner(
controller->setChatStyleTheme(_theme); controller->setChatStyleTheme(_theme);
}, lifetime()); }, lifetime());
_touchSelectTimer.setSingleShot(true);
connect(&_touchSelectTimer, SIGNAL(timeout()), this, SLOT(onTouchSelect()));
setAttribute(Qt::WA_AcceptTouchEvents); setAttribute(Qt::WA_AcceptTouchEvents);
connect(&_touchScrollTimer, SIGNAL(timeout()), this, SLOT(onTouchScrollTimer()));
_trippleClickTimer.setSingleShot(true);
notifyIsBotChanged(); notifyIsBotChanged();
@ -891,7 +887,7 @@ void HistoryInner::onTouchScrollTimer() {
if (_touchSpeed.isNull() || !hasScrolled) { if (_touchSpeed.isNull() || !hasScrolled) {
_touchScrollState = Ui::TouchScrollState::Manual; _touchScrollState = Ui::TouchScrollState::Manual;
_touchScroll = false; _touchScroll = false;
_touchScrollTimer.stop(); _touchScrollTimer.cancel();
} else { } else {
_touchTime = nowTime; _touchTime = nowTime;
} }
@ -966,7 +962,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
if (e->type() == QEvent::TouchCancel) { // cancel if (e->type() == QEvent::TouchCancel) { // cancel
if (!_touchInProgress) return; if (!_touchInProgress) return;
_touchInProgress = false; _touchInProgress = false;
_touchSelectTimer.stop(); _touchSelectTimer.cancel();
_touchScroll = _touchSelect = false; _touchScroll = _touchSelect = false;
_touchScrollState = Ui::TouchScrollState::Manual; _touchScrollState = Ui::TouchScrollState::Manual;
mouseActionCancel(); mouseActionCancel();
@ -996,7 +992,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
_touchStart = _touchPos; _touchStart = _touchPos;
} else { } else {
_touchScroll = false; _touchScroll = false;
_touchSelectTimer.start(QApplication::startDragTime()); _touchSelectTimer.callOnce(QApplication::startDragTime());
} }
_touchSelect = false; _touchSelect = false;
_touchStart = _touchPrevPos = _touchPos; _touchStart = _touchPrevPos = _touchPos;
@ -1007,7 +1003,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
if (_touchSelect) { if (_touchSelect) {
mouseActionUpdate(_touchPos); mouseActionUpdate(_touchPos);
} else if (!_touchScroll && (_touchPos - _touchStart).manhattanLength() >= QApplication::startDragDistance()) { } else if (!_touchScroll && (_touchPos - _touchStart).manhattanLength() >= QApplication::startDragDistance()) {
_touchSelectTimer.stop(); _touchSelectTimer.cancel();
_touchScroll = true; _touchScroll = true;
touchUpdateSpeed(); touchUpdateSpeed();
} }
@ -1037,7 +1033,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
if (_touchScrollState == Ui::TouchScrollState::Manual) { if (_touchScrollState == Ui::TouchScrollState::Manual) {
_touchScrollState = Ui::TouchScrollState::Auto; _touchScrollState = Ui::TouchScrollState::Auto;
_touchPrevPosValid = false; _touchPrevPosValid = false;
_touchScrollTimer.start(15); _touchScrollTimer.callEach(15);
_touchTime = crl::now(); _touchTime = crl::now();
} else if (_touchScrollState == Ui::TouchScrollState::Auto) { } else if (_touchScrollState == Ui::TouchScrollState::Auto) {
_touchScrollState = Ui::TouchScrollState::Manual; _touchScrollState = Ui::TouchScrollState::Manual;
@ -1053,7 +1049,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
mouseActionFinish(_touchPos, Qt::LeftButton); mouseActionFinish(_touchPos, Qt::LeftButton);
} }
if (weak) { if (weak) {
_touchSelectTimer.stop(); _touchSelectTimer.cancel();
_touchSelect = false; _touchSelect = false;
} }
} break; } break;
@ -1161,7 +1157,8 @@ void HistoryInner::mouseActionStart(const QPoint &screenPos, Qt::MouseButton but
_mouseAction = MouseAction::Selecting; _mouseAction = MouseAction::Selecting;
_mouseSelectType = TextSelectType::Paragraphs; _mouseSelectType = TextSelectType::Paragraphs;
mouseActionUpdate(_mousePosition); mouseActionUpdate(_mousePosition);
_trippleClickTimer.start(QApplication::doubleClickInterval()); _trippleClickTimer.callOnce(
QApplication::doubleClickInterval());
} }
} }
} else if (App::pressedItem()) { } else if (App::pressedItem()) {
@ -1530,7 +1527,7 @@ void HistoryInner::mouseDoubleClickEvent(QMouseEvent *e) {
mouseMoveEvent(e); mouseMoveEvent(e);
_trippleClickPoint = e->globalPos(); _trippleClickPoint = e->globalPos();
_trippleClickTimer.start(QApplication::doubleClickInterval()); _trippleClickTimer.callOnce(QApplication::doubleClickInterval());
} }
} }
if (!ClickHandler::getActive() if (!ClickHandler::getActive()

View file

@ -150,6 +150,8 @@ public:
QPoint tooltipPos() const override; QPoint tooltipPos() const override;
bool tooltipWindowActive() const override; bool tooltipWindowActive() const override;
void onParentGeometryChanged();
// HistoryView::ElementDelegate interface. // HistoryView::ElementDelegate interface.
static not_null<HistoryView::ElementDelegate*> ElementDelegate(); static not_null<HistoryView::ElementDelegate*> ElementDelegate();
@ -171,13 +173,10 @@ protected:
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;
public Q_SLOTS: private:
void onParentGeometryChanged();
void onTouchSelect(); void onTouchSelect();
void onTouchScrollTimer(); void onTouchScrollTimer();
private:
class BotAbout; class BotAbout;
using SelectedItems = std::map<HistoryItem*, TextSelection, std::less<>>; using SelectedItems = std::map<HistoryItem*, TextSelection, std::less<>>;
enum class MouseAction { enum class MouseAction {
@ -400,7 +399,7 @@ private:
bool _pressWasInactive = false; bool _pressWasInactive = false;
QPoint _trippleClickPoint; QPoint _trippleClickPoint;
QTimer _trippleClickTimer; base::Timer _trippleClickTimer;
Element *_dragSelFrom = nullptr; Element *_dragSelFrom = nullptr;
Element *_dragSelTo = nullptr; Element *_dragSelTo = nullptr;
@ -412,7 +411,7 @@ private:
bool _touchSelect = false; bool _touchSelect = false;
bool _touchInProgress = false; bool _touchInProgress = false;
QPoint _touchStart, _touchPrevPos, _touchPos; QPoint _touchStart, _touchPrevPos, _touchPos;
QTimer _touchSelectTimer; base::Timer _touchSelectTimer;
Ui::TouchScrollState _touchScrollState = Ui::TouchScrollState::Manual; Ui::TouchScrollState _touchScrollState = Ui::TouchScrollState::Manual;
bool _touchPrevPosValid = false; bool _touchPrevPosValid = false;
@ -421,7 +420,7 @@ private:
crl::time _touchSpeedTime = 0; crl::time _touchSpeedTime = 0;
crl::time _touchAccelerationTime = 0; crl::time _touchAccelerationTime = 0;
crl::time _touchTime = 0; crl::time _touchTime = 0;
QTimer _touchScrollTimer; base::Timer _touchScrollTimer;
base::unique_qptr<Ui::PopupMenu> _menu; base::unique_qptr<Ui::PopupMenu> _menu;