From 9ee1e4347b07567525924efcd8c6c8cbd9287683 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Wed, 22 Jul 2020 17:20:32 +0300 Subject: [PATCH] Show poll's multiple answer radios as checkboxes --- .../history/view/media/history_view_poll.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp index 7ee629a98..25f457914 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp @@ -1168,7 +1168,11 @@ void Poll::paintRadio( auto pen = regular->p; pen.setWidth(st.thickness); p.setPen(pen); - p.drawEllipse(rect); + if (_flags & PollData::Flag::MultiChoice) { + p.drawRoundedRect(rect, st::buttonRadius, st::buttonRadius); + } else { + p.drawEllipse(rect); + } } if (checkmark > 0.) { const auto removeFull = (st.diameter / 2 - st.thickness); @@ -1178,7 +1182,13 @@ void Poll::paintRadio( pen.setWidth(st.thickness); p.setPen(pen); p.setBrush(color); - p.drawEllipse(rect.marginsRemoved({ removeNow, removeNow, removeNow, removeNow })); + if (_flags & PollData::Flag::MultiChoice) { + p.drawRoundedRect( + rect.marginsRemoved({ removeNow, removeNow, removeNow, removeNow }), + st::buttonRadius, st::buttonRadius); + } else { + p.drawEllipse(rect.marginsRemoved({ removeNow, removeNow, removeNow, removeNow })); + } const auto &icon = outbg ? (selected ? st::historyPollOutChosenSelected : st::historyPollOutChosen) : (selected ? st::historyPollInChosenSelected : st::historyPollInChosen); icon.paint(p, left + (st.diameter - icon.width()) / 2, top + (st.diameter - icon.height()) / 2, width()); } @@ -1251,7 +1261,13 @@ void Poll::paintFilling( : st::historyPollChoiceRight; const auto cleft = aleft - st::historyPollPercentSkip - icon.width(); const auto ctop = ftop - (icon.height() - thickness) / 2; - p.drawEllipse(cleft, ctop, icon.width(), icon.height()); + if (_flags & PollData::Flag::MultiChoice) { + p.drawRoundedRect( + QRect{ cleft, ctop, icon.width(), icon.height() }, + st::buttonRadius, st::buttonRadius); + } else { + p.drawEllipse(cleft, ctop, icon.width(), icon.height()); + } icon.paint(p, cleft, ctop, width); //barleft += icon.width() - radius; //barwidth -= icon.width() - radius;