diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-07-25 01:02:30 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-07-25 01:02:30 +0200 |
commit | 7dfe73df0c26733d68abc576c3eefab1a69e2149 (patch) | |
tree | 0e490b13ad475f0d551f8087851f83869589eb09 /application/pages/instance/WorldListPage.cpp | |
parent | c3e61536a3ba7b0dca1171df36e9aeb09b6e2a0d (diff) | |
download | PrismLauncher-7dfe73df0c26733d68abc576c3eefab1a69e2149.tar.gz PrismLauncher-7dfe73df0c26733d68abc576c3eefab1a69e2149.tar.bz2 PrismLauncher-7dfe73df0c26733d68abc576c3eefab1a69e2149.zip |
NOISSUE add context menus to pages with toolbars
Diffstat (limited to 'application/pages/instance/WorldListPage.cpp')
-rw-r--r-- | application/pages/instance/WorldListPage.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/application/pages/instance/WorldListPage.cpp b/application/pages/instance/WorldListPage.cpp index 75805838..ca419fc5 100644 --- a/application/pages/instance/WorldListPage.cpp +++ b/application/pages/instance/WorldListPage.cpp @@ -45,6 +45,8 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl ui->worldTreeView->setSortingEnabled(true); ui->worldTreeView->setModel(proxy); ui->worldTreeView->installEventFilter(this); + ui->worldTreeView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->worldTreeView, &QTreeView::customContextMenuRequested, this, &WorldListPage::ShowContextMenu); auto head = ui->worldTreeView->header(); head->setSectionResizeMode(0, QHeaderView::Stretch); @@ -70,6 +72,13 @@ WorldListPage::~WorldListPage() delete ui; } +void WorldListPage::ShowContextMenu(const QPoint& pos) +{ + auto menu = ui->toolBar->createContextMenu(this, tr("Context menu")); + menu->exec(ui->worldTreeView->mapToGlobal(pos)); + delete menu; +} + QMenu * WorldListPage::createPopupMenu() { QMenu* filteredMenu = QMainWindow::createPopupMenu(); |