mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Removed observable dragFinished from MainWindow.
This commit is contained in:
parent
3340b2dc03
commit
9e6afa0d4e
5 changed files with 12 additions and 17 deletions
|
@ -176,9 +176,6 @@ HistoryInner::HistoryInner(
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
subscribe(_controller->widget()->dragFinished(), [this] {
|
|
||||||
mouseActionUpdate(QCursor::pos());
|
|
||||||
});
|
|
||||||
session().data().itemRemoved(
|
session().data().itemRemoved(
|
||||||
) | rpl::start_with_next(
|
) | rpl::start_with_next(
|
||||||
[this](auto item) { itemRemoved(item); },
|
[this](auto item) { itemRemoved(item); },
|
||||||
|
@ -1261,7 +1258,9 @@ std::unique_ptr<QMimeData> HistoryInner::prepareDrag() {
|
||||||
void HistoryInner::performDrag() {
|
void HistoryInner::performDrag() {
|
||||||
if (auto mimeData = prepareDrag()) {
|
if (auto mimeData = prepareDrag()) {
|
||||||
// This call enters event loop and can destroy any QObject.
|
// This call enters event loop and can destroy any QObject.
|
||||||
_controller->widget()->launchDrag(std::move(mimeData));
|
_controller->widget()->launchDrag(
|
||||||
|
std::move(mimeData),
|
||||||
|
crl::guard(this, [=] { mouseActionUpdate(QCursor::pos()); }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ enum class ReportReason;
|
||||||
class HistoryWidget;
|
class HistoryWidget;
|
||||||
class HistoryInner
|
class HistoryInner
|
||||||
: public Ui::RpWidget
|
: public Ui::RpWidget
|
||||||
, public Ui::AbstractTooltipShower
|
, public Ui::AbstractTooltipShower {
|
||||||
, private base::Subscriber {
|
|
||||||
// The Q_OBJECT meta info is used for qobject_cast!
|
// The Q_OBJECT meta info is used for qobject_cast!
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -2567,7 +2567,9 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
||||||
void ListWidget::performDrag() {
|
void ListWidget::performDrag() {
|
||||||
if (auto mimeData = prepareDrag()) {
|
if (auto mimeData = prepareDrag()) {
|
||||||
// This call enters event loop and can destroy any QObject.
|
// This call enters event loop and can destroy any QObject.
|
||||||
_controller->widget()->launchDrag(std::move(mimeData));
|
_controller->widget()->launchDrag(
|
||||||
|
std::move(mimeData),
|
||||||
|
crl::guard(this, [=] { mouseActionUpdate(QCursor::pos()); }));;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -827,17 +827,16 @@ int MainWindow::tryToExtendWidthBy(int addToWidth) {
|
||||||
return addToWidth;
|
return addToWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
void MainWindow::launchDrag(
|
||||||
auto weak = QPointer<MainWindow>(this);
|
std::unique_ptr<QMimeData> data,
|
||||||
|
Fn<void()> &&callback) {
|
||||||
auto drag = std::make_unique<QDrag>(this);
|
auto drag = std::make_unique<QDrag>(this);
|
||||||
drag->setMimeData(data.release());
|
drag->setMimeData(data.release());
|
||||||
drag->exec(Qt::CopyAction);
|
drag->exec(Qt::CopyAction);
|
||||||
|
|
||||||
// We don't receive mouseReleaseEvent when drag is finished.
|
// We don't receive mouseReleaseEvent when drag is finished.
|
||||||
ClickHandler::unpressed();
|
ClickHandler::unpressed();
|
||||||
if (weak) {
|
callback();
|
||||||
weak->dragFinished().notify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
|
|
|
@ -103,10 +103,7 @@ public:
|
||||||
return _body.data();
|
return _body.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void launchDrag(std::unique_ptr<QMimeData> data);
|
void launchDrag(std::unique_ptr<QMimeData> data, Fn<void()> &&callback);
|
||||||
base::Observable<void> &dragFinished() {
|
|
||||||
return _dragFinished;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<> leaveEvents() const;
|
rpl::producer<> leaveEvents() const;
|
||||||
|
|
||||||
|
@ -229,7 +226,6 @@ private:
|
||||||
|
|
||||||
bool _isActive = false;
|
bool _isActive = false;
|
||||||
|
|
||||||
base::Observable<void> _dragFinished;
|
|
||||||
rpl::event_stream<> _leaveEvents;
|
rpl::event_stream<> _leaveEvents;
|
||||||
|
|
||||||
bool _maximizedBeforeHide = false;
|
bool _maximizedBeforeHide = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue