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