mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-22 16:26:52 +00:00
Add three dot menu to settings. Edit + logout.
This commit is contained in:
parent
cfce189201
commit
316d015d23
@ -330,6 +330,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"lng_settings_language" = "Language";
|
||||
"lng_settings_default_scale" = "Default interface scale";
|
||||
"lng_settings_edit_info" = "Edit information";
|
||||
|
||||
"lng_backgrounds_header" = "Choose your new chat background";
|
||||
"lng_theme_sure_keep" = "Keep this theme?";
|
||||
|
@ -378,11 +378,15 @@ void WrapWidget::createTopBar() {
|
||||
_controller->searchEnabledByContent(),
|
||||
_controller->takeSearchStartsFocused());
|
||||
}
|
||||
if (_controller->section().type() == Section::Type::Profile
|
||||
const auto section = _controller->section();
|
||||
if (section.type() == Section::Type::Profile
|
||||
&& (wrapValue != Wrap::Side || hasStackHistory())) {
|
||||
addProfileMenuButton();
|
||||
addTopBarMenuButton();
|
||||
addProfileCallsButton();
|
||||
// addProfileNotificationsButton();
|
||||
} else if (section.type() == Section::Type::Settings
|
||||
&& section.settingsType() == Section::SettingsType::Main) {
|
||||
addTopBarMenuButton();
|
||||
}
|
||||
|
||||
_topBar->lower();
|
||||
@ -391,7 +395,7 @@ void WrapWidget::createTopBar() {
|
||||
_topBar->show();
|
||||
}
|
||||
|
||||
void WrapWidget::addProfileMenuButton() {
|
||||
void WrapWidget::addTopBarMenuButton() {
|
||||
Expects(_topBar != nullptr);
|
||||
|
||||
_topBarMenuToggle.reset(_topBar->addButton(
|
||||
@ -401,7 +405,7 @@ void WrapWidget::addProfileMenuButton() {
|
||||
? st::infoLayerTopBarMenu
|
||||
: st::infoTopBarMenu))));
|
||||
_topBarMenuToggle->addClickHandler([this] {
|
||||
showProfileMenu();
|
||||
showTopBarMenu();
|
||||
});
|
||||
}
|
||||
|
||||
@ -471,7 +475,7 @@ void WrapWidget::addProfileNotificationsButton() {
|
||||
}, notifications->lifetime());
|
||||
}
|
||||
|
||||
void WrapWidget::showProfileMenu() {
|
||||
void WrapWidget::showTopBarMenu() {
|
||||
if (_topBarMenu) {
|
||||
_topBarMenu->hideAnimated(
|
||||
Ui::InnerDropdown::HideOption::IgnoreShow);
|
||||
@ -515,9 +519,12 @@ void WrapWidget::showProfileMenu() {
|
||||
addAction,
|
||||
Window::PeerMenuSource::Profile);
|
||||
} else if (const auto self = key().settingsSelf()) {
|
||||
// #TODO settings top menu
|
||||
_topBarMenu = nullptr;
|
||||
return;
|
||||
const auto showOther = [=](::Settings::Type type) {
|
||||
const auto controller = _controller.get();
|
||||
_topBarMenu = nullptr;
|
||||
controller->showSettings(type);
|
||||
};
|
||||
::Settings::FillMenu(showOther, addAction);
|
||||
} else {
|
||||
_topBarMenu = nullptr;
|
||||
return;
|
||||
|
@ -191,10 +191,10 @@ private:
|
||||
rpl::producer<SelectedItems> selectedListValue() const;
|
||||
bool requireTopBarSearch() const;
|
||||
|
||||
void addProfileMenuButton();
|
||||
void addTopBarMenuButton();
|
||||
void addProfileCallsButton();
|
||||
void addProfileNotificationsButton();
|
||||
void showProfileMenu();
|
||||
void showTopBarMenu();
|
||||
|
||||
rpl::variable<Wrap> _wrap;
|
||||
std::unique_ptr<Controller> _controller;
|
||||
|
@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_main.h"
|
||||
#include "settings/settings_notifications.h"
|
||||
#include "settings/settings_privacy_security.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@ -38,4 +40,13 @@ object_ptr<Section> CreateSection(
|
||||
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
|
||||
|
@ -48,4 +48,12 @@ object_ptr<Section> CreateSection(
|
||||
not_null<Window::Controller*> controller,
|
||||
UserData *self = nullptr);
|
||||
|
||||
using MenuCallback = Fn<QAction*(
|
||||
const QString &text,
|
||||
Fn<void()> handler)>;
|
||||
|
||||
void FillMenu(
|
||||
Fn<void(Type)> showOther,
|
||||
MenuCallback addAction);
|
||||
|
||||
} // namespace Settings
|
||||
|
Loading…
Reference in New Issue
Block a user