mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Added first shown tooltip to ttl button from voice record bar.
This commit is contained in:
parent
8895e49466
commit
cb4781360a
4 changed files with 55 additions and 9 deletions
|
@ -2492,6 +2492,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"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_record_once_first_tooltip" = "Tap to set this message to **Play Once**.";
|
||||
"lng_record_once_active_tooltip" = "The recipients will be able to listen to it only once.";
|
||||
"lng_will_be_notified" = "Members will be notified when you post";
|
||||
"lng_wont_be_notified" = "Members will not be notified when you post";
|
||||
|
|
|
@ -339,7 +339,8 @@ QByteArray Settings::serialize() const {
|
|||
<< qint32(_ignoreBatterySaving.current() ? 1 : 0)
|
||||
<< quint64(_macRoundIconDigest.value_or(0))
|
||||
<< qint32(_storiesClickTooltipHidden.current() ? 1 : 0)
|
||||
<< qint32(_recentEmojiSkip.size());
|
||||
<< qint32(_recentEmojiSkip.size())
|
||||
<< qint32(_ttlVoiceClickTooltipHidden.current() ? 1 : 0);
|
||||
for (const auto &id : _recentEmojiSkip) {
|
||||
stream << id;
|
||||
}
|
||||
|
@ -453,6 +454,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
qint32 storiesClickTooltipHidden = _storiesClickTooltipHidden.current() ? 1 : 0;
|
||||
base::flat_set<QString> recentEmojiSkip;
|
||||
qint32 trayIconMonochrome = (_trayIconMonochrome.current() ? 1 : 0);
|
||||
qint32 ttlVoiceClickTooltipHidden = _ttlVoiceClickTooltipHidden.current() ? 1 : 0;
|
||||
|
||||
stream >> themesAccentColors;
|
||||
if (!stream.atEnd()) {
|
||||
|
@ -709,6 +711,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
// Let existing clients use the old value.
|
||||
trayIconMonochrome = 0;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> ttlVoiceClickTooltipHidden;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||
|
@ -903,6 +908,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_storiesClickTooltipHidden = (storiesClickTooltipHidden == 1);
|
||||
_recentEmojiSkip = std::move(recentEmojiSkip);
|
||||
_trayIconMonochrome = (trayIconMonochrome == 1);
|
||||
_ttlVoiceClickTooltipHidden = (ttlVoiceClickTooltipHidden == 1);
|
||||
}
|
||||
|
||||
QString Settings::getSoundPath(const QString &key) const {
|
||||
|
@ -1259,6 +1265,7 @@ void Settings::resetOnLastLogout() {
|
|||
_systemDarkModeEnabled = false;
|
||||
_hiddenGroupCallTooltips = 0;
|
||||
_storiesClickTooltipHidden = false;
|
||||
_ttlVoiceClickTooltipHidden = false;
|
||||
|
||||
_recentEmojiPreload.clear();
|
||||
_recentEmoji.clear();
|
||||
|
|
|
@ -820,6 +820,15 @@ public:
|
|||
void setStoriesClickTooltipHidden(bool value) {
|
||||
_storiesClickTooltipHidden = value;
|
||||
}
|
||||
[[nodiscard]] bool ttlVoiceClickTooltipHidden() const {
|
||||
return _ttlVoiceClickTooltipHidden.current();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<bool> ttlVoiceClickTooltipHiddenValue() const {
|
||||
return _ttlVoiceClickTooltipHidden.value();
|
||||
}
|
||||
void setTtlVoiceClickTooltipHidden(bool value) {
|
||||
_ttlVoiceClickTooltipHidden = value;
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool ThirdColumnByDefault();
|
||||
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
|
||||
|
@ -945,6 +954,7 @@ private:
|
|||
rpl::variable<bool> _ignoreBatterySaving = false;
|
||||
std::optional<uint64> _macRoundIconDigest;
|
||||
rpl::variable<bool> _storiesClickTooltipHidden = false;
|
||||
rpl::variable<bool> _ttlVoiceClickTooltipHidden = false;
|
||||
|
||||
bool _tabbedReplacedWithInfo = false; // per-window
|
||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
||||
|
|
|
@ -280,7 +280,6 @@ protected:
|
|||
private:
|
||||
const style::RecordBar &_st;
|
||||
const QRect _rippleRect;
|
||||
const QString _text;
|
||||
|
||||
Ui::Animations::Simple _activeAnimation;
|
||||
|
||||
|
@ -292,8 +291,7 @@ TTLButton::TTLButton(
|
|||
: RippleButton(parent, st.lock.ripple)
|
||||
, _st(st)
|
||||
, _rippleRect(Rect(Size(st::historyRecordLockTopShadow.width()))
|
||||
- (st::historyRecordLockRippleMargin))
|
||||
, _text(u"1"_q) {
|
||||
- (st::historyRecordLockRippleMargin)) {
|
||||
resize(Size(st::historyRecordLockTopShadow.width()));
|
||||
|
||||
setClickedCallback([=] {
|
||||
|
@ -306,20 +304,27 @@ TTLButton::TTLButton(
|
|||
st::historyRecordVoiceShowDuration);
|
||||
});
|
||||
|
||||
{
|
||||
Ui::RpWidget::shownValue() | rpl::filter(
|
||||
rpl::mappers::_1
|
||||
) | rpl::skip(1) | rpl::take(1) | rpl::start_with_next([=] {
|
||||
auto text = rpl::conditional(
|
||||
Core::App().settings().ttlVoiceClickTooltipHiddenValue(),
|
||||
tr::lng_record_once_active_tooltip(
|
||||
Ui::Text::RichLangValue),
|
||||
tr::lng_record_once_first_tooltip(
|
||||
Ui::Text::RichLangValue));
|
||||
const auto tooltip = Ui::CreateChild<Ui::ImportantTooltip>(
|
||||
parent.get(),
|
||||
object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
|
||||
parent.get(),
|
||||
Ui::MakeNiceTooltipLabel(
|
||||
parent,
|
||||
tr::lng_record_once_active_tooltip(
|
||||
Ui::Text::RichLangValue),
|
||||
std::move(text),
|
||||
st::historyMessagesTTLLabel.minWidth,
|
||||
st::ttlMediaImportantTooltipLabel),
|
||||
st::defaultImportantTooltip.padding),
|
||||
st::historyRecordTooltip);
|
||||
geometryValue(
|
||||
Ui::RpWidget::geometryValue(
|
||||
) | rpl::start_with_next([=](const QRect &r) {
|
||||
if (r.isEmpty()) {
|
||||
return;
|
||||
|
@ -336,6 +341,15 @@ TTLButton::TTLButton(
|
|||
});
|
||||
}, tooltip->lifetime());
|
||||
tooltip->show();
|
||||
if (!Core::App().settings().ttlVoiceClickTooltipHidden()) {
|
||||
clicks(
|
||||
) | rpl::take(1) | rpl::start_with_next([=] {
|
||||
Core::App().settings().setTtlVoiceClickTooltipHidden(true);
|
||||
}, tooltip->lifetime());
|
||||
tooltip->toggleAnimated(true);
|
||||
} else {
|
||||
tooltip->toggleFast(false);
|
||||
}
|
||||
|
||||
clicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
@ -347,7 +361,19 @@ TTLButton::TTLButton(
|
|||
tooltip->hideAfter(kTimeout);
|
||||
}
|
||||
}, tooltip->lifetime());
|
||||
}
|
||||
|
||||
Ui::RpWidget::geometryValue(
|
||||
) | rpl::map([=](const QRect &r) {
|
||||
return (r.left() + r.width() > parentWidget()->width());
|
||||
}) | rpl::distinct_until_changed(
|
||||
) | rpl::start_with_next([=](bool toHide) {
|
||||
const auto isFirstTooltip =
|
||||
!Core::App().settings().ttlVoiceClickTooltipHidden();
|
||||
if (isFirstTooltip || (!isFirstTooltip && toHide)) {
|
||||
tooltip->toggleAnimated(!toHide);
|
||||
}
|
||||
}, tooltip->lifetime());
|
||||
}, lifetime());
|
||||
|
||||
paintRequest(
|
||||
) | rpl::start_with_next([=](const QRect &clip) {
|
||||
|
@ -1633,6 +1659,8 @@ void VoiceRecordBar::finish() {
|
|||
|
||||
_listen = nullptr;
|
||||
|
||||
[[maybe_unused]] const auto s = takeTTLState();
|
||||
|
||||
_sendActionUpdates.fire({ Api::SendProgressType::RecordVoice, -1 });
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue