diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index f52ea30a2..1cb4309aa 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -824,6 +824,8 @@ PRIVATE history/history_view_highlight_manager.h history/history_widget.cpp history/history_widget.h + info/boosts/create_giveaway_box.cpp + info/boosts/create_giveaway_box.h info/boosts/info_boosts_inner_widget.cpp info/boosts/info_boosts_inner_widget.h info/boosts/info_boosts_widget.cpp diff --git a/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp new file mode 100644 index 000000000..828d1283d --- /dev/null +++ b/Telegram/SourceFiles/info/boosts/create_giveaway_box.cpp @@ -0,0 +1,81 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "info/boosts/create_giveaway_box.h" + +#include "boxes/peers/edit_participants_box.h" // ParticipantsBoxController +#include "data/data_peer.h" +#include "data/data_user.h" +#include "info/info_controller.h" +#include "lang/lang_keys.h" +#include "ui/layers/generic_box.h" +#include "ui/widgets/labels.h" + +namespace { + +class MembersListController : public ParticipantsBoxController { +public: + using ParticipantsBoxController::ParticipantsBoxController; + + void rowClicked(not_null row) override; + std::unique_ptr createRow( + not_null participant) const override; + base::unique_qptr rowContextMenu( + QWidget *parent, + not_null row) override; + +private: + +}; + +void MembersListController::rowClicked(not_null row) { + delegate()->peerListSetRowChecked(row, !row->checked()); +} + +std::unique_ptr MembersListController::createRow( + not_null participant) const { + const auto user = participant->asUser(); + if (!user || user->isInaccessible() || user->isBot() || user->isSelf()) { + return nullptr; + } + return std::make_unique(participant); +} + +base::unique_qptr MembersListController::rowContextMenu( + QWidget *parent, + not_null row) { + return nullptr; +} + +} // namespace + +void CreateGiveawayBox( + not_null box, + not_null controller, + not_null peer) { + box->addButton(tr::lng_box_ok(), [=] { + auto initBox = [=](not_null peersBox) { + peersBox->setTitle(tr::lng_giveaway_award_option()); + peersBox->addButton(tr::lng_settings_save(), [=] { + const auto selected = peersBox->collectSelectedRows(); + peersBox->closeBox(); + }); + peersBox->addButton(tr::lng_cancel(), [=] { + peersBox->closeBox(); + }); + }; + + box->uiShow()->showBox( + Box( + std::make_unique( + controller, + peer, + ParticipantsRole::Members), + std::move(initBox)), + Ui::LayerOption::KeepOther); + }); +} diff --git a/Telegram/SourceFiles/info/boosts/create_giveaway_box.h b/Telegram/SourceFiles/info/boosts/create_giveaway_box.h new file mode 100644 index 000000000..7463732dc --- /dev/null +++ b/Telegram/SourceFiles/info/boosts/create_giveaway_box.h @@ -0,0 +1,23 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +class PeerData; + +namespace Info { +class Controller; +} // namespace Info + +namespace Ui { +class GenericBox; +} // namespace Ui + +void CreateGiveawayBox( + not_null box, + not_null controller, + not_null peer); diff --git a/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp b/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp index da6e11c48..73edbd68d 100644 --- a/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp +++ b/Telegram/SourceFiles/info/boosts/info_boosts_inner_widget.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_statistics.h" #include "boxes/peers/edit_peer_invite_link.h" +#include "info/boosts/create_giveaway_box.h" #include "info/boosts/info_boosts_widget.h" #include "info/info_controller.h" #include "info/profile/info_profile_icon.h" @@ -178,6 +179,7 @@ void FillShareLink( void FillGetBoostsButton( not_null content, + not_null controller, std::shared_ptr show, not_null peer) { const auto &st = st::getBoostsButton; @@ -188,6 +190,7 @@ void FillGetBoostsButton( tr::lng_boosts_get_boosts(), st)); button->setClickedCallback([=] { + show->showBox(Box(CreateGiveawayBox, controller, peer)); }); Ui::CreateChild( button, @@ -291,7 +294,7 @@ void InnerWidget::fill() { ::Settings::AddDividerText(inner, tr::lng_boosts_link_subtext()); ::Settings::AddSkip(inner); - FillGetBoostsButton(inner, _show, _peer); + FillGetBoostsButton(inner, _controller, _show, _peer); ::Settings::AddSkip(inner); ::Settings::AddDividerText(inner, tr::lng_boosts_get_boosts_subtext()); diff --git a/Telegram/SourceFiles/info/boosts/info_boosts_widget.cpp b/Telegram/SourceFiles/info/boosts/info_boosts_widget.cpp index 2679f67a0..fac44f16a 100644 --- a/Telegram/SourceFiles/info/boosts/info_boosts_widget.cpp +++ b/Telegram/SourceFiles/info/boosts/info_boosts_widget.cpp @@ -118,4 +118,3 @@ std::shared_ptr Make(not_null peer) { } } // namespace Info::Boosts -