mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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/toast/toast.h"
|
||||||
#include "ui/vertical_list.h"
|
#include "ui/vertical_list.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
|
||||||
#include "ui/widgets/label_with_custom_emoji.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_channel_earn.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -333,29 +335,29 @@ void ShowReportSponsoredBox(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ShowSponsored(
|
void FillSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
const Ui::Menu::MenuCallback &addAction,
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
not_null<HistoryItem*> item) {
|
not_null<HistoryItem*> item) {
|
||||||
Expects(item->isSponsored());
|
Expects(item->isSponsored());
|
||||||
|
|
||||||
const auto session = &item->history()->session();
|
const auto session = &item->history()->session();
|
||||||
|
|
||||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
||||||
parent.get(),
|
|
||||||
st::popupMenuWithIcons);
|
|
||||||
|
|
||||||
menu->addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
|
||||||
show->show(Box(AboutBox, show));
|
show->show(Box(AboutBox, show));
|
||||||
}, &st::menuIconInfo);
|
}, &st::menuIconInfo);
|
||||||
|
|
||||||
menu->addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] {
|
addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] {
|
||||||
ShowReportSponsoredBox(show, item);
|
ShowReportSponsoredBox(show, item);
|
||||||
}, &st::menuIconBlock);
|
}, &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()) {
|
if (session->premium()) {
|
||||||
using Result = Data::SponsoredReportResult;
|
using Result = Data::SponsoredReportResult;
|
||||||
session->sponsoredMessages().createReportCallback(
|
session->sponsoredMessages().createReportCallback(
|
||||||
|
@ -364,6 +366,23 @@ void ShowSponsored(
|
||||||
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
||||||
}
|
}
|
||||||
}, &st::menuIconCancel);
|
}, &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());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,21 @@ class Show;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RpWidget;
|
class RpWidget;
|
||||||
|
namespace Menu {
|
||||||
|
class MenuCallback;
|
||||||
|
} // namespace Menu
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
class HistoryItem;
|
class HistoryItem;
|
||||||
|
|
||||||
namespace Menu {
|
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(
|
void ShowSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
|
|
Loading…
Add table
Reference in a new issue