mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Split out settings_common module into td_ui and non-td_ui variants.
This commit is contained in:
parent
f629bf76ff
commit
85e2d54a05
23 changed files with 186 additions and 153 deletions
|
@ -1278,8 +1278,8 @@ PRIVATE
|
|||
settings/settings_calls.h
|
||||
settings/settings_codes.cpp
|
||||
settings/settings_codes.h
|
||||
settings/settings_common.cpp
|
||||
settings/settings_common.h
|
||||
settings/settings_common_session.cpp
|
||||
settings/settings_common_session.h
|
||||
settings/settings_experimental.cpp
|
||||
settings/settings_experimental.h
|
||||
settings/settings_folders.cpp
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Ui {
|
||||
class VerticalLayout;
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
|
@ -25,12 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
void AddSkip(not_null<Ui::VerticalLayout*> container) {
|
||||
container->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
container,
|
||||
st::settingsSectionSkip));
|
||||
}
|
||||
|
||||
[[nodiscard]] QImage CacheFlagEmoji(const QString &flag) {
|
||||
const auto &st = st::giveawayGiftCodeCountrySelect.item;
|
||||
auto roundPaintCache = QImage(
|
||||
|
@ -74,7 +69,7 @@ void SelectCountriesBox(
|
|||
box,
|
||||
st::giveawayGiftCodeCountrySelect,
|
||||
tr::lng_participant_filter()));
|
||||
AddSkip(box->verticalLayout());
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
const auto &buttonSt = st::giveawayGiftCodeCountryButton;
|
||||
|
||||
struct Entry final {
|
||||
|
@ -179,8 +174,8 @@ void SelectCountriesBox(
|
|||
{
|
||||
noResults->toggle(false, anim::type::instant);
|
||||
const auto container = noResults->entity();
|
||||
AddSkip(container);
|
||||
AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
container->add(
|
||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
||||
container,
|
||||
|
@ -188,8 +183,8 @@ void SelectCountriesBox(
|
|||
container,
|
||||
tr::lng_search_messages_none(),
|
||||
st::membersAbout)));
|
||||
AddSkip(container);
|
||||
AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
}
|
||||
|
||||
multiSelect->setQueryChangedCallback([=](const QString &query) {
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "ui/widgets/box_content_divider.h"
|
||||
|
||||
namespace Ui {
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Main {
|
||||
class Account;
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Ui {
|
||||
class VerticalLayout;
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
|
|
|
@ -7,42 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "settings/settings_common.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_cloud_password.h"
|
||||
#include "settings/cloud_password/settings_cloud_password_email_confirm.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/settings_advanced.h"
|
||||
#include "settings/settings_information.h"
|
||||
#include "settings/settings_main.h"
|
||||
#include "settings/settings_notifications.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "settings/settings_folders.h"
|
||||
#include "settings/settings_calls.h"
|
||||
#include "settings/settings_experimental.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/box_content_divider.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/continuous_sliders.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "ui/painter.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "boxes/sessions_box.h"
|
||||
#include "window/themes/window_theme_editor_box.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_domain.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "base/options.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
@ -282,50 +253,6 @@ LottieIcon CreateLottieIcon(
|
|||
return { .widget = std::move(object), .animate = std::move(animate) };
|
||||
}
|
||||
|
||||
void FillMenu(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Type type,
|
||||
Fn<void(Type)> showOther,
|
||||
Ui::Menu::MenuCallback addAction) {
|
||||
const auto window = &controller->window();
|
||||
if (type == Chat::Id()) {
|
||||
addAction(
|
||||
tr::lng_settings_bg_theme_create(tr::now),
|
||||
[=] { window->show(Box(Window::Theme::CreateBox, window)); },
|
||||
&st::menuIconChangeColors);
|
||||
} else if (type == CloudPasswordEmailConfirmId()) {
|
||||
const auto api = &controller->session().api();
|
||||
if (const auto state = api->cloudPassword().stateCurrent()) {
|
||||
if (state->unconfirmedPattern.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
addAction(
|
||||
tr::lng_settings_password_abort(tr::now),
|
||||
[=] { api->cloudPassword().clearUnconfirmedPassword(); },
|
||||
&st::menuIconCancel);
|
||||
} else {
|
||||
const auto &list = Core::App().domain().accounts();
|
||||
if (list.size() < Core::App().domain().maxAccounts()) {
|
||||
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||
Core::App().domain().addActivated(MTP::Environment{});
|
||||
}, &st::menuIconAddAccount);
|
||||
}
|
||||
if (!controller->session().supportMode()) {
|
||||
addAction(
|
||||
tr::lng_settings_information(tr::now),
|
||||
[=] { showOther(Information::Id()); },
|
||||
&st::menuIconInfo);
|
||||
}
|
||||
addAction({
|
||||
.text = tr::lng_settings_logout(tr::now),
|
||||
.handler = [=] { window->showLogoutConfirmation(); },
|
||||
.icon = &st::menuIconLeaveAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SliderWithLabel MakeSliderWithLabel(
|
||||
QWidget *parent,
|
||||
const style::MediaSlider &sliderSt,
|
||||
|
|
|
@ -50,34 +50,6 @@ namespace Settings {
|
|||
|
||||
using Button = Ui::SettingsButton;
|
||||
|
||||
class AbstractSection;
|
||||
|
||||
struct AbstractSectionFactory {
|
||||
[[nodiscard]] virtual object_ptr<AbstractSection> create(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller) const = 0;
|
||||
[[nodiscard]] virtual bool hasCustomTopBar() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual ~AbstractSectionFactory() = default;
|
||||
};
|
||||
|
||||
template <typename SectionType>
|
||||
struct SectionFactory : AbstractSectionFactory {
|
||||
object_ptr<AbstractSection> create(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller
|
||||
) const final override {
|
||||
return object_ptr<SectionType>(parent, controller);
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::shared_ptr<SectionFactory> &Instance() {
|
||||
static const auto result = std::make_shared<SectionFactory>();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
class AbstractSection : public Ui::RpWidget {
|
||||
public:
|
||||
using RpWidget::RpWidget;
|
||||
|
@ -119,19 +91,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename SectionType>
|
||||
class Section : public AbstractSection {
|
||||
public:
|
||||
using AbstractSection::AbstractSection;
|
||||
|
||||
[[nodiscard]] static Type Id() {
|
||||
return SectionFactory<SectionType>::Instance();
|
||||
}
|
||||
[[nodiscard]] Type id() const final override {
|
||||
return Id();
|
||||
}
|
||||
};
|
||||
|
||||
enum class IconType {
|
||||
Rounded,
|
||||
Round,
|
||||
|
@ -207,12 +166,6 @@ struct LottieIcon {
|
|||
Lottie::IconDescriptor &&descriptor,
|
||||
style::margins padding = {});
|
||||
|
||||
void FillMenu(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Type type,
|
||||
Fn<void(Type)> showOther,
|
||||
Ui::Menu::MenuCallback addAction);
|
||||
|
||||
struct SliderWithLabel {
|
||||
object_ptr<Ui::RpWidget> widget;
|
||||
not_null<Ui::MediaSlider*> slider;
|
||||
|
|
81
Telegram/SourceFiles/settings/settings_common_session.cpp
Normal file
81
Telegram/SourceFiles/settings/settings_common_session.cpp
Normal file
|
@ -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 "settings/settings_common_session.h"
|
||||
|
||||
#include "api/api_cloud_password.h"
|
||||
#include "apiwrap.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_domain.h"
|
||||
#include "main/main_session.h"
|
||||
#include "settings/cloud_password/settings_cloud_password_email_confirm.h"
|
||||
#include "settings/settings_advanced.h"
|
||||
#include "settings/settings_calls.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/settings_experimental.h"
|
||||
#include "settings/settings_folders.h"
|
||||
#include "settings/settings_information.h"
|
||||
#include "settings/settings_main.h"
|
||||
#include "settings/settings_notifications.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "window/themes/window_theme_editor_box.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
namespace Settings {
|
||||
|
||||
void FillMenu(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Type type,
|
||||
Fn<void(Type)> showOther,
|
||||
Ui::Menu::MenuCallback addAction) {
|
||||
const auto window = &controller->window();
|
||||
if (type == Chat::Id()) {
|
||||
addAction(
|
||||
tr::lng_settings_bg_theme_create(tr::now),
|
||||
[=] { window->show(Box(Window::Theme::CreateBox, window)); },
|
||||
&st::menuIconChangeColors);
|
||||
} else if (type == CloudPasswordEmailConfirmId()) {
|
||||
const auto api = &controller->session().api();
|
||||
if (const auto state = api->cloudPassword().stateCurrent()) {
|
||||
if (state->unconfirmedPattern.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
addAction(
|
||||
tr::lng_settings_password_abort(tr::now),
|
||||
[=] { api->cloudPassword().clearUnconfirmedPassword(); },
|
||||
&st::menuIconCancel);
|
||||
} else {
|
||||
const auto &list = Core::App().domain().accounts();
|
||||
if (list.size() < Core::App().domain().maxAccounts()) {
|
||||
addAction(tr::lng_menu_add_account(tr::now), [=] {
|
||||
Core::App().domain().addActivated(MTP::Environment{});
|
||||
}, &st::menuIconAddAccount);
|
||||
}
|
||||
if (!controller->session().supportMode()) {
|
||||
addAction(
|
||||
tr::lng_settings_information(tr::now),
|
||||
[=] { showOther(Information::Id()); },
|
||||
&st::menuIconInfo);
|
||||
}
|
||||
addAction({
|
||||
.text = tr::lng_settings_logout(tr::now),
|
||||
.handler = [=] { window->showLogoutConfirmation(); },
|
||||
.icon = &st::menuIconLeaveAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Settings
|
72
Telegram/SourceFiles/settings/settings_common_session.h
Normal file
72
Telegram/SourceFiles/settings/settings_common_session.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
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
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "base/object_ptr.h"
|
||||
#include "settings/settings_type.h"
|
||||
|
||||
namespace Ui::Menu {
|
||||
struct MenuCallback;
|
||||
} // namespace Ui::Menu
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Settings {
|
||||
|
||||
class AbstractSection;
|
||||
|
||||
struct AbstractSectionFactory {
|
||||
[[nodiscard]] virtual object_ptr<AbstractSection> create(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller) const = 0;
|
||||
[[nodiscard]] virtual bool hasCustomTopBar() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual ~AbstractSectionFactory() = default;
|
||||
};
|
||||
|
||||
template <typename SectionType>
|
||||
struct SectionFactory : AbstractSectionFactory {
|
||||
object_ptr<AbstractSection> create(
|
||||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> controller
|
||||
) const final override {
|
||||
return object_ptr<SectionType>(parent, controller);
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::shared_ptr<SectionFactory> &Instance() {
|
||||
static const auto result = std::make_shared<SectionFactory>();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename SectionType>
|
||||
class Section : public AbstractSection {
|
||||
public:
|
||||
using AbstractSection::AbstractSection;
|
||||
|
||||
[[nodiscard]] static Type Id() {
|
||||
return SectionFactory<SectionType>::Instance();
|
||||
}
|
||||
[[nodiscard]] Type id() const final override {
|
||||
return Id();
|
||||
}
|
||||
};
|
||||
|
||||
void FillMenu(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Type type,
|
||||
Fn<void(Type)> showOther,
|
||||
Ui::Menu::MenuCallback addAction);
|
||||
|
||||
} // namespace Settings
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lottie/lottie_icon.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_ttl_validator.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/vertical_list.h"
|
||||
|
|
|
@ -7,7 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
class UserData;
|
||||
|
||||
namespace Ui {
|
||||
struct UnreadBadgeStyle;
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "data/notify/data_notify_settings.h"
|
||||
|
||||
namespace Data {
|
||||
|
|
|
@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "ui/abstract_button.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/effects/gradient.h"
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
#include "api/api_user_privacy.h"
|
||||
|
||||
class EditPrivacyController;
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
#include "settings/settings_common_session.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
|
|
|
@ -169,6 +169,9 @@ PRIVATE
|
|||
platform/mac/file_bookmark_mac.mm
|
||||
platform/platform_file_bookmark.h
|
||||
|
||||
settings/settings_common.cpp
|
||||
settings/settings_common.h
|
||||
|
||||
statistics/chart_lines_filter_controller.cpp
|
||||
statistics/chart_lines_filter_controller.h
|
||||
statistics/chart_rulers_data.cpp
|
||||
|
|
Loading…
Add table
Reference in a new issue