mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-01 23:00:58 +00:00
Elide 'Delete for {user}' checkbox text.
This commit is contained in:
parent
7705696d54
commit
9f76be9d26
Telegram/SourceFiles/boxes
@ -431,8 +431,12 @@ bool PinMessageBox::pinFail(const RPCError &error) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteMessagesBox::DeleteMessagesBox(QWidget*, HistoryItem *item, bool suggestModerateActions) : _singleItem(true) {
|
DeleteMessagesBox::DeleteMessagesBox(
|
||||||
_ids.push_back(item->fullId());
|
QWidget*,
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
bool suggestModerateActions)
|
||||||
|
: _ids(1, item->fullId())
|
||||||
|
, _singleItem(true) {
|
||||||
if (suggestModerateActions) {
|
if (suggestModerateActions) {
|
||||||
_moderateBan = item->suggestBanReport();
|
_moderateBan = item->suggestBanReport();
|
||||||
_moderateDeleteAll = item->suggestDeleteAllReport();
|
_moderateDeleteAll = item->suggestDeleteAllReport();
|
||||||
@ -443,13 +447,21 @@ DeleteMessagesBox::DeleteMessagesBox(QWidget*, HistoryItem *item, bool suggestMo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteMessagesBox::DeleteMessagesBox(QWidget*, const SelectedItemSet &selected) {
|
DeleteMessagesBox::DeleteMessagesBox(
|
||||||
auto count = selected.size();
|
QWidget*,
|
||||||
Assert(count > 0);
|
const SelectedItemSet &selected)
|
||||||
_ids.reserve(count);
|
: _ids(CollectFrom(selected)) {
|
||||||
for_const (auto item, selected) {
|
Expects(!_ids.empty());
|
||||||
_ids.push_back(item->fullId());
|
}
|
||||||
}
|
|
||||||
|
std::vector<FullMsgId> DeleteMessagesBox::CollectFrom(
|
||||||
|
const SelectedItemSet &items) {
|
||||||
|
return ranges::make_range(
|
||||||
|
items.begin(),
|
||||||
|
items.end()
|
||||||
|
) | ranges::view::transform([](not_null<HistoryItem*> item) {
|
||||||
|
return item->fullId();
|
||||||
|
}) | ranges::to_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteMessagesBox::prepare() {
|
void DeleteMessagesBox::prepare() {
|
||||||
@ -471,8 +483,8 @@ void DeleteMessagesBox::prepare() {
|
|||||||
auto deleteForUser = (UserData*)nullptr;
|
auto deleteForUser = (UserData*)nullptr;
|
||||||
auto peer = (PeerData*)nullptr;
|
auto peer = (PeerData*)nullptr;
|
||||||
auto forEveryoneText = lang(lng_delete_for_everyone_check);
|
auto forEveryoneText = lang(lng_delete_for_everyone_check);
|
||||||
for_const (auto fullId, _ids) {
|
for (const auto fullId : std::as_const(_ids)) {
|
||||||
if (auto item = App::histItemById(fullId)) {
|
if (const auto item = App::histItemById(fullId)) {
|
||||||
peer = item->history()->peer;
|
peer = item->history()->peer;
|
||||||
if (!item->canDeleteForEveryone(now)) {
|
if (!item->canDeleteForEveryone(now)) {
|
||||||
canDeleteAllForEveryone = false;
|
canDeleteAllForEveryone = false;
|
||||||
@ -480,7 +492,9 @@ void DeleteMessagesBox::prepare() {
|
|||||||
} else if (auto user = item->history()->peer->asUser()) {
|
} else if (auto user = item->history()->peer->asUser()) {
|
||||||
if (!deleteForUser || deleteForUser == user) {
|
if (!deleteForUser || deleteForUser == user) {
|
||||||
deleteForUser = user;
|
deleteForUser = user;
|
||||||
forEveryoneText = lng_delete_for_other_check(lt_user, user->firstName);
|
forEveryoneText = lng_delete_for_other_check(
|
||||||
|
lt_user,
|
||||||
|
user->firstName);
|
||||||
} else {
|
} else {
|
||||||
forEveryoneText = lang(lng_delete_for_everyone_check);
|
forEveryoneText = lang(lng_delete_for_everyone_check);
|
||||||
}
|
}
|
||||||
@ -489,7 +503,7 @@ void DeleteMessagesBox::prepare() {
|
|||||||
canDeleteAllForEveryone = false;
|
canDeleteAllForEveryone = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto count = qMax(1, _ids.size());
|
auto count = int(_ids.size());
|
||||||
if (canDeleteAllForEveryone) {
|
if (canDeleteAllForEveryone) {
|
||||||
_forEveryone.create(this, forEveryoneText, false, st::defaultBoxCheckbox);
|
_forEveryone.create(this, forEveryoneText, false, st::defaultBoxCheckbox);
|
||||||
} else if (peer && peer->isChannel()) {
|
} else if (peer && peer->isChannel()) {
|
||||||
@ -525,6 +539,7 @@ void DeleteMessagesBox::prepare() {
|
|||||||
|
|
||||||
void DeleteMessagesBox::resizeEvent(QResizeEvent *e) {
|
void DeleteMessagesBox::resizeEvent(QResizeEvent *e) {
|
||||||
BoxContent::resizeEvent(e);
|
BoxContent::resizeEvent(e);
|
||||||
|
|
||||||
_text->moveToLeft(st::boxPadding.left(), st::boxPadding.top());
|
_text->moveToLeft(st::boxPadding.left(), st::boxPadding.top());
|
||||||
if (_moderateFrom) {
|
if (_moderateFrom) {
|
||||||
auto top = _text->bottomNoMargins() + st::boxMediumSkip;
|
auto top = _text->bottomNoMargins() + st::boxMediumSkip;
|
||||||
@ -538,6 +553,8 @@ void DeleteMessagesBox::resizeEvent(QResizeEvent *e) {
|
|||||||
_deleteAll->moveToLeft(st::boxPadding.left(), top);
|
_deleteAll->moveToLeft(st::boxPadding.left(), top);
|
||||||
}
|
}
|
||||||
} else if (_forEveryone) {
|
} else if (_forEveryone) {
|
||||||
|
auto availableWidth = width() - 2 * st::boxPadding.left();
|
||||||
|
_forEveryone->resizeToNaturalWidth(availableWidth);
|
||||||
_forEveryone->moveToLeft(st::boxPadding.left(), _text->bottomNoMargins() + st::boxMediumSkip);
|
_forEveryone->moveToLeft(st::boxPadding.left(), _text->bottomNoMargins() + st::boxMediumSkip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,10 @@ private:
|
|||||||
|
|
||||||
class DeleteMessagesBox : public BoxContent, public RPCSender {
|
class DeleteMessagesBox : public BoxContent, public RPCSender {
|
||||||
public:
|
public:
|
||||||
DeleteMessagesBox(QWidget*, HistoryItem *item, bool suggestModerateActions);
|
DeleteMessagesBox(
|
||||||
|
QWidget*,
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
bool suggestModerateActions);
|
||||||
DeleteMessagesBox(QWidget*, const SelectedItemSet &selected);
|
DeleteMessagesBox(QWidget*, const SelectedItemSet &selected);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -184,8 +187,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void deleteAndClear();
|
void deleteAndClear();
|
||||||
|
|
||||||
QVector<FullMsgId> _ids;
|
static std::vector<FullMsgId> CollectFrom(const SelectedItemSet &items);
|
||||||
bool _singleItem = false;
|
|
||||||
|
const std::vector<FullMsgId> _ids;
|
||||||
|
const bool _singleItem = false;
|
||||||
UserData *_moderateFrom = nullptr;
|
UserData *_moderateFrom = nullptr;
|
||||||
ChannelData *_moderateInChannel = nullptr;
|
ChannelData *_moderateInChannel = nullptr;
|
||||||
bool _moderateBan = false;
|
bool _moderateBan = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user