Add three dot menu to settings. Edit + logout.

This commit is contained in:
John Preston 2018-09-06 18:24:24 +03:00
parent cfce189201
commit 316d015d23
5 changed files with 37 additions and 10 deletions

View File

@ -330,6 +330,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_language" = "Language"; "lng_settings_language" = "Language";
"lng_settings_default_scale" = "Default interface scale"; "lng_settings_default_scale" = "Default interface scale";
"lng_settings_edit_info" = "Edit information";
"lng_backgrounds_header" = "Choose your new chat background"; "lng_backgrounds_header" = "Choose your new chat background";
"lng_theme_sure_keep" = "Keep this theme?"; "lng_theme_sure_keep" = "Keep this theme?";

View File

@ -378,11 +378,15 @@ void WrapWidget::createTopBar() {
_controller->searchEnabledByContent(), _controller->searchEnabledByContent(),
_controller->takeSearchStartsFocused()); _controller->takeSearchStartsFocused());
} }
if (_controller->section().type() == Section::Type::Profile const auto section = _controller->section();
if (section.type() == Section::Type::Profile
&& (wrapValue != Wrap::Side || hasStackHistory())) { && (wrapValue != Wrap::Side || hasStackHistory())) {
addProfileMenuButton(); addTopBarMenuButton();
addProfileCallsButton(); addProfileCallsButton();
// addProfileNotificationsButton(); // addProfileNotificationsButton();
} else if (section.type() == Section::Type::Settings
&& section.settingsType() == Section::SettingsType::Main) {
addTopBarMenuButton();
} }
_topBar->lower(); _topBar->lower();
@ -391,7 +395,7 @@ void WrapWidget::createTopBar() {
_topBar->show(); _topBar->show();
} }
void WrapWidget::addProfileMenuButton() { void WrapWidget::addTopBarMenuButton() {
Expects(_topBar != nullptr); Expects(_topBar != nullptr);
_topBarMenuToggle.reset(_topBar->addButton( _topBarMenuToggle.reset(_topBar->addButton(
@ -401,7 +405,7 @@ void WrapWidget::addProfileMenuButton() {
? st::infoLayerTopBarMenu ? st::infoLayerTopBarMenu
: st::infoTopBarMenu)))); : st::infoTopBarMenu))));
_topBarMenuToggle->addClickHandler([this] { _topBarMenuToggle->addClickHandler([this] {
showProfileMenu(); showTopBarMenu();
}); });
} }
@ -471,7 +475,7 @@ void WrapWidget::addProfileNotificationsButton() {
}, notifications->lifetime()); }, notifications->lifetime());
} }
void WrapWidget::showProfileMenu() { void WrapWidget::showTopBarMenu() {
if (_topBarMenu) { if (_topBarMenu) {
_topBarMenu->hideAnimated( _topBarMenu->hideAnimated(
Ui::InnerDropdown::HideOption::IgnoreShow); Ui::InnerDropdown::HideOption::IgnoreShow);
@ -515,9 +519,12 @@ void WrapWidget::showProfileMenu() {
addAction, addAction,
Window::PeerMenuSource::Profile); Window::PeerMenuSource::Profile);
} else if (const auto self = key().settingsSelf()) { } else if (const auto self = key().settingsSelf()) {
// #TODO settings top menu const auto showOther = [=](::Settings::Type type) {
_topBarMenu = nullptr; const auto controller = _controller.get();
return; _topBarMenu = nullptr;
controller->showSettings(type);
};
::Settings::FillMenu(showOther, addAction);
} else { } else {
_topBarMenu = nullptr; _topBarMenu = nullptr;
return; return;

View File

@ -191,10 +191,10 @@ private:
rpl::producer<SelectedItems> selectedListValue() const; rpl::producer<SelectedItems> selectedListValue() const;
bool requireTopBarSearch() const; bool requireTopBarSearch() const;
void addProfileMenuButton(); void addTopBarMenuButton();
void addProfileCallsButton(); void addProfileCallsButton();
void addProfileNotificationsButton(); void addProfileNotificationsButton();
void showProfileMenu(); void showTopBarMenu();
rpl::variable<Wrap> _wrap; rpl::variable<Wrap> _wrap;
std::unique_ptr<Controller> _controller; std::unique_ptr<Controller> _controller;

View File

@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_main.h" #include "settings/settings_main.h"
#include "settings/settings_notifications.h" #include "settings/settings_notifications.h"
#include "settings/settings_privacy_security.h" #include "settings/settings_privacy_security.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
namespace Settings { namespace Settings {
@ -38,4 +40,13 @@ object_ptr<Section> CreateSection(
Unexpected("Settings section type in Widget::createInnerWidget."); Unexpected("Settings section type in Widget::createInnerWidget.");
} }
void FillMenu(Fn<void(Type)> showOther, MenuCallback addAction) {
addAction(
lang(lng_settings_edit_info),
[=] { showOther(Type::Information); });
addAction(
lang(lng_settings_logout),
[=] { App::wnd()->onLogout(); });
}
} // namespace Settings } // namespace Settings

View File

@ -48,4 +48,12 @@ object_ptr<Section> CreateSection(
not_null<Window::Controller*> controller, not_null<Window::Controller*> controller,
UserData *self = nullptr); UserData *self = nullptr);
using MenuCallback = Fn<QAction*(
const QString &text,
Fn<void()> handler)>;
void FillMenu(
Fn<void(Type)> showOther,
MenuCallback addAction);
} // namespace Settings } // namespace Settings