1
0
mirror of https://github.com/altlinux/admc.git synced 2025-03-22 02:50:30 +03:00

remove exec_menu_from_view()

also use async popup() for group policy tab context menu
This commit is contained in:
Dmitry Degtyarev 2021-09-01 14:33:35 +04:00
parent 48dc5ed441
commit 74f3cf2dfc
3 changed files with 7 additions and 12 deletions

View File

@ -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<QString> 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() {

View File

@ -59,11 +59,6 @@ QList<QStandardItem *> 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<int, QString> &labels_map) {
for (int col = 0; col < model->columnCount(); col++) {
const QString label = [=]() {

View File

@ -52,8 +52,6 @@ class QHash;
QList<QStandardItem *> 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