mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Add initial support for all deep links.
This commit is contained in:
@@ -358,6 +358,16 @@ const style::MultiSelect &PeerListController::computeSelectSt() const {
|
||||
return _selectSt ? *_selectSt : st::defaultMultiSelect;
|
||||
}
|
||||
|
||||
void PeerListController::showFinished() {
|
||||
if (const auto onstack = _showFinished) {
|
||||
onstack();
|
||||
}
|
||||
}
|
||||
|
||||
void PeerListController::setShowFinishedCallback(Fn<void()> callback) {
|
||||
_showFinished = std::move(callback);
|
||||
}
|
||||
|
||||
bool PeerListController::hasComplexSearch() const {
|
||||
return (_searchController != nullptr);
|
||||
}
|
||||
|
||||
@@ -486,8 +486,8 @@ public:
|
||||
|
||||
virtual void prepare() = 0;
|
||||
|
||||
virtual void showFinished() {
|
||||
}
|
||||
virtual void showFinished();
|
||||
void setShowFinishedCallback(Fn<void()> callback);
|
||||
|
||||
virtual void rowClicked(not_null<PeerListRow*> row) = 0;
|
||||
virtual void rowMiddleClicked(not_null<PeerListRow*> row) {
|
||||
@@ -621,6 +621,8 @@ private:
|
||||
const style::PeerList *_listSt = nullptr;
|
||||
const style::MultiSelect *_selectSt = nullptr;
|
||||
|
||||
Fn<void()> _showFinished;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_premium.h" // MessageMoneyRestriction.
|
||||
#include "base/random.h"
|
||||
#include "boxes/filters/edit_filter_chats_list.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/effects/round_checkbox.h"
|
||||
@@ -62,7 +63,7 @@ constexpr auto kSearchPerPage = 50;
|
||||
} // namespace
|
||||
|
||||
object_ptr<Ui::BoxContent> PrepareContactsBox(
|
||||
not_null<Window::SessionController*> sessionController) {
|
||||
not_null<Window::SessionController*> window) {
|
||||
using Mode = ContactsBoxController::SortMode;
|
||||
class Controller final : public ContactsBoxController {
|
||||
public:
|
||||
@@ -90,7 +91,7 @@ object_ptr<Ui::BoxContent> PrepareContactsBox(
|
||||
|
||||
};
|
||||
auto controller = std::make_unique<Controller>(
|
||||
&sessionController->session());
|
||||
&window->session());
|
||||
controller->setStyleOverrides(&st::contactsWithStories);
|
||||
controller->setStoriesShown(true);
|
||||
const auto raw = controller.get();
|
||||
@@ -105,7 +106,7 @@ object_ptr<Ui::BoxContent> PrepareContactsBox(
|
||||
box->addButton(tr::lng_close(), [=] { box->closeBox(); });
|
||||
box->addLeftButton(
|
||||
tr::lng_profile_add_contact(),
|
||||
[=] { sessionController->showAddContact(); });
|
||||
[=] { window->showAddContact(); });
|
||||
state->toggleSort = box->addTopButton(st::contactsSortButton, [=] {
|
||||
const auto online = (state->mode.current() == Mode::Online);
|
||||
const auto mode = online ? Mode::Alphabet : Mode::Online;
|
||||
@@ -118,8 +119,15 @@ object_ptr<Ui::BoxContent> PrepareContactsBox(
|
||||
raw->setSortMode(Mode::Online);
|
||||
|
||||
raw->wheelClicks() | rpl::on_next([=](not_null<PeerData*> p) {
|
||||
sessionController->showInNewWindow(p);
|
||||
window->showInNewWindow(p);
|
||||
}, box->lifetime());
|
||||
|
||||
raw->setShowFinishedCallback([=] {
|
||||
window->checkHighlightControl(
|
||||
u"contacts/sort"_q,
|
||||
state->toggleSort,
|
||||
{ .rippleShape = true });
|
||||
});
|
||||
};
|
||||
return Box<PeerListBox>(std::move(controller), std::move(init));
|
||||
}
|
||||
|
||||
@@ -2716,7 +2716,7 @@ void SetupPeerColorSample(
|
||||
emojiStatusWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
||||
void AddPeerColorButton(
|
||||
not_null<Ui::SettingsButton*> AddPeerColorButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<PeerData*> peer,
|
||||
@@ -2769,6 +2769,7 @@ void AddPeerColorButton(
|
||||
button->setClickedCallback([=] {
|
||||
show->show(Box(EditPeerColorBox, show, peer, style, theme));
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
void CheckBoostLevel(
|
||||
|
||||
@@ -45,7 +45,7 @@ void EditPeerColorBox(
|
||||
std::shared_ptr<Ui::ChatStyle> style = nullptr,
|
||||
std::shared_ptr<Ui::ChatTheme> theme = nullptr);
|
||||
|
||||
void AddPeerColorButton(
|
||||
not_null<Ui::SettingsButton*> AddPeerColorButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
not_null<PeerData*> peer,
|
||||
|
||||
@@ -1203,7 +1203,6 @@ void Controller::refreshForumToggleLocked() {
|
||||
void Controller::fillColorIndexButton() {
|
||||
Expects(_controls.buttonsLayout != nullptr);
|
||||
|
||||
const auto show = _navigation->uiShow();
|
||||
AddPeerColorButton(
|
||||
_controls.buttonsLayout,
|
||||
_navigation->uiShow(),
|
||||
|
||||
@@ -7,11 +7,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "core/deep_links/deep_links_router.h"
|
||||
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
namespace Core::DeepLinks {
|
||||
namespace {
|
||||
|
||||
Result ShowContacts(const Context &ctx) {
|
||||
if (!ctx.controller) {
|
||||
return Result::NeedsAuth;
|
||||
}
|
||||
ctx.controller->show(PrepareContactsBox(ctx.controller));
|
||||
return Result::Handled;
|
||||
}
|
||||
|
||||
Result ShowAddContact(const Context &ctx) {
|
||||
if (!ctx.controller) {
|
||||
return Result::NeedsAuth;
|
||||
@@ -23,6 +32,32 @@ Result ShowAddContact(const Context &ctx) {
|
||||
} // namespace
|
||||
|
||||
void RegisterContactsHandlers(Router &router) {
|
||||
router.add(u"contacts"_q, {
|
||||
.path = QString(),
|
||||
.action = CodeBlock{ [](const Context &ctx) {
|
||||
return ShowContacts(ctx);
|
||||
}},
|
||||
});
|
||||
|
||||
router.add(u"contacts"_q, {
|
||||
.path = u"search"_q,
|
||||
.action = CodeBlock{ [](const Context &ctx) {
|
||||
return ShowContacts(ctx);
|
||||
}},
|
||||
});
|
||||
|
||||
router.add(u"contacts"_q, {
|
||||
.path = u"sort"_q,
|
||||
.action = CodeBlock{ [](const Context &ctx) {
|
||||
if (!ctx.controller) {
|
||||
return Result::NeedsAuth;
|
||||
}
|
||||
ctx.controller->setHighlightControlId(u"contacts/sort"_q);
|
||||
ctx.controller->show(PrepareContactsBox(ctx.controller));
|
||||
return Result::Handled;
|
||||
}},
|
||||
});
|
||||
|
||||
router.add(u"contacts"_q, {
|
||||
.path = u"new"_q,
|
||||
.action = CodeBlock{ ShowAddContact },
|
||||
|
||||
@@ -156,6 +156,9 @@ Result Router::executeAction(const Action &action, const Context &ctx) {
|
||||
if (!ctx.controller) {
|
||||
return Result::NeedsAuth;
|
||||
}
|
||||
if (!s.controlId.isEmpty()) {
|
||||
ctx.controller->setHighlightControlId(s.controlId);
|
||||
}
|
||||
ctx.controller->showSettings(s.sectionId);
|
||||
return Result::Handled;
|
||||
}, [&](const CodeBlock &c) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,8 @@ Ui::RpWidget *SectionBuilder::addControl(ControlArgs &&args) {
|
||||
|
||||
Ui::SettingsButton *SectionBuilder::addSettingsButton(ButtonArgs &&args) {
|
||||
const auto &st = args.st ? *args.st : st::settingsButton;
|
||||
auto highlight = std::move(args.highlight);
|
||||
const auto id = args.id;
|
||||
const auto button = v::match(_context, [&](const WidgetContext &ctx) -> Ui::SettingsButton* {
|
||||
if (args.label) {
|
||||
return AddButtonWithLabel(
|
||||
@@ -86,6 +88,10 @@ Ui::SettingsButton *SectionBuilder::addSettingsButton(ButtonArgs &&args) {
|
||||
if (button && args.onClick) {
|
||||
button->addClickHandler(std::move(args.onClick));
|
||||
}
|
||||
if (button && !id.isEmpty()) {
|
||||
const auto highlightId = highlight.id.isEmpty() ? id : highlight.id;
|
||||
registerHighlight(highlightId, button, std::move(highlight.args));
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -251,7 +257,9 @@ Ui::SettingsButton *SectionBuilder::addPremiumButton(PremiumButtonArgs &&args) {
|
||||
}
|
||||
|
||||
Ui::SettingsButton *SectionBuilder::addToggle(ToggleArgs &&args) {
|
||||
return v::match(_context, [&](const WidgetContext &ctx)
|
||||
auto highlight = std::move(args.highlight);
|
||||
const auto id = args.id;
|
||||
const auto button = v::match(_context, [&](const WidgetContext &ctx)
|
||||
-> Ui::SettingsButton* {
|
||||
const auto &st = args.st ? *args.st : st::settingsButton;
|
||||
const auto button = ctx.container->add(CreateButtonWithIcon(
|
||||
@@ -271,6 +279,11 @@ Ui::SettingsButton *SectionBuilder::addToggle(ToggleArgs &&args) {
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
if (button && !id.isEmpty()) {
|
||||
const auto highlightId = highlight.id.isEmpty() ? id : highlight.id;
|
||||
registerHighlight(highlightId, button, std::move(highlight.args));
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
Ui::SlideWrap<Ui::SettingsButton> *SectionBuilder::addSlideToggle(
|
||||
@@ -335,4 +348,19 @@ Fn<void(Type)> SectionBuilder::showOther() const {
|
||||
});
|
||||
}
|
||||
|
||||
void SectionBuilder::registerHighlight(
|
||||
QString id,
|
||||
QWidget *widget,
|
||||
HighlightArgs &&args) {
|
||||
v::match(_context, [&](const WidgetContext &ctx) {
|
||||
if (ctx.highlights && widget) {
|
||||
ctx.highlights->push_back({
|
||||
std::move(id),
|
||||
{ widget, std::move(args) },
|
||||
});
|
||||
}
|
||||
}, [](const SearchContext &) {
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Settings::Builder
|
||||
|
||||
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_type.h"
|
||||
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
@@ -40,11 +41,19 @@ struct SearchEntry {
|
||||
QStringList keywords;
|
||||
};
|
||||
|
||||
struct HighlightEntry {
|
||||
QPointer<QWidget> widget;
|
||||
HighlightArgs args;
|
||||
};
|
||||
|
||||
using HighlightRegistry = std::vector<std::pair<QString, HighlightEntry>>;
|
||||
|
||||
struct WidgetContext {
|
||||
not_null<Ui::VerticalLayout*> container;
|
||||
not_null<Window::SessionController*> controller;
|
||||
Fn<void(Type)> showOther;
|
||||
Fn<bool()> isPaused;
|
||||
HighlightRegistry *highlights = nullptr;
|
||||
};
|
||||
|
||||
struct SearchContext {
|
||||
@@ -74,6 +83,7 @@ public:
|
||||
rpl::producer<QString> label;
|
||||
Fn<void()> onClick;
|
||||
QStringList keywords;
|
||||
HighlightDescriptor highlight;
|
||||
};
|
||||
Ui::SettingsButton *addSettingsButton(ButtonArgs &&args);
|
||||
Ui::SettingsButton *addLabeledButton(ButtonArgs &&args);
|
||||
@@ -128,6 +138,7 @@ public:
|
||||
IconDescriptor icon;
|
||||
rpl::producer<bool> toggled;
|
||||
QStringList keywords;
|
||||
HighlightDescriptor highlight;
|
||||
};
|
||||
Ui::SettingsButton *addToggle(ToggleArgs &&args);
|
||||
|
||||
@@ -153,7 +164,13 @@ public:
|
||||
[[nodiscard]] Fn<void(Type)> showOther() const;
|
||||
|
||||
private:
|
||||
void registerHighlight(
|
||||
QString id,
|
||||
QWidget *widget,
|
||||
HighlightArgs &&args);
|
||||
|
||||
BuildContext _context;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Settings::Builder
|
||||
|
||||
@@ -279,7 +279,7 @@ void BuildPremiumSection(
|
||||
|
||||
if (!controller || controller->session().premiumCanBuy()) {
|
||||
builder.addSettingsButton({
|
||||
.id = u"main/gift"_q,
|
||||
.id = u"main/send-gift"_q,
|
||||
.title = tr::lng_settings_gift_premium(),
|
||||
.icon = { .icon = &st::menuIconGiftPremium, .newBadge = true },
|
||||
.onClick = controller
|
||||
@@ -299,14 +299,14 @@ void BuildHelpSection(
|
||||
builder.addSkip();
|
||||
|
||||
const auto faqClick = controller
|
||||
? Fn<void()>([=] {
|
||||
? [=] {
|
||||
UrlClickHandler::Open(
|
||||
tr::lng_settings_faq_link(tr::now),
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(controller),
|
||||
}));
|
||||
})
|
||||
: Fn<void()>(nullptr);
|
||||
}
|
||||
: Fn<void()>();
|
||||
builder.addSettingsButton({
|
||||
.id = u"main/faq"_q,
|
||||
.title = tr::lng_settings_faq(),
|
||||
@@ -326,9 +326,12 @@ void BuildHelpSection(
|
||||
});
|
||||
|
||||
builder.addSettingsButton({
|
||||
.id = u"main/ask"_q,
|
||||
.id = u"main/ask-question"_q,
|
||||
.title = tr::lng_settings_ask_question(),
|
||||
.icon = { &st::menuIconDiscussion },
|
||||
.onClick = [] {
|
||||
UrlClickHandler::Open(tr::lng_telegram_features_url(tr::now));
|
||||
},
|
||||
.keywords = { u"contact"_q, u"feedback"_q },
|
||||
});
|
||||
|
||||
@@ -380,10 +383,13 @@ void BuildMainSectionContent(
|
||||
|
||||
} // namespace
|
||||
|
||||
void BuildMainSection(
|
||||
void MainSection(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void(Type)> showOther) {
|
||||
Fn<void(Type)> showOther,
|
||||
rpl::producer<> showFinished) {
|
||||
auto &lifetime = container->lifetime();
|
||||
const auto highlights = lifetime.make_state<HighlightRegistry>();
|
||||
const auto isPaused = Window::PausedIn(
|
||||
controller,
|
||||
Window::GifPauseReason::Layer);
|
||||
@@ -392,11 +398,23 @@ void BuildMainSection(
|
||||
.controller = controller,
|
||||
.showOther = std::move(showOther),
|
||||
.isPaused = isPaused,
|
||||
.highlights = highlights,
|
||||
});
|
||||
BuildMainSectionContent(builder, controller);
|
||||
|
||||
std::move(showFinished) | rpl::on_next([=] {
|
||||
for (const auto &[id, entry] : *highlights) {
|
||||
if (const auto widget = entry.widget.data()) {
|
||||
controller->checkHighlightControl(
|
||||
id,
|
||||
widget,
|
||||
base::duplicate(entry.args));
|
||||
}
|
||||
}
|
||||
}, lifetime);
|
||||
}
|
||||
|
||||
std::vector<SearchEntry> BuildMainSectionForSearch() {
|
||||
std::vector<SearchEntry> MainSectionForSearch() {
|
||||
auto entries = std::vector<SearchEntry>();
|
||||
auto builder = SectionBuilder(SearchContext{
|
||||
.entries = &entries,
|
||||
|
||||
@@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <vector>
|
||||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
class SettingsButton;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
@@ -23,11 +25,12 @@ namespace Settings::Builder {
|
||||
|
||||
struct SearchEntry;
|
||||
|
||||
void BuildMainSection(
|
||||
void MainSection(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void(Type)> showOther);
|
||||
Fn<void(Type)> showOther,
|
||||
rpl::producer<> showFinished);
|
||||
|
||||
[[nodiscard]] std::vector<SearchEntry> BuildMainSectionForSearch();
|
||||
[[nodiscard]] std::vector<SearchEntry> MainSectionForSearch();
|
||||
|
||||
} // namespace Settings::Builder
|
||||
|
||||
@@ -74,7 +74,7 @@ void BuildMultiAccountSection(
|
||||
}
|
||||
|
||||
const auto fromAll = builder.addToggle({
|
||||
.id = u"notifications/multi_account"_q,
|
||||
.id = u"notifications/accounts"_q,
|
||||
.title = tr::lng_settings_notify_all(),
|
||||
.st = &st::settingsButtonNoIcon,
|
||||
.toggled = rpl::single(Core::App().settings().notifyFromAll()),
|
||||
@@ -468,7 +468,7 @@ void BuildBadgeCounterSection(
|
||||
const auto &settings = Core::App().settings();
|
||||
|
||||
const auto muted = builder.addToggle({
|
||||
.id = u"notifications/badge/muted"_q,
|
||||
.id = u"notifications/include-muted-chats"_q,
|
||||
.title = tr::lng_settings_include_muted(),
|
||||
.st = &st::settingsButtonNoIcon,
|
||||
.toggled = rpl::single(settings.includeMutedCounter()),
|
||||
@@ -486,7 +486,7 @@ void BuildBadgeCounterSection(
|
||||
}) : nullptr;
|
||||
|
||||
const auto count = builder.addToggle({
|
||||
.id = u"notifications/badge/count"_q,
|
||||
.id = u"notifications/count-unread-messages"_q,
|
||||
.title = tr::lng_settings_count_unread(),
|
||||
.st = &st::settingsButtonNoIcon,
|
||||
.toggled = rpl::single(settings.countUnreadMessages()),
|
||||
@@ -742,10 +742,13 @@ void BuildNotificationsSectionContent(
|
||||
|
||||
} // namespace
|
||||
|
||||
void BuildNotificationsSection(
|
||||
void NotificationsSection(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void(Type)> showOther) {
|
||||
Fn<void(Type)> showOther,
|
||||
rpl::producer<> showFinished) {
|
||||
auto &lifetime = container->lifetime();
|
||||
const auto highlights = lifetime.make_state<HighlightRegistry>();
|
||||
const auto isPaused = Window::PausedIn(
|
||||
controller,
|
||||
Window::GifPauseReason::Layer);
|
||||
@@ -754,11 +757,21 @@ void BuildNotificationsSection(
|
||||
.controller = controller,
|
||||
.showOther = std::move(showOther),
|
||||
.isPaused = isPaused,
|
||||
.highlights = highlights,
|
||||
});
|
||||
BuildNotificationsSectionContent(builder, controller);
|
||||
|
||||
std::move(showFinished) | rpl::on_next([=] {
|
||||
for (const auto &[id, entry] : *highlights) {
|
||||
if (entry.widget) {
|
||||
auto args = entry.args;
|
||||
controller->checkHighlightControl(id, entry.widget, std::move(args));
|
||||
}
|
||||
}
|
||||
}, lifetime);
|
||||
}
|
||||
|
||||
std::vector<SearchEntry> BuildNotificationsSectionForSearch() {
|
||||
std::vector<SearchEntry> NotificationsSectionForSearch() {
|
||||
auto entries = std::vector<SearchEntry>();
|
||||
auto builder = SectionBuilder(SearchContext{
|
||||
.entries = &entries,
|
||||
|
||||
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_type.h"
|
||||
#include "settings/builder/settings_builder.h"
|
||||
|
||||
namespace Ui {
|
||||
@@ -19,11 +20,12 @@ class SessionController;
|
||||
|
||||
namespace Settings::Builder {
|
||||
|
||||
void BuildNotificationsSection(
|
||||
void NotificationsSection(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void(Type)> showOther);
|
||||
Fn<void(Type)> showOther,
|
||||
rpl::producer<> showFinished);
|
||||
|
||||
[[nodiscard]] std::vector<SearchEntry> BuildNotificationsSectionForSearch();
|
||||
[[nodiscard]] std::vector<SearchEntry> NotificationsSectionForSearch();
|
||||
|
||||
} // namespace Settings::Builder
|
||||
|
||||
@@ -607,6 +607,8 @@ public:
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
void setupContent();
|
||||
[[nodiscard]] Ui::RpWidget *terminateAllButton() const;
|
||||
[[nodiscard]] Ui::RpWidget *autoTerminateButton() const;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
@@ -685,6 +687,8 @@ public:
|
||||
[[nodiscard]] rpl::producer<EntryData> showRequests() const;
|
||||
[[nodiscard]] rpl::producer<uint64> terminateOne() const;
|
||||
[[nodiscard]] rpl::producer<> terminateAll() const;
|
||||
[[nodiscard]] Ui::RpWidget *terminateAllButton() const;
|
||||
[[nodiscard]] Ui::RpWidget *autoTerminateButton() const;
|
||||
|
||||
private:
|
||||
void setupContent();
|
||||
@@ -692,6 +696,7 @@ private:
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
std::unique_ptr<ListController> _current;
|
||||
QPointer<Ui::SettingsButton> _terminateAll;
|
||||
QPointer<Ui::SettingsButton> _autoTerminate;
|
||||
std::unique_ptr<ListController> _incomplete;
|
||||
std::unique_ptr<ListController> _list;
|
||||
rpl::variable<int> _ttlDays;
|
||||
@@ -874,6 +879,14 @@ void SessionsContent::terminateAll() {
|
||||
terminate(std::move(callback), tr::lng_settings_reset_sure(tr::now));
|
||||
}
|
||||
|
||||
Ui::RpWidget *SessionsContent::terminateAllButton() const {
|
||||
return _inner ? _inner->terminateAllButton() : nullptr;
|
||||
}
|
||||
|
||||
Ui::RpWidget *SessionsContent::autoTerminateButton() const {
|
||||
return _inner ? _inner->autoTerminateButton() : nullptr;
|
||||
}
|
||||
|
||||
SessionsContent::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
@@ -961,12 +974,12 @@ void SessionsContent::Inner::setupContent() {
|
||||
AddSkip(ttlInner, st::sessionSubtitleSkip);
|
||||
AddSubsectionTitle(ttlInner, tr::lng_settings_terminate_title());
|
||||
|
||||
AddButtonWithLabel(
|
||||
_autoTerminate = AddButtonWithLabel(
|
||||
ttlInner,
|
||||
tr::lng_settings_terminate_if(),
|
||||
_ttlDays.value() | rpl::map(SelfDestructionBox::DaysLabel),
|
||||
st::settingsButtonNoIcon
|
||||
)->addClickHandler([=] {
|
||||
st::settingsButtonNoIcon);
|
||||
_autoTerminate->addClickHandler([=] {
|
||||
_controller->show(Box<SelfDestructionBox>(
|
||||
&_controller->session(),
|
||||
SelfDestructionBox::Type::Sessions,
|
||||
@@ -1007,6 +1020,14 @@ rpl::producer<> SessionsContent::Inner::terminateAll() const {
|
||||
return _terminateAll->clicks() | rpl::to_empty;
|
||||
}
|
||||
|
||||
Ui::RpWidget *SessionsContent::Inner::terminateAllButton() const {
|
||||
return _terminateAll.data();
|
||||
}
|
||||
|
||||
Ui::RpWidget *SessionsContent::Inner::autoTerminateButton() const {
|
||||
return _autoTerminate.data();
|
||||
}
|
||||
|
||||
rpl::producer<uint64> SessionsContent::Inner::terminateOne() const {
|
||||
return rpl::merge(
|
||||
_incomplete->terminateRequests(),
|
||||
@@ -1124,7 +1145,8 @@ namespace Settings {
|
||||
Sessions::Sessions(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent) {
|
||||
: Section(parent)
|
||||
, _controller(controller) {
|
||||
setupContent(controller);
|
||||
}
|
||||
|
||||
@@ -1132,6 +1154,11 @@ rpl::producer<QString> Sessions::title() {
|
||||
return tr::lng_settings_sessions_title();
|
||||
}
|
||||
|
||||
void Sessions::showFinished() {
|
||||
_controller->checkHighlightControl(u"devices/terminate-sessions"_q, _terminateAll);
|
||||
_controller->checkHighlightControl(u"devices/auto-terminate"_q, _autoTerminate);
|
||||
}
|
||||
|
||||
void Sessions::setupContent(not_null<Window::SessionController*> controller) {
|
||||
const auto container = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
AddSkip(container, st::settingsPrivacySkip);
|
||||
@@ -1139,6 +1166,9 @@ void Sessions::setupContent(not_null<Window::SessionController*> controller) {
|
||||
object_ptr<SessionsContent>(container, controller));
|
||||
content->setupContent();
|
||||
|
||||
_terminateAll = content->terminateAllButton();
|
||||
_autoTerminate = content->autoTerminateButton();
|
||||
|
||||
Ui::ResizeFitChild(this, container);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,15 @@ public:
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
[[nodiscard]] rpl::producer<QString> title() override;
|
||||
void showFinished() override;
|
||||
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
QPointer<Ui::RpWidget> _terminateAll;
|
||||
QPointer<Ui::RpWidget> _autoTerminate;
|
||||
|
||||
};
|
||||
|
||||
void AddSessionInfoRow(
|
||||
|
||||
@@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "lang/lang_keys.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "main/main_session.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_privacy_controllers.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
@@ -76,12 +77,13 @@ base::weak_qptr<Ui::RpWidget> Blocked::createPinnedToTop(not_null<QWidget*> pare
|
||||
|
||||
Ui::AddSkip(content);
|
||||
|
||||
AddButtonWithIcon(
|
||||
const auto blockButton = AddButtonWithIcon(
|
||||
content,
|
||||
tr::lng_blocked_list_add(),
|
||||
st::settingsButtonActive,
|
||||
{ &st::menuIconBlockSettings }
|
||||
)->addClickHandler([=] {
|
||||
{ &st::menuIconBlockSettings });
|
||||
_blockUserButton = blockButton;
|
||||
blockButton->addClickHandler([=] {
|
||||
BlockedBoxController::BlockNewPeer(_controller);
|
||||
});
|
||||
|
||||
@@ -236,6 +238,7 @@ void Blocked::visibleTopBottomUpdated(int visibleTop, int visibleBottom) {
|
||||
|
||||
void Blocked::showFinished() {
|
||||
_showFinished.fire({});
|
||||
_controller->checkHighlightControl(u"privacy/blocked/block-user"_q, _blockUserButton);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
||||
@@ -48,6 +48,8 @@ private:
|
||||
rpl::event_stream<> _showFinished;
|
||||
rpl::event_stream<bool> _emptinessChanges;
|
||||
|
||||
QPointer<Ui::RpWidget> _blockUserButton;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
|
||||
@@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/business/settings_location.h"
|
||||
#include "settings/business/settings_quick_replies.h"
|
||||
#include "settings/business/settings_working_hours.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "ui/effects/gradient.h"
|
||||
@@ -366,6 +367,8 @@ private:
|
||||
|
||||
PremiumFeature _waitingToShow = PremiumFeature::Business;
|
||||
|
||||
QPointer<Ui::SettingsButton> _sponsoredButton;
|
||||
|
||||
};
|
||||
|
||||
Business::Business(
|
||||
@@ -563,6 +566,7 @@ void Business::setupContent() {
|
||||
const auto button = inner->add(object_ptr<Ui::SettingsButton>(
|
||||
inner,
|
||||
tr::lng_business_button_sponsored()));
|
||||
_sponsoredButton = button;
|
||||
Ui::AddSkip(inner);
|
||||
|
||||
const auto session = &_controller->session();
|
||||
@@ -716,6 +720,7 @@ base::weak_qptr<Ui::RpWidget> Business::createPinnedToTop(
|
||||
|
||||
void Business::showFinished() {
|
||||
_showFinished.fire({});
|
||||
_controller->checkHighlightControl(u"business/sponsored"_q, _sponsoredButton);
|
||||
}
|
||||
|
||||
base::weak_qptr<Ui::RpWidget> Business::createPinnedToBottom(
|
||||
|
||||
@@ -226,7 +226,13 @@ void HighlightOverlay::finish() {
|
||||
|
||||
} // namespace
|
||||
|
||||
void HighlightWidget(not_null<QWidget*> target, HighlightArgs &&args) {
|
||||
void HighlightWidget(QWidget *target, HighlightArgs &&args) {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
if (args.scroll) {
|
||||
ScrollToWidget(target);
|
||||
}
|
||||
new HighlightOverlay(target, std::move(args));
|
||||
}
|
||||
|
||||
@@ -257,13 +263,6 @@ void ScrollToWidget(not_null<QWidget*> target) {
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollAndHighlightWidget(
|
||||
not_null<QWidget*> target,
|
||||
HighlightArgs &&args) {
|
||||
ScrollToWidget(target);
|
||||
HighlightWidget(target, std::move(args));
|
||||
}
|
||||
|
||||
Icon::Icon(IconDescriptor descriptor) : _icon(descriptor.icon) {
|
||||
const auto background = [&]() -> const style::color* {
|
||||
if (descriptor.type == IconType::Simple) {
|
||||
|
||||
@@ -69,17 +69,23 @@ struct HighlightArgs {
|
||||
float64 opacity = 0.15;
|
||||
bool below = false;
|
||||
bool rippleShape = false;
|
||||
bool scroll = true;
|
||||
crl::time showDuration = 600;
|
||||
crl::time shownDuration = 800;
|
||||
crl::time hideDuration = 600;
|
||||
};
|
||||
|
||||
void HighlightWidget(not_null<QWidget*> target, HighlightArgs &&args = {});
|
||||
void ScrollToWidget(not_null<QWidget*> target);
|
||||
struct HighlightDescriptor {
|
||||
QString id;
|
||||
HighlightArgs args;
|
||||
|
||||
void ScrollAndHighlightWidget(
|
||||
not_null<QWidget*> target,
|
||||
HighlightArgs &&args = {});
|
||||
explicit operator bool() const {
|
||||
return !id.isEmpty();
|
||||
}
|
||||
};
|
||||
|
||||
void HighlightWidget(QWidget *target, HighlightArgs &&args = {});
|
||||
void ScrollToWidget(not_null<QWidget*> target);
|
||||
|
||||
class AbstractSection : public Ui::RpWidget {
|
||||
public:
|
||||
|
||||
@@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Ui {
|
||||
class ScrollArea;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Ui::Menu {
|
||||
@@ -64,6 +65,12 @@ struct SectionFactory : AbstractSectionFactory {
|
||||
|
||||
};
|
||||
|
||||
using SectionBuilder = void(*)(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void(Type)> showOther,
|
||||
rpl::producer<> showFinished);
|
||||
|
||||
template <typename SectionType>
|
||||
class Section : public AbstractSection {
|
||||
public:
|
||||
@@ -88,8 +95,32 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
void showFinished() override {
|
||||
_showFinished.fire({});
|
||||
}
|
||||
|
||||
protected:
|
||||
void setController(not_null<Window::SessionController*> controller) {
|
||||
_controller = controller;
|
||||
}
|
||||
[[nodiscard]] Window::SessionController *controller() const {
|
||||
return _controller;
|
||||
}
|
||||
|
||||
void build(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
SectionBuilder builder) {
|
||||
builder(
|
||||
container,
|
||||
_controller,
|
||||
showOtherMethod(),
|
||||
_showFinished.events());
|
||||
}
|
||||
|
||||
private:
|
||||
rpl::event_stream<Type> _showOtherRequests;
|
||||
rpl::event_stream<> _showFinished;
|
||||
Window::SessionController *_controller = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "info/statistics/info_statistics_list_controllers.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "settings/settings_credits_graphics.h"
|
||||
#include "statistics/widgets/chart_header_widget.h"
|
||||
@@ -115,6 +116,10 @@ private:
|
||||
rpl::event_stream<> _showFinished;
|
||||
rpl::variable<QString> _buttonText;
|
||||
|
||||
QPointer<Ui::SettingsButton> _statsButton;
|
||||
QPointer<Ui::SettingsButton> _giftButton;
|
||||
QPointer<Ui::SettingsButton> _earnButton;
|
||||
|
||||
};
|
||||
|
||||
Credits::Credits(
|
||||
@@ -611,6 +616,7 @@ void Credits::setupContent() {
|
||||
tr::lng_credits_stats_button(),
|
||||
st::settingsCreditsButton,
|
||||
{ &st::menuIconStats })));
|
||||
_statsButton = static_cast<Button*>(wrap->entity());
|
||||
wrap->entity()->setClickedCallback([=] {
|
||||
controller->showSection(Info::BotEarn::Make(self));
|
||||
});
|
||||
@@ -620,21 +626,23 @@ void Credits::setupContent() {
|
||||
}));
|
||||
}
|
||||
if (!isCurrency) {
|
||||
AddButtonWithIcon(
|
||||
_giftButton = AddButtonWithIcon(
|
||||
content,
|
||||
tr::lng_credits_gift_button(),
|
||||
st::settingsCreditsButton,
|
||||
{ &st::settingsButtonIconGift })->setClickedCallback([=] {
|
||||
{ &st::settingsButtonIconGift });
|
||||
_giftButton->setClickedCallback([=] {
|
||||
Ui::ShowGiftCreditsBox(controller, paid);
|
||||
});
|
||||
}
|
||||
|
||||
if (!isCurrency && Info::BotStarRef::Join::Allowed(self)) {
|
||||
AddButtonWithIcon(
|
||||
_earnButton = AddButtonWithIcon(
|
||||
content,
|
||||
tr::lng_credits_earn_button(),
|
||||
st::settingsCreditsButton,
|
||||
{ &st::settingsButtonIconEarn })->setClickedCallback([=] {
|
||||
{ &st::settingsButtonIconEarn });
|
||||
_earnButton->setClickedCallback([=] {
|
||||
controller->showSection(Info::BotStarRef::Join::Make(self));
|
||||
});
|
||||
}
|
||||
@@ -904,6 +912,9 @@ base::weak_qptr<Ui::RpWidget> Credits::createPinnedToTop(
|
||||
|
||||
void Credits::showFinished() {
|
||||
_showFinished.fire({});
|
||||
_controller->checkHighlightControl(u"stars/stats"_q, _statsButton);
|
||||
_controller->checkHighlightControl(u"stars/gift"_q, _giftButton);
|
||||
_controller->checkHighlightControl(u"stars/earn"_q, _earnButton);
|
||||
}
|
||||
|
||||
class Currency {
|
||||
|
||||
@@ -48,6 +48,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_chat_helpers.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
struct FoldersHighlightTargets {
|
||||
QPointer<Ui::RpWidget> createButton;
|
||||
QPointer<Ui::RpWidget> tagsButton;
|
||||
QPointer<Ui::RpWidget> viewSection;
|
||||
};
|
||||
namespace {
|
||||
|
||||
using Flag = Data::ChatFilter::Flag;
|
||||
@@ -350,7 +356,8 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
|
||||
[[nodiscard]] Fn<void()> SetupFoldersContent(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<rpl::event_stream<bool>*> tagsButtonEnabled) {
|
||||
not_null<rpl::event_stream<bool>*> tagsButtonEnabled,
|
||||
FoldersHighlightTargets *targets) {
|
||||
auto &lifetime = container->lifetime();
|
||||
|
||||
const auto weak = base::make_weak(container);
|
||||
@@ -557,12 +564,15 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
|
||||
j->button->updateCount(j->filter);
|
||||
}, container->lifetime());
|
||||
|
||||
AddButtonWithIcon(
|
||||
const auto createButton = AddButtonWithIcon(
|
||||
container,
|
||||
tr::lng_filters_create(),
|
||||
st::settingsButtonActive,
|
||||
{ &st::settingsIconAdd, IconType::Round, &st::windowBgActive }
|
||||
)->setClickedCallback([=] {
|
||||
{ &st::settingsIconAdd, IconType::Round, &st::windowBgActive });
|
||||
if (targets) {
|
||||
targets->createButton = createButton;
|
||||
}
|
||||
createButton->setClickedCallback([=] {
|
||||
if (showLimitReached()) {
|
||||
return;
|
||||
}
|
||||
@@ -879,7 +889,8 @@ void SetupTopContent(
|
||||
void SetupTagContent(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> content,
|
||||
not_null<rpl::event_stream<bool>*> tagsButtonEnabled) {
|
||||
not_null<rpl::event_stream<bool>*> tagsButtonEnabled,
|
||||
FoldersHighlightTargets *targets) {
|
||||
Ui::AddDivider(content);
|
||||
Ui::AddSkip(content);
|
||||
|
||||
@@ -897,6 +908,9 @@ void SetupTagContent(
|
||||
content,
|
||||
tr::lng_filters_enable_tags(),
|
||||
st::settingsButtonNoIconLocked));
|
||||
if (targets) {
|
||||
targets->tagsButton = tagsButton;
|
||||
}
|
||||
const auto state = tagsButton->lifetime().make_state<State>();
|
||||
tagsButton->toggleOn(rpl::merge(
|
||||
rpl::combine(
|
||||
@@ -970,12 +984,16 @@ void SetupTagContent(
|
||||
void SetupView(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> content,
|
||||
bool dividerNeeded) {
|
||||
bool dividerNeeded,
|
||||
FoldersHighlightTargets *targets) {
|
||||
const auto wrap = content->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
content,
|
||||
object_ptr<Ui::VerticalLayout>(content)));
|
||||
wrap->toggleOn(controller->enoughSpaceForFiltersValue());
|
||||
if (targets) {
|
||||
targets->viewSection = wrap->entity();
|
||||
}
|
||||
content = wrap->entity();
|
||||
|
||||
if (dividerNeeded) {
|
||||
@@ -1012,7 +1030,8 @@ void SetupView(
|
||||
Folders::Folders(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent) {
|
||||
: Section(parent)
|
||||
, _controller(controller) {
|
||||
setupContent(controller);
|
||||
}
|
||||
|
||||
@@ -1035,21 +1054,29 @@ void Folders::setupContent(not_null<Window::SessionController*> controller) {
|
||||
|
||||
SetupTopContent(content, _showFinished.events());
|
||||
|
||||
_save = SetupFoldersContent(controller, content, tagsButtonEnabled);
|
||||
auto targets = FoldersHighlightTargets();
|
||||
_save = SetupFoldersContent(controller, content, tagsButtonEnabled, &targets);
|
||||
_createButton = targets.createButton;
|
||||
|
||||
auto dividerNeeded = true;
|
||||
if (controller->session().premiumPossible()) {
|
||||
SetupTagContent(controller, content, tagsButtonEnabled);
|
||||
SetupTagContent(controller, content, tagsButtonEnabled, &targets);
|
||||
_tagsButton = targets.tagsButton;
|
||||
dividerNeeded = false;
|
||||
}
|
||||
|
||||
SetupView(controller, content, dividerNeeded);
|
||||
SetupView(controller, content, dividerNeeded, &targets);
|
||||
_viewSection = targets.viewSection;
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
||||
void Folders::showFinished() {
|
||||
_showFinished.fire({});
|
||||
|
||||
_controller->checkHighlightControl(u"folders/create"_q, _createButton);
|
||||
_controller->checkHighlightControl(u"folders/show-tags"_q, _tagsButton);
|
||||
_controller->checkHighlightControl(u"folders/tab-view"_q, _viewSection);
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
||||
@@ -25,9 +25,13 @@ public:
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
Fn<void()> _save;
|
||||
|
||||
rpl::event_stream<> _showFinished;
|
||||
QPointer<Ui::RpWidget> _createButton;
|
||||
QPointer<Ui::RpWidget> _tagsButton;
|
||||
QPointer<Ui::RpWidget> _viewSection;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -68,6 +68,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <QtCore/QBuffer>
|
||||
|
||||
namespace Settings {
|
||||
|
||||
struct InformationHighlightTargets {
|
||||
QPointer<Ui::RpWidget> bio;
|
||||
QPointer<Ui::RpWidget> colorButton;
|
||||
QPointer<Ui::RpWidget> addAccount;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kSaveBioTimeout = 1000;
|
||||
@@ -191,6 +198,7 @@ public:
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
[[nodiscard]] rpl::producer<> closeRequests() const;
|
||||
[[nodiscard]] Ui::RpWidget *addAccountButton() const;
|
||||
|
||||
private:
|
||||
void setup();
|
||||
@@ -418,7 +426,8 @@ void SetupBirthday(
|
||||
void SetupPersonalChannel(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<UserData*> self) {
|
||||
not_null<UserData*> self,
|
||||
InformationHighlightTargets *targets) {
|
||||
Ui::AddSkip(container);
|
||||
|
||||
auto value = rpl::combine(
|
||||
@@ -442,11 +451,14 @@ void SetupPersonalChannel(
|
||||
edit,
|
||||
{ &st::menuIconChannel });
|
||||
|
||||
AddPeerColorButton(
|
||||
const auto colorButton = AddPeerColorButton(
|
||||
container,
|
||||
controller->uiShow(),
|
||||
self,
|
||||
st::settingsColorButton);
|
||||
if (targets) {
|
||||
targets->colorButton = colorButton;
|
||||
}
|
||||
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddDivider(container);
|
||||
@@ -539,7 +551,8 @@ void SetupRows(
|
||||
|
||||
void SetupBio(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<UserData*> self) {
|
||||
not_null<UserData*> self,
|
||||
InformationHighlightTargets *targets) {
|
||||
const auto limits = Data::PremiumLimits(&self->session());
|
||||
const auto defaultLimit = limits.aboutLengthDefault();
|
||||
const auto premiumLimit = limits.aboutLengthPremium();
|
||||
@@ -561,6 +574,9 @@ void SetupBio(
|
||||
tr::lng_bio_placeholder(),
|
||||
*current),
|
||||
st::settingsBioMargins);
|
||||
if (targets) {
|
||||
targets->bio = bio;
|
||||
}
|
||||
|
||||
const auto countdown = Ui::CreateChild<Ui::FlatLabel>(
|
||||
container.get(),
|
||||
@@ -659,10 +675,14 @@ void SetupBio(
|
||||
|
||||
void SetupAccountsWrap(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
not_null<Window::SessionController*> controller,
|
||||
InformationHighlightTargets *targets) {
|
||||
Ui::AddSkip(container);
|
||||
|
||||
SetupAccounts(container, controller);
|
||||
auto events = SetupAccounts(container, controller);
|
||||
if (targets) {
|
||||
targets->addAccount = events.addAccountButton;
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsAltShift(Qt::KeyboardModifiers modifiers) {
|
||||
@@ -839,6 +859,10 @@ rpl::producer<> AccountsList::closeRequests() const {
|
||||
return _closeRequests.events();
|
||||
}
|
||||
|
||||
Ui::RpWidget *AccountsList::addAccountButton() const {
|
||||
return _addAccount ? _addAccount->entity() : nullptr;
|
||||
}
|
||||
|
||||
void AccountsList::setup() {
|
||||
_addAccount = setupAdd();
|
||||
|
||||
@@ -1052,7 +1076,8 @@ void AccountsList::rebuild() {
|
||||
Information::Information(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent) {
|
||||
: Section(parent)
|
||||
, _controller(controller) {
|
||||
setupContent(controller);
|
||||
}
|
||||
|
||||
@@ -1060,17 +1085,29 @@ rpl::producer<QString> Information::title() {
|
||||
return tr::lng_settings_section_info();
|
||||
}
|
||||
|
||||
void Information::showFinished() {
|
||||
_controller->checkHighlightControl(u"edit/bio"_q, _bio);
|
||||
_controller->checkHighlightControl(u"edit/your-color"_q, _colorButton);
|
||||
_controller->checkHighlightControl(u"edit/add-account"_q, _addAccount);
|
||||
}
|
||||
|
||||
void Information::setupContent(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
const auto self = controller->session().user();
|
||||
auto targets = InformationHighlightTargets();
|
||||
|
||||
SetupPhoto(content, controller, self);
|
||||
SetupBio(content, self);
|
||||
SetupBio(content, self, &targets);
|
||||
SetupRows(content, controller, self);
|
||||
SetupPersonalChannel(content, controller, self);
|
||||
SetupPersonalChannel(content, controller, self, &targets);
|
||||
SetupBirthday(content, controller, self);
|
||||
SetupAccountsWrap(content, controller);
|
||||
SetupAccountsWrap(content, controller, &targets);
|
||||
|
||||
_bio = targets.bio;
|
||||
_colorButton = targets.colorButton;
|
||||
_addAccount = targets.addAccount;
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
@@ -1083,6 +1120,7 @@ AccountsEvents SetupAccounts(
|
||||
controller);
|
||||
return {
|
||||
.closeRequests = list->closeRequests(),
|
||||
.addAccountButton = list->addAccountButton(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,21 @@ public:
|
||||
|
||||
[[nodiscard]] rpl::producer<QString> title() override;
|
||||
|
||||
void showFinished() override;
|
||||
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
QPointer<Ui::RpWidget> _bio;
|
||||
QPointer<Ui::RpWidget> _colorButton;
|
||||
QPointer<Ui::RpWidget> _addAccount;
|
||||
|
||||
};
|
||||
|
||||
struct AccountsEvents {
|
||||
rpl::producer<> closeRequests;
|
||||
QPointer<Ui::RpWidget> addAccountButton;
|
||||
};
|
||||
AccountsEvents SetupAccounts(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
|
||||
@@ -671,10 +671,10 @@ void SetupInterfaceScale(
|
||||
Main::Main(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent)
|
||||
, _controller(controller) {
|
||||
setupContentWithBuilder(controller);
|
||||
_controller->session().api().premium().reload();
|
||||
: Section(parent) {
|
||||
setController(controller);
|
||||
setupContent();
|
||||
controller->session().api().premium().reload();
|
||||
}
|
||||
|
||||
rpl::producer<QString> Main::title() {
|
||||
@@ -688,13 +688,13 @@ void Main::fillTopBarMenu(const Ui::Menu::MenuCallback &addAction) {
|
||||
Core::App().domain().addActivated(MTP::Environment{});
|
||||
}, &st::menuIconAddAccount);
|
||||
}
|
||||
if (!_controller->session().supportMode()) {
|
||||
if (!controller()->session().supportMode()) {
|
||||
addAction(
|
||||
tr::lng_settings_information(tr::now),
|
||||
[=] { showOther(Information::Id()); },
|
||||
&st::menuIconEdit);
|
||||
}
|
||||
const auto window = &_controller->window();
|
||||
const auto window = &controller()->window();
|
||||
addAction({
|
||||
.text = tr::lng_settings_logout(tr::now),
|
||||
.handler = [=] { window->showLogoutConfirmation(); },
|
||||
@@ -705,29 +705,28 @@ void Main::fillTopBarMenu(const Ui::Menu::MenuCallback &addAction) {
|
||||
|
||||
void Main::keyPressEvent(QKeyEvent *e) {
|
||||
crl::on_main(this, [=, text = e->text()]{
|
||||
CodesFeedString(_controller, text);
|
||||
CodesFeedString(controller(), text);
|
||||
});
|
||||
return Section::keyPressEvent(e);
|
||||
}
|
||||
|
||||
void Main::setupContentWithBuilder(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
void Main::setupContent() {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
content->add(object_ptr<Cover>(
|
||||
content,
|
||||
controller,
|
||||
controller->session().user()));
|
||||
controller(),
|
||||
controller()->session().user()));
|
||||
|
||||
Builder::BuildMainSection(content, controller, showOtherMethod());
|
||||
build(content, Builder::MainSection);
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
|
||||
controller->session().api().cloudPassword().reload();
|
||||
controller->session().api().reloadContactSignupSilent();
|
||||
controller->session().api().sensitiveContent().reload();
|
||||
controller->session().api().globalPrivacy().reload();
|
||||
controller->session().data().cloudThemes().refresh();
|
||||
controller()->session().api().cloudPassword().reload();
|
||||
controller()->session().api().reloadContactSignupSilent();
|
||||
controller()->session().api().sensitiveContent().reload();
|
||||
controller()->session().api().globalPrivacy().reload();
|
||||
controller()->session().data().cloudThemes().refresh();
|
||||
}
|
||||
|
||||
void OpenFaq(base::weak_ptr<Window::SessionController> weak) {
|
||||
|
||||
@@ -15,6 +15,7 @@ class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
class SettingsButton;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
@@ -53,9 +54,7 @@ protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
private:
|
||||
void setupContentWithBuilder(not_null<Window::SessionController*> controller);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
void setupContent();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -797,22 +797,17 @@ Notifications::Notifications(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent) {
|
||||
setupContent(controller);
|
||||
setController(controller);
|
||||
setupContent();
|
||||
}
|
||||
|
||||
rpl::producer<QString> Notifications::title() {
|
||||
return tr::lng_settings_section_notify();
|
||||
}
|
||||
|
||||
void Notifications::setupContent(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
void Notifications::setupContent() {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
Builder::BuildNotificationsSection(
|
||||
content,
|
||||
controller,
|
||||
showOtherMethod());
|
||||
|
||||
build(content, Builder::NotificationsSection);
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
[[nodiscard]] rpl::producer<QString> title() override;
|
||||
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
void setupContent();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
#include "styles/style_settings.h"
|
||||
@@ -40,6 +41,13 @@ namespace {
|
||||
|
||||
using Notify = Data::DefaultNotify;
|
||||
|
||||
struct NotificationsTypeHighlightTargets {
|
||||
QPointer<Ui::RpWidget> showToggle;
|
||||
QPointer<Ui::RpWidget> soundToggle;
|
||||
QPointer<Ui::RpWidget> addException;
|
||||
QPointer<Ui::RpWidget> deleteExceptions;
|
||||
};
|
||||
|
||||
struct Factory : AbstractSectionFactory {
|
||||
explicit Factory(Notify type) : type(type) {
|
||||
}
|
||||
@@ -394,7 +402,8 @@ void ExceptionsController::sort() {
|
||||
void SetupChecks(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Notify type) {
|
||||
Notify type,
|
||||
NotificationsTypeHighlightTargets *targets) {
|
||||
Ui::AddSubsectionTitle(container, Title(type));
|
||||
|
||||
const auto session = &controller->session();
|
||||
@@ -409,6 +418,9 @@ void SetupChecks(
|
||||
enabled->toggleOn(
|
||||
NotificationsEnabledForTypeValue(session, type),
|
||||
true);
|
||||
if (targets) {
|
||||
targets->showToggle = enabled;
|
||||
}
|
||||
|
||||
enabled->setAcceptBoth();
|
||||
MuteMenu::SetupMuteMenu(
|
||||
@@ -450,6 +462,9 @@ void SetupChecks(
|
||||
) | rpl::then(settings->defaultUpdates(
|
||||
type
|
||||
) | rpl::map([=] { return soundValue(); })));
|
||||
if (targets) {
|
||||
targets->soundToggle = sound;
|
||||
}
|
||||
|
||||
const auto toneWrap = soundInner->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
@@ -538,12 +553,16 @@ void SetupChecks(
|
||||
void SetupExceptions(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> window,
|
||||
Notify type) {
|
||||
Notify type,
|
||||
NotificationsTypeHighlightTargets *targets) {
|
||||
const auto add = AddButtonWithIcon(
|
||||
container,
|
||||
tr::lng_notification_exceptions_add(),
|
||||
st::settingsButtonActive,
|
||||
{ &st::menuIconInviteSettings });
|
||||
if (targets) {
|
||||
targets->addException = add;
|
||||
}
|
||||
|
||||
auto controller = std::make_unique<ExceptionsController>(window, type);
|
||||
controller->setStyleOverrides(&st::settingsBlockedList);
|
||||
@@ -588,6 +607,9 @@ void SetupExceptions(
|
||||
tr::lng_notification_exceptions_clear(),
|
||||
st::settingsAttentionButtonWithIcon,
|
||||
{ &st::menuIconDeleteAttention })));
|
||||
if (targets) {
|
||||
targets->deleteExceptions = wrap->entity();
|
||||
}
|
||||
wrap->entity()->setClickedCallback([=] {
|
||||
const auto clear = [=](Fn<void()> close) {
|
||||
window->session().data().notifySettings().clearExceptions(type);
|
||||
@@ -613,6 +635,7 @@ NotificationsType::NotificationsType(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Notify type)
|
||||
: AbstractSection(parent)
|
||||
, _controller(controller)
|
||||
, _type(type) {
|
||||
setupContent(controller);
|
||||
}
|
||||
@@ -626,6 +649,13 @@ rpl::producer<QString> NotificationsType::title() {
|
||||
Unexpected("Type in NotificationsType.");
|
||||
}
|
||||
|
||||
void NotificationsType::showFinished() {
|
||||
_controller->checkHighlightControl(u"notifications/type/show"_q, _showToggle);
|
||||
_controller->checkHighlightControl(u"notifications/type/sound"_q, _soundToggle);
|
||||
_controller->checkHighlightControl(u"notifications/type/add-exception"_q, _addException);
|
||||
_controller->checkHighlightControl(u"notifications/type/delete-exceptions"_q, _deleteExceptions);
|
||||
}
|
||||
|
||||
Type NotificationsType::Id(Notify type) {
|
||||
return std::make_shared<Factory>(type);
|
||||
}
|
||||
@@ -634,14 +664,21 @@ void NotificationsType::setupContent(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
const auto container = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
auto targets = NotificationsTypeHighlightTargets();
|
||||
|
||||
Ui::AddSkip(container, st::settingsPrivacySkip);
|
||||
SetupChecks(container, controller, _type);
|
||||
SetupChecks(container, controller, _type, &targets);
|
||||
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddDivider(container);
|
||||
Ui::AddSkip(container);
|
||||
|
||||
SetupExceptions(container, controller, _type);
|
||||
SetupExceptions(container, controller, _type, &targets);
|
||||
|
||||
_showToggle = targets.showToggle;
|
||||
_soundToggle = targets.soundToggle;
|
||||
_addException = targets.addException;
|
||||
_deleteExceptions = targets.deleteExceptions;
|
||||
|
||||
Ui::ResizeFitChild(this, container);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,19 @@ public:
|
||||
return Id(_type);
|
||||
}
|
||||
|
||||
void showFinished() override;
|
||||
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
const Data::DefaultNotify _type;
|
||||
|
||||
QPointer<Ui::RpWidget> _showToggle;
|
||||
QPointer<Ui::RpWidget> _soundToggle;
|
||||
QPointer<Ui::RpWidget> _addException;
|
||||
QPointer<Ui::RpWidget> _deleteExceptions;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] bool NotificationsEnabledForType(
|
||||
|
||||
@@ -986,13 +986,15 @@ void FillPeerQrBox(
|
||||
box->showFinishes(
|
||||
) | rpl::take(1) | rpl::on_next([=] {
|
||||
if (const auto window = Core::App().findWindow(box)) {
|
||||
if (window->takeHighlightControlId(u"self-qr-code/copy"_q)) {
|
||||
Settings::HighlightWidget(saveButton, {
|
||||
.radius = st::boxRadius,
|
||||
window->checkHighlightControl(
|
||||
u"self-qr-code/copy"_q,
|
||||
saveButton,
|
||||
{
|
||||
.radius = st::buttonRadius,
|
||||
.color = &st::activeButtonFg,
|
||||
.opacity = 0.6,
|
||||
.scroll = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, box->lifetime());
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "data/components/promo_suggestions.h"
|
||||
#include "data/data_thread.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "apiwrap.h" // ApiWrap::acceptTerms.
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
@@ -631,6 +632,19 @@ bool Controller::takeHighlightControlId(const QString &id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Controller::checkHighlightControl(
|
||||
const QString &id,
|
||||
QWidget *widget,
|
||||
Settings::HighlightArgs &&args) {
|
||||
if (widget && takeHighlightControlId(id)) {
|
||||
Settings::HighlightWidget(widget, std::move(args));
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::checkHighlightControl(const QString &id, QWidget *widget) {
|
||||
checkHighlightControl(id, widget, {});
|
||||
}
|
||||
|
||||
rpl::lifetime &Controller::lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ namespace Media::Player {
|
||||
class FloatDelegate;
|
||||
} // namespace Media::Player
|
||||
|
||||
namespace Settings {
|
||||
struct HighlightArgs;
|
||||
} // namespace Settings
|
||||
|
||||
namespace Window {
|
||||
|
||||
class Controller final : public base::has_weak_ptr {
|
||||
@@ -145,6 +149,11 @@ public:
|
||||
void setHighlightControlId(const QString &id);
|
||||
[[nodiscard]] QString highlightControlId() const;
|
||||
[[nodiscard]] bool takeHighlightControlId(const QString &id);
|
||||
void checkHighlightControl(
|
||||
const QString &id,
|
||||
QWidget *widget,
|
||||
Settings::HighlightArgs &&args);
|
||||
void checkHighlightControl(const QString &id, QWidget *widget);
|
||||
|
||||
[[nodiscard]] rpl::lifetime &lifetime();
|
||||
|
||||
|
||||
@@ -637,13 +637,11 @@ void MainMenu::parentResized() {
|
||||
void MainMenu::showFinished() {
|
||||
_showFinished = true;
|
||||
|
||||
if (_controller->takeHighlightControlId(u"main-menu/emoji-status"_q)) {
|
||||
const auto radius = st::roundRadiusSmall;
|
||||
Settings::HighlightWidget(_setEmojiStatus, {
|
||||
.margin = { radius, 0, radius, 0 },
|
||||
.radius = radius,
|
||||
});
|
||||
}
|
||||
const auto radius = st::roundRadiusSmall;
|
||||
_controller->checkHighlightControl(
|
||||
u"main-menu/emoji-status"_q,
|
||||
_setEmojiStatus,
|
||||
{ .margin = { -radius, 0, -radius, 0 }, .radius = radius });
|
||||
}
|
||||
|
||||
void MainMenu::setupMenu() {
|
||||
|
||||
@@ -3692,6 +3692,19 @@ bool SessionController::takeHighlightControlId(const QString &id) {
|
||||
return _window->takeHighlightControlId(id);
|
||||
}
|
||||
|
||||
void SessionController::checkHighlightControl(
|
||||
const QString &id,
|
||||
QWidget *widget,
|
||||
Settings::HighlightArgs &&args) {
|
||||
_window->checkHighlightControl(id, widget, std::move(args));
|
||||
}
|
||||
|
||||
void SessionController::checkHighlightControl(
|
||||
const QString &id,
|
||||
QWidget *widget) {
|
||||
_window->checkHighlightControl(id, widget);
|
||||
}
|
||||
|
||||
SessionController::~SessionController() {
|
||||
resetFakeUnreadWhileOpened();
|
||||
dropSubsectionTabs();
|
||||
|
||||
@@ -90,6 +90,10 @@ namespace HistoryView::Reactions {
|
||||
class CachedIconFactory;
|
||||
} // namespace HistoryView::Reactions
|
||||
|
||||
namespace Settings {
|
||||
struct HighlightArgs;
|
||||
} // namespace Settings
|
||||
|
||||
namespace Window {
|
||||
|
||||
using GifPauseReason = ChatHelpers::PauseReason;
|
||||
@@ -703,6 +707,11 @@ public:
|
||||
void setHighlightControlId(const QString &id);
|
||||
[[nodiscard]] QString highlightControlId() const;
|
||||
[[nodiscard]] bool takeHighlightControlId(const QString &id);
|
||||
void checkHighlightControl(
|
||||
const QString &id,
|
||||
QWidget *widget,
|
||||
Settings::HighlightArgs &&args);
|
||||
void checkHighlightControl(const QString &id, QWidget *widget);
|
||||
|
||||
[[nodiscard]] rpl::lifetime &lifetime() {
|
||||
return _lifetime;
|
||||
|
||||
Reference in New Issue
Block a user