Added ability to finish reordering in vertical layout from external.
This commit is contained in:
parent
d1619b728e
commit
23009b62ad
2 changed files with 10 additions and 9 deletions
|
|
@ -61,9 +61,7 @@ void VerticalLayoutReorder::start() {
|
|||
static_cast<QMouseEvent*>(e.get())->globalPos());
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
mouseRelease(
|
||||
widget,
|
||||
static_cast<QMouseEvent*>(e.get())->button());
|
||||
mouseRelease(static_cast<QMouseEvent*>(e.get())->button());
|
||||
break;
|
||||
}
|
||||
}, [=] {
|
||||
|
|
@ -158,14 +156,11 @@ void VerticalLayoutReorder::mousePress(
|
|||
_currentStart = position.y();
|
||||
}
|
||||
|
||||
void VerticalLayoutReorder::mouseRelease(
|
||||
not_null<RpWidget*> 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;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
void start();
|
||||
void cancel();
|
||||
void finishReordering();
|
||||
[[nodiscard]] rpl::producer<Single> updates() const;
|
||||
|
||||
private:
|
||||
|
|
@ -50,7 +51,7 @@ private:
|
|||
not_null<RpWidget*> widget,
|
||||
Qt::MouseButton button,
|
||||
QPoint position);
|
||||
void mouseRelease(not_null<RpWidget*> widget, Qt::MouseButton button);
|
||||
void mouseRelease(Qt::MouseButton button);
|
||||
|
||||
void checkForStart(QPoint position);
|
||||
void updateOrder(int index, QPoint position);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue