Move calls settings to Settings > Advanced.

Also add calls settings button to the calls list box.
This commit is contained in:
John Preston 2019-01-11 13:04:28 +04:00
parent c4d919d46b
commit 8711830f66
8 changed files with 77 additions and 15 deletions

View File

@ -378,11 +378,14 @@ void AbstractBox::updateButtonsPositions() {
if (_leftButton) {
_leftButton->moveToLeft(right, top);
}
for_const (auto &button, _buttons) {
for (const auto &button : _buttons) {
button->moveToRight(right, top);
right += button->width() + padding.left();
}
}
if (_topButton) {
_topButton->moveToRight(0, 0);
}
}
QPointer<QWidget> AbstractBox::outerContainer() {
@ -403,6 +406,7 @@ void AbstractBox::clearButtons() {
button.destroy();
}
_leftButton.destroy();
_topButton = nullptr;
}
QPointer<Ui::RoundButton> AbstractBox::addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) {
@ -423,6 +427,15 @@ QPointer<Ui::RoundButton> AbstractBox::addLeftButton(Fn<QString()> textFactory,
return result;
}
QPointer<Ui::IconButton> AbstractBox::addTopButton(const style::IconButton &st, Fn<void()> clickCallback) {
_topButton = base::make_unique_q<Ui::IconButton>(this, st);
auto result = QPointer<Ui::IconButton>(_topButton.get());
result->setClickedCallback(std::move(clickCallback));
result->show();
updateButtonsPositions();
return result;
}
void AbstractBox::setDimensions(int newWidth, int maxHeight) {
_maxContentHeight = maxHeight;

View File

@ -8,10 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "window/layer_widget.h"
#include "base/unique_qptr.h"
#include "ui/rp_widget.h"
namespace style {
struct RoundButton;
struct IconButton;
struct ScrollArea;
} // namespace style
@ -35,6 +37,7 @@ public:
virtual void clearButtons() = 0;
virtual QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) = 0;
virtual QPointer<Ui::RoundButton> addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) = 0;
virtual QPointer<Ui::IconButton> addTopButton(const style::IconButton &st, Fn<void()> clickCallback) = 0;
virtual void updateButtonsPositions() = 0;
virtual void showBox(
@ -102,6 +105,9 @@ public:
}
QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback);
QPointer<Ui::RoundButton> addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback);
QPointer<Ui::IconButton> addTopButton(const style::IconButton &st, Fn<void()> clickCallback) {
return getDelegate()->addTopButton(st, std::move(clickCallback));
}
QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) {
return getDelegate()->addButton(std::move(textFactory), std::move(clickCallback), st);
}
@ -251,6 +257,7 @@ public:
void clearButtons() override;
QPointer<Ui::RoundButton> addButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) override;
QPointer<Ui::RoundButton> addLeftButton(Fn<QString()> textFactory, Fn<void()> clickCallback, const style::RoundButton &st) override;
QPointer<Ui::IconButton> addTopButton(const style::IconButton &st, Fn<void()> clickCallback) override;
void updateButtonsPositions() override;
QPointer<QWidget> outerContainer() override;
@ -319,6 +326,7 @@ private:
std::vector<object_ptr<Ui::RoundButton>> _buttons;
object_ptr<Ui::RoundButton> _leftButton = { nullptr };
base::unique_qptr<Ui::IconButton> _topButton = { nullptr };
};

View File

@ -896,3 +896,16 @@ createPollWarning: FlatLabel(defaultFlatLabel) {
}
}
createPollWarningPosition: point(16px, 6px);
callSettingsButton: IconButton {
width: 50px;
height: boxLayerTitleHeight;
icon: icon {{ "menu_settings", boxTitleCloseFg }};
iconOver: icon {{ "menu_settings", boxTitleCloseFgOver }};
iconPosition: point(8px, -1px);
rippleAreaSize: 44px;
rippleAreaPosition: point(0px, 6px);
ripple: RippleAnimation(defaultRippleAnimation) {
color: windowBgOver;
}
}

View File

@ -60,7 +60,6 @@ settingsIconFaq: icon {{ "settings_faq", menuIconFg }};
settingsIconStickers: icon {{ "settings_stickers", menuIconFg }};
settingsIconEmoji: icon {{ "settings_emoji", menuIconFg }};
settingsIconThemes: icon {{ "settings_themes", menuIconFg }};
settingsIconCalls: icon {{ "settings_phone_number", menuIconFg }};
settingsSetPhotoSkip: 7px;

View File

@ -436,11 +436,32 @@ void SetupPerformance(not_null<Ui::VerticalLayout*> container) {
}, container->lifetime());
}
void SetupSystemIntegration(
not_null<Ui::VerticalLayout*> container,
Fn<void(Type)> showOther) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, lng_settings_system_integration);
AddButton(
container,
lng_settings_section_call_settings,
st::settingsButton
)->addClickHandler([=] {
showOther(Type::Calls);
});
SetupTray(container);
AddSkip(container);
}
Advanced::Advanced(QWidget *parent, UserData *self)
: Section(parent) {
setupContent();
}
rpl::producer<Type> Advanced::sectionShowOther() {
return _showOther.events();
}
void Advanced::setupContent() {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
@ -473,18 +494,16 @@ void Advanced::setupContent() {
}
SetupDataStorage(content);
SetupAutoDownload(content);
if (HasTray()) {
addDivider();
AddSkip(content);
AddSubsectionTitle(content, lng_settings_system_integration);
SetupTray(content);
AddSkip(content);
}
addDivider();
SetupSystemIntegration(content, [=](Type type) {
_showOther.fire_copy(type);
});
AddDivider(content);
AddSkip(content);
AddSubsectionTitle(content, lng_settings_performance);
SetupPerformance(content);
AddSkip(content);
if (cAutoUpdate()) {
addUpdate();
}

View File

@ -23,9 +23,13 @@ class Advanced : public Section {
public:
explicit Advanced(QWidget *parent, UserData *self = nullptr);
rpl::producer<Type> sectionShowOther() override;
private:
void setupContent();
rpl::event_stream<Type> _showOther;
};
} // namespace Settings

View File

@ -87,10 +87,6 @@ void SetupSections(
lng_settings_section_chat_settings,
Type::Chat,
&st::settingsIconChat);
addSection(
lng_settings_section_call_settings,
Type::Calls,
&st::settingsIconCalls);
addSection(
lng_settings_advanced,
Type::Advanced,

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_main_menu.h"
#include "window/themes/window_theme.h"
#include "window/window_controller.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/menu.h"
@ -16,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "storage/localstorage.h"
#include "support/support_templates.h"
#include "settings/settings_common.h"
#include "boxes/about_box.h"
#include "boxes/peer_list_controllers.h"
#include "calls/calls_box_controller.h"
@ -27,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_window.h"
#include "styles/style_dialogs.h"
#include "styles/style_settings.h"
#include "styles/style_boxes.h"
namespace Window {
namespace {
@ -193,7 +196,14 @@ void MainMenu::refreshMenu() {
if (Global::PhoneCallsEnabled()) {
_menu->addAction(lang(lng_menu_calls), [] {
Ui::show(Box<PeerListBox>(std::make_unique<Calls::BoxController>(), [](not_null<PeerListBox*> box) {
box->addButton(langFactory(lng_close), [box] { box->closeBox(); });
box->addButton(langFactory(lng_close), [=] {
box->closeBox();
});
box->addTopButton(st::callSettingsButton, [=] {
App::wnd()->controller()->showSettings(
Settings::Type::Calls,
Window::SectionShow(anim::type::instant));
});
}));
}, &st::mainMenuCalls, &st::mainMenuCallsOver);
}