From 57eb4f8234995eab3b82588f3bf34c9ad0691a70 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 12 Oct 2020 14:45:48 +0300 Subject: [PATCH] Disabled drag'n'drop area when user is recording voice message. --- Telegram/SourceFiles/history/history_widget.cpp | 2 +- .../history/view/controls/history_view_compose_controls.cpp | 6 +++++- .../history/view/controls/history_view_compose_controls.h | 1 + .../history/view/history_view_replies_section.cpp | 2 +- .../history/view/history_view_scheduled_section.cpp | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index f02f1eb310..83c81180f6 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -368,7 +368,7 @@ HistoryWidget::HistoryWidget( _attachDragAreas = DragArea::SetupDragAreaToContainer( this, crl::guard(this, [=](not_null d) { - return _history && _canSendMessages; + return _history && _canSendMessages && !isRecording(); }), crl::guard(this, [=](bool f) { _field->setAcceptDrops(f); }), crl::guard(this, [=] { updateControlsGeometry(); })); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 69b8f1fe0c..3bd0d458db 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -580,7 +580,7 @@ int ComposeControls::heightCurrent() const { } bool ComposeControls::focus() { - if (_voiceRecordBar->isRecording()) { + if (isRecording()) { return false; } _field->setFocus(); @@ -1345,4 +1345,8 @@ rpl::producer ComposeControls::lockShowStarts() const { return _voiceRecordBar->lockShowStarts(); } +bool ComposeControls::isRecording() const { + return _voiceRecordBar->isRecording(); +} + } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h index 5df22827dd..926e3da329 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h @@ -137,6 +137,7 @@ public: [[nodiscard]] rpl::producer lockShowStarts() const; [[nodiscard]] bool isLockPresent() const; + [[nodiscard]] bool isRecording() const; private: enum class TextUpdateEvent { diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index af7297e634..c10451a42e 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1761,7 +1761,7 @@ void RepliesWidget::clearSelected() { void RepliesWidget::setupDragArea() { const auto areas = DragArea::SetupDragAreaToContainer( this, - [=](not_null d) { return _history; }, + [=](auto d) { return _history && !_composeControls->isRecording(); }, nullptr, [=] { updateControlsGeometry(); }); diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 4367b4d5c7..4465ac2ffd 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -1188,7 +1188,7 @@ void ScheduledWidget::clearSelected() { void ScheduledWidget::setupDragArea() { const auto areas = DragArea::SetupDragAreaToContainer( this, - [=](not_null d) { return _history; }, + [=](auto d) { return _history && !_composeControls->isRecording(); }, nullptr, [=] { updateControlsGeometry(); });