From 23009b62add39f22cca27438a17f83762d8c2f94 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 28 Mar 2020 17:32:58 +0300 Subject: [PATCH] Added ability to finish reordering in vertical layout from external. --- ui/wrap/vertical_layout_reorder.cpp | 16 ++++++++-------- ui/wrap/vertical_layout_reorder.h | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/wrap/vertical_layout_reorder.cpp b/ui/wrap/vertical_layout_reorder.cpp index ed97b06..7ddc773 100644 --- a/ui/wrap/vertical_layout_reorder.cpp +++ b/ui/wrap/vertical_layout_reorder.cpp @@ -61,9 +61,7 @@ void VerticalLayoutReorder::start() { static_cast(e.get())->globalPos()); break; case QEvent::MouseButtonRelease: - mouseRelease( - widget, - static_cast(e.get())->button()); + mouseRelease(static_cast(e.get())->button()); break; } }, [=] { @@ -158,14 +156,11 @@ void VerticalLayoutReorder::mousePress( _currentStart = position.y(); } -void VerticalLayoutReorder::mouseRelease( - not_null widget, - Qt::MouseButton button) { +void VerticalLayoutReorder::mouseRelease(Qt::MouseButton button) { if (button != Qt::LeftButton) { return; } - _scrollAnimation.stop(); - finishCurrent(); + finishReordering(); } void VerticalLayoutReorder::cancelCurrent() { @@ -187,6 +182,11 @@ void VerticalLayoutReorder::cancelCurrent(int index) { } } +void VerticalLayoutReorder::finishReordering() { + _scrollAnimation.stop(); + finishCurrent(); +} + void VerticalLayoutReorder::finishCurrent() { if (!_currentWidget) { return; diff --git a/ui/wrap/vertical_layout_reorder.h b/ui/wrap/vertical_layout_reorder.h index 27e62af..502031c 100644 --- a/ui/wrap/vertical_layout_reorder.h +++ b/ui/wrap/vertical_layout_reorder.h @@ -34,6 +34,7 @@ public: void start(); void cancel(); + void finishReordering(); [[nodiscard]] rpl::producer updates() const; private: @@ -50,7 +51,7 @@ private: not_null widget, Qt::MouseButton button, QPoint position); - void mouseRelease(not_null widget, Qt::MouseButton button); + void mouseRelease(Qt::MouseButton button); void checkForStart(QPoint position); void updateOrder(int index, QPoint position);