From 74f3cf2dfc8dbc89e7760de7e7e9496e59523242 Mon Sep 17 00:00:00 2001 From: Dmitry Degtyarev Date: Wed, 1 Sep 2021 14:33:35 +0400 Subject: [PATCH] remove exec_menu_from_view() also use async popup() for group policy tab context menu --- src/admc/tabs/group_policy_tab.cpp | 12 +++++++----- src/admc/utils.cpp | 5 ----- src/admc/utils.h | 2 -- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/admc/tabs/group_policy_tab.cpp b/src/admc/tabs/group_policy_tab.cpp index 0ef3650c..b6348804 100644 --- a/src/admc/tabs/group_policy_tab.cpp +++ b/src/admc/tabs/group_policy_tab.cpp @@ -159,19 +159,21 @@ void GroupPolicyTab::on_context_menu(const QPoint pos) { return; } - QMenu menu(this); - menu.addAction(tr("Remove link"), [this, gpo]() { + auto menu = new QMenu(this); + menu->setAttribute(Qt::WA_DeleteOnClose); + + menu->addAction(tr("Remove link"), [this, gpo]() { const QList removed = {gpo}; remove_link(removed); }); - menu.addAction(tr("Move up"), [this, gpo]() { + menu->addAction(tr("Move up"), [this, gpo]() { move_link_up(gpo); }); - menu.addAction(tr("Move down"), [this, gpo]() { + menu->addAction(tr("Move down"), [this, gpo]() { move_link_down(gpo); }); - exec_menu_from_view(&menu, view, pos); + menu->popup(pos); } void GroupPolicyTab::on_add_button() { diff --git a/src/admc/utils.cpp b/src/admc/utils.cpp index 014f2390..4639318a 100644 --- a/src/admc/utils.cpp +++ b/src/admc/utils.cpp @@ -59,11 +59,6 @@ QList make_item_row(const int count) { return row; } -void exec_menu_from_view(QMenu *menu, const QAbstractItemView *view, const QPoint &pos) { - const QPoint global_pos = view->mapToGlobal(pos); - menu->exec(global_pos); -} - void set_horizontal_header_labels_from_map(QStandardItemModel *model, const QMap &labels_map) { for (int col = 0; col < model->columnCount(); col++) { const QString label = [=]() { diff --git a/src/admc/utils.h b/src/admc/utils.h index 728c873a..2ebf1c5e 100644 --- a/src/admc/utils.h +++ b/src/admc/utils.h @@ -52,8 +52,6 @@ class QHash; QList make_item_row(const int count); -void exec_menu_from_view(QMenu *menu, const QAbstractItemView *view, const QPoint &pos); - // Convenience f-n so that you can pass a mapping of // column => label // Columns not in the map get empty labels