mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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,
|
.icon = &st::menuIconDeleteAttention,
|
||||||
.isAttention = true,
|
.isAttention = true,
|
||||||
});
|
});
|
||||||
|
if (!descriptor.removeAllText.isEmpty()) {
|
||||||
add({
|
add({
|
||||||
.text = descriptor.removeAllText,
|
.text = descriptor.removeAllText,
|
||||||
.handler = RemoveAllConfirm(
|
.handler = RemoveAllConfirm(
|
||||||
descriptor.controller,
|
descriptor.controller,
|
||||||
descriptor.removeAllConfirm,
|
descriptor.removeAllConfirm,
|
||||||
descriptor.removeAll),
|
descriptor.removeAll),
|
||||||
.icon = &st::menuIconCancelAttention,
|
.icon = &st::menuIconCancelAttention,
|
||||||
.isAttention = true,
|
.isAttention = true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RecentRow::RecentRow(not_null<PeerData*> peer)
|
RecentRow::RecentRow(not_null<PeerData*> peer)
|
||||||
|
@ -422,6 +423,9 @@ public:
|
||||||
not_null<Window::SessionController*> window);
|
not_null<Window::SessionController*> window);
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
base::unique_qptr<Ui::PopupMenu> rowContextMenu(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<PeerListRow*> row) override;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
@ -1031,6 +1035,35 @@ void RecentAppsController::prepare() {
|
||||||
}, _lifetime);
|
}, _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() {
|
void RecentAppsController::load() {
|
||||||
session().topBotApps().reload();
|
session().topBotApps().reload();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue