diff options
Diffstat (limited to 'application/pages/global')
-rw-r--r-- | application/pages/global/AccountListPage.cpp | 16 | ||||
-rw-r--r-- | application/pages/global/AccountListPage.h | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/application/pages/global/AccountListPage.cpp b/application/pages/global/AccountListPage.cpp index 5270a305..c14134f3 100644 --- a/application/pages/global/AccountListPage.cpp +++ b/application/pages/global/AccountListPage.cpp @@ -43,20 +43,23 @@ AccountListPage::AccountListPage(QWidget *parent) "If you're new here, you can click the \"Add\" button to add your Mojang or Minecraft account." )); ui->listView->setEmptyMode(VersionListView::String); + ui->listView->setContextMenuPolicy(Qt::CustomContextMenu); m_accounts = MMC->accounts(); ui->listView->setModel(m_accounts.get()); ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); + ui->listView->setSelectionMode(QAbstractItemView::SingleSelection); // Expand the account column ui->listView->header()->setSectionResizeMode(1, QHeaderView::Stretch); QItemSelectionModel *selectionModel = ui->listView->selectionModel(); - connect(selectionModel, &QItemSelectionModel::selectionChanged, - [this](const QItemSelection &sel, const QItemSelection &dsel) - { updateButtonStates(); }); + connect(selectionModel, &QItemSelectionModel::selectionChanged, [this](const QItemSelection &sel, const QItemSelection &dsel) { + updateButtonStates(); + }); + connect(ui->listView, &VersionListView::customContextMenuRequested, this, &AccountListPage::ShowContextMenu); connect(m_accounts.get(), SIGNAL(listChanged()), SLOT(listChanged())); connect(m_accounts.get(), SIGNAL(activeAccountChanged()), SLOT(listChanged())); @@ -69,6 +72,13 @@ AccountListPage::~AccountListPage() delete ui; } +void AccountListPage::ShowContextMenu(const QPoint& pos) +{ + auto menu = ui->toolBar->createContextMenu(this, tr("Context menu")); + menu->exec(ui->listView->mapToGlobal(pos)); + delete menu; +} + void AccountListPage::changeEvent(QEvent* event) { if (event->type() == QEvent::LanguageChange) diff --git a/application/pages/global/AccountListPage.h b/application/pages/global/AccountListPage.h index 9de73f70..4c8bc00b 100644 --- a/application/pages/global/AccountListPage.h +++ b/application/pages/global/AccountListPage.h @@ -85,6 +85,7 @@ protected: protected slots: + void ShowContextMenu(const QPoint &pos); void addAccount(const QString& errMsg=""); private: |