mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-22 08:16:56 +00:00
Show sessions list in a Settings Section.
This commit is contained in:
parent
2ad20d6c4a
commit
d4c6475ae8
@ -129,7 +129,7 @@ void SessionInfoBox(
|
||||
[[nodiscard]] QString LocationAndDate(const EntryData &entry) {
|
||||
return (entry.location.isEmpty() ? entry.ip : entry.location)
|
||||
+ (entry.hash
|
||||
? (QString::fromUtf8(" \xe2\x80\x93 ") + entry.active)
|
||||
? (QString::fromUtf8(" \xE2\x80\xA2 ") + entry.active)
|
||||
: QString());
|
||||
}
|
||||
|
||||
@ -768,6 +768,7 @@ Sessions::Sessions(
|
||||
|
||||
void Sessions::setupContent(not_null<Window::SessionController*> controller) {
|
||||
const auto container = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
AddSkip(container, st::settingsPrivacySkip);
|
||||
const auto content = container->add(
|
||||
object_ptr<SessionsContent>(container, controller));
|
||||
content->setupContent();
|
||||
|
@ -376,17 +376,16 @@ bool ResolveSettings(
|
||||
if (section.isEmpty()) {
|
||||
controller->window().showSettings();
|
||||
return true;
|
||||
}
|
||||
if (section == qstr("devices")) {
|
||||
controller->session().api().authorizations().reload();
|
||||
controller->show(Box<SessionsBox>(controller));
|
||||
return true;
|
||||
} else if (section == qstr("language")) {
|
||||
ShowLanguagesBox();
|
||||
return true;
|
||||
} else if (section == qstr("devices")) {
|
||||
controller->session().api().authorizations().reload();
|
||||
}
|
||||
const auto type = (section == qstr("folders"))
|
||||
? ::Settings::Type::Folders
|
||||
: (section == qstr("devices"))
|
||||
? ::Settings::Type::Sessions
|
||||
: ::Settings::Type::Main;
|
||||
controller->showSettings(type);
|
||||
return true;
|
||||
|
@ -617,6 +617,8 @@ rpl::producer<QString> TitleValue(
|
||||
return tr::lng_settings_section_notify();
|
||||
case Section::SettingsType::PrivacySecurity:
|
||||
return tr::lng_settings_section_privacy();
|
||||
case Section::SettingsType::Sessions:
|
||||
return tr::lng_settings_sessions_title();
|
||||
case Section::SettingsType::Advanced:
|
||||
return tr::lng_settings_advanced();
|
||||
case Section::SettingsType::Chat:
|
||||
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/widgets/box_content_divider.h"
|
||||
#include "ui/widgets/buttons.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"
|
||||
@ -47,6 +48,8 @@ object_ptr<Section> CreateSection(
|
||||
return object_ptr<Notifications>(parent, controller);
|
||||
case Type::PrivacySecurity:
|
||||
return object_ptr<PrivacySecurity>(parent, controller);
|
||||
case Type::Sessions:
|
||||
return object_ptr<Sessions>(parent, controller);
|
||||
case Type::Advanced:
|
||||
return object_ptr<Advanced>(parent, controller);
|
||||
case Type::Folders:
|
||||
|
@ -36,6 +36,7 @@ enum class Type {
|
||||
Information,
|
||||
Notifications,
|
||||
PrivacySecurity,
|
||||
Sessions,
|
||||
Advanced,
|
||||
Chat,
|
||||
Folders,
|
||||
|
@ -780,7 +780,8 @@ void SetupBotsAndWebsites(
|
||||
void SetupSessionsList(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<> updateTrigger) {
|
||||
rpl::producer<> updateTrigger,
|
||||
Fn<void(Type)> showOther) {
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::lng_settings_sessions_title());
|
||||
|
||||
@ -801,7 +802,7 @@ void SetupSessionsList(
|
||||
std::move(count),
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
controller->show(Box<SessionsBox>(controller));
|
||||
showOther(Type::Sessions);
|
||||
});
|
||||
AddSkip(container, st::settingsPrivacySecurityPadding);
|
||||
AddDividerText(container, tr::lng_settings_sessions_about());
|
||||
@ -929,6 +930,10 @@ PrivacySecurity::PrivacySecurity(
|
||||
setupContent(controller);
|
||||
}
|
||||
|
||||
rpl::producer<Type> PrivacySecurity::sectionShowOther() {
|
||||
return _showOther.events();
|
||||
}
|
||||
|
||||
void PrivacySecurity::setupContent(
|
||||
not_null<Window::SessionController*> controller) {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
@ -941,7 +946,9 @@ void PrivacySecurity::setupContent(
|
||||
|
||||
SetupPrivacy(controller, content, trigger());
|
||||
SetupArchiveAndMute(controller, content);
|
||||
SetupSessionsList(controller, content, trigger());
|
||||
SetupSessionsList(controller, content, trigger(), [=](Type type) {
|
||||
_showOther.fire_copy(type);
|
||||
});
|
||||
SetupLocalPasscode(controller, content);
|
||||
SetupCloudPassword(controller, content);
|
||||
#if !defined OS_MAC_STORE && !defined OS_WIN_STORE
|
||||
|
@ -39,9 +39,13 @@ public:
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
rpl::producer<Type> sectionShowOther() override;
|
||||
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
|
||||
rpl::event_stream<Type> _showOther;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
|
Loading…
Reference in New Issue
Block a user