mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +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();
|
||||
}
|
||||
}, lifetime());
|
||||
subscribe(_controller->widget()->dragFinished(), [this] {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
});
|
||||
session().data().itemRemoved(
|
||||
) | rpl::start_with_next(
|
||||
[this](auto item) { itemRemoved(item); },
|
||||
|
@ -1261,7 +1258,9 @@ std::unique_ptr<QMimeData> HistoryInner::prepareDrag() {
|
|||
void HistoryInner::performDrag() {
|
||||
if (auto mimeData = prepareDrag()) {
|
||||
// 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 HistoryInner
|
||||
: public Ui::RpWidget
|
||||
, public Ui::AbstractTooltipShower
|
||||
, private base::Subscriber {
|
||||
, public Ui::AbstractTooltipShower {
|
||||
// The Q_OBJECT meta info is used for qobject_cast!
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -2567,7 +2567,9 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
|||
void ListWidget::performDrag() {
|
||||
if (auto mimeData = prepareDrag()) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
||||
auto weak = QPointer<MainWindow>(this);
|
||||
void MainWindow::launchDrag(
|
||||
std::unique_ptr<QMimeData> data,
|
||||
Fn<void()> &&callback) {
|
||||
auto drag = std::make_unique<QDrag>(this);
|
||||
drag->setMimeData(data.release());
|
||||
drag->exec(Qt::CopyAction);
|
||||
|
||||
// We don't receive mouseReleaseEvent when drag is finished.
|
||||
ClickHandler::unpressed();
|
||||
if (weak) {
|
||||
weak->dragFinished().notify();
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
|
|
@ -103,10 +103,7 @@ public:
|
|||
return _body.data();
|
||||
}
|
||||
|
||||
void launchDrag(std::unique_ptr<QMimeData> data);
|
||||
base::Observable<void> &dragFinished() {
|
||||
return _dragFinished;
|
||||
}
|
||||
void launchDrag(std::unique_ptr<QMimeData> data, Fn<void()> &&callback);
|
||||
|
||||
rpl::producer<> leaveEvents() const;
|
||||
|
||||
|
@ -229,7 +226,6 @@ private:
|
|||
|
||||
bool _isActive = false;
|
||||
|
||||
base::Observable<void> _dragFinished;
|
||||
rpl::event_stream<> _leaveEvents;
|
||||
|
||||
bool _maximizedBeforeHide = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue