mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced menu in media viewer with menu for sponsored messages.
This commit is contained in:
parent
e51b2c0c91
commit
074dbf41e0
6 changed files with 36 additions and 26 deletions
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_peer_photo.h"
|
#include "api/api_peer_photo.h"
|
||||||
#include "base/qt/qt_common_adapters.h"
|
#include "base/qt/qt_common_adapters.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "menu/menu_sponsored.h"
|
||||||
#include "boxes/premium_preview_box.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
@ -21,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/crash_reports.h"
|
#include "core/crash_reports.h"
|
||||||
#include "core/sandbox.h"
|
#include "core/sandbox.h"
|
||||||
#include "core/shortcuts.h"
|
#include "core/shortcuts.h"
|
||||||
|
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||||
|
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||||
#include "ui/widgets/dropdown_menu.h"
|
#include "ui/widgets/dropdown_menu.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -1484,7 +1487,15 @@ void OverlayWidget::refreshCaptionGeometry() {
|
||||||
captionHeight);
|
captionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::fillContextMenuActions(const MenuCallback &addAction) {
|
void OverlayWidget::fillContextMenuActions(
|
||||||
|
const Ui::Menu::MenuCallback &addAction) {
|
||||||
|
if (_message && _message->isSponsored()) {
|
||||||
|
if (const auto window = findWindow()) {
|
||||||
|
const auto show = window->uiShow();
|
||||||
|
Menu::FillSponsored(_body, addAction, show, _message, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto story = _stories ? _stories->story() : nullptr;
|
const auto story = _stories ? _stories->story() : nullptr;
|
||||||
if (!story && _document && _document->loading()) {
|
if (!story && _document && _document->loading()) {
|
||||||
addAction(
|
addAction(
|
||||||
|
@ -5944,12 +5955,7 @@ bool OverlayWidget::handleContextMenu(std::optional<QPoint> position) {
|
||||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
_window,
|
_window,
|
||||||
st::mediaviewPopupMenu);
|
st::mediaviewPopupMenu);
|
||||||
fillContextMenuActions([&](
|
fillContextMenuActions(Ui::Menu::CreateAddActionCallback(_menu));
|
||||||
const QString &text,
|
|
||||||
Fn<void()> handler,
|
|
||||||
const style::icon *icon) {
|
|
||||||
_menu->addAction(text, std::move(handler), icon);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (_menu->empty()) {
|
if (_menu->empty()) {
|
||||||
_menu = nullptr;
|
_menu = nullptr;
|
||||||
|
@ -6233,12 +6239,7 @@ void OverlayWidget::receiveMouse() {
|
||||||
|
|
||||||
void OverlayWidget::showDropdown() {
|
void OverlayWidget::showDropdown() {
|
||||||
_dropdown->clearActions();
|
_dropdown->clearActions();
|
||||||
fillContextMenuActions([&](
|
fillContextMenuActions(Ui::Menu::CreateAddActionCallback(_dropdown));
|
||||||
const QString &text,
|
|
||||||
Fn<void()> handler,
|
|
||||||
const style::icon *icon) {
|
|
||||||
_dropdown->addAction(text, std::move(handler), icon);
|
|
||||||
});
|
|
||||||
_dropdown->moveToRight(0, height() - _dropdown->height());
|
_dropdown->moveToRight(0, height() - _dropdown->height());
|
||||||
_dropdown->showAnimated(Ui::PanelAnimation::Origin::BottomRight);
|
_dropdown->showAnimated(Ui::PanelAnimation::Origin::BottomRight);
|
||||||
_dropdown->setFocus();
|
_dropdown->setFocus();
|
||||||
|
|
|
@ -47,6 +47,10 @@ struct ChosenRenderer;
|
||||||
enum class Backend;
|
enum class Backend;
|
||||||
} // namespace Ui::GL
|
} // namespace Ui::GL
|
||||||
|
|
||||||
|
namespace Ui::Menu {
|
||||||
|
class MenuCallback;
|
||||||
|
} // namespace Ui::Menu
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
class OverlayWidgetHelper;
|
class OverlayWidgetHelper;
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
@ -364,11 +368,7 @@ private:
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
void updateNavigationControlsGeometry();
|
void updateNavigationControlsGeometry();
|
||||||
|
|
||||||
using MenuCallback = Fn<void(
|
void fillContextMenuActions(const Ui::Menu::MenuCallback &addAction);
|
||||||
const QString &,
|
|
||||||
Fn<void()>,
|
|
||||||
const style::icon *)>;
|
|
||||||
void fillContextMenuActions(const MenuCallback &addAction);
|
|
||||||
|
|
||||||
void resizeCenteredControls();
|
void resizeCenteredControls();
|
||||||
void resizeContentByScreenSize();
|
void resizeContentByScreenSize();
|
||||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#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"
|
||||||
|
#include "styles/style_media_view.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
#include "styles/style_premium.h"
|
#include "styles/style_premium.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
|
@ -339,21 +340,24 @@ void FillSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const Ui::Menu::MenuCallback &addAction,
|
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,
|
||||||
|
bool mediaViewer) {
|
||||||
Expects(item->isSponsored());
|
Expects(item->isSponsored());
|
||||||
|
|
||||||
const auto session = &item->history()->session();
|
const auto session = &item->history()->session();
|
||||||
|
|
||||||
addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
||||||
show->show(Box(AboutBox, show));
|
show->show(Box(AboutBox, show));
|
||||||
}, &st::menuIconInfo);
|
}, (mediaViewer ? &st::mediaMenuIconInfo : &st::menuIconInfo));
|
||||||
|
|
||||||
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);
|
}, (mediaViewer ? &st::mediaMenuIconBlock : &st::menuIconBlock));
|
||||||
|
|
||||||
addAction({
|
addAction({
|
||||||
.separatorSt = &st::expandedMenuSeparator,
|
.separatorSt = (mediaViewer
|
||||||
|
? &st::mediaviewMenuSeparator
|
||||||
|
: &st::expandedMenuSeparator),
|
||||||
.isSeparator = true,
|
.isSeparator = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -365,7 +369,7 @@ void FillSponsored(
|
||||||
} else {
|
} else {
|
||||||
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
||||||
}
|
}
|
||||||
}, &st::menuIconCancel);
|
}, (mediaViewer ? &st::mediaMenuIconCancel : &st::menuIconCancel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowSponsored(
|
void ShowSponsored(
|
||||||
|
@ -382,7 +386,8 @@ void ShowSponsored(
|
||||||
parent,
|
parent,
|
||||||
Ui::Menu::CreateAddActionCallback(menu),
|
Ui::Menu::CreateAddActionCallback(menu),
|
||||||
show,
|
show,
|
||||||
item);
|
item,
|
||||||
|
false);
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ void FillSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const Ui::Menu::MenuCallback &addAction,
|
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,
|
||||||
|
bool mediaViewer);
|
||||||
|
|
||||||
void ShowSponsored(
|
void ShowSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
|
|
@ -193,6 +193,9 @@ mediaMenuIconStealthLocked: icon {{ "menu/stealth_locked", mediaviewMenuFg }};
|
||||||
mediaMenuIconStealth: icon {{ "menu/stealth", mediaviewMenuFg }};
|
mediaMenuIconStealth: icon {{ "menu/stealth", mediaviewMenuFg }};
|
||||||
mediaMenuIconStats: icon {{ "menu/stats", mediaviewMenuFg }};
|
mediaMenuIconStats: icon {{ "menu/stats", mediaviewMenuFg }};
|
||||||
|
|
||||||
|
mediaMenuIconInfo: icon {{ "menu/info", mediaviewMenuFg }};
|
||||||
|
mediaMenuIconBlock: icon {{ "menu/block", mediaviewMenuFg }};
|
||||||
|
|
||||||
menuIconDeleteAttention: icon {{ "menu/delete", menuIconAttentionColor }};
|
menuIconDeleteAttention: icon {{ "menu/delete", menuIconAttentionColor }};
|
||||||
menuIconLeaveAttention: icon {{ "menu/leave", menuIconAttentionColor }};
|
menuIconLeaveAttention: icon {{ "menu/leave", menuIconAttentionColor }};
|
||||||
menuIconDisableAttention: icon {{ "menu/disable", menuIconAttentionColor }};
|
menuIconDisableAttention: icon {{ "menu/disable", menuIconAttentionColor }};
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c48bbd9b910480bc4a179df7b96d84b7dfe44671
|
Subproject commit e5c685c47aa21856a591b77ca6853a5aa2d0624b
|
Loading…
Add table
Reference in a new issue