mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Correctly edit video stream comment price.
This commit is contained in:
@@ -4161,6 +4161,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_video_stream_live" = "LIVE";
|
||||
"lng_video_stream_watched#one" = "{count} watching";
|
||||
"lng_video_stream_watched#other" = "{count} watching";
|
||||
"lng_video_stream_edit_stars" = "Edit Stars";
|
||||
"lng_video_stream_remove_stars" = "Remove Stars";
|
||||
"lng_message_stars_ph#one" = "Message for {count} Star";
|
||||
"lng_message_stars_ph#other" = "Message for {count} Stars";
|
||||
"lng_send_text_no" = "Text not allowed.";
|
||||
|
||||
@@ -747,7 +747,9 @@ void SendFilesBox::refreshButtons() {
|
||||
_send,
|
||||
_show,
|
||||
_sendMenuDetails,
|
||||
_sendMenuCallback);
|
||||
_sendMenuCallback,
|
||||
&_st.tabbed.menu,
|
||||
&_st.tabbed.icons);
|
||||
}
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
_addFile = addLeftButton(
|
||||
|
||||
@@ -54,7 +54,7 @@ constexpr auto kMaxShownVideoStreamMessages = 100;
|
||||
if (!date || !stars) {
|
||||
return 0;
|
||||
}
|
||||
return date + (Ui::StarsColoringForCount(stars).minutesPin * TimeId(60));
|
||||
return date + Ui::StarsColoringForCount(stars).secondsPin;
|
||||
}
|
||||
|
||||
[[nodiscard]] TimeId PinFinishDate(const Message &message) {
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Calls::Group {
|
||||
namespace {
|
||||
|
||||
constexpr auto kMessageBgOpacity = 0.8;
|
||||
constexpr auto kDarkOverOpacity = 0.25;
|
||||
constexpr auto kColoredMessageBgOpacity = 0.65;
|
||||
|
||||
[[nodiscard]] int CountMessageRadius() {
|
||||
@@ -69,7 +70,8 @@ constexpr auto kColoredMessageBgOpacity = 0.65;
|
||||
}
|
||||
|
||||
[[nodiscard]] uint64 ColoringKey(const Ui::StarsColoring &value) {
|
||||
return (uint64(uint32(value.bg1)) << 32) | uint64(uint32(value.bg2));
|
||||
return uint64(uint32(value.bgLight))
|
||||
| (uint64(uint32(value.bgDark)) << 32);
|
||||
}
|
||||
|
||||
void ReceiveSomeMouseEvents(
|
||||
@@ -199,11 +201,12 @@ struct MessagesUi::PinnedView {
|
||||
};
|
||||
|
||||
MessagesUi::PayedBg::PayedBg(const Ui::StarsColoring &coloring)
|
||||
: color1(Ui::ColorFromSerialized(coloring.bg1))
|
||||
, color2(Ui::ColorFromSerialized(coloring.bg2))
|
||||
, rounded1(CountPinnedRadius(), color1.color())
|
||||
, rounded2(CountPinnedRadius(), color2.color())
|
||||
, rounded(CountMessageRadius(), color2.color()) {
|
||||
: light(Ui::ColorFromSerialized(coloring.bgLight))
|
||||
, dark(Ui::ColorFromSerialized(coloring.bgDark))
|
||||
, pinnedLight(CountPinnedRadius(), light.color())
|
||||
, pinnedDark(CountPinnedRadius(), dark.color())
|
||||
, messageLight(CountMessageRadius(), light.color())
|
||||
, badgeDark(st::roundRadiusLarge, dark.color()) {
|
||||
}
|
||||
|
||||
MessagesUi::MessagesUi(
|
||||
@@ -988,7 +991,7 @@ void MessagesUi::setupMessagesWidget() {
|
||||
bg = std::make_unique<PayedBg>(coloring);
|
||||
}
|
||||
p.setOpacity(kColoredMessageBgOpacity);
|
||||
bg->rounded.paint(p, { x, y, width, use });
|
||||
bg->messageLight.paint(p, { x, y, width, use });
|
||||
p.setOpacity(1.);
|
||||
if (_highlightAnimation.animating()
|
||||
&& entry.id == _highlightId) {
|
||||
@@ -1221,14 +1224,16 @@ void MessagesUi::setupPinnedWidget() {
|
||||
const auto part = int(base::SafeRound(still * use));
|
||||
const auto line = st::lineWidth;
|
||||
if (part > 0) {
|
||||
p.setClipRect(x - line, y, part + line, height);
|
||||
bg->rounded1.paint(p, { x, y, use, height });
|
||||
p.setOpacity(kColoredMessageBgOpacity);
|
||||
bg->pinnedLight.paint(p, { x, y, use, height });
|
||||
}
|
||||
if (part < use) {
|
||||
p.setClipRect(x + part, y, use - part + line, height);
|
||||
bg->rounded2.paint(p, { x, y, use, height });
|
||||
p.setOpacity(kDarkOverOpacity);
|
||||
bg->pinnedDark.paint(p, { x, y, use, height });
|
||||
}
|
||||
p.setClipping(false);
|
||||
p.setOpacity(1.);
|
||||
|
||||
const auto userpicSize = st::groupCallPinnedUserpic;
|
||||
const auto userpicPadding = st::groupCallUserpicPadding;
|
||||
|
||||
@@ -68,11 +68,12 @@ private:
|
||||
struct PayedBg {
|
||||
explicit PayedBg(const Ui::StarsColoring &coloring);
|
||||
|
||||
style::owned_color color1;
|
||||
style::owned_color color2;
|
||||
Ui::RoundRect rounded1;
|
||||
Ui::RoundRect rounded2;
|
||||
Ui::RoundRect rounded;
|
||||
style::owned_color light;
|
||||
style::owned_color dark;
|
||||
Ui::RoundRect pinnedLight;
|
||||
Ui::RoundRect pinnedDark;
|
||||
Ui::RoundRect messageLight;
|
||||
Ui::RoundRect badgeDark;
|
||||
};
|
||||
|
||||
void setupList(
|
||||
|
||||
@@ -70,63 +70,23 @@ namespace {
|
||||
} // namespace
|
||||
|
||||
StarsColoring StarsColoringForCount(int stars) {
|
||||
//name: "Purple" [STRING],
|
||||
//center_color: 11431086 [INT],
|
||||
//edge_color: 8669060 [INT],
|
||||
//pattern_color: 4656199 [INT],
|
||||
//text_color: 15977459 [INT],
|
||||
|
||||
//name: "Celtic Blue" [STRING],
|
||||
//center_color: 4569325 [INT],
|
||||
//edge_color: 3704537 [INT],
|
||||
//pattern_color: 16005 [INT],
|
||||
//text_color: 12773375 [INT],
|
||||
|
||||
//name: "Mint Green" [STRING],
|
||||
//center_color: 8309634 [INT],
|
||||
//edge_color: 4562522 [INT],
|
||||
//pattern_color: 158498 [INT],
|
||||
//text_color: 12451788 [INT],
|
||||
|
||||
//name: "Pure Gold" [STRING],
|
||||
//center_color: 13413185 [INT],
|
||||
//edge_color: 9993010 [INT],
|
||||
//pattern_color: 7355392 [INT],
|
||||
//text_color: 16770475 [INT],
|
||||
|
||||
//name: "Orange" [STRING],
|
||||
//center_color: 13736506 [INT],
|
||||
//edge_color: 12611399 [INT],
|
||||
//pattern_color: 10303751 [INT],
|
||||
//text_color: 16769475 [INT],
|
||||
|
||||
//name: "Strawberry" [STRING],
|
||||
//center_color: 14519919 [INT],
|
||||
//edge_color: 12016224 [INT],
|
||||
//pattern_color: 11078668 [INT],
|
||||
//text_color: 16765907 [INT],
|
||||
|
||||
//name: "Steel Grey" [STRING],
|
||||
//center_color: 9937580 [INT],
|
||||
//edge_color: 6517372 [INT],
|
||||
//pattern_color: 3360082 [INT],
|
||||
//text_color: 14673128 [INT],
|
||||
|
||||
const auto list = std::vector<StarsColoring>{
|
||||
{ 11431086, 8669060, 50, 1, 60, 1 },
|
||||
{ 4569325, 3704537, 100, 1, 80, 2 },
|
||||
{ 8309634, 4562522, 250, 5, 110, 3 },
|
||||
{ 13413185, 9993010, 500, 10, 150, 4 },
|
||||
{ 13736506, 12611399, 2000, 15, 200, 7 },
|
||||
{ 14519919, 12016224, 7500, 30, 280, 10 },
|
||||
{ 9937580, 6517372, 0, 60, 400, 20 },
|
||||
{ 0x955CDB, 0x49079B, 0, 30, 30, 0 }, // purple
|
||||
{ 0x955CDB, 0x49079B, 10, 60, 60, 1 }, // still purple
|
||||
{ 0x46A3EB, 0x00508E, 50, 120, 80, 2 }, // blue
|
||||
{ 0x40A920, 0x176200, 100, 300, 110, 3 }, // green
|
||||
{ 0xE29A09, 0x9A3E00, 250, 600, 150, 4 }, // yellow
|
||||
{ 0xED771E, 0x9B3100, 500, 900, 200, 7 }, // orange
|
||||
{ 0xE14542, 0x8B0503, 2'000, 1800, 280, 10 }, // red
|
||||
{ 0x596473, 0x252C36, 10'000, 3600, 400, 20 }, // silver
|
||||
};
|
||||
for (const auto &entry : list) {
|
||||
if (!entry.tillStars || stars < entry.tillStars) {
|
||||
return entry;
|
||||
for (auto i = begin(list), e = end(list); i != e; ++i) {
|
||||
if (i->fromStars > stars) {
|
||||
Assert(i != begin(list));
|
||||
return *(std::prev(i));
|
||||
}
|
||||
}
|
||||
Unexpected("StarsColoringForCount: should not reach here.");
|
||||
return list.back();
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> VideoStreamStarsLevel(
|
||||
@@ -149,10 +109,12 @@ object_ptr<Ui::RpWidget> VideoStreamStarsLevel(
|
||||
|
||||
state->blocks.push_back(MakeInfoBlock(raw, state->coloring.value(
|
||||
) | rpl::map([=](const StarsColoring &value) {
|
||||
const auto minutes = value.minutesPin;
|
||||
return (minutes >= 60)
|
||||
? tr::lng_hours_tiny(tr::now, lt_count, minutes / 60)
|
||||
: tr::lng_minutes_tiny(tr::now, lt_count, minutes);
|
||||
const auto seconds = value.secondsPin;
|
||||
return (seconds >= 3600)
|
||||
? tr::lng_hours_tiny(tr::now, lt_count, seconds / 3600)
|
||||
: (seconds >= 60)
|
||||
? tr::lng_minutes_tiny(tr::now, lt_count, seconds / 60)
|
||||
: tr::lng_seconds_tiny(tr::now, lt_count, seconds);
|
||||
}), tr::lng_paid_comment_pin_about()));
|
||||
|
||||
state->blocks.push_back(MakeInfoBlock(raw, state->coloring.value(
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace Calls::Group::Ui {
|
||||
using namespace ::Ui;
|
||||
|
||||
struct StarsColoring {
|
||||
int bg1 = 0;
|
||||
int bg2 = 0;
|
||||
int tillStars = 0;
|
||||
int minutesPin = 0;
|
||||
int bgLight = 0;
|
||||
int bgDark = 0;
|
||||
int fromStars = 0;
|
||||
TimeId secondsPin = 0;
|
||||
int charactersMax = 0;
|
||||
int emojiLimit = 0;
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ ComposeIcons {
|
||||
menuBelow: icon;
|
||||
menuAbove: icon;
|
||||
menuPrice: icon;
|
||||
menuEditStars: icon;
|
||||
|
||||
stripBubble: icon;
|
||||
stripExpandPanel: icon;
|
||||
@@ -156,8 +157,6 @@ SendButton {
|
||||
recordOver: icon;
|
||||
round: icon;
|
||||
roundOver: icon;
|
||||
editPrice: icon;
|
||||
editPriceOver: icon;
|
||||
sendDisabledFg: color;
|
||||
}
|
||||
|
||||
@@ -214,6 +213,7 @@ ComposeControls {
|
||||
emoji: EmojiButton;
|
||||
like: IconButton;
|
||||
liked: icon;
|
||||
editStars: IconButton;
|
||||
commentsShow: IconButton;
|
||||
commentsShown: icon;
|
||||
commentsSkip: pixels;
|
||||
|
||||
@@ -533,6 +533,7 @@ void GroupCall::applyCallFields(const MTPDgroupCall &data) {
|
||||
_canChangeMessagesEnabled = data.is_can_change_messages_enabled();
|
||||
_messagesEnabled = data.is_messages_enabled();
|
||||
}
|
||||
_messagesMinPrice = data.vsend_paid_messages_stars().value_or_empty();
|
||||
_joinedToTop = !data.is_join_date_asc();
|
||||
setServerParticipantsCount(data.vparticipants_count().v);
|
||||
changePeerEmptyCallFlag();
|
||||
|
||||
@@ -206,6 +206,12 @@ public:
|
||||
[[nodiscard]] rpl::producer<bool> messagesEnabledValue() const {
|
||||
return _messagesEnabled.value();
|
||||
}
|
||||
[[nodiscard]] int messagesMinPrice() const {
|
||||
return _messagesMinPrice.current();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<int> messagesMinPriceValue() const {
|
||||
return _messagesMinPrice.value();
|
||||
}
|
||||
|
||||
private:
|
||||
enum class ApplySliceSource {
|
||||
@@ -269,6 +275,7 @@ private:
|
||||
rpl::variable<int> _fullCount = 0;
|
||||
rpl::variable<int> _unmutedVideoLimit = 0;
|
||||
rpl::variable<bool> _messagesEnabled = false;
|
||||
rpl::variable<int> _messagesMinPrice = 0;
|
||||
rpl::variable<TimeId> _recordStartDate = 0;
|
||||
rpl::variable<TimeId> _scheduleDate = 0;
|
||||
rpl::variable<bool> _scheduleStartSubscribed = false;
|
||||
|
||||
@@ -909,6 +909,9 @@ ComposeControls::ComposeControls(
|
||||
, _mode(descriptor.mode)
|
||||
, _wrap(std::make_unique<Ui::RpWidget>(parent))
|
||||
, _send(std::make_shared<Ui::SendButton>(_wrap.get(), _st.send))
|
||||
, _editStars(_features.editMessageStars
|
||||
? Ui::CreateChild<Ui::IconButton>(_wrap.get(), _st.editStars)
|
||||
: nullptr)
|
||||
, _like(_features.likes
|
||||
? Ui::CreateChild<Ui::IconButton>(_wrap.get(), _st.like)
|
||||
: nullptr)
|
||||
@@ -1080,6 +1083,22 @@ void ComposeControls::initLikeButton() {
|
||||
}
|
||||
}
|
||||
|
||||
void ComposeControls::initEditStarsButton() {
|
||||
if (_editStars) {
|
||||
_editStars->setClickedCallback([=] {
|
||||
_show->show(Calls::Group::MakeVideoStreamStarsBox({
|
||||
.show = _show,
|
||||
.current = _chosenStarsCount.value_or(0),
|
||||
.save = crl::guard(_editStars, [=](int count) {
|
||||
_chosenStarsCount = count;
|
||||
updateSendButtonType();
|
||||
}),
|
||||
.name = _history ? _history->peer->shortName() : QString(),
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ComposeControls::updateLikeParent() {
|
||||
if (_like) {
|
||||
using namespace Controls;
|
||||
@@ -1115,8 +1134,19 @@ void ComposeControls::updateFeatures(ChatHelpers::ComposeFeatures features) {
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
if (was.editMessageStars != features.editMessageStars
|
||||
|| was.recordMediaMessage != features.recordMediaMessage) {
|
||||
if (was.editMessageStars != features.editMessageStars) {
|
||||
if (!features.editMessageStars) {
|
||||
delete base::take(_editStars);
|
||||
_chosenStarsCount = std::nullopt;
|
||||
} else {
|
||||
_editStars = Ui::CreateChild<Ui::IconButton>(
|
||||
_wrap.get(),
|
||||
_st.editStars);
|
||||
initEditStarsButton();
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
if (was.recordMediaMessage != features.recordMediaMessage) {
|
||||
_chosenStarsCount = features.editMessageStars
|
||||
? 0
|
||||
: std::optional<int>();
|
||||
@@ -2457,7 +2487,10 @@ void ComposeControls::initSendButton() {
|
||||
|
||||
using namespace SendMenu;
|
||||
const auto sendAction = [=](Action action, Details details) {
|
||||
if (action.type == ActionType::CaptionUp
|
||||
if (action.type == ActionType::ChangePrice) {
|
||||
_chosenStarsCount = details.price.value_or(0);
|
||||
updateSendButtonType();
|
||||
} else if (action.type == ActionType::CaptionUp
|
||||
|| action.type == ActionType::CaptionDown
|
||||
|| action.type == ActionType::SpoilerOn
|
||||
|| action.type == ActionType::SpoilerOff) {
|
||||
@@ -2471,7 +2504,9 @@ void ComposeControls::initSendButton() {
|
||||
_send.get(),
|
||||
_show,
|
||||
[=] { return sendButtonMenuDetails(); },
|
||||
sendAction);
|
||||
sendAction,
|
||||
&_st.tabbed.menu,
|
||||
&_st.tabbed.icons);
|
||||
|
||||
_send->widthValue() | rpl::skip(1) | rpl::start_with_next([=] {
|
||||
updateControlsGeometry(_wrap->size());
|
||||
@@ -2913,6 +2948,7 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||
- (_sendAs ? _sendAs->width() : 0)
|
||||
- _st.padding.right()
|
||||
- _send->width()
|
||||
- (_editStars ? _editStars->width() : 0)
|
||||
- _tabbedSelectorToggle->width()
|
||||
- (_likeShown ? _like->width() : 0)
|
||||
- (_botCommandShown ? _botCommandStart->width() : 0)
|
||||
@@ -2968,6 +3004,10 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
||||
right += _st.padding.right();
|
||||
_send->moveToRight(right, buttonsTop);
|
||||
right += _send->width();
|
||||
if (_editStars) {
|
||||
_editStars->moveToRight(right, buttonsTop);
|
||||
right += _editStars->width();
|
||||
}
|
||||
_tabbedSelectorToggle->moveToRight(right, buttonsTop);
|
||||
right += _tabbedSelectorToggle->width();
|
||||
if (_like) {
|
||||
@@ -3012,6 +3052,9 @@ void ComposeControls::updateControlsVisibility() {
|
||||
if (_like) {
|
||||
_like->setVisible(_likeShown);
|
||||
}
|
||||
if (_editStars) {
|
||||
_editStars->show();
|
||||
}
|
||||
if (_ttlInfo) {
|
||||
_ttlInfo->show();
|
||||
}
|
||||
|
||||
@@ -294,6 +294,7 @@ private:
|
||||
void initVoiceRecordBar();
|
||||
void initKeyHandler();
|
||||
void initLikeButton();
|
||||
void initEditStarsButton();
|
||||
void updateLikeParent();
|
||||
void updateSubmitSettings();
|
||||
void updateSendButtonType();
|
||||
@@ -403,6 +404,7 @@ private:
|
||||
std::optional<Ui::RoundRect> _backgroundRect;
|
||||
|
||||
const std::shared_ptr<Ui::SendButton> _send;
|
||||
Ui::IconButton *_editStars = nullptr;
|
||||
Ui::IconButton *_like = nullptr;
|
||||
std::optional<int> _chosenStarsCount;
|
||||
Ui::IconButton *_commentsShown = nullptr;
|
||||
|
||||
@@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_chat_participant_status.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_group_call.h"
|
||||
#include "data/data_message_reaction_id.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_session.h"
|
||||
@@ -599,9 +600,27 @@ void ReplyArea::chooseAttach(
|
||||
|
||||
Fn<SendMenu::Details()> ReplyArea::sendMenuDetails() const {
|
||||
return crl::guard(this, [=] {
|
||||
const auto call = _videoStream
|
||||
? _videoStream->lookupReal()
|
||||
: nullptr;
|
||||
return SendMenu::Details{
|
||||
.type = SendMenu::Type::SilentOnly,
|
||||
.effectAllowed = _data.peer && _data.peer->isUser(),
|
||||
.type = (!_data.videoStream
|
||||
? SendMenu::Type::SilentOnly
|
||||
: !call
|
||||
? SendMenu::Type::Disabled
|
||||
: SendMenu::Type::EditCommentPrice),
|
||||
.commentStreamerName = (call
|
||||
? call->peer()->shortName()
|
||||
: QString()),
|
||||
.price = (_data.videoStream
|
||||
? uint64(_controls->chosenStarsForMessage())
|
||||
: std::optional<uint64>()),
|
||||
.commentPriceMin = (call
|
||||
? uint64(call->messagesMinPrice())
|
||||
: std::optional<uint64>()),
|
||||
.effectAllowed = (!_data.videoStream
|
||||
&& _data.peer
|
||||
&& _data.peer->isUser()),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -495,12 +495,10 @@ storiesRecordVoice: icon {{ "chat/input_record", storiesComposeGrayIcon }};
|
||||
storiesRecordVoiceOver: icon {{ "chat/input_record", storiesComposeGrayIcon }};
|
||||
storiesRecordRound: icon {{ "chat/input_video", storiesComposeGrayIcon }};
|
||||
storiesRecordRoundOver: icon {{ "chat/input_video", storiesComposeGrayIcon }};
|
||||
storiesEditPrice: icon{{ "chat/input_paid", storiesComposeGrayIcon }};
|
||||
storiesEditPriceOver: icon{{ "chat/input_paid", storiesComposeGrayIcon }};
|
||||
//storiesEditStars: IconButton(storiesAttach) {
|
||||
// icon: storiesEditPrice;
|
||||
// iconOver: storiesEditPriceOver;
|
||||
//}
|
||||
storiesEditStars: IconButton(storiesAttach) {
|
||||
icon: icon{{ "chat/input_paid", storiesComposeGrayIcon }};
|
||||
iconOver: icon{{ "chat/input_paid", storiesComposeGrayIcon }};
|
||||
}
|
||||
storiesRemoveSet: IconButton(stickerPanRemoveSet) {
|
||||
icon: icon {{ "simple_close", storiesComposeGrayIcon }};
|
||||
iconOver: icon {{ "simple_close", storiesComposeGrayIcon }};
|
||||
@@ -665,6 +663,7 @@ storiesEmojiPan: EmojiPan(defaultEmojiPan) {
|
||||
menuBelow: icon {{ "menu/link_below", storiesComposeWhiteText }};
|
||||
menuAbove: icon {{ "menu/link_above", storiesComposeWhiteText }};
|
||||
menuPrice: icon {{ "menu/earn", storiesComposeWhiteText }};
|
||||
menuEditStars: icon {{ "chat/input_paid", storiesComposeWhiteText }};
|
||||
|
||||
stripBubble: icon{
|
||||
{ "chat/reactions_bubble_shadow", windowShadowFg },
|
||||
@@ -719,14 +718,13 @@ storiesComposeControls: ComposeControls(defaultComposeControls) {
|
||||
recordOver: storiesRecordVoiceOver;
|
||||
round: storiesRecordRound;
|
||||
roundOver: storiesRecordRoundOver;
|
||||
editPrice: storiesEditPrice;
|
||||
editPriceOver: storiesEditPriceOver;
|
||||
sendDisabledFg: storiesComposeGrayText;
|
||||
}
|
||||
attach: storiesAttach;
|
||||
emoji: storiesAttachEmoji;
|
||||
like: storiesLike;
|
||||
liked: icon{};
|
||||
editStars: storiesEditStars;
|
||||
commentsShow: IconButton(storiesAttach) {
|
||||
icon: icon {{ "chat/input_comments_expand", storiesComposeGrayIcon }};
|
||||
iconOver: icon {{ "chat/input_comments_expand", storiesComposeGrayIcon }};
|
||||
|
||||
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "boxes/premium_preview_box.h"
|
||||
#include "calls/group/calls_group_stars_box.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "chat_helpers/stickers_emoji_pack.h"
|
||||
#include "core/shortcuts.h"
|
||||
@@ -670,9 +671,44 @@ FillMenuResult AttachSendMenuEffect(
|
||||
return FillMenuResult::Prepared;
|
||||
}
|
||||
|
||||
FillMenuResult FillEditCommentPriceMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Details details,
|
||||
Fn<void(Action, Details)> action,
|
||||
const style::ComposeIcons *iconsOverride,
|
||||
std::optional<QPoint> desiredPositionOverride) {
|
||||
const auto &icons = iconsOverride
|
||||
? *iconsOverride
|
||||
: st::defaultComposeIcons;
|
||||
menu->addAction(tr::lng_video_stream_edit_stars(tr::now), [=] {
|
||||
show->show(Calls::Group::MakeVideoStreamStarsBox({
|
||||
.show = show,
|
||||
.current = int(details.price.value_or(0)),
|
||||
.save = [=](int count) {
|
||||
auto copy = details;
|
||||
copy.price = count;
|
||||
action({ {}, Action::Type::ChangePrice }, copy);
|
||||
},
|
||||
.name = details.commentStreamerName,
|
||||
//.preview = details.commentPreview,
|
||||
}));
|
||||
}, &icons.menuEditStars);
|
||||
if (details.price.value_or(0) > details.commentPriceMin.value_or(0)) {
|
||||
auto copy = details;
|
||||
copy.price = details.commentPriceMin.value_or(0);
|
||||
menu->addAction(tr::lng_video_stream_remove_stars(tr::now), [=] {
|
||||
action({ {}, Action::Type::ChangePrice }, copy);
|
||||
}, &icons.menuGifRemove);
|
||||
}
|
||||
const auto position = desiredPositionOverride.value_or(QCursor::pos());
|
||||
menu->prepareGeometryFor(position);
|
||||
return FillMenuResult::Prepared;
|
||||
}
|
||||
|
||||
FillMenuResult FillSendMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
std::shared_ptr<ChatHelpers::Show> showForEffect,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Details details,
|
||||
Fn<void(Action, Details)> action,
|
||||
const style::ComposeIcons *iconsOverride,
|
||||
@@ -685,6 +721,14 @@ FillMenuResult FillSendMenu(
|
||||
&& !details.price.has_value();
|
||||
if (empty || !action) {
|
||||
return FillMenuResult::Skipped;
|
||||
} else if (type == Type::EditCommentPrice) {
|
||||
return FillEditCommentPriceMenu(
|
||||
menu,
|
||||
show,
|
||||
details,
|
||||
action,
|
||||
iconsOverride,
|
||||
desiredPositionOverride);
|
||||
}
|
||||
const auto &icons = iconsOverride
|
||||
? *iconsOverride
|
||||
@@ -752,10 +796,10 @@ FillMenuResult FillSendMenu(
|
||||
&icons.menuPrice);
|
||||
}
|
||||
|
||||
if (showForEffect) {
|
||||
if (show) {
|
||||
return AttachSendMenuEffect(
|
||||
menu,
|
||||
showForEffect,
|
||||
show,
|
||||
details,
|
||||
action,
|
||||
desiredPositionOverride);
|
||||
@@ -769,13 +813,20 @@ void SetupMenuAndShortcuts(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Fn<Details()> details,
|
||||
Fn<void(Action, Details)> action) {
|
||||
Fn<void(Action, Details)> action,
|
||||
const style::PopupMenu *stOverride,
|
||||
const style::ComposeIcons *iconsOverride) {
|
||||
const auto menu = std::make_shared<base::unique_qptr<Ui::PopupMenu>>();
|
||||
const auto showMenu = [=] {
|
||||
*menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
button,
|
||||
st::popupMenuWithIcons);
|
||||
const auto result = FillSendMenu(*menu, show, details(), action);
|
||||
stOverride ? *stOverride : st::popupMenuWithIcons);
|
||||
const auto result = FillSendMenu(
|
||||
*menu,
|
||||
show,
|
||||
details(),
|
||||
action,
|
||||
iconsOverride);
|
||||
if (result != FillMenuResult::Prepared) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace style {
|
||||
struct ComposeIcons;
|
||||
struct PopupMenu;
|
||||
} // namespace style
|
||||
|
||||
namespace ChatHelpers {
|
||||
@@ -35,6 +36,7 @@ enum class Type : uchar {
|
||||
Scheduled,
|
||||
ScheduledToUser, // For "Send when online".
|
||||
Reminder,
|
||||
EditCommentPrice,
|
||||
};
|
||||
|
||||
enum class SpoilerState : uchar {
|
||||
@@ -53,7 +55,10 @@ struct Details {
|
||||
Type type = Type::Disabled;
|
||||
SpoilerState spoiler = SpoilerState::None;
|
||||
CaptionState caption = CaptionState::None;
|
||||
TextWithTags commentPreview;
|
||||
QString commentStreamerName;
|
||||
std::optional<uint64> price;
|
||||
std::optional<uint64> commentPriceMin;
|
||||
bool effectAllowed = false;
|
||||
};
|
||||
|
||||
@@ -101,7 +106,9 @@ void SetupMenuAndShortcuts(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Fn<Details()> details,
|
||||
Fn<void(Action, Details)> action);
|
||||
Fn<void(Action, Details)> action,
|
||||
const style::PopupMenu *stOverride = nullptr,
|
||||
const style::ComposeIcons *iconsOverride = nullptr);
|
||||
|
||||
void SetupUnreadMentionsMenu(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
|
||||
@@ -540,7 +540,7 @@ void PaidReactionsBox(
|
||||
});
|
||||
const auto activeFgOverride = [=](int count) {
|
||||
const auto coloring = Calls::Group::Ui::StarsColoringForCount(count);
|
||||
return Ui::ColorFromSerialized(coloring.bg2);
|
||||
return Ui::ColorFromSerialized(coloring.bgLight);
|
||||
};
|
||||
|
||||
const auto bubble = Premium::AddBubbleRow(
|
||||
|
||||
@@ -142,7 +142,7 @@ void SendButton::paintEvent(QPaintEvent *e) {
|
||||
break;
|
||||
case Type::Schedule: paintSchedule(p, over); break;
|
||||
case Type::Slowmode: paintSlowmode(p); break;
|
||||
case Type::EditPrice: paintEditPrice(p, over); break;
|
||||
case Type::EditPrice: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,6 +281,10 @@ SendButton::StarsGeometry SendButton::starsGeometry() const {
|
||||
}
|
||||
|
||||
void SendButton::updateSize() {
|
||||
if (_state.type == Type::EditPrice) {
|
||||
resize(0, _st.inner.height);
|
||||
return;
|
||||
}
|
||||
const auto finalWidth = _starsToSendText.isEmpty()
|
||||
? _st.inner.width
|
||||
: starsGeometry().outer.width();
|
||||
@@ -318,20 +322,6 @@ QPoint SendButton::prepareRippleStartPosition() const {
|
||||
return real - QPoint((width() - size) / 2, y);
|
||||
}
|
||||
|
||||
void SendButton::paintEditPrice(QPainter &p, bool over) {
|
||||
if (!isDisabled()) {
|
||||
paintRipple(
|
||||
p,
|
||||
(width() - _st.inner.rippleAreaSize) / 2,
|
||||
_st.inner.rippleAreaPosition.y());
|
||||
}
|
||||
|
||||
const auto &icon = (isDisabled() || !over)
|
||||
? _st.editPrice
|
||||
: _st.editPriceOver;
|
||||
icon.paintInCenter(p, rect());
|
||||
}
|
||||
|
||||
SendStarButton::SendStarButton(
|
||||
QWidget *parent,
|
||||
const style::RoundButton &st,
|
||||
|
||||
@@ -72,7 +72,6 @@ private:
|
||||
void paintSend(QPainter &p, bool over);
|
||||
void paintSchedule(QPainter &p, bool over);
|
||||
void paintSlowmode(QPainter &p);
|
||||
void paintEditPrice(QPainter &p, bool over);
|
||||
void paintStarsToSend(QPainter &p, bool over);
|
||||
|
||||
const style::SendButton &_st;
|
||||
|
||||
Reference in New Issue
Block a user