mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Show status duration menu only in status panel.
This commit is contained in:
parent
49773dde72
commit
898edad09b
8 changed files with 81 additions and 81 deletions
|
@ -796,26 +796,24 @@ void EmojiListWidget::fillRecentFrom(const std::vector<DocumentId> &list) {
|
|||
}
|
||||
}
|
||||
|
||||
void EmojiListWidget::fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
base::unique_qptr<Ui::PopupMenu> EmojiListWidget::fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
if (v::is_null(_selected)) {
|
||||
return;
|
||||
if (_mode != Mode::EmojiStatus || v::is_null(_selected)) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto over = std::get_if<OverEmoji>(&_selected);
|
||||
if (!over) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
const auto section = over->section;
|
||||
const auto index = over->index;
|
||||
// Ignore the default status.
|
||||
if (!index && (section == int(Section::Recent))) {
|
||||
return;
|
||||
}
|
||||
const auto chosen = lookupCustomEmoji(index, section);
|
||||
if (!chosen) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
auto menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::defaultPopupMenu);
|
||||
for (const auto &value : { 3600, 3600 * 8, 3600 * 24, 3600 * 24 * 7 }) {
|
||||
const auto text = tr::lng_emoji_status_menu_duration_any(
|
||||
tr::now,
|
||||
|
@ -833,6 +831,7 @@ void EmojiListWidget::fillContextMenu(
|
|||
menu->addAction(
|
||||
tr::lng_manage_messages_ttl_after_custom(tr::now),
|
||||
crl::guard(this, [=] { selectCustom(chosen, options); }));
|
||||
return menu;
|
||||
}
|
||||
|
||||
void EmojiListWidget::paintEvent(QPaintEvent *e) {
|
||||
|
@ -1094,8 +1093,7 @@ bool EmojiListWidget::checkPickerHide() {
|
|||
DocumentData *EmojiListWidget::lookupCustomEmoji(
|
||||
int index,
|
||||
int section) const {
|
||||
if (section == int(Section::Recent)
|
||||
&& index < _recent.size()) {
|
||||
if (section == int(Section::Recent) && index < _recent.size()) {
|
||||
const auto document = std::get_if<RecentEmojiDocument>(
|
||||
&_recent[index].id.data);
|
||||
const auto custom = document
|
||||
|
|
|
@ -126,8 +126,7 @@ public:
|
|||
float64 progress,
|
||||
RectPart origin);
|
||||
|
||||
void fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
base::unique_qptr<Ui::PopupMenu> fillContextMenu(
|
||||
SendMenu::Type type) override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -376,13 +376,15 @@ void GifsListWidget::mousePressEvent(QMouseEvent *e) {
|
|||
_previewTimer.callOnce(QApplication::startDragTime());
|
||||
}
|
||||
|
||||
void GifsListWidget::fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
base::unique_qptr<Ui::PopupMenu> GifsListWidget::fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
if (_selected < 0 || _pressed >= 0) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::popupMenuWithIcons);
|
||||
const auto send = [=, selected = _selected](Api::SendOptions options) {
|
||||
selectInlineResult(selected, options, true);
|
||||
};
|
||||
|
@ -405,7 +407,8 @@ void GifsListWidget::fillContextMenu(
|
|||
};
|
||||
AddGifAction(std::move(callback), _controller, document);
|
||||
}
|
||||
};
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
void GifsListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
|
|
|
@ -82,8 +82,7 @@ public:
|
|||
void cancelled();
|
||||
rpl::producer<> cancelRequests() const;
|
||||
|
||||
void fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
base::unique_qptr<Ui::PopupMenu> fillContextMenu(
|
||||
SendMenu::Type type) override;
|
||||
|
||||
~GifsListWidget();
|
||||
|
|
|
@ -1542,65 +1542,71 @@ void StickersListWidget::showStickerSetBox(not_null<DocumentData*> document) {
|
|||
}
|
||||
}
|
||||
|
||||
void StickersListWidget::fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
base::unique_qptr<Ui::PopupMenu> StickersListWidget::fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
auto selected = _selected;
|
||||
auto &sets = shownSets();
|
||||
if (v::is_null(selected) || !v::is_null(_pressed)) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
if (auto sticker = std::get_if<OverSticker>(&selected)) {
|
||||
const auto section = sticker->section;
|
||||
const auto index = sticker->index;
|
||||
Assert(section >= 0 && section < sets.size());
|
||||
auto &set = sets[section];
|
||||
Assert(index >= 0 && index < set.stickers.size());
|
||||
const auto sticker = std::get_if<OverSticker>(&selected);
|
||||
if (!sticker) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto section = sticker->section;
|
||||
const auto index = sticker->index;
|
||||
Assert(section >= 0 && section < sets.size());
|
||||
auto &set = sets[section];
|
||||
Assert(index >= 0 && index < set.stickers.size());
|
||||
|
||||
const auto document = set.stickers[sticker->index].document;
|
||||
const auto send = [=](Api::SendOptions options) {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
.options = options,
|
||||
.messageSendingFrom = options.scheduled
|
||||
? Ui::MessageSendingAnimationFrom()
|
||||
: messageSentAnimationInfo(section, index, document),
|
||||
});
|
||||
};
|
||||
SendMenu::FillSendMenu(
|
||||
menu,
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(this, type, send));
|
||||
auto menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::popupMenuWithIcons);
|
||||
|
||||
const auto window = _controller;
|
||||
const auto toggleFavedSticker = [=] {
|
||||
Api::ToggleFavedSticker(
|
||||
window,
|
||||
const auto document = set.stickers[sticker->index].document;
|
||||
const auto send = [=](Api::SendOptions options) {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
.options = options,
|
||||
.messageSendingFrom = options.scheduled
|
||||
? Ui::MessageSendingAnimationFrom()
|
||||
: messageSentAnimationInfo(section, index, document),
|
||||
});
|
||||
};
|
||||
SendMenu::FillSendMenu(
|
||||
menu,
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(this, type, send));
|
||||
|
||||
const auto window = _controller;
|
||||
const auto toggleFavedSticker = [=] {
|
||||
Api::ToggleFavedSticker(
|
||||
window,
|
||||
document,
|
||||
Data::FileOriginStickerSet(Data::Stickers::FavedSetId, 0));
|
||||
};
|
||||
const auto isFaved = document->owner().stickers().isFaved(document);
|
||||
menu->addAction(
|
||||
(isFaved
|
||||
? tr::lng_faved_stickers_remove
|
||||
: tr::lng_faved_stickers_add)(tr::now),
|
||||
toggleFavedSticker,
|
||||
isFaved ? &st::menuIconUnfave : &st::menuIconFave);
|
||||
|
||||
menu->addAction(tr::lng_context_pack_info(tr::now), [=] {
|
||||
showStickerSetBox(document);
|
||||
}, &st::menuIconStickers);
|
||||
|
||||
if (const auto id = set.id; id == Data::Stickers::RecentSetId) {
|
||||
menu->addAction(tr::lng_recent_stickers_remove(tr::now), [=] {
|
||||
Api::ToggleRecentSticker(
|
||||
document,
|
||||
Data::FileOriginStickerSet(Data::Stickers::FavedSetId, 0));
|
||||
};
|
||||
const auto isFaved = document->owner().stickers().isFaved(document);
|
||||
menu->addAction(
|
||||
(isFaved
|
||||
? tr::lng_faved_stickers_remove
|
||||
: tr::lng_faved_stickers_add)(tr::now),
|
||||
toggleFavedSticker,
|
||||
isFaved ? &st::menuIconUnfave : &st::menuIconFave);
|
||||
|
||||
menu->addAction(tr::lng_context_pack_info(tr::now), [=] {
|
||||
showStickerSetBox(document);
|
||||
}, &st::menuIconStickers);
|
||||
|
||||
if (const auto id = set.id; id == Data::Stickers::RecentSetId) {
|
||||
menu->addAction(tr::lng_recent_stickers_remove(tr::now), [=] {
|
||||
Api::ToggleRecentSticker(
|
||||
document,
|
||||
Data::FileOriginStickerSet(id, 0),
|
||||
false);
|
||||
}, &st::menuIconDelete);
|
||||
}
|
||||
Data::FileOriginStickerSet(id, 0),
|
||||
false);
|
||||
}, &st::menuIconDelete);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
Ui::MessageSendingAnimationFrom StickersListWidget::messageSentAnimationInfo(
|
||||
|
|
|
@ -91,8 +91,7 @@ public:
|
|||
|
||||
std::shared_ptr<Lottie::FrameRenderer> getLottieRenderer();
|
||||
|
||||
void fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
base::unique_qptr<Ui::PopupMenu> fillContextMenu(
|
||||
SendMenu::Type type) override;
|
||||
|
||||
bool mySetsEmpty() const;
|
||||
|
|
|
@ -1145,12 +1145,8 @@ void TabbedSelector::scrollToY(int y) {
|
|||
}
|
||||
|
||||
void TabbedSelector::showMenuWithType(SendMenu::Type type) {
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::popupMenuWithIcons);
|
||||
currentTab()->widget()->fillContextMenu(_menu, type);
|
||||
|
||||
if (!_menu->empty()) {
|
||||
_menu = currentTab()->widget()->fillContextMenu(type);
|
||||
if (_menu && !_menu->empty()) {
|
||||
_menu->popup(QCursor::pos());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,9 +328,9 @@ public:
|
|||
}
|
||||
virtual void beforeHiding() {
|
||||
}
|
||||
virtual void fillContextMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
SendMenu::Type type) {
|
||||
[[nodiscard]] virtual base::unique_qptr<Ui::PopupMenu> fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rpl::producer<int> scrollToRequests() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue