mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added printable representation to PollData.
This commit is contained in:
@@ -368,6 +368,43 @@ bool PollData::creator() const {
|
||||
return (_flags & Flag::Creator);
|
||||
}
|
||||
|
||||
QString PollData::debugString() const {
|
||||
auto result = QString();
|
||||
result += u"Poll #"_q + QString::number(id) + u'\n';
|
||||
result += u"Q: "_q + question.text + u'\n';
|
||||
if (quiz()) {
|
||||
result += u"[Quiz]"_q;
|
||||
}
|
||||
if (multiChoice()) {
|
||||
result += u"[MultiChoice]"_q;
|
||||
}
|
||||
if (closed()) {
|
||||
result += u"[Closed]"_q;
|
||||
}
|
||||
if (publicVotes()) {
|
||||
result += u"[PublicVotes]"_q;
|
||||
}
|
||||
if (!result.endsWith(u'\n')) {
|
||||
result += u'\n';
|
||||
}
|
||||
result += u"Total voters: "_q + QString::number(totalVoters) + u'\n';
|
||||
for (const auto &answer : answers) {
|
||||
result += u" - "_q + answer.text.text
|
||||
+ u" ["_q + QString::number(answer.votes) + u" votes"_q;
|
||||
if (answer.chosen) {
|
||||
result += u", chosen"_q;
|
||||
}
|
||||
if (answer.correct) {
|
||||
result += u", correct"_q;
|
||||
}
|
||||
result += u"]\n"_q;
|
||||
}
|
||||
if (!solution.text.isEmpty()) {
|
||||
result += u"Solution: "_q + solution.text + u'\n';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
MTPInputMedia PollMediaToMTP(const PollMedia &media) {
|
||||
if (media.photo) {
|
||||
return MTP_inputMediaPhoto(
|
||||
|
||||
@@ -102,6 +102,8 @@ struct PollData {
|
||||
[[nodiscard]] bool hideResultsUntilClose() const;
|
||||
[[nodiscard]] bool creator() const;
|
||||
|
||||
[[nodiscard]] QString debugString() const;
|
||||
|
||||
PollId id = 0;
|
||||
TextWithEntities question;
|
||||
std::vector<PollAnswer> answers;
|
||||
|
||||
@@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/crc32hash.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "apiwrap.h"
|
||||
@@ -2525,6 +2526,11 @@ ClickHandlerPtr Poll::Options::createAnswerClickHandler(
|
||||
auto result = ClickHandlerPtr();
|
||||
if (_owner->_flags & PollData::Flag::MultiChoice) {
|
||||
result = std::make_shared<LambdaClickHandler>(crl::guard(this, [=] {
|
||||
if (Logs::DebugEnabled() && base::IsCtrlPressed()) {
|
||||
TextUtilities::SetClipboardText(
|
||||
TextForMimeData::Simple(_owner->_poll->debugString()));
|
||||
return;
|
||||
}
|
||||
if (_owner->canVote()) {
|
||||
toggleMultiOption(option);
|
||||
} else if (_owner->showVotes()) {
|
||||
@@ -2533,6 +2539,11 @@ ClickHandlerPtr Poll::Options::createAnswerClickHandler(
|
||||
}));
|
||||
} else {
|
||||
result = std::make_shared<LambdaClickHandler>(crl::guard(this, [=] {
|
||||
if (Logs::DebugEnabled() && base::IsCtrlPressed()) {
|
||||
TextUtilities::SetClipboardText(
|
||||
TextForMimeData::Simple(_owner->_poll->debugString()));
|
||||
return;
|
||||
}
|
||||
if (_owner->canVote()) {
|
||||
_votedFromHere = true;
|
||||
_owner->history()->session().api().polls().sendVotes(
|
||||
|
||||
Reference in New Issue
Block a user