Added ability to set auto-delete from profile info.
|
@ -898,6 +898,8 @@ PRIVATE
|
||||||
menu/menu_mute.h
|
menu/menu_mute.h
|
||||||
menu/menu_send.cpp
|
menu/menu_send.cpp
|
||||||
menu/menu_send.h
|
menu/menu_send.h
|
||||||
|
menu/menu_ttl_validator.cpp
|
||||||
|
menu/menu_ttl_validator.h
|
||||||
mtproto/config_loader.cpp
|
mtproto/config_loader.cpp
|
||||||
mtproto/config_loader.h
|
mtproto/config_loader.h
|
||||||
mtproto/connection_abstract.cpp
|
mtproto/connection_abstract.cpp
|
||||||
|
|
BIN
Telegram/Resources/icons/chat/input_autodelete.png
Normal file
After Width: | Height: | Size: 667 B |
BIN
Telegram/Resources/icons/chat/input_autodelete@2x.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
Telegram/Resources/icons/chat/input_autodelete@3x.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 860 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 840 B |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 878 B |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.6 KiB |
|
@ -1123,7 +1123,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_manage_history_visibility_hidden_legacy" = "New members won't see more than 100 previous messages.";
|
"lng_manage_history_visibility_hidden_legacy" = "New members won't see more than 100 previous messages.";
|
||||||
|
|
||||||
"lng_manage_messages_ttl_title" = "Auto-delete after...";
|
"lng_manage_messages_ttl_title" = "Auto-delete after...";
|
||||||
"lng_manage_messages_ttl_never" = "Disable";
|
"lng_manage_messages_ttl_disable" = "Disable";
|
||||||
"lng_manage_messages_ttl_after1" = "1 hour";
|
"lng_manage_messages_ttl_after1" = "1 hour";
|
||||||
"lng_manage_messages_ttl_after2" = "1 day";
|
"lng_manage_messages_ttl_after2" = "1 day";
|
||||||
"lng_manage_messages_ttl_after3" = "1 week";
|
"lng_manage_messages_ttl_after3" = "1 week";
|
||||||
|
|
|
@ -7,102 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "history/view/controls/history_view_ttl_button.h"
|
#include "history/view/controls/history_view_ttl_button.h"
|
||||||
|
|
||||||
#include "data/data_peer.h"
|
|
||||||
#include "data/data_chat.h"
|
|
||||||
#include "data/data_channel.h"
|
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_peer.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "menu/menu_ttl.h"
|
#include "menu/menu_ttl_validator.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "boxes/peers/edit_peer_info_box.h"
|
|
||||||
#include "ui/boxes/auto_delete_settings.h"
|
|
||||||
#include "ui/toast/toast.h"
|
|
||||||
#include "ui/toasts/common_toasts.h"
|
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "apiwrap.h"
|
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
namespace HistoryView::Controls {
|
namespace HistoryView::Controls {
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr auto kToastDuration = crl::time(3500);
|
|
||||||
|
|
||||||
void ShowAutoDeleteToast(
|
|
||||||
not_null<QWidget*> parent,
|
|
||||||
not_null<PeerData*> peer) {
|
|
||||||
const auto period = peer->messagesTTL();
|
|
||||||
if (!period) {
|
|
||||||
Ui::Toast::Show(parent, tr::lng_ttl_about_tooltip_off(tr::now));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto duration = (period == 5)
|
|
||||||
? u"5 seconds"_q
|
|
||||||
: (period < 2 * 86400)
|
|
||||||
? tr::lng_ttl_about_duration1(tr::now)
|
|
||||||
: (period < 8 * 86400)
|
|
||||||
? tr::lng_ttl_about_duration2(tr::now)
|
|
||||||
: tr::lng_ttl_about_duration3(tr::now);
|
|
||||||
const auto text = peer->isBroadcast()
|
|
||||||
? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration)
|
|
||||||
: tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration);
|
|
||||||
Ui::ShowMultilineToast({
|
|
||||||
.parentOverride = parent,
|
|
||||||
.text = { text },
|
|
||||||
.duration = kToastDuration,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void AutoDeleteSettingsMenu(
|
|
||||||
not_null<Ui::RpWidget*> parent,
|
|
||||||
std::shared_ptr<Ui::Show> show,
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
rpl::producer<> triggers) {
|
|
||||||
struct State {
|
|
||||||
TimeId savingPeriod = 0;
|
|
||||||
mtpRequestId savingRequestId = 0;
|
|
||||||
QPointer<Ui::RpWidget> weak;
|
|
||||||
};
|
|
||||||
const auto state = std::make_shared<State>(State{
|
|
||||||
.weak = Ui::MakeWeak(parent.get()),
|
|
||||||
});
|
|
||||||
auto callback = [=](TimeId period) {
|
|
||||||
auto &api = peer->session().api();
|
|
||||||
if (state->savingRequestId) {
|
|
||||||
if (period == state->savingPeriod) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
api.request(state->savingRequestId).cancel();
|
|
||||||
}
|
|
||||||
state->savingPeriod = period;
|
|
||||||
state->savingRequestId = api.request(MTPmessages_SetHistoryTTL(
|
|
||||||
peer->input,
|
|
||||||
MTP_int(period)
|
|
||||||
)).done([=](const MTPUpdates &result) {
|
|
||||||
peer->session().api().applyUpdates(result);
|
|
||||||
ShowAutoDeleteToast(show->toastParent(), peer);
|
|
||||||
#if 0
|
|
||||||
if (const auto strong = state->weak.data()) {
|
|
||||||
strong->closeBox();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}).fail([=] {
|
|
||||||
state->savingRequestId = 0;
|
|
||||||
}).send();
|
|
||||||
};
|
|
||||||
auto about = peer->isUser()
|
|
||||||
? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName()))
|
|
||||||
: peer->isBroadcast()
|
|
||||||
? tr::lng_ttl_edit_about_channel()
|
|
||||||
: tr::lng_ttl_edit_about_group();
|
|
||||||
const auto ttl = peer->messagesTTL();
|
|
||||||
TTLMenu::SetupTTLMenu(
|
|
||||||
parent,
|
|
||||||
std::move(triggers),
|
|
||||||
{ std::move(show), ttl, std::move(about), std::move(callback) });
|
|
||||||
}
|
|
||||||
|
|
||||||
TTLButton::TTLButton(
|
TTLButton::TTLButton(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
@ -110,37 +23,23 @@ TTLButton::TTLButton(
|
||||||
not_null<PeerData*> peer)
|
not_null<PeerData*> peer)
|
||||||
: _peer(peer)
|
: _peer(peer)
|
||||||
, _button(parent, st::historyMessagesTTL) {
|
, _button(parent, st::historyMessagesTTL) {
|
||||||
auto triggers = _button.clicks(
|
|
||||||
|
const auto validator = TTLMenu::TTLValidator(std::move(show), peer);
|
||||||
|
auto clicks = _button.clicks(
|
||||||
) | rpl::to_empty | rpl::filter([=] {
|
) | rpl::to_empty | rpl::filter([=] {
|
||||||
const auto canEdit = peer->isUser()
|
if (!validator.can()) {
|
||||||
|| (peer->isChat()
|
validator.showToast();
|
||||||
&& peer->asChat()->canDeleteMessages())
|
|
||||||
|| (peer->isChannel()
|
|
||||||
&& peer->asChannel()->canDeleteMessages());
|
|
||||||
if (!canEdit) {
|
|
||||||
ShowAutoDeleteToast(show->toastParent(), peer);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
AutoDeleteSettingsMenu(parent, show, peer, std::move(triggers));
|
TTLMenu::SetupTTLMenu(parent, std::move(clicks), validator.createArgs());
|
||||||
|
|
||||||
peer->session().changes().peerFlagsValue(
|
peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
Data::PeerUpdate::Flag::MessagesTTL
|
Data::PeerUpdate::Flag::MessagesTTL
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
const auto ttl = peer->messagesTTL();
|
_button.setText(Ui::FormatTTLTiny(peer->messagesTTL()));
|
||||||
if (ttl < 2 * 86400) {
|
|
||||||
_button.setIconOverride(nullptr, nullptr);
|
|
||||||
} else if (ttl < 8 * 86400) {
|
|
||||||
_button.setIconOverride(
|
|
||||||
&st::historyMessagesTTL2Icon,
|
|
||||||
&st::historyMessagesTTL2IconOver);
|
|
||||||
} else {
|
|
||||||
_button.setIconOverride(
|
|
||||||
&st::historyMessagesTTL3Icon,
|
|
||||||
&st::historyMessagesTTL3IconOver);
|
|
||||||
}
|
|
||||||
}, _button.lifetime());
|
}, _button.lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/icon_button_with_text.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Show;
|
class Show;
|
||||||
|
@ -15,12 +15,6 @@ class Show;
|
||||||
|
|
||||||
namespace HistoryView::Controls {
|
namespace HistoryView::Controls {
|
||||||
|
|
||||||
void AutoDeleteSettingsMenu(
|
|
||||||
not_null<Ui::RpWidget*> parent,
|
|
||||||
std::shared_ptr<Ui::Show> show,
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
rpl::producer<> triggers);
|
|
||||||
|
|
||||||
class TTLButton final {
|
class TTLButton final {
|
||||||
public:
|
public:
|
||||||
TTLButton(
|
TTLButton(
|
||||||
|
@ -40,7 +34,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const not_null<PeerData*> _peer;
|
const not_null<PeerData*> _peer;
|
||||||
Ui::IconButton _button;
|
Ui::IconButtonWithText _button;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "styles/style_chat.h" // popupMenuExpandedSeparator
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_profile.h"
|
#include "styles/style_profile.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
@ -494,7 +495,7 @@ void WrapWidget::showTopBarMenu() {
|
||||||
}
|
}
|
||||||
_topBarMenu = base::make_unique_q<Ui::PopupMenu>(
|
_topBarMenu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
this,
|
this,
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuExpandedSeparator);
|
||||||
|
|
||||||
_topBarMenu->setDestroyedCallback([this] {
|
_topBarMenu->setDestroyedCallback([this] {
|
||||||
InvokeQueued(this, [this] { _topBarMenu = nullptr; });
|
InvokeQueued(this, [this] { _topBarMenu = nullptr; });
|
||||||
|
@ -506,6 +507,19 @@ void WrapWidget::showTopBarMenu() {
|
||||||
|
|
||||||
const auto addAction = Window::PeerMenuCallback([=](
|
const auto addAction = Window::PeerMenuCallback([=](
|
||||||
Window::PeerMenuCallback::Args a) {
|
Window::PeerMenuCallback::Args a) {
|
||||||
|
if (a.isSeparator) {
|
||||||
|
return _topBarMenu->addSeparator();
|
||||||
|
} else if (a.fillSubmenu) {
|
||||||
|
const auto action = _topBarMenu->addAction(
|
||||||
|
a.text,
|
||||||
|
std::move(a.handler),
|
||||||
|
a.icon);
|
||||||
|
// Dummy menu.
|
||||||
|
action->setMenu(
|
||||||
|
Ui::CreateChild<QMenu>(_topBarMenu->menu().get()));
|
||||||
|
a.fillSubmenu(_topBarMenu->ensureSubmenu(action));
|
||||||
|
return action;
|
||||||
|
}
|
||||||
return _topBarMenu->addAction(a.text, std::move(a.handler), a.icon);
|
return _topBarMenu->addAction(a.text, std::move(a.handler), a.icon);
|
||||||
});
|
});
|
||||||
if (key().isDownloads()) {
|
if (key().isDownloads()) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ void TTLBox(
|
||||||
) | rpl::map([=](int seconds) {
|
) | rpl::map([=](int seconds) {
|
||||||
state->lastSeconds = seconds;
|
state->lastSeconds = seconds;
|
||||||
return !seconds
|
return !seconds
|
||||||
? tr::lng_manage_messages_ttl_never()
|
? tr::lng_manage_messages_ttl_disable()
|
||||||
: tr::lng_enable_auto_delete();
|
: tr::lng_enable_auto_delete();
|
||||||
}) | rpl::flatten_latest();
|
}) | rpl::flatten_latest();
|
||||||
const auto confirm = box->addButton(std::move(confirmText), [=] {
|
const auto confirm = box->addButton(std::move(confirmText), [=] {
|
||||||
|
@ -178,7 +178,7 @@ void FillTTLMenu(not_null<Ui::PopupMenu*> menu, Args args) {
|
||||||
|
|
||||||
if (args.startTtl) {
|
if (args.startTtl) {
|
||||||
const auto disable = menu->addAction(
|
const auto disable = menu->addAction(
|
||||||
tr::lng_manage_messages_ttl_never(tr::now),
|
tr::lng_manage_messages_ttl_disable(tr::now),
|
||||||
[=] { args.callback(0); },
|
[=] { args.callback(0); },
|
||||||
&st::menuIconDisableAttention);
|
&st::menuIconDisableAttention);
|
||||||
disable->setData(st::menuIconAttentionColor->c);
|
disable->setData(st::menuIconAttentionColor->c);
|
||||||
|
|
122
Telegram/SourceFiles/menu/menu_ttl_validator.cpp
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "menu/menu_ttl_validator.h"
|
||||||
|
|
||||||
|
#include "apiwrap.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_peer.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "menu/menu_ttl.h"
|
||||||
|
#include "ui/layers/show.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
|
#include "styles/style_chat.h"
|
||||||
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
|
namespace TTLMenu {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kToastDuration = crl::time(3500);
|
||||||
|
|
||||||
|
void ShowAutoDeleteToast(
|
||||||
|
not_null<QWidget*> parent,
|
||||||
|
not_null<PeerData*> peer) {
|
||||||
|
const auto period = peer->messagesTTL();
|
||||||
|
if (!period) {
|
||||||
|
Ui::Toast::Show(parent, tr::lng_ttl_about_tooltip_off(tr::now));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto duration = (period == 5)
|
||||||
|
? u"5 seconds"_q
|
||||||
|
: (period < 2 * 86400)
|
||||||
|
? tr::lng_ttl_about_duration1(tr::now)
|
||||||
|
: (period < 8 * 86400)
|
||||||
|
? tr::lng_ttl_about_duration2(tr::now)
|
||||||
|
: tr::lng_ttl_about_duration3(tr::now);
|
||||||
|
const auto text = peer->isBroadcast()
|
||||||
|
? tr::lng_ttl_about_tooltip_channel(tr::now, lt_duration, duration)
|
||||||
|
: tr::lng_ttl_about_tooltip(tr::now, lt_duration, duration);
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.parentOverride = parent,
|
||||||
|
.text = { text },
|
||||||
|
.duration = kToastDuration,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
TTLValidator::TTLValidator(
|
||||||
|
std::shared_ptr<Ui::Show> show,
|
||||||
|
not_null<PeerData*> peer)
|
||||||
|
: _peer(peer)
|
||||||
|
, _show(std::move(show)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Args TTLValidator::createArgs() const {
|
||||||
|
const auto peer = _peer;
|
||||||
|
const auto show = _show;
|
||||||
|
struct State {
|
||||||
|
TimeId savingPeriod = 0;
|
||||||
|
mtpRequestId savingRequestId = 0;
|
||||||
|
};
|
||||||
|
const auto state = std::make_shared<State>();
|
||||||
|
auto callback = [=, toastParent = show->toastParent()](TimeId period) {
|
||||||
|
auto &api = peer->session().api();
|
||||||
|
if (state->savingRequestId) {
|
||||||
|
if (period == state->savingPeriod) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
api.request(state->savingRequestId).cancel();
|
||||||
|
}
|
||||||
|
state->savingPeriod = period;
|
||||||
|
state->savingRequestId = api.request(MTPmessages_SetHistoryTTL(
|
||||||
|
peer->input,
|
||||||
|
MTP_int(period)
|
||||||
|
)).done([=](const MTPUpdates &result) {
|
||||||
|
peer->session().api().applyUpdates(result);
|
||||||
|
ShowAutoDeleteToast(toastParent, peer);
|
||||||
|
state->savingRequestId = 0;
|
||||||
|
#if 0
|
||||||
|
if (const auto strong = state->weak.data()) {
|
||||||
|
strong->closeBox();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}).fail([=] {
|
||||||
|
state->savingRequestId = 0;
|
||||||
|
}).send();
|
||||||
|
};
|
||||||
|
auto about = peer->isUser()
|
||||||
|
? tr::lng_ttl_edit_about(lt_user, rpl::single(peer->shortName()))
|
||||||
|
: peer->isBroadcast()
|
||||||
|
? tr::lng_ttl_edit_about_channel()
|
||||||
|
: tr::lng_ttl_edit_about_group();
|
||||||
|
const auto ttl = peer->messagesTTL();
|
||||||
|
return { std::move(show), ttl, std::move(about), std::move(callback) };
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TTLValidator::can() const {
|
||||||
|
return _peer->isUser()
|
||||||
|
|| (_peer->isChat()
|
||||||
|
&& _peer->asChat()->canDeleteMessages())
|
||||||
|
|| (_peer->isChannel()
|
||||||
|
&& _peer->asChannel()->canDeleteMessages());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTLValidator::showToast() const {
|
||||||
|
ShowAutoDeleteToast(_show->toastParent(), _peer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const style::icon *TTLValidator::icon() const {
|
||||||
|
return &st::menuIconTTL;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TTLMenu
|
38
Telegram/SourceFiles/menu/menu_ttl_validator.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "menu/menu_ttl.h"
|
||||||
|
|
||||||
|
class PeerData;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Show;
|
||||||
|
class RpWidget;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace TTLMenu {
|
||||||
|
|
||||||
|
class TTLValidator final {
|
||||||
|
public:
|
||||||
|
TTLValidator(
|
||||||
|
std::shared_ptr<Ui::Show> show,
|
||||||
|
not_null<PeerData*> peer);
|
||||||
|
|
||||||
|
[[nodiscard]] bool can() const;
|
||||||
|
[[nodiscard]] Args createArgs() const;
|
||||||
|
void showToast() const;
|
||||||
|
const style::icon *icon() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const not_null<PeerData*> _peer;
|
||||||
|
const std::shared_ptr<Ui::Show> _show;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace TTLMenu
|
|
@ -200,7 +200,7 @@ void AutoDeleteSettingsBox(
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto options = std::vector<QString>{
|
const auto options = std::vector<QString>{
|
||||||
tr::lng_manage_messages_ttl_never(tr::now),
|
tr::lng_manage_messages_ttl_disable(tr::now),
|
||||||
//u"5 seconds"_q, AssertIsDebug()
|
//u"5 seconds"_q, AssertIsDebug()
|
||||||
tr::lng_manage_messages_ttl_after1(tr::now),
|
tr::lng_manage_messages_ttl_after1(tr::now),
|
||||||
tr::lng_manage_messages_ttl_after2(tr::now),
|
tr::lng_manage_messages_ttl_after2(tr::now),
|
||||||
|
|
|
@ -311,14 +311,17 @@ historyAttachEmoji: IconButton(historyAttach) {
|
||||||
icon: icon {{ "chat/input_smile_face", historyComposeIconFg }};
|
icon: icon {{ "chat/input_smile_face", historyComposeIconFg }};
|
||||||
iconOver: icon {{ "chat/input_smile_face", historyComposeIconFgOver }};
|
iconOver: icon {{ "chat/input_smile_face", historyComposeIconFgOver }};
|
||||||
}
|
}
|
||||||
historyMessagesTTL: IconButton(historyAttach) {
|
historyMessagesTTL: IconButtonWithText {
|
||||||
icon: icon {{ "chat/input_autodelete_1d", historyComposeIconFg }};
|
iconButton: IconButton(historyAttach) {
|
||||||
iconOver: icon {{ "chat/input_autodelete_1d", historyComposeIconFgOver }};
|
icon: icon {{ "chat/input_autodelete", historyComposeIconFg }};
|
||||||
|
iconOver: icon {{ "chat/input_autodelete", historyComposeIconFgOver }};
|
||||||
|
}
|
||||||
|
textFg: historyComposeIconFg;
|
||||||
|
textFgOver: historyComposeIconFgOver;
|
||||||
|
textPadding: margins(16px, 20px, 6px, 7px);
|
||||||
|
|
||||||
|
font: font(10px semibold);
|
||||||
}
|
}
|
||||||
historyMessagesTTL2Icon: icon {{ "chat/input_autodelete_7d", historyComposeIconFg }};
|
|
||||||
historyMessagesTTL2IconOver: icon {{ "chat/input_autodelete_7d", historyComposeIconFgOver }};
|
|
||||||
historyMessagesTTL3Icon: icon {{ "chat/input_autodelete_30d", historyComposeIconFg }};
|
|
||||||
historyMessagesTTL3IconOver: icon {{ "chat/input_autodelete_30d", historyComposeIconFgOver }};
|
|
||||||
historyMessagesTTLLabel: FlatLabel(defaultFlatLabel) {
|
historyMessagesTTLLabel: FlatLabel(defaultFlatLabel) {
|
||||||
minWidth: 200px;
|
minWidth: 200px;
|
||||||
align: align(topleft);
|
align: align(topleft);
|
||||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "menu/menu_mute.h"
|
#include "menu/menu_mute.h"
|
||||||
|
#include "menu/menu_ttl_validator.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -191,6 +192,7 @@ private:
|
||||||
void addBotToGroup();
|
void addBotToGroup();
|
||||||
void addNewMembers();
|
void addNewMembers();
|
||||||
void addDeleteContact();
|
void addDeleteContact();
|
||||||
|
void addTTLSubmenu(bool addSeparator);
|
||||||
|
|
||||||
not_null<SessionController*> _controller;
|
not_null<SessionController*> _controller;
|
||||||
Dialogs::EntryState _request;
|
Dialogs::EntryState _request;
|
||||||
|
@ -764,6 +766,26 @@ void Filler::addThemeEdit() {
|
||||||
&st::menuIconChangeColors);
|
&st::menuIconChangeColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Filler::addTTLSubmenu(bool addSeparator) {
|
||||||
|
const auto validator = TTLMenu::TTLValidator(
|
||||||
|
std::make_shared<Window::Show>(_controller),
|
||||||
|
_peer);
|
||||||
|
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());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (addSeparator) {
|
||||||
|
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Filler::fill() {
|
void Filler::fill() {
|
||||||
if (_folder) {
|
if (_folder) {
|
||||||
fillArchiveActions();
|
fillArchiveActions();
|
||||||
|
@ -808,6 +830,7 @@ void Filler::fillHistoryActions() {
|
||||||
addThemeEdit();
|
addThemeEdit();
|
||||||
addViewDiscussion();
|
addViewDiscussion();
|
||||||
addExportChat();
|
addExportChat();
|
||||||
|
addTTLSubmenu(false);
|
||||||
addReport();
|
addReport();
|
||||||
addClearHistory();
|
addClearHistory();
|
||||||
addDeleteChat();
|
addDeleteChat();
|
||||||
|
@ -816,6 +839,7 @@ void Filler::fillHistoryActions() {
|
||||||
|
|
||||||
void Filler::fillProfileActions() {
|
void Filler::fillProfileActions() {
|
||||||
addSupportInfo();
|
addSupportInfo();
|
||||||
|
addTTLSubmenu(true);
|
||||||
addNewContact();
|
addNewContact();
|
||||||
addShareContact();
|
addShareContact();
|
||||||
addEditContact();
|
addEditContact();
|
||||||
|
|