mirror of https://github.com/procxx/kepka.git
Simplest poll layout.
This commit is contained in:
parent
b0d01389c6
commit
4bb5dcf50c
|
@ -258,19 +258,6 @@ videoIcon: icon {
|
||||||
};
|
};
|
||||||
locationSize: size(320px, 240px);
|
locationSize: size(320px, 240px);
|
||||||
|
|
||||||
webPageLeft: 10px;
|
|
||||||
webPageBar: 2px;
|
|
||||||
webPageTitleFont: semiboldFont;
|
|
||||||
webPageTitleStyle: semiboldTextStyle;
|
|
||||||
webPageTitleOutFg: historyTextOutFg;
|
|
||||||
webPageTitleInFg: historyTextInFg;
|
|
||||||
webPageDescriptionOutFg: historyTextOutFg;
|
|
||||||
webPageDescriptionInFg: historyTextInFg;
|
|
||||||
webPageDescriptionFont: normalFont;
|
|
||||||
webPageDescriptionStyle: defaultTextStyle;
|
|
||||||
webPagePhotoSize: 100px;
|
|
||||||
webPagePhotoDelta: 8px;
|
|
||||||
|
|
||||||
mediaPlayerSuppressDuration: 150;
|
mediaPlayerSuppressDuration: 150;
|
||||||
|
|
||||||
botDescSkip: 8px;
|
botDescSkip: 8px;
|
||||||
|
|
|
@ -1829,6 +1829,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_launch_exe_sure" = "Run";
|
"lng_launch_exe_sure" = "Run";
|
||||||
"lng_launch_exe_dont_ask" = "Don't ask me again";
|
"lng_launch_exe_dont_ask" = "Don't ask me again";
|
||||||
|
|
||||||
|
"lng_polls_anonymous" = "Anonymous Poll";
|
||||||
|
"lng_polls_votes_count#one" = "{count} vote";
|
||||||
|
"lng_polls_votes_count#other" = "{count} votes";
|
||||||
|
|
||||||
// Wnd specific
|
// Wnd specific
|
||||||
|
|
||||||
"lng_wnd_choose_program_menu" = "Choose Default Program...";
|
"lng_wnd_choose_program_menu" = "Choose Default Program...";
|
||||||
|
|
|
@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
//#include "history/media/history_media_types.h"
|
|
||||||
#include "history/history_message.h"
|
#include "history/history_message.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "boxes/peer_list_box.h"
|
#include "boxes/peer_list_box.h"
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/media/history_media_invoice.h"
|
#include "history/media/history_media_invoice.h"
|
||||||
#include "history/media/history_media_call.h"
|
#include "history/media/history_media_call.h"
|
||||||
#include "history/media/history_media_web_page.h"
|
#include "history/media/history_media_web_page.h"
|
||||||
|
#include "history/media/history_media_poll.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/image/image_source.h"
|
#include "ui/image/image_source.h"
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
|
@ -1241,7 +1242,7 @@ bool MediaPoll::updateSentMedia(const MTPMessageMedia &media) {
|
||||||
std::unique_ptr<HistoryMedia> MediaPoll::createView(
|
std::unique_ptr<HistoryMedia> MediaPoll::createView(
|
||||||
not_null<HistoryView::Element*> message,
|
not_null<HistoryView::Element*> message,
|
||||||
not_null<HistoryItem*> realParent) {
|
not_null<HistoryItem*> realParent) {
|
||||||
return nullptr;
|
return std::make_unique<HistoryPoll>(message, _poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -67,6 +67,7 @@ bool PollData::applyChanges(const MTPDpoll &poll) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++version;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ struct PollData {
|
||||||
int totalVoters = 0;
|
int totalVoters = 0;
|
||||||
bool closed = false;
|
bool closed = false;
|
||||||
|
|
||||||
|
int version = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool applyResultToAnswers(
|
bool applyResultToAnswers(
|
||||||
const MTPPollAnswerVoters &result,
|
const MTPPollAnswerVoters &result,
|
||||||
|
|
|
@ -1529,22 +1529,16 @@ not_null<PollData*> Session::poll(const MTPDmessageMediaPoll &data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::applyPollUpdate(const MTPDupdateMessagePoll &update) {
|
void Session::applyPollUpdate(const MTPDupdateMessagePoll &update) {
|
||||||
const auto poll = [&] {
|
const auto updated = [&] {
|
||||||
if (update.has_poll()) {
|
const auto i = _polls.find(update.vpoll_id.v);
|
||||||
return update.vpoll.match([&](const MTPDpoll &data) {
|
return (i == end(_polls))
|
||||||
const auto i = _polls.find(data.vid.v);
|
? nullptr
|
||||||
return (i != end(_polls)) ? i->second.get() : nullptr;
|
: update.has_poll()
|
||||||
});
|
? poll(update.vpoll).get()
|
||||||
}
|
: i->second.get();
|
||||||
const auto item = App::histItemById(
|
|
||||||
peerToChannel(peerFromMTP(update.vpeer)),
|
|
||||||
update.vmsg_id.v);
|
|
||||||
return (item && item->media())
|
|
||||||
? item->media()->poll()
|
|
||||||
: nullptr;
|
|
||||||
}();
|
}();
|
||||||
if (poll && poll->applyResults(update.vresults)) {
|
if (updated && updated->applyResults(update.vresults)) {
|
||||||
requestPollViewRepaint(poll);
|
requestPollViewRepaint(updated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -479,6 +479,26 @@ historyAboutProxyPadding: margins(20px, 10px, 20px, 10px);
|
||||||
historyMapPoint: icon {{ "map_point", mapPointDrop }};
|
historyMapPoint: icon {{ "map_point", mapPointDrop }};
|
||||||
historyMapPointInner: icon {{ "map_point_inner", mapPointDot }};
|
historyMapPointInner: icon {{ "map_point_inner", mapPointDot }};
|
||||||
|
|
||||||
|
webPageLeft: 10px;
|
||||||
|
webPageBar: 2px;
|
||||||
|
webPageTitleFont: semiboldFont;
|
||||||
|
webPageTitleStyle: semiboldTextStyle;
|
||||||
|
webPageTitleOutFg: historyTextOutFg;
|
||||||
|
webPageTitleInFg: historyTextInFg;
|
||||||
|
webPageDescriptionOutFg: historyTextOutFg;
|
||||||
|
webPageDescriptionInFg: historyTextInFg;
|
||||||
|
webPageDescriptionFont: normalFont;
|
||||||
|
webPageDescriptionStyle: defaultTextStyle;
|
||||||
|
webPagePhotoSize: 100px;
|
||||||
|
webPagePhotoDelta: 8px;
|
||||||
|
|
||||||
|
historyPollQuestionStyle: semiboldTextStyle;
|
||||||
|
historyPollAnswerStyle: defaultTextStyle;
|
||||||
|
historyPollQuestionTop: 7px;
|
||||||
|
historyPollSubtitleSkip: 5px;
|
||||||
|
historyPollAnswerPadding: margins(30px, 16px, 0px, 16px);
|
||||||
|
historyPollAnswersSkip: 5px;
|
||||||
|
|
||||||
boxAttachEmoji: IconButton(historyAttachEmoji) {
|
boxAttachEmoji: IconButton(historyAttachEmoji) {
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/media/history_media_document.h"
|
#include "history/media/history_media_document.h"
|
||||||
#include "history/media/history_media_sticker.h"
|
#include "history/media/history_media_sticker.h"
|
||||||
#include "history/media/history_media_video.h"
|
#include "history/media/history_media_video.h"
|
||||||
|
#include "styles/style_history.h"
|
||||||
|
|
||||||
int documentMaxStatusWidth(DocumentData *document) {
|
int documentMaxStatusWidth(DocumentData *document) {
|
||||||
auto result = st::normalFont->width(formatDownloadText(document->size, document->size));
|
auto result = st::normalFont->width(formatDownloadText(document->size, document->size));
|
||||||
|
|
|
@ -0,0 +1,270 @@
|
||||||
|
/*
|
||||||
|
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/media/history_media_poll.h"
|
||||||
|
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "layout.h"
|
||||||
|
#include "history/history.h"
|
||||||
|
#include "history/history_item.h"
|
||||||
|
#include "history/view/history_view_element.h"
|
||||||
|
#include "history/view/history_view_cursor_state.h"
|
||||||
|
#include "calls/calls_instance.h"
|
||||||
|
#include "ui/text_options.h"
|
||||||
|
#include "data/data_media_types.h"
|
||||||
|
#include "data/data_poll.h"
|
||||||
|
#include "styles/style_history.h"
|
||||||
|
#include "styles/style_widgets.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using TextState = HistoryView::TextState;
|
||||||
|
|
||||||
|
struct FormattedLargeNumber {
|
||||||
|
int rounded = 0;
|
||||||
|
bool shortened = false;
|
||||||
|
QString text;
|
||||||
|
};
|
||||||
|
|
||||||
|
FormattedLargeNumber FormatLargeNumber(int64 number) {
|
||||||
|
auto result = FormattedLargeNumber();
|
||||||
|
const auto abs = std::abs(number);
|
||||||
|
const auto shorten = [&](int64 divider, char multiplier) {
|
||||||
|
const auto sign = (number > 0) ? 1 : -1;
|
||||||
|
const auto rounded = abs / (divider / 10);
|
||||||
|
result.rounded = sign * rounded * (divider / 10);
|
||||||
|
result.text = QString::number(sign * rounded / 10);
|
||||||
|
if (rounded % 10) {
|
||||||
|
result.text += '.' + QString::number(rounded % 10) + multiplier;
|
||||||
|
} else {
|
||||||
|
result.text += multiplier;
|
||||||
|
}
|
||||||
|
result.shortened = true;
|
||||||
|
};
|
||||||
|
if (abs >= 1'000'000) {
|
||||||
|
shorten(1'000'000, 'M');
|
||||||
|
} else if (abs >= 10'000) {
|
||||||
|
shorten(1'000, 'K');
|
||||||
|
} else {
|
||||||
|
result.rounded = number;
|
||||||
|
result.text = QString::number(number);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
HistoryPoll::Answer::Answer() : text(st::msgMinWidth / 2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryPoll::HistoryPoll(
|
||||||
|
not_null<Element*> parent,
|
||||||
|
not_null<PollData*> poll)
|
||||||
|
: HistoryMedia(parent)
|
||||||
|
, _poll(poll)
|
||||||
|
, _question(st::msgMinWidth / 2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize HistoryPoll::countOptimalSize() {
|
||||||
|
updateTexts();
|
||||||
|
|
||||||
|
const auto paddings = st::msgPadding.left() + st::msgPadding.right();
|
||||||
|
|
||||||
|
auto maxWidth = st::msgFileMinWidth;
|
||||||
|
accumulate_max(maxWidth, paddings + _question.maxWidth());
|
||||||
|
for (const auto &answer : _answers) {
|
||||||
|
accumulate_max(
|
||||||
|
maxWidth,
|
||||||
|
paddings
|
||||||
|
+ st::historyPollAnswerPadding.left()
|
||||||
|
+ answer.text.maxWidth()
|
||||||
|
+ st::historyPollAnswerPadding.right());
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto answersHeight = ranges::accumulate(ranges::view::all(
|
||||||
|
_answers
|
||||||
|
) | ranges::view::transform([](const Answer &answer) {
|
||||||
|
return st::historyPollAnswerPadding.top()
|
||||||
|
+ 2 * st::defaultCheckbox.textPosition.y()
|
||||||
|
+ answer.text.minHeight()
|
||||||
|
+ st::historyPollAnswerPadding.bottom()
|
||||||
|
+ st::lineWidth;
|
||||||
|
}), 0);
|
||||||
|
|
||||||
|
auto minHeight = st::historyPollQuestionTop
|
||||||
|
+ _question.minHeight()
|
||||||
|
+ st::historyPollSubtitleSkip
|
||||||
|
+ st::msgDateTextStyle.font->height
|
||||||
|
+ st::historyPollAnswersSkip
|
||||||
|
+ answersHeight
|
||||||
|
+ st::msgPadding.bottom()
|
||||||
|
+ st::msgDateTextStyle.font->height
|
||||||
|
+ st::msgPadding.bottom();
|
||||||
|
if (!isBubbleTop()) {
|
||||||
|
minHeight -= st::msgFileTopMinus;
|
||||||
|
}
|
||||||
|
return { maxWidth, minHeight };
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize HistoryPoll::countCurrentSize(int newWidth) {
|
||||||
|
const auto paddings = st::msgPadding.left() + st::msgPadding.right();
|
||||||
|
|
||||||
|
accumulate_min(newWidth, maxWidth());
|
||||||
|
const auto innerWidth = newWidth
|
||||||
|
- st::msgPadding.left()
|
||||||
|
- st::msgPadding.right();
|
||||||
|
|
||||||
|
const auto answerWidth = innerWidth
|
||||||
|
- st::historyPollAnswerPadding.left()
|
||||||
|
- st::historyPollAnswerPadding.right();
|
||||||
|
const auto answersHeight = ranges::accumulate(ranges::view::all(
|
||||||
|
_answers
|
||||||
|
) | ranges::view::transform([&](const Answer &answer) {
|
||||||
|
return st::historyPollAnswerPadding.top()
|
||||||
|
+ 2 * st::defaultCheckbox.textPosition.y()
|
||||||
|
+ answer.text.countHeight(answerWidth)
|
||||||
|
+ st::historyPollAnswerPadding.bottom()
|
||||||
|
+ st::lineWidth;
|
||||||
|
}), 0);
|
||||||
|
|
||||||
|
auto newHeight = st::historyPollQuestionTop
|
||||||
|
+ _question.countHeight(innerWidth)
|
||||||
|
+ st::historyPollSubtitleSkip
|
||||||
|
+ st::msgDateTextStyle.font->height
|
||||||
|
+ st::historyPollAnswersSkip
|
||||||
|
+ answersHeight
|
||||||
|
+ st::msgPadding.bottom()
|
||||||
|
+ st::msgDateTextStyle.font->height
|
||||||
|
+ st::msgPadding.bottom();
|
||||||
|
if (!isBubbleTop()) {
|
||||||
|
newHeight -= st::msgFileTopMinus;
|
||||||
|
}
|
||||||
|
return { newWidth, newHeight };
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryPoll::updateTexts() {
|
||||||
|
if (_pollVersion == _poll->version) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_pollVersion = _poll->version;
|
||||||
|
_question.setText(
|
||||||
|
st::historyPollQuestionStyle,
|
||||||
|
_poll->question,
|
||||||
|
Ui::WebpageTextTitleOptions());
|
||||||
|
_subtitle.setText(
|
||||||
|
st::msgDateTextStyle,
|
||||||
|
lang(lng_polls_anonymous));
|
||||||
|
|
||||||
|
_answers = ranges::view::all(
|
||||||
|
_poll->answers
|
||||||
|
) | ranges::view::transform([](const PollAnswer &answer) {
|
||||||
|
auto result = Answer();
|
||||||
|
result.option = answer.option;
|
||||||
|
result.text.setText(
|
||||||
|
st::historyPollAnswerStyle,
|
||||||
|
answer.text,
|
||||||
|
Ui::WebpageTextTitleOptions());
|
||||||
|
return result;
|
||||||
|
}) | ranges::to_vector;
|
||||||
|
|
||||||
|
_voted = ranges::find(
|
||||||
|
_poll->answers,
|
||||||
|
true,
|
||||||
|
[](const PollAnswer &answer) { return answer.chosen; }
|
||||||
|
) != end(_poll->answers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryPoll::updateVotes() const {
|
||||||
|
updateTotalVotes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryPoll::updateTotalVotes() const {
|
||||||
|
if (_totalVotes == _poll->totalVoters) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_totalVotes = _poll->totalVoters;
|
||||||
|
if (!_totalVotes) {
|
||||||
|
_totalVotesLabel.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto formatted = FormatLargeNumber(_totalVotes);
|
||||||
|
auto string = lng_polls_votes_count(lt_count, formatted.rounded);
|
||||||
|
if (formatted.shortened) {
|
||||||
|
string.replace(QString::number(formatted.rounded), formatted.text);
|
||||||
|
}
|
||||||
|
_totalVotesLabel.setText(st::msgDateTextStyle, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HistoryPoll::draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const {
|
||||||
|
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
|
||||||
|
auto paintx = 0, painty = 0, paintw = width(), painth = height();
|
||||||
|
|
||||||
|
updateVotes();
|
||||||
|
|
||||||
|
auto outbg = _parent->hasOutLayout();
|
||||||
|
bool selected = (selection == FullSelection);
|
||||||
|
|
||||||
|
auto &semibold = selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg);
|
||||||
|
auto ®ular = selected ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) : (outbg ? st::msgOutDateFg : st::msgInDateFg);
|
||||||
|
|
||||||
|
auto padding = st::msgPadding;
|
||||||
|
auto tshift = st::historyPollQuestionTop;
|
||||||
|
if (!isBubbleTop()) {
|
||||||
|
tshift -= st::msgFileTopMinus;
|
||||||
|
}
|
||||||
|
paintw -= padding.left() + padding.right();
|
||||||
|
|
||||||
|
p.setPen(outbg ? st::webPageTitleOutFg : st::webPageTitleInFg);
|
||||||
|
_question.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, selection);
|
||||||
|
tshift += _question.countHeight(paintw) + st::historyPollSubtitleSkip;
|
||||||
|
|
||||||
|
p.setPen(regular);
|
||||||
|
_subtitle.drawLeftElided(p, padding.left(), tshift, paintw, width());
|
||||||
|
tshift += st::msgDateTextStyle.font->height + st::historyPollAnswersSkip;
|
||||||
|
|
||||||
|
const auto aleft = padding.left() + st::historyPollAnswerPadding.left();
|
||||||
|
const auto awidth = paintw - st::historyPollAnswerPadding.left() - st::historyPollAnswerPadding.right();
|
||||||
|
for (const auto &answer : _answers) {
|
||||||
|
tshift += st::historyPollAnswerPadding.top();
|
||||||
|
|
||||||
|
{
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
const auto &st = st::defaultRadio;
|
||||||
|
auto pen = regular->p;
|
||||||
|
pen.setWidth(st.thickness);
|
||||||
|
p.setPen(pen);
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.drawEllipse(QRectF(padding.left(), tshift, st.diameter, st.diameter).marginsRemoved(QMarginsF(st.thickness / 2., st.thickness / 2., st.thickness / 2., st.thickness / 2.)));
|
||||||
|
}
|
||||||
|
|
||||||
|
tshift += st::defaultCheckbox.textPosition.y();
|
||||||
|
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg);
|
||||||
|
answer.text.drawLeft(p, aleft, tshift, awidth, width());
|
||||||
|
tshift += answer.text.countHeight(awidth)
|
||||||
|
+ st::defaultCheckbox.textPosition.y()
|
||||||
|
+ st::historyPollAnswerPadding.bottom();
|
||||||
|
|
||||||
|
p.setOpacity(0.5);
|
||||||
|
p.fillRect(aleft, tshift, width() - aleft, st::lineWidth, regular);
|
||||||
|
tshift += st::lineWidth;
|
||||||
|
p.setOpacity(1.);
|
||||||
|
}
|
||||||
|
if (!_totalVotesLabel.isEmpty()) {
|
||||||
|
tshift += st::msgPadding.bottom();
|
||||||
|
p.setPen(regular);
|
||||||
|
_totalVotesLabel.drawLeftElided(p, padding.left(), tshift, paintw, width());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextState HistoryPoll::textState(QPoint point, StateRequest request) const {
|
||||||
|
auto result = TextState(_parent);
|
||||||
|
if (QRect(0, 0, width(), height()).contains(point)) {
|
||||||
|
// result.link = _link;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
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 "history/media/history_media.h"
|
||||||
|
|
||||||
|
class HistoryPoll : public HistoryMedia {
|
||||||
|
public:
|
||||||
|
HistoryPoll(
|
||||||
|
not_null<Element*> parent,
|
||||||
|
not_null<PollData*> poll);
|
||||||
|
|
||||||
|
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||||
|
TextState textState(QPoint point, StateRequest request) const override;
|
||||||
|
|
||||||
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool needsBubble() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool customInfoLayout() const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Answer {
|
||||||
|
Answer();
|
||||||
|
|
||||||
|
Text text;
|
||||||
|
QByteArray option;
|
||||||
|
mutable int votes = 0;
|
||||||
|
mutable bool chosen = false;
|
||||||
|
};
|
||||||
|
QSize countOptimalSize() override;
|
||||||
|
QSize countCurrentSize(int newWidth) override;
|
||||||
|
|
||||||
|
void updateTexts();
|
||||||
|
void updateVotes() const;
|
||||||
|
void updateTotalVotes() const;
|
||||||
|
|
||||||
|
not_null<PollData*> _poll;
|
||||||
|
int _pollVersion = 0;
|
||||||
|
mutable int _totalVotes = 0;
|
||||||
|
mutable bool _voted = false;
|
||||||
|
|
||||||
|
Text _question;
|
||||||
|
Text _subtitle;
|
||||||
|
std::vector<Answer> _answers;
|
||||||
|
mutable Text _totalVotesLabel;
|
||||||
|
|
||||||
|
};
|
|
@ -7,9 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "ui/text_options.h"
|
#include "ui/text_options.h"
|
||||||
|
|
||||||
#include "styles/style_window.h"
|
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
#include "styles/style_history.h"
|
||||||
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -244,6 +244,8 @@
|
||||||
<(src_loc)/history/media/history_media_location.cpp
|
<(src_loc)/history/media/history_media_location.cpp
|
||||||
<(src_loc)/history/media/history_media_photo.h
|
<(src_loc)/history/media/history_media_photo.h
|
||||||
<(src_loc)/history/media/history_media_photo.cpp
|
<(src_loc)/history/media/history_media_photo.cpp
|
||||||
|
<(src_loc)/history/media/history_media_poll.h
|
||||||
|
<(src_loc)/history/media/history_media_poll.cpp
|
||||||
<(src_loc)/history/media/history_media_sticker.h
|
<(src_loc)/history/media/history_media_sticker.h
|
||||||
<(src_loc)/history/media/history_media_sticker.cpp
|
<(src_loc)/history/media/history_media_sticker.cpp
|
||||||
<(src_loc)/history/media/history_media_video.h
|
<(src_loc)/history/media/history_media_video.h
|
||||||
|
|
Loading…
Reference in New Issue