From b79d8d6c82065e1c18d311390dc83d555c19c6d8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 16 Mar 2019 19:59:59 +0300 Subject: [PATCH] Removed Checkbox for Sign Messages and added Toggle Button. - That is how it looks in mobile clients. --- .../boxes/peers/edit_peer_info_box.cpp | 60 +++++++------------ Telegram/SourceFiles/info/info.style | 1 - 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index be01569f6..828a1d535 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -95,12 +95,12 @@ void AddButtonWithCount( &icon); } -void AddButtonWithText( +Info::Profile::Button *AddButtonWithText( not_null parent, rpl::producer &&text, rpl::producer &&label, Fn callback) { - ManagePeerBox::CreateButton( + return ManagePeerBox::CreateButton( parent, std::move(text), std::move(label), @@ -297,12 +297,12 @@ private: Ui::SlideWrap *editInviteLinkWrap = nullptr; Ui::FlatLabel *inviteLink = nullptr; - Ui::Checkbox *signatures = nullptr; - Ui::SlideWrap *historyVisibilityWrap = nullptr; std::optional historyVisibilitySavedValue = std::nullopt; std::optional privacySavedValue = std::nullopt; std::optional usernameSavedValue = std::nullopt; + + std::optional signaturesSavedValue = std::nullopt; }; struct Saving { std::optional username; @@ -321,7 +321,6 @@ private: object_ptr createUsernameEdit(); object_ptr createInviteLinkCreate(); object_ptr createInviteLinkEdit(); - object_ptr createSignaturesEdit(); object_ptr createStickersEdit(); object_ptr createDeleteButton(); @@ -458,7 +457,6 @@ object_ptr Controller::createContent() { _wrap->add(createPrivaciesEdit()); _wrap->add(createInviteLinkCreate()); _wrap->add(createInviteLinkEdit()); - _wrap->add(createSignaturesEdit()); _wrap->add(createStickersEdit()); _wrap->add(createDeleteButton()); @@ -760,6 +758,23 @@ object_ptr Controller::createPrivaciesButtons() { updateType->fire(std::move(defaultValuePrivacy)); refreshHistoryVisibility(); + // Draw Signatures toggle button. + if (!channel + || !channel->canEditSignatures() + || channel->isMegagroup()) { + return std::move(result); + } + AddButtonWithText( + resultContainer, + std::move(Lang::Viewer(lng_edit_sign_messages)), + rpl::single(QString()), + [=] {} + )->toggleOn(rpl::single(channel->addsSignature()) + )->toggledValue( + ) | rpl::start_with_next([=](bool toggled) { + _controls.signaturesSavedValue = toggled; + }, resultContainer->lifetime()); + return std::move(result); } @@ -1192,35 +1207,6 @@ void Controller::refreshHistoryVisibility() { anim::type::normal); } -object_ptr Controller::createSignaturesEdit() { - Expects(_wrap != nullptr); - - auto channel = _peer->asChannel(); - if (!channel - || !channel->canEditSignatures() - || channel->isMegagroup()) { - return nullptr; - } - auto result = object_ptr(_wrap); - auto container = result.data(); - container->add(object_ptr( - container, - st::defaultBoxCheckbox.margin.top())); - _controls.signatures = container->add( - object_ptr>( - container, - object_ptr( - container, - lang(lng_edit_sign_messages), - channel->addsSignature(), - st::defaultBoxCheckbox), - st::editPeerSignaturesMargins))->entity(); - container->add(object_ptr( - container, - st::defaultBoxCheckbox.margin.bottom())); - return std::move(result); -} - object_ptr Controller::createStickersEdit() { Expects(_wrap != nullptr); @@ -1375,10 +1361,10 @@ bool Controller::validateHistoryVisibility(Saving &to) const { } bool Controller::validateSignatures(Saving &to) const { - if (!_controls.signatures) { + if (!_controls.signaturesSavedValue.has_value()) { return true; } - to.signatures = _controls.signatures->checked(); + to.signatures = _controls.signaturesSavedValue; return true; } diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 1bd4bf37e..fdbb06c05 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -684,7 +684,6 @@ editPeerUsernameError: FlatLabel(editPeerUsernameGood) { editPeerUsernamePosition: point(35px, 3px); editPeerInviteLinkSkip: 10px; editPeerInviteLinkMargins: margins(15px, 10px, 14px, 16px); -editPeerSignaturesMargins: margins(23px, 10px, 23px, 16px); editPeerInvitesMargins: margins(23px, 10px, 23px, 16px); editPeerInvitesTopSkip: 10px; editPeerInvitesSkip: 10px;