2018-09-05 19:05:49 +00:00
|
|
|
/*
|
|
|
|
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 "ui/rp_widget.h"
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "base/object_ptr.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2018-09-06 17:58:44 +00:00
|
|
|
namespace Ui {
|
|
|
|
class VerticalLayout;
|
2019-09-04 15:59:43 +00:00
|
|
|
class FlatLabel;
|
2019-11-02 17:06:47 +00:00
|
|
|
class SettingsButton;
|
2018-09-06 17:58:44 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2018-09-05 19:39:35 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2018-09-05 19:39:35 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2018-09-07 09:40:25 +00:00
|
|
|
namespace style {
|
2019-11-02 17:06:47 +00:00
|
|
|
struct SettingsButton;
|
2018-09-07 09:40:25 +00:00
|
|
|
} // namespace style
|
|
|
|
|
2018-09-05 19:05:49 +00:00
|
|
|
namespace Settings {
|
|
|
|
|
|
|
|
enum class Type {
|
|
|
|
Main,
|
|
|
|
Information,
|
|
|
|
Notifications,
|
|
|
|
PrivacySecurity,
|
2018-09-20 16:47:02 +00:00
|
|
|
Advanced,
|
2018-09-05 19:05:49 +00:00
|
|
|
Chat,
|
2019-01-05 11:08:02 +00:00
|
|
|
Calls,
|
2018-09-05 19:05:49 +00:00
|
|
|
};
|
|
|
|
|
2019-11-02 17:06:47 +00:00
|
|
|
using Button = Ui::SettingsButton;
|
2018-09-05 19:05:49 +00:00
|
|
|
|
|
|
|
class Section : public Ui::RpWidget {
|
|
|
|
public:
|
|
|
|
using RpWidget::RpWidget;
|
|
|
|
|
|
|
|
virtual rpl::producer<Type> sectionShowOther() {
|
2019-06-18 14:07:45 +00:00
|
|
|
return nullptr;
|
2018-09-05 19:05:49 +00:00
|
|
|
}
|
2018-09-09 17:38:08 +00:00
|
|
|
virtual rpl::producer<bool> sectionCanSaveChanges() {
|
|
|
|
return rpl::single(false);
|
|
|
|
}
|
|
|
|
virtual void sectionSaveChanges(FnMut<void()> done) {
|
|
|
|
done();
|
|
|
|
}
|
2018-09-05 19:05:49 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
object_ptr<Section> CreateSection(
|
|
|
|
Type type,
|
|
|
|
not_null<QWidget*> parent,
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> controller);
|
2018-09-05 19:05:49 +00:00
|
|
|
|
2018-09-06 17:58:44 +00:00
|
|
|
void AddSkip(not_null<Ui::VerticalLayout*> container);
|
2018-09-07 12:19:56 +00:00
|
|
|
void AddSkip(not_null<Ui::VerticalLayout*> container, int skip);
|
2018-09-06 17:58:44 +00:00
|
|
|
void AddDivider(not_null<Ui::VerticalLayout*> container);
|
2018-09-09 12:10:54 +00:00
|
|
|
void AddDividerText(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
rpl::producer<QString> text);
|
2018-09-13 20:09:26 +00:00
|
|
|
not_null<Button*> AddButton(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
rpl::producer<QString> text,
|
2019-11-02 17:06:47 +00:00
|
|
|
const style::SettingsButton &st,
|
2018-09-28 11:20:36 +00:00
|
|
|
const style::icon *leftIcon = nullptr,
|
|
|
|
int iconLeft = 0);
|
2018-09-07 09:40:25 +00:00
|
|
|
not_null<Button*> AddButtonWithLabel(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> text,
|
2018-09-07 09:40:25 +00:00
|
|
|
rpl::producer<QString> label,
|
2019-11-02 17:06:47 +00:00
|
|
|
const style::SettingsButton &st,
|
2018-09-28 11:20:36 +00:00
|
|
|
const style::icon *leftIcon = nullptr,
|
|
|
|
int iconLeft = 0);
|
2018-09-09 12:10:54 +00:00
|
|
|
void CreateRightLabel(
|
|
|
|
not_null<Button*> button,
|
2018-09-15 10:37:48 +00:00
|
|
|
rpl::producer<QString> label,
|
2019-11-02 17:06:47 +00:00
|
|
|
const style::SettingsButton &st,
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> buttonText);
|
2019-09-04 15:59:43 +00:00
|
|
|
not_null<Ui::FlatLabel*> AddSubsectionTitle(
|
2018-09-29 12:18:26 +00:00
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
rpl::producer<QString> text);
|
2018-09-06 17:58:44 +00:00
|
|
|
|
2018-09-06 15:24:24 +00:00
|
|
|
using MenuCallback = Fn<QAction*(
|
|
|
|
const QString &text,
|
|
|
|
Fn<void()> handler)>;
|
|
|
|
|
|
|
|
void FillMenu(
|
2019-09-08 12:47:22 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
Type type,
|
2018-09-06 15:24:24 +00:00
|
|
|
Fn<void(Type)> showOther,
|
|
|
|
MenuCallback addAction);
|
|
|
|
|
2018-09-05 19:05:49 +00:00
|
|
|
} // namespace Settings
|