mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added fast right action to sponsored messages.
This commit is contained in:
parent
4c5c2aadc4
commit
0da515abc5
6 changed files with 34 additions and 5 deletions
|
@ -35,6 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
#include "core/click_handler_types.h" // ClickHandlerContext.
|
||||||
|
#include "settings/settings_premium.h" // Settings::ShowPremium.
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/text/text_entity.h"
|
#include "ui/text/text_entity.h"
|
||||||
|
@ -330,6 +332,15 @@ ClickHandlerPtr JumpToStoryClickHandler(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClickHandlerPtr HideSponsoredClickHandler() {
|
||||||
|
return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
||||||
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
|
Settings::ShowPremium(controller, "no_ads");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
MessageFlags FlagsFromMTP(
|
MessageFlags FlagsFromMTP(
|
||||||
MsgId id,
|
MsgId id,
|
||||||
MTPDmessage::Flags flags,
|
MTPDmessage::Flags flags,
|
||||||
|
|
|
@ -136,6 +136,7 @@ struct SendingErrorRequest {
|
||||||
ClickHandlerPtr JumpToStoryClickHandler(
|
ClickHandlerPtr JumpToStoryClickHandler(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
StoryId storyId);
|
StoryId storyId);
|
||||||
|
[[nodiscard]] ClickHandlerPtr HideSponsoredClickHandler();
|
||||||
|
|
||||||
[[nodiscard]] not_null<HistoryItem*> GenerateJoinedMessage(
|
[[nodiscard]] not_null<HistoryItem*> GenerateJoinedMessage(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
|
|
|
@ -1191,7 +1191,9 @@ void Message::draw(Painter &p, const PaintContext &context) const {
|
||||||
0,
|
0,
|
||||||
st::historyFastShareBottom);
|
st::historyFastShareBottom);
|
||||||
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
|
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
|
||||||
const auto fastShareTop = g.top() + g.height() - fastShareSkip - size->height();
|
const auto fastShareTop = data()->isSponsored()
|
||||||
|
? g.top() + fastShareSkip
|
||||||
|
: g.top() + g.height() - fastShareSkip - size->height();
|
||||||
drawRightAction(p, context, fastShareLeft, fastShareTop, width());
|
drawRightAction(p, context, fastShareLeft, fastShareTop, width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2209,7 +2211,9 @@ TextState Message::textState(
|
||||||
0,
|
0,
|
||||||
st::historyFastShareBottom);
|
st::historyFastShareBottom);
|
||||||
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
|
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
|
||||||
const auto fastShareTop = g.top() + g.height() - fastShareSkip - size->height();
|
const auto fastShareTop = data()->isSponsored()
|
||||||
|
? g.top() + fastShareSkip
|
||||||
|
: g.top() + g.height() - fastShareSkip - size->height();
|
||||||
if (QRect(
|
if (QRect(
|
||||||
fastShareLeft,
|
fastShareLeft,
|
||||||
fastShareTop,
|
fastShareTop,
|
||||||
|
@ -3343,7 +3347,9 @@ std::optional<QSize> Message::rightActionSize() const {
|
||||||
st::historyFastShareSize + st::historyFastShareBottom + st::semiboldFont->height)
|
st::historyFastShareSize + st::historyFastShareBottom + st::semiboldFont->height)
|
||||||
: QSize(st::historyFastShareSize, st::historyFastShareSize);
|
: QSize(st::historyFastShareSize, st::historyFastShareSize);
|
||||||
}
|
}
|
||||||
return (displayFastShare() || displayGoToOriginal())
|
return data()->isSponsored()
|
||||||
|
? QSize(st::historyFastCloseSize, st::historyFastCloseSize)
|
||||||
|
: (displayFastShare() || displayGoToOriginal())
|
||||||
? QSize(st::historyFastShareSize, st::historyFastShareSize)
|
? QSize(st::historyFastShareSize, st::historyFastShareSize)
|
||||||
: std::optional<QSize>();
|
: std::optional<QSize>();
|
||||||
}
|
}
|
||||||
|
@ -3447,7 +3453,9 @@ void Message::drawRightAction(
|
||||||
views->repliesSmall.textWidth);
|
views->repliesSmall.textWidth);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto &icon = (displayFastShare() && !isPinnedContext())
|
const auto &icon = data()->isSponsored()
|
||||||
|
? st->historyFastCloseIcon()
|
||||||
|
: (displayFastShare() && !isPinnedContext())
|
||||||
? st->historyFastShareIcon()
|
? st->historyFastShareIcon()
|
||||||
: st->historyGoToOriginalIcon();
|
: st->historyGoToOriginalIcon();
|
||||||
icon.paintInCenter(p, { left, top, size->width(), size->height() });
|
icon.paintInCenter(p, { left, top, size->width(), size->height() });
|
||||||
|
@ -3475,7 +3483,9 @@ void Message::ensureRightAction() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickHandlerPtr Message::prepareRightActionLink() const {
|
ClickHandlerPtr Message::prepareRightActionLink() const {
|
||||||
if (isPinnedContext()) {
|
if (data()->isSponsored()) {
|
||||||
|
return HideSponsoredClickHandler();
|
||||||
|
} else if (isPinnedContext()) {
|
||||||
return JumpToMessageClickHandler(data());
|
return JumpToMessageClickHandler(data());
|
||||||
} else if (displayRightActionComments()) {
|
} else if (displayRightActionComments()) {
|
||||||
return createGoToCommentsLink();
|
return createGoToCommentsLink();
|
||||||
|
|
|
@ -559,6 +559,8 @@ historyFastShareBottom: 5px;
|
||||||
historyFastShareIcon: icon {{ "fast_share", msgServiceFg }};
|
historyFastShareIcon: icon {{ "fast_share", msgServiceFg }};
|
||||||
historyGoToOriginalIcon: icon {{ "fast_to_original", msgServiceFg, point(1px, 0px) }};
|
historyGoToOriginalIcon: icon {{ "fast_to_original", msgServiceFg, point(1px, 0px) }};
|
||||||
historyFastCommentsIcon: icon {{ "fast_comments", msgServiceFg }};
|
historyFastCommentsIcon: icon {{ "fast_comments", msgServiceFg }};
|
||||||
|
historyFastCloseSize: 30px;
|
||||||
|
historyFastCloseIcon: icon {{ "box_button_close", msgServiceFg }};
|
||||||
historyFastTranscribeIcon: icon {{ "chat/voice_to_text", msgServiceFg }};
|
historyFastTranscribeIcon: icon {{ "chat/voice_to_text", msgServiceFg }};
|
||||||
|
|
||||||
historySavedFont: font(semibold 14px);
|
historySavedFont: font(semibold 14px);
|
||||||
|
|
|
@ -190,6 +190,7 @@ ChatStyle::ChatStyle(rpl::producer<ColorIndicesCompressed> colorIndices) {
|
||||||
make(_historyFastShareIcon, st::historyFastShareIcon);
|
make(_historyFastShareIcon, st::historyFastShareIcon);
|
||||||
make(_historyFastTranscribeIcon, st::historyFastTranscribeIcon);
|
make(_historyFastTranscribeIcon, st::historyFastTranscribeIcon);
|
||||||
make(_historyGoToOriginalIcon, st::historyGoToOriginalIcon);
|
make(_historyGoToOriginalIcon, st::historyGoToOriginalIcon);
|
||||||
|
make(_historyFastCloseIcon, st::historyFastCloseIcon);
|
||||||
make(_historyMapPoint, st::historyMapPoint);
|
make(_historyMapPoint, st::historyMapPoint);
|
||||||
make(_historyMapPointInner, st::historyMapPointInner);
|
make(_historyMapPointInner, st::historyMapPointInner);
|
||||||
make(_youtubeIcon, st::youtubeIcon);
|
make(_youtubeIcon, st::youtubeIcon);
|
||||||
|
|
|
@ -388,6 +388,9 @@ public:
|
||||||
[[nodiscard]] const style::icon &historyGoToOriginalIcon() const {
|
[[nodiscard]] const style::icon &historyGoToOriginalIcon() const {
|
||||||
return _historyGoToOriginalIcon;
|
return _historyGoToOriginalIcon;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] const style::icon &historyFastCloseIcon() const {
|
||||||
|
return _historyFastCloseIcon;
|
||||||
|
}
|
||||||
[[nodiscard]] const style::icon &historyMapPoint() const {
|
[[nodiscard]] const style::icon &historyMapPoint() const {
|
||||||
return _historyMapPoint;
|
return _historyMapPoint;
|
||||||
}
|
}
|
||||||
|
@ -512,6 +515,7 @@ private:
|
||||||
style::icon _historyFastShareIcon = { Qt::Uninitialized };
|
style::icon _historyFastShareIcon = { Qt::Uninitialized };
|
||||||
style::icon _historyFastTranscribeIcon = { Qt::Uninitialized };
|
style::icon _historyFastTranscribeIcon = { Qt::Uninitialized };
|
||||||
style::icon _historyGoToOriginalIcon = { Qt::Uninitialized };
|
style::icon _historyGoToOriginalIcon = { Qt::Uninitialized };
|
||||||
|
style::icon _historyFastCloseIcon = { Qt::Uninitialized };
|
||||||
style::icon _historyMapPoint = { Qt::Uninitialized };
|
style::icon _historyMapPoint = { Qt::Uninitialized };
|
||||||
style::icon _historyMapPointInner = { Qt::Uninitialized };
|
style::icon _historyMapPointInner = { Qt::Uninitialized };
|
||||||
style::icon _youtubeIcon = { Qt::Uninitialized };
|
style::icon _youtubeIcon = { Qt::Uninitialized };
|
||||||
|
|
Loading…
Add table
Reference in a new issue