mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Improved Menu::ShowSponsored to be more generic.
This commit is contained in:
parent
e4538947c3
commit
e51b2c0c91
2 changed files with 38 additions and 10 deletions
|
@ -23,8 +23,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/toast/toast.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/widgets/label_with_custom_emoji.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "styles/style_channel_earn.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
@ -333,29 +335,29 @@ void ShowReportSponsoredBox(
|
|||
|
||||
} // namespace
|
||||
|
||||
void ShowSponsored(
|
||||
void FillSponsored(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
const Ui::Menu::MenuCallback &addAction,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<HistoryItem*> item) {
|
||||
Expects(item->isSponsored());
|
||||
|
||||
const auto session = &item->history()->session();
|
||||
|
||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
||||
parent.get(),
|
||||
st::popupMenuWithIcons);
|
||||
|
||||
menu->addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
||||
addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
||||
show->show(Box(AboutBox, show));
|
||||
}, &st::menuIconInfo);
|
||||
|
||||
menu->addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] {
|
||||
addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] {
|
||||
ShowReportSponsoredBox(show, item);
|
||||
}, &st::menuIconBlock);
|
||||
|
||||
menu->addSeparator(&st::expandedMenuSeparator);
|
||||
addAction({
|
||||
.separatorSt = &st::expandedMenuSeparator,
|
||||
.isSeparator = true,
|
||||
});
|
||||
|
||||
menu->addAction(tr::lng_sponsored_hide_ads(tr::now), [=] {
|
||||
addAction(tr::lng_sponsored_hide_ads(tr::now), [=] {
|
||||
if (session->premium()) {
|
||||
using Result = Data::SponsoredReportResult;
|
||||
session->sponsoredMessages().createReportCallback(
|
||||
|
@ -364,6 +366,23 @@ void ShowSponsored(
|
|||
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
||||
}
|
||||
}, &st::menuIconCancel);
|
||||
}
|
||||
|
||||
void ShowSponsored(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<HistoryItem*> item) {
|
||||
Expects(item->isSponsored());
|
||||
|
||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
||||
parent.get(),
|
||||
st::popupMenuWithIcons);
|
||||
|
||||
FillSponsored(
|
||||
parent,
|
||||
Ui::Menu::CreateAddActionCallback(menu),
|
||||
show,
|
||||
item);
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
|
|
@ -13,12 +13,21 @@ class Show;
|
|||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
namespace Menu {
|
||||
class MenuCallback;
|
||||
} // namespace Menu
|
||||
} // namespace Ui
|
||||
|
||||
class HistoryItem;
|
||||
|
||||
namespace Menu {
|
||||
|
||||
void FillSponsored(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
const Ui::Menu::MenuCallback &addAction,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<HistoryItem*> item);
|
||||
|
||||
void ShowSponsored(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
|
|
Loading…
Add table
Reference in a new issue