mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Allow removing mini apps from recents.
This commit is contained in:
parent
51fc104c60
commit
7f3dc27aa9
1 changed files with 43 additions and 10 deletions
|
@ -166,16 +166,17 @@ void FillEntryMenu(
|
|||
.icon = &st::menuIconDeleteAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
|
||||
add({
|
||||
.text = descriptor.removeAllText,
|
||||
.handler = RemoveAllConfirm(
|
||||
descriptor.controller,
|
||||
descriptor.removeAllConfirm,
|
||||
descriptor.removeAll),
|
||||
.icon = &st::menuIconCancelAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
if (!descriptor.removeAllText.isEmpty()) {
|
||||
add({
|
||||
.text = descriptor.removeAllText,
|
||||
.handler = RemoveAllConfirm(
|
||||
descriptor.controller,
|
||||
descriptor.removeAllConfirm,
|
||||
descriptor.removeAll),
|
||||
.icon = &st::menuIconCancelAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RecentRow::RecentRow(not_null<PeerData*> peer)
|
||||
|
@ -422,6 +423,9 @@ public:
|
|||
not_null<Window::SessionController*> window);
|
||||
|
||||
void prepare() override;
|
||||
base::unique_qptr<Ui::PopupMenu> rowContextMenu(
|
||||
QWidget *parent,
|
||||
not_null<PeerListRow*> row) override;
|
||||
|
||||
void load();
|
||||
|
||||
|
@ -1031,6 +1035,35 @@ void RecentAppsController::prepare() {
|
|||
}, _lifetime);
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> RecentAppsController::rowContextMenu(
|
||||
QWidget *parent,
|
||||
not_null<PeerListRow*> row) {
|
||||
auto result = base::make_unique_q<Ui::PopupMenu>(
|
||||
parent,
|
||||
st::popupMenuWithIcons);
|
||||
const auto peer = row->peer();
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto session = &this->session();
|
||||
const auto removeOne = crl::guard(session, [=] {
|
||||
if (weak) {
|
||||
const auto rowId = peer->id.value;
|
||||
if (const auto row = delegate()->peerListFindRow(rowId)) {
|
||||
setCount(std::max(0, countCurrent() - 1));
|
||||
delegate()->peerListRemoveRow(row);
|
||||
delegate()->peerListRefreshRows();
|
||||
}
|
||||
}
|
||||
session->topBotApps().remove(peer);
|
||||
});
|
||||
FillEntryMenu(Ui::Menu::CreateAddActionCallback(result), {
|
||||
.controller = window(),
|
||||
.peer = peer,
|
||||
.removeOneText = tr::lng_recent_remove(tr::now),
|
||||
.removeOne = removeOne,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
void RecentAppsController::load() {
|
||||
session().topBotApps().reload();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue