mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Show mouse hold tip when clicking record button.
This commit is contained in:
parent
05efc925f8
commit
7ad6699bff
4 changed files with 33 additions and 7 deletions
|
@ -1542,6 +1542,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_record_lock_cancel_sure" = "Are you sure you want to stop recording and discard your voice message?";
|
||||
"lng_record_listen_cancel_sure" = "Are you sure you want to discard your recorded voice message?";
|
||||
"lng_record_lock_discard" = "Discard";
|
||||
"lng_record_hold_tip" = "Please hold the mouse button pressed to record a voice message.";
|
||||
"lng_will_be_notified" = "Members will be notified when you post";
|
||||
"lng_wont_be_notified" = "Members will not be notified when you post";
|
||||
"lng_willbe_history" = "Please select a chat to start messaging";
|
||||
|
|
|
@ -918,6 +918,13 @@ void HistoryWidget::initVoiceRecordBar() {
|
|||
_scroll->viewportEvent(e);
|
||||
}, lifetime());
|
||||
|
||||
_voiceRecordBar->recordingTipRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
Ui::ShowMultilineToast({
|
||||
.text = { tr::lng_record_hold_tip(tr::now) },
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
_voiceRecordBar->hideFast();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,10 @@ using VoiceToSend = VoiceRecordBar::VoiceToSend;
|
|||
|
||||
constexpr auto kAudioVoiceUpdateView = crl::time(200);
|
||||
constexpr auto kAudioVoiceMaxLength = 100 * 60; // 100 minutes
|
||||
constexpr auto kMaxSamples =
|
||||
::Media::Player::kDefaultFrequency * kAudioVoiceMaxLength;
|
||||
constexpr auto kMaxSamples
|
||||
= ::Media::Player::kDefaultFrequency * kAudioVoiceMaxLength;
|
||||
constexpr auto kMinSamples
|
||||
= ::Media::Player::kDefaultFrequency / 5; // 0.2 seconds
|
||||
|
||||
constexpr auto kInactiveWaveformBarAlpha = int(255 * 0.6);
|
||||
|
||||
|
@ -1190,8 +1192,12 @@ void VoiceRecordBar::init() {
|
|||
if (_startRecordingFilter && _startRecordingFilter()) {
|
||||
return;
|
||||
}
|
||||
_recordingTipRequired = true;
|
||||
_startTimer.callOnce(st::historyRecordVoiceShowDuration);
|
||||
} else if (e->type() == QEvent::MouseButtonRelease) {
|
||||
if (base::take(_recordingTipRequired)) {
|
||||
_recordingTipRequests.fire({});
|
||||
}
|
||||
_startTimer.cancel();
|
||||
}
|
||||
}, lifetime());
|
||||
|
@ -1278,7 +1284,7 @@ void VoiceRecordBar::startRecording() {
|
|||
return;
|
||||
}
|
||||
auto appearanceCallback = [=] {
|
||||
if(_showAnimation.animating()) {
|
||||
if (_showAnimation.animating()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1296,6 +1302,7 @@ void VoiceRecordBar::startRecording() {
|
|||
instance()->start();
|
||||
instance()->updated(
|
||||
) | rpl::start_with_next_error([=](const Update &update) {
|
||||
_recordingTipRequired = (update.samples < kMinSamples);
|
||||
recordUpdated(update.level, update.samples);
|
||||
}, [=] {
|
||||
stop(false);
|
||||
|
@ -1311,10 +1318,10 @@ void VoiceRecordBar::startRecording() {
|
|||
|
||||
_send->events(
|
||||
) | rpl::filter([=](not_null<QEvent*> e) {
|
||||
return isTypeRecord()
|
||||
&& !_lock->isLocked()
|
||||
&& (e->type() == QEvent::MouseMove
|
||||
|| e->type() == QEvent::MouseButtonRelease);
|
||||
return (e->type() == QEvent::MouseMove
|
||||
|| e->type() == QEvent::MouseButtonRelease)
|
||||
&& isTypeRecord()
|
||||
&& !_lock->isLocked();
|
||||
}) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
const auto type = e->type();
|
||||
if (type == QEvent::MouseMove) {
|
||||
|
@ -1331,6 +1338,9 @@ void VoiceRecordBar::startRecording() {
|
|||
}
|
||||
computeAndSetLockProgress(mouse->globalPos());
|
||||
} else if (type == QEvent::MouseButtonRelease) {
|
||||
if (base::take(_recordingTipRequired)) {
|
||||
_recordingTipRequests.fire({});
|
||||
}
|
||||
stop(_inField.current());
|
||||
}
|
||||
}, _recordingLifetime);
|
||||
|
@ -1533,6 +1543,10 @@ rpl::producer<> VoiceRecordBar::updateSendButtonTypeRequests() const {
|
|||
return _listenChanges.events();
|
||||
}
|
||||
|
||||
rpl::producer<> VoiceRecordBar::recordingTipRequests() const {
|
||||
return _recordingTipRequests.events();
|
||||
}
|
||||
|
||||
bool VoiceRecordBar::isLockPresent() const {
|
||||
return _lockShowing.current();
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
[[nodiscard]] rpl::producer<bool> lockShowStarts() const;
|
||||
[[nodiscard]] rpl::producer<not_null<QEvent*>> lockViewportEvents() const;
|
||||
[[nodiscard]] rpl::producer<> updateSendButtonTypeRequests() const;
|
||||
[[nodiscard]] rpl::producer<> recordingTipRequests() const;
|
||||
|
||||
void requestToSendWithOptions(Api::SendOptions options);
|
||||
|
||||
|
@ -151,6 +152,9 @@ private:
|
|||
int _recordingSamples = 0;
|
||||
float64 _redCircleProgress = 0.;
|
||||
|
||||
rpl::event_stream<> _recordingTipRequests;
|
||||
bool _recordingTipRequired = false;
|
||||
|
||||
const style::font &_cancelFont;
|
||||
|
||||
rpl::lifetime _recordingLifetime;
|
||||
|
|
Loading…
Add table
Reference in a new issue