summaryrefslogtreecommitdiffstats
path: root/application/pages
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
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')
-rw-r--r--application/pages/global/AccountListPage.cpp16
-rw-r--r--application/pages/global/AccountListPage.h1
-rw-r--r--application/pages/instance/ModFolderPage.cpp25
-rw-r--r--application/pages/instance/ModFolderPage.h1
-rw-r--r--application/pages/instance/ScreenshotsPage.cpp9
-rw-r--r--application/pages/instance/ScreenshotsPage.h1
-rw-r--r--application/pages/instance/ServersPage.cpp10
-rw-r--r--application/pages/instance/ServersPage.h4
-rw-r--r--application/pages/instance/VersionPage.cpp10
-rw-r--r--application/pages/instance/VersionPage.h2
-rw-r--r--application/pages/instance/WorldListPage.cpp9
-rw-r--r--application/pages/instance/WorldListPage.h2
12 files changed, 81 insertions, 9 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:
diff --git a/application/pages/instance/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp
index d0de4ac2..97225832 100644
--- a/application/pages/instance/ModFolderPage.cpp
+++ b/application/pages/instance/ModFolderPage.cpp
@@ -32,10 +32,17 @@
#include "minecraft/ComponentList.h"
#include <DesktopServices.h>
-ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> mods, QString id,
- QString iconName, QString displayName, QString helpPage,
- QWidget *parent)
- : QMainWindow(parent), ui(new Ui::ModFolderPage)
+ModFolderPage::ModFolderPage(
+ BaseInstance *inst,
+ std::shared_ptr<SimpleModList> mods,
+ QString id,
+ QString iconName,
+ QString displayName,
+ QString helpPage,
+ QWidget *parent
+) :
+ QMainWindow(parent),
+ ui(new Ui::ModFolderPage)
{
ui->setupUi(this);
ui->actionsToolbar->insertSpacer(ui->actionView_configs);
@@ -57,6 +64,9 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList>
ui->modTreeView->setModel(m_filterModel);
ui->modTreeView->installEventFilter(this);
ui->modTreeView->sortByColumn(1, Qt::AscendingOrder);
+ ui->modTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(ui->modTreeView, &ModListView::customContextMenuRequested, this, &ModFolderPage::ShowContextMenu);
+
auto smodel = ui->modTreeView->selectionModel();
connect(smodel, &QItemSelectionModel::currentChanged, this, &ModFolderPage::modCurrent);
connect(ui->filterEdit, &QLineEdit::textChanged, this, &ModFolderPage::on_filterTextChanged );
@@ -70,6 +80,13 @@ QMenu * ModFolderPage::createPopupMenu()
return filteredMenu;
}
+void ModFolderPage::ShowContextMenu(const QPoint& pos)
+{
+ auto menu = ui->actionsToolbar->createContextMenu(this, tr("Context menu"));
+ menu->exec(ui->modTreeView->mapToGlobal(pos));
+ delete menu;
+}
+
void ModFolderPage::openedImpl()
{
m_mods->startWatching();
diff --git a/application/pages/instance/ModFolderPage.h b/application/pages/instance/ModFolderPage.h
index 1bdf03a2..a52e1611 100644
--- a/application/pages/instance/ModFolderPage.h
+++ b/application/pages/instance/ModFolderPage.h
@@ -102,6 +102,7 @@ slots:
void on_actionDisable_triggered();
void on_actionView_Folder_triggered();
void on_actionView_configs_triggered();
+ void ShowContextMenu(const QPoint &pos);
};
class CoreModFolderPage : public ModFolderPage
diff --git a/application/pages/instance/ScreenshotsPage.cpp b/application/pages/instance/ScreenshotsPage.cpp
index d73fda51..efa0f9f2 100644
--- a/application/pages/instance/ScreenshotsPage.cpp
+++ b/application/pages/instance/ScreenshotsPage.cpp
@@ -235,6 +235,8 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
ui->listView->installEventFilter(this);
ui->listView->setEditTriggers(0);
ui->listView->setItemDelegate(new CenteredEditingDelegate(this));
+ ui->listView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(ui->listView, &QListView::customContextMenuRequested, this, &ScreenshotsPage::ShowContextMenu);
connect(ui->listView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex)));
}
@@ -266,6 +268,13 @@ ScreenshotsPage::~ScreenshotsPage()
delete ui;
}
+void ScreenshotsPage::ShowContextMenu(const QPoint& pos)
+{
+ auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
+ menu->exec(ui->listView->mapToGlobal(pos));
+ delete menu;
+}
+
QMenu * ScreenshotsPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
diff --git a/application/pages/instance/ScreenshotsPage.h b/application/pages/instance/ScreenshotsPage.h
index 22ead49a..9adf79af 100644
--- a/application/pages/instance/ScreenshotsPage.h
+++ b/application/pages/instance/ScreenshotsPage.h
@@ -77,6 +77,7 @@ private slots:
void on_actionRename_triggered();
void on_actionView_Folder_triggered();
void onItemActivated(QModelIndex);
+ void ShowContextMenu(const QPoint &pos);
private:
Ui::ScreenshotsPage *ui;
diff --git a/application/pages/instance/ServersPage.cpp b/application/pages/instance/ServersPage.cpp
index 44ede664..c33eef1f 100644
--- a/application/pages/instance/ServersPage.cpp
+++ b/application/pages/instance/ServersPage.cpp
@@ -564,6 +564,9 @@ ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent)
m_model = new ServersModel(inst->gameRoot(), this);
ui->serversView->setIconSize(QSize(64,64));
ui->serversView->setModel(m_model);
+ ui->serversView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(ui->serversView, &QTreeView::customContextMenuRequested, this, &ServersPage::ShowContextMenu);
+
auto head = ui->serversView->header();
if(head->count())
{
@@ -596,6 +599,13 @@ ServersPage::~ServersPage()
m_model->saveNow();
}
+void ServersPage::ShowContextMenu(const QPoint& pos)
+{
+ auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
+ menu->exec(ui->serversView->mapToGlobal(pos));
+ delete menu;
+}
+
QMenu * ServersPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
diff --git a/application/pages/instance/ServersPage.h b/application/pages/instance/ServersPage.h
index 9c9cc388..c81f47be 100644
--- a/application/pages/instance/ServersPage.h
+++ b/application/pages/instance/ServersPage.h
@@ -79,7 +79,9 @@ private slots:
void nameEdited(const QString & name);
void addressEdited(const QString & address);
- void resourceIndexChanged(int index);
+ void resourceIndexChanged(int index);\
+
+ void ShowContextMenu(const QPoint &pos);
private: // data
int currentServer = -1;
diff --git a/application/pages/instance/VersionPage.cpp b/application/pages/instance/VersionPage.cpp
index 8b95c8b2..eb918626 100644
--- a/application/pages/instance/VersionPage.cpp
+++ b/application/pages/instance/VersionPage.cpp
@@ -123,6 +123,8 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
ui->packageView->setModel(proxy);
ui->packageView->installEventFilter(this);
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
+ ui->packageView->setContextMenuPolicy(Qt::CustomContextMenu);
+
connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent);
auto smodel = ui->packageView->selectionModel();
connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
@@ -132,6 +134,7 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
updateVersionControls();
preselect(0);
connect(m_inst, &BaseInstance::runningStatusChanged, this, &VersionPage::updateRunningStatus);
+ connect(ui->packageView, &ModListView::customContextMenuRequested, this, &VersionPage::ShowContextMenu);
}
VersionPage::~VersionPage()
@@ -139,6 +142,13 @@ VersionPage::~VersionPage()
delete ui;
}
+void VersionPage::ShowContextMenu(const QPoint& pos)
+{
+ auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
+ menu->exec(ui->packageView->mapToGlobal(pos));
+ delete menu;
+}
+
void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &previous)
{
if (!current.isValid())
diff --git a/application/pages/instance/VersionPage.h b/application/pages/instance/VersionPage.h
index 553c6ae3..31344eb9 100644
--- a/application/pages/instance/VersionPage.h
+++ b/application/pages/instance/VersionPage.h
@@ -95,5 +95,5 @@ private slots:
void updateRunningStatus(bool running);
void onGameUpdateError(QString error);
void packageCurrent(const QModelIndex &current, const QModelIndex &previous);
-
+ void ShowContextMenu(const QPoint &pos);
};
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();
diff --git a/application/pages/instance/WorldListPage.h b/application/pages/instance/WorldListPage.h
index d07f8d9f..c39420da 100644
--- a/application/pages/instance/WorldListPage.h
+++ b/application/pages/instance/WorldListPage.h
@@ -92,4 +92,6 @@ private slots:
void on_actionView_Folder_triggered();
void worldChanged(const QModelIndex &current, const QModelIndex &previous);
void mceditState(LoggedProcess::State state);
+
+ void ShowContextMenu(const QPoint &pos);
};