mirror of https://github.com/procxx/kepka.git
Support poll solution display in a toast.
This commit is contained in:
parent
f50c50a152
commit
699761b42f
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/radial_animation.h"
|
#include "ui/effects/radial_animation.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/effects/fireworks_animation.h"
|
#include "ui/effects/fireworks_animation.h"
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_poll.h"
|
#include "data/data_poll.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
@ -28,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "styles/style_history.h"
|
#include "styles/style_history.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -116,6 +118,13 @@ void CountNicePercent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
|
||||||
|
return std::clamp(
|
||||||
|
crl::time(1000) * text.text.size() / 14,
|
||||||
|
crl::time(1000) * 5,
|
||||||
|
crl::time(1000) * 8);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct Poll::AnswerAnimation {
|
struct Poll::AnswerAnimation {
|
||||||
|
@ -405,9 +414,23 @@ void Poll::checkQuizAnswered() {
|
||||||
1.,
|
1.,
|
||||||
kRollDuration,
|
kRollDuration,
|
||||||
anim::linear);
|
anim::linear);
|
||||||
|
showSolution();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Poll::showSolution() {
|
||||||
|
if (_poll->solution.text.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto config = Ui::Toast::Config();
|
||||||
|
config.multiline = true;
|
||||||
|
config.minWidth = st::msgMinWidth;
|
||||||
|
config.maxWidth = st::windowMinWidth;
|
||||||
|
config.text = _poll->solution;
|
||||||
|
config.durationMs = CountToastDuration(config.text);
|
||||||
|
Ui::Toast::Show(config);
|
||||||
|
}
|
||||||
|
|
||||||
void Poll::updateRecentVoters() {
|
void Poll::updateRecentVoters() {
|
||||||
auto &&sliced = ranges::view::all(
|
auto &&sliced = ranges::view::all(
|
||||||
_poll->recentVoters
|
_poll->recentVoters
|
||||||
|
|
|
@ -155,6 +155,7 @@ private:
|
||||||
void sendMultiOptions();
|
void sendMultiOptions();
|
||||||
void showResults();
|
void showResults();
|
||||||
void checkQuizAnswered();
|
void checkQuizAnswered();
|
||||||
|
void showSolution();
|
||||||
|
|
||||||
[[nodiscard]] int bottomButtonHeight() const;
|
[[nodiscard]] int bottomButtonHeight() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue