summaryrefslogtreecommitdiffstats
path: root/application/pages/global
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-07-25 01:02:30 +0200
committerPetr Mrázek <peterix@gmail.com>2019-07-25 01:02:30 +0200
commit7dfe73df0c26733d68abc576c3eefab1a69e2149 (patch)
tree0e490b13ad475f0d551f8087851f83869589eb09 /application/pages/global
parentc3e61536a3ba7b0dca1171df36e9aeb09b6e2a0d (diff)
downloadMultiMC-7dfe73df0c26733d68abc576c3eefab1a69e2149.tar
MultiMC-7dfe73df0c26733d68abc576c3eefab1a69e2149.tar.gz
MultiMC-7dfe73df0c26733d68abc576c3eefab1a69e2149.tar.lz
MultiMC-7dfe73df0c26733d68abc576c3eefab1a69e2149.tar.xz
MultiMC-7dfe73df0c26733d68abc576c3eefab1a69e2149.zip
NOISSUE add context menus to pages with toolbars
Diffstat (limited to 'application/pages/global')
-rw-r--r--application/pages/global/AccountListPage.cpp16
-rw-r--r--application/pages/global/AccountListPage.h1
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: