tdesktop/Telegram/SourceFiles/settings/settings_common.h

107 lines
2.4 KiB
C
Raw Normal View History

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"
2018-09-07 09:40:25 +00:00
enum LangKey : int;
namespace Ui {
class VerticalLayout;
} // namespace Ui
2018-09-05 19:39:35 +00:00
namespace Window {
class Controller;
} // namespace Window
2018-09-05 19:05:49 +00:00
namespace Info {
namespace Profile {
class Button;
} // namespace Profile
} // namespace Info
2018-09-07 09:40:25 +00:00
namespace style {
struct InfoProfileButton;
} // 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,
};
using Button = Info::Profile::Button;
class Section : public Ui::RpWidget {
public:
using RpWidget::RpWidget;
virtual rpl::producer<Type> sectionShowOther() {
return rpl::never<Type>();
}
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,
2018-09-11 18:07:04 +00:00
Window::Controller *controller = nullptr,
2018-09-05 19:05:49 +00:00
UserData *self = nullptr);
void AddSkip(not_null<Ui::VerticalLayout*> container);
2018-09-07 12:19:56 +00:00
void AddSkip(not_null<Ui::VerticalLayout*> container, int skip);
void AddDivider(not_null<Ui::VerticalLayout*> container);
void AddDividerText(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text);
2018-09-07 09:40:25 +00:00
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
LangKey text,
const style::InfoProfileButton &st,
const style::icon *leftIcon = nullptr);
2018-09-13 20:09:26 +00:00
not_null<Button*> AddButton(
not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> text,
const style::InfoProfileButton &st,
const style::icon *leftIcon = nullptr);
2018-09-07 09:40:25 +00:00
not_null<Button*> AddButtonWithLabel(
not_null<Ui::VerticalLayout*> container,
LangKey text,
rpl::producer<QString> label,
const style::InfoProfileButton &st,
const style::icon *leftIcon = nullptr);
void CreateRightLabel(
not_null<Button*> button,
rpl::producer<QString> label,
2018-09-17 10:52:34 +00:00
const style::InfoProfileButton &st,
LangKey buttonText);
void AddSubsectionTitle(
not_null<Ui::VerticalLayout*> conatiner,
LangKey text);
using MenuCallback = Fn<QAction*(
const QString &text,
Fn<void()> handler)>;
void FillMenu(
Fn<void(Type)> showOther,
MenuCallback addAction);
2018-09-05 19:05:49 +00:00
} // namespace Settings