Fixed display of quiz solution in sections.
This commit is contained in:
parent
5fbbdd8a9e
commit
38322dc998
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "history/history_view_top_toast.h"
|
||||||
|
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
|
||||||
|
return std::clamp(
|
||||||
|
crl::time(1000) * int(text.text.size()) / 14,
|
||||||
|
crl::time(1000) * 5,
|
||||||
|
crl::time(1000) * 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
InfoTooltip::InfoTooltip() = default;
|
||||||
|
|
||||||
|
void InfoTooltip::show(
|
||||||
|
not_null<QWidget*> parent,
|
||||||
|
const TextWithEntities &text,
|
||||||
|
Fn<void()> hiddenCallback) {
|
||||||
|
hide(anim::type::normal);
|
||||||
|
_topToast = Ui::Toast::Show(parent, Ui::Toast::Config{
|
||||||
|
.text = text,
|
||||||
|
.st = &st::historyInfoToast,
|
||||||
|
.durationMs = CountToastDuration(text),
|
||||||
|
.multiline = true,
|
||||||
|
.dark = true,
|
||||||
|
.slideSide = RectPart::Top,
|
||||||
|
});
|
||||||
|
if (const auto strong = _topToast.get()) {
|
||||||
|
if (hiddenCallback) {
|
||||||
|
QObject::connect(
|
||||||
|
strong->widget(),
|
||||||
|
&QObject::destroyed,
|
||||||
|
hiddenCallback);
|
||||||
|
}
|
||||||
|
} else if (hiddenCallback) {
|
||||||
|
hiddenCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoTooltip::hide(anim::type animated) {
|
||||||
|
if (const auto strong = _topToast.get()) {
|
||||||
|
if (animated == anim::type::normal) {
|
||||||
|
strong->hideAnimated();
|
||||||
|
} else {
|
||||||
|
strong->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace HistoryView
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/weak_ptr.h"
|
||||||
|
|
||||||
|
namespace Ui::Toast {
|
||||||
|
class Instance;
|
||||||
|
} // namespace Ui::Toast
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
|
||||||
|
class InfoTooltip final {
|
||||||
|
public:
|
||||||
|
InfoTooltip();
|
||||||
|
|
||||||
|
void show(
|
||||||
|
not_null<QWidget*> parent,
|
||||||
|
const TextWithEntities &text,
|
||||||
|
Fn<void()> hiddenCallback);
|
||||||
|
void hide(anim::type animated);
|
||||||
|
|
||||||
|
private:
|
||||||
|
base::weak_ptr<Ui::Toast::Instance> _topToast;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace HistoryView
|
|
@ -198,13 +198,6 @@ base::options::toggle AutoScrollInactiveChat({
|
||||||
"even when the window is not in focus.",
|
"even when the window is not in focus.",
|
||||||
});
|
});
|
||||||
|
|
||||||
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
|
|
||||||
return std::clamp(
|
|
||||||
crl::time(1000) * int(text.text.size()) / 14,
|
|
||||||
crl::time(1000) * 5,
|
|
||||||
crl::time(1000) * 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<PeerData*> ActivePeerValue(
|
[[nodiscard]] rpl::producer<PeerData*> ActivePeerValue(
|
||||||
not_null<Window::SessionController*> controller) {
|
not_null<Window::SessionController*> controller) {
|
||||||
return controller->activeChatValue(
|
return controller->activeChatValue(
|
||||||
|
@ -2020,7 +2013,7 @@ void HistoryWidget::showHistory(
|
||||||
|
|
||||||
_highlighter.clear();
|
_highlighter.clear();
|
||||||
controller()->sendingAnimation().clear();
|
controller()->sendingAnimation().clear();
|
||||||
hideInfoTooltip(anim::type::instant);
|
_topToast.hide(anim::type::instant);
|
||||||
if (_history) {
|
if (_history) {
|
||||||
if (_peer->id == peerId && !reload) {
|
if (_peer->id == peerId && !reload) {
|
||||||
updateForwarding();
|
updateForwarding();
|
||||||
|
@ -6723,32 +6716,7 @@ bool HistoryWidget::sendExistingPhoto(
|
||||||
void HistoryWidget::showInfoTooltip(
|
void HistoryWidget::showInfoTooltip(
|
||||||
const TextWithEntities &text,
|
const TextWithEntities &text,
|
||||||
Fn<void()> hiddenCallback) {
|
Fn<void()> hiddenCallback) {
|
||||||
hideInfoTooltip(anim::type::normal);
|
_topToast.show(_scroll.data(), text, std::move(hiddenCallback));
|
||||||
_topToast = Ui::Toast::Show(_scroll, Ui::Toast::Config{
|
|
||||||
.text = text,
|
|
||||||
.st = &st::historyInfoToast,
|
|
||||||
.durationMs = CountToastDuration(text),
|
|
||||||
.multiline = true,
|
|
||||||
.dark = true,
|
|
||||||
.slideSide = RectPart::Top,
|
|
||||||
});
|
|
||||||
if (const auto strong = _topToast.get()) {
|
|
||||||
if (hiddenCallback) {
|
|
||||||
connect(strong->widget(), &QObject::destroyed, hiddenCallback);
|
|
||||||
}
|
|
||||||
} else if (hiddenCallback) {
|
|
||||||
hiddenCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HistoryWidget::hideInfoTooltip(anim::type animated) {
|
|
||||||
if (const auto strong = _topToast.get()) {
|
|
||||||
if (animated == anim::type::normal) {
|
|
||||||
strong->hideAnimated();
|
|
||||||
} else {
|
|
||||||
strong->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::showPremiumStickerTooltip(
|
void HistoryWidget::showPremiumStickerTooltip(
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "history/history_drag_area.h"
|
#include "history/history_drag_area.h"
|
||||||
#include "history/history_view_highlight_manager.h"
|
#include "history/history_view_highlight_manager.h"
|
||||||
|
#include "history/history_view_top_toast.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "chat_helpers/bot_command.h"
|
#include "chat_helpers/bot_command.h"
|
||||||
#include "chat_helpers/field_autocomplete.h"
|
#include "chat_helpers/field_autocomplete.h"
|
||||||
|
@ -74,9 +75,6 @@ struct PreparedList;
|
||||||
class SendFilesWay;
|
class SendFilesWay;
|
||||||
class SendAsButton;
|
class SendAsButton;
|
||||||
enum class ReportReason;
|
enum class ReportReason;
|
||||||
namespace Toast {
|
|
||||||
class Instance;
|
|
||||||
} // namespace Toast
|
|
||||||
class ChooseThemeController;
|
class ChooseThemeController;
|
||||||
class ContinuousScroll;
|
class ContinuousScroll;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -265,7 +263,6 @@ public:
|
||||||
void showInfoTooltip(
|
void showInfoTooltip(
|
||||||
const TextWithEntities &text,
|
const TextWithEntities &text,
|
||||||
Fn<void()> hiddenCallback);
|
Fn<void()> hiddenCallback);
|
||||||
void hideInfoTooltip(anim::type animated);
|
|
||||||
void showPremiumStickerTooltip(
|
void showPremiumStickerTooltip(
|
||||||
not_null<const HistoryView::Element*> view);
|
not_null<const HistoryView::Element*> view);
|
||||||
|
|
||||||
|
@ -779,7 +776,7 @@ private:
|
||||||
base::Timer _saveDraftTimer;
|
base::Timer _saveDraftTimer;
|
||||||
base::Timer _saveCloudDraftTimer;
|
base::Timer _saveCloudDraftTimer;
|
||||||
|
|
||||||
base::weak_ptr<Ui::Toast::Instance> _topToast;
|
HistoryView::InfoTooltip _topToast;
|
||||||
std::unique_ptr<HistoryView::StickerToast> _stickerToast;
|
std::unique_ptr<HistoryView::StickerToast> _stickerToast;
|
||||||
std::unique_ptr<ChooseMessagesForReport> _chooseForReport;
|
std::unique_ptr<ChooseMessagesForReport> _chooseForReport;
|
||||||
|
|
||||||
|
|
|
@ -1447,8 +1447,10 @@ void ListWidget::elementCancelUpload(const FullMsgId &context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::elementShowTooltip(
|
void ListWidget::elementShowTooltip(
|
||||||
const TextWithEntities &text,
|
const TextWithEntities &text,
|
||||||
Fn<void()> hiddenCallback) {
|
Fn<void()> hiddenCallback) {
|
||||||
|
// Under the parent is supposed to be a scroll widget.
|
||||||
|
_topToast.show(parentWidget(), text, hiddenCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListWidget::elementIsGifPaused() {
|
bool ListWidget::elementIsGifPaused() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_messages.h"
|
#include "data/data_messages.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
#include "history/history_view_highlight_manager.h"
|
#include "history/history_view_highlight_manager.h"
|
||||||
|
#include "history/history_view_top_toast.h"
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
class Session;
|
class Session;
|
||||||
|
@ -641,6 +642,8 @@ private:
|
||||||
|
|
||||||
Ui::DraggingScrollManager _selectScroll;
|
Ui::DraggingScrollManager _selectScroll;
|
||||||
|
|
||||||
|
InfoTooltip _topToast;
|
||||||
|
|
||||||
rpl::event_stream<FullMsgId> _requestedToEditMessage;
|
rpl::event_stream<FullMsgId> _requestedToEditMessage;
|
||||||
rpl::event_stream<FullMsgId> _requestedToReplyToMessage;
|
rpl::event_stream<FullMsgId> _requestedToReplyToMessage;
|
||||||
rpl::event_stream<FullMsgId> _requestedToReadMessage;
|
rpl::event_stream<FullMsgId> _requestedToReadMessage;
|
||||||
|
|
|
@ -85,6 +85,9 @@ PRIVATE
|
||||||
editor/scene/scene_item_line.cpp
|
editor/scene/scene_item_line.cpp
|
||||||
editor/scene/scene_item_line.h
|
editor/scene/scene_item_line.h
|
||||||
|
|
||||||
|
history/history_view_top_toast.cpp
|
||||||
|
history/history_view_top_toast.h
|
||||||
|
|
||||||
layout/abstract_layout_item.cpp
|
layout/abstract_layout_item.cpp
|
||||||
layout/abstract_layout_item.h
|
layout/abstract_layout_item.h
|
||||||
layout/layout_mosaic.cpp
|
layout/layout_mosaic.cpp
|
||||||
|
|
Loading…
Reference in New Issue