mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Simplified settings of auto-delete.
This commit is contained in:
parent
8d923489d3
commit
320ff9d606
7 changed files with 61 additions and 61 deletions
|
@ -17,9 +17,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_user.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/controls/history_view_ttl_button.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_ttl_validator.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
@ -228,31 +228,22 @@ void DeleteMessagesBox::prepare() {
|
|||
}
|
||||
_text.create(this, rpl::single(std::move(details)), st::boxLabel);
|
||||
|
||||
if (_wipeHistoryJustClear
|
||||
&& _wipeHistoryPeer
|
||||
&& ((_wipeHistoryPeer->isUser()
|
||||
&& !_wipeHistoryPeer->isSelf()
|
||||
&& !_wipeHistoryPeer->isNotificationsUser())
|
||||
|| (_wipeHistoryPeer->isChat()
|
||||
&& _wipeHistoryPeer->asChat()->canDeleteMessages())
|
||||
|| (_wipeHistoryPeer->isChannel()
|
||||
&& _wipeHistoryPeer->asChannel()->canDeleteMessages()))) {
|
||||
_wipeHistoryPeer->updateFull();
|
||||
#if 0
|
||||
_autoDeleteSettings.create(
|
||||
this,
|
||||
(_wipeHistoryPeer->messagesTTL()
|
||||
? tr::lng_edit_auto_delete_settings(tr::now)
|
||||
: tr::lng_enable_auto_delete(tr::now)),
|
||||
st::boxLinkButton);
|
||||
_autoDeleteSettings->setClickedCallback([=] {
|
||||
getDelegate()->show(
|
||||
Box(
|
||||
HistoryView::Controls::AutoDeleteSettingsMenu,
|
||||
_wipeHistoryPeer),
|
||||
Ui::LayerOption(0));
|
||||
});
|
||||
#endif
|
||||
if (_wipeHistoryJustClear && _wipeHistoryPeer) {
|
||||
const auto validator = TTLMenu::TTLValidator(
|
||||
std::make_shared<Ui::BoxShow>(this),
|
||||
_wipeHistoryPeer);
|
||||
if (validator.can()) {
|
||||
_wipeHistoryPeer->updateFull();
|
||||
_autoDeleteSettings.create(
|
||||
this,
|
||||
(_wipeHistoryPeer->messagesTTL()
|
||||
? tr::lng_edit_auto_delete_settings(tr::now)
|
||||
: tr::lng_enable_auto_delete(tr::now)),
|
||||
st::boxLinkButton);
|
||||
_autoDeleteSettings->setClickedCallback([=] {
|
||||
validator.showBox();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (canDelete) {
|
||||
|
|
|
@ -25,15 +25,13 @@ TTLButton::TTLButton(
|
|||
, _button(parent, st::historyMessagesTTL) {
|
||||
|
||||
const auto validator = TTLMenu::TTLValidator(std::move(show), peer);
|
||||
auto clicks = _button.clicks(
|
||||
) | rpl::to_empty | rpl::filter([=] {
|
||||
_button.setClickedCallback([=] {
|
||||
if (!validator.can()) {
|
||||
validator.showToast();
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
validator.showBox();
|
||||
});
|
||||
TTLMenu::SetupTTLMenu(parent, std::move(clicks), validator.createArgs());
|
||||
|
||||
peer->session().changes().peerFlagsValue(
|
||||
peer,
|
||||
|
|
|
@ -9,23 +9,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "base/event_filter.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/boxes/choose_time.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/vertical_drum_picker.h"
|
||||
#if 0
|
||||
#include "ui/boxes/choose_time.h"
|
||||
#include "ui/widgets/menu/menu_action.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/widgets/vertical_drum_picker.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_dialogs.h" // dialogsScamFont
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
#endif
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace TTLMenu {
|
||||
|
||||
namespace {
|
||||
|
||||
#if 0
|
||||
constexpr auto kTTLDurHours1 = crl::time(1);
|
||||
constexpr auto kTTLDurSeconds1 = kTTLDurHours1 * 3600;
|
||||
constexpr auto kTTLDurHours2 = crl::time(24);
|
||||
|
@ -34,6 +37,7 @@ constexpr auto kTTLDurHours3 = crl::time(24 * 7);
|
|||
constexpr auto kTTLDurSeconds3 = kTTLDurHours3 * 3600;
|
||||
constexpr auto kTTLDurHours4 = crl::time(24 * 30);
|
||||
constexpr auto kTTLDurSeconds4 = kTTLDurHours4 * 3600;
|
||||
#endif
|
||||
|
||||
void SetupPickerAndConfirm(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
|
@ -144,6 +148,7 @@ void SetupPickerAndConfirm(
|
|||
});
|
||||
}
|
||||
|
||||
#if 0
|
||||
class IconWithText final : public Ui::Menu::Action {
|
||||
public:
|
||||
using Ui::Menu::Action::Action;
|
||||
|
@ -259,29 +264,27 @@ void TTLBoxOld(
|
|||
});
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
}
|
||||
#endif
|
||||
|
||||
void TTLBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
rpl::producer<QString> &&about,
|
||||
Fn<void(TimeId)> callback,
|
||||
TimeId startTtlPeriod) {
|
||||
} // namespace
|
||||
|
||||
void TTLBox(not_null<Ui::GenericBox*> box, Args args) {
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
std::move(about),
|
||||
std::move(args.about),
|
||||
st::boxLabel));
|
||||
SetupPickerAndConfirm(box, callback, startTtlPeriod);
|
||||
SetupPickerAndConfirm(box, args.callback, args.startTtl);
|
||||
box->setTitle(tr::lng_manage_messages_ttl_title());
|
||||
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
if (startTtlPeriod) {
|
||||
if (args.startTtl) {
|
||||
box->addLeftButton(tr::lng_manage_messages_ttl_disable(), [=] {
|
||||
callback(0);
|
||||
args.callback(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#if 0
|
||||
void FillTTLMenu(not_null<Ui::PopupMenu*> menu, Args args) {
|
||||
const auto &st = menu->st().menu;
|
||||
const auto iconTextPosition = st.itemIconPosition
|
||||
|
@ -306,10 +309,7 @@ void FillTTLMenu(not_null<Ui::PopupMenu*> menu, Args args) {
|
|||
|
||||
menu->addAction(
|
||||
tr::lng_manage_messages_ttl_after_custom(tr::now),
|
||||
[a = args] {
|
||||
a.show->showBox(
|
||||
Box(TTLBox, std::move(a.about), a.callback, a.startTtl));
|
||||
},
|
||||
[a = args] { a.show->showBox(Box(TTLBox, a)); },
|
||||
&st::menuIconCustomize);
|
||||
|
||||
if (args.startTtl) {
|
||||
|
@ -349,5 +349,6 @@ void SetupTTLMenu(
|
|||
state->menu->popup(QCursor::pos());
|
||||
}, parent->lifetime());
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace TTLMenu
|
||||
|
|
|
@ -8,9 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
namespace Ui {
|
||||
#if 0
|
||||
class PopupMenu;
|
||||
class RpWidget;
|
||||
#endif
|
||||
class Show;
|
||||
class GenericBox;
|
||||
} // namespace Ui
|
||||
|
||||
namespace TTLMenu {
|
||||
|
@ -22,11 +25,14 @@ struct Args {
|
|||
Fn<void(TimeId)> callback;
|
||||
};
|
||||
|
||||
void TTLBox(not_null<Ui::GenericBox*> box, Args args);
|
||||
#if 0
|
||||
void FillTTLMenu(not_null<Ui::PopupMenu*> menu, Args args);
|
||||
|
||||
void SetupTTLMenu(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<> triggers,
|
||||
Args args);
|
||||
#endif
|
||||
|
||||
} // namespace TTLMenu
|
||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_ttl.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/layers/show.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
|
@ -101,7 +102,9 @@ Args TTLValidator::createArgs() const {
|
|||
}
|
||||
|
||||
bool TTLValidator::can() const {
|
||||
return _peer->isUser()
|
||||
return (_peer->isUser()
|
||||
&& !_peer->isSelf()
|
||||
&& !_peer->isNotificationsUser())
|
||||
|| (_peer->isChat()
|
||||
&& _peer->asChat()->canDeleteMessages())
|
||||
|| (_peer->isChannel()
|
||||
|
@ -116,4 +119,8 @@ const style::icon *TTLValidator::icon() const {
|
|||
return &st::menuIconTTL;
|
||||
}
|
||||
|
||||
void TTLValidator::showBox() const {
|
||||
_show->showBox(Box(TTLBox, createArgs()));
|
||||
}
|
||||
|
||||
} // namespace TTLMenu
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
std::shared_ptr<Ui::Show> show,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
void showBox() const;
|
||||
[[nodiscard]] bool can() const;
|
||||
[[nodiscard]] Args createArgs() const;
|
||||
void showToast() const;
|
||||
|
|
|
@ -779,14 +779,11 @@ void Filler::addTTLSubmenu(bool addSeparator) {
|
|||
if (!validator.can()) {
|
||||
return;
|
||||
}
|
||||
_addAction(PeerMenuCallback::Args{
|
||||
.text = tr::lng_manage_messages_ttl_menu(tr::now),
|
||||
.handler = nullptr,
|
||||
.icon = validator.icon(),
|
||||
.fillSubmenu = [=](not_null<Ui::PopupMenu*> menu) {
|
||||
TTLMenu::FillTTLMenu(menu, validator.createArgs());
|
||||
},
|
||||
});
|
||||
const auto text = tr::lng_manage_messages_ttl_menu(tr::now)
|
||||
+ (_peer->messagesTTL()
|
||||
? ('\t' + Ui::FormatTTLTiny(_peer->messagesTTL()))
|
||||
: QString());
|
||||
_addAction(text, [=] { validator.showBox(); }, validator.icon());
|
||||
if (addSeparator) {
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
}
|
||||
|
@ -836,7 +833,6 @@ void Filler::fillHistoryActions() {
|
|||
addThemeEdit();
|
||||
addViewDiscussion();
|
||||
addExportChat();
|
||||
addTTLSubmenu(false);
|
||||
addReport();
|
||||
addClearHistory();
|
||||
addDeleteChat();
|
||||
|
@ -844,8 +840,8 @@ void Filler::fillHistoryActions() {
|
|||
}
|
||||
|
||||
void Filler::fillProfileActions() {
|
||||
addSupportInfo();
|
||||
addTTLSubmenu(true);
|
||||
addSupportInfo();
|
||||
addNewContact();
|
||||
addShareContact();
|
||||
addEditContact();
|
||||
|
|
Loading…
Add table
Reference in a new issue