From a89ad5d0fb94322056c68994e7bf252a83ba470a Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 20 Jun 2018 17:41:59 +0100 Subject: [PATCH] Add export my data button in Settings. --- Telegram/Resources/langs/lang.strings | 1 + .../settings/settings_privacy_widget.cpp | 13 ++++++++++++- .../SourceFiles/settings/settings_privacy_widget.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index d9e3dde2b2..a886159566 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -469,6 +469,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_calls_privacy" = "Phone calls privacy"; "lng_settings_groups_invite_privacy" = "Group invite settings"; "lng_settings_show_sessions" = "Show all sessions"; +"lng_settings_export_data" = "Export all my data"; "lng_settings_self_destruct" = "Account self-destruct settings"; "lng_settings_change_phone" = "Change phone number"; diff --git a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp index de762564cb..6651c2a643 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp @@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_settings.h" #include "lang/lang_keys.h" #include "application.h" +#include "auth_session.h" +#include "data/data_session.h" #include "platform/platform_specific.h" #include "base/openssl_help.h" #include "boxes/sessions_box.h" @@ -234,8 +236,9 @@ void PrivacyWidget::createControls() { _autoLock->hide(anim::type::instant); } createChildRow(_cloudPasswordState, marginSmall); - createChildRow(_showAllSessions, marginSmall, lang(lng_settings_show_sessions), SLOT(onShowSessions())); createChildRow(_selfDestruction, marginSmall, lang(lng_settings_self_destruct), SLOT(onSelfDestruction())); + createChildRow(_showAllSessions, marginSmall, lang(lng_settings_show_sessions), SLOT(onShowSessions())); + createChildRow(_exportData, marginSmall, lang(lng_settings_export_data), SLOT(onExportData())); } void PrivacyWidget::autoLockUpdated() { @@ -280,4 +283,12 @@ void PrivacyWidget::onSelfDestruction() { Ui::show(Box()); } +void PrivacyWidget::onExportData() { + Ui::hideSettingsAndLayer(); + App::CallDelayed( + st::boxDuration, + &Auth(), + [] { Auth().data().startExport(); }); +} + } // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_privacy_widget.h b/Telegram/SourceFiles/settings/settings_privacy_widget.h index b0a070be52..59e840e988 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_widget.h +++ b/Telegram/SourceFiles/settings/settings_privacy_widget.h @@ -87,6 +87,7 @@ private slots: void onAutoLock(); void onShowSessions(); void onSelfDestruction(); + void onExportData(); private: static QString GetAutoLockText(); @@ -103,6 +104,7 @@ private: CloudPasswordState *_cloudPasswordState = nullptr; Ui::LinkButton *_showAllSessions = nullptr; Ui::LinkButton *_selfDestruction = nullptr; + Ui::LinkButton *_exportData = nullptr; };