summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-04-08 00:16:49 +0200
committerPetr Mrázek <peterix@gmail.com>2014-04-08 00:16:49 +0200
commit50d18a06d57ce1bb6b8cd77230ff8d79968aebb3 (patch)
tree245f6c207080c67b70d5c36cf259fd0c4435dcd9 /gui
parent17d4947b30f00a347d7fb8648040271e4b65f966 (diff)
downloadMultiMC-50d18a06d57ce1bb6b8cd77230ff8d79968aebb3.tar
MultiMC-50d18a06d57ce1bb6b8cd77230ff8d79968aebb3.tar.gz
MultiMC-50d18a06d57ce1bb6b8cd77230ff8d79968aebb3.tar.lz
MultiMC-50d18a06d57ce1bb6b8cd77230ff8d79968aebb3.tar.xz
MultiMC-50d18a06d57ce1bb6b8cd77230ff8d79968aebb3.zip
Context menu tweaks
* Add create/copy instance actions to the context menu. * Context menu for the instance view background. * Top of the context menu is now a header, fixing the misclick problems.
Diffstat (limited to 'gui')
-rw-r--r--gui/MainWindow.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index ce09c42d..19c5c66f 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -353,25 +353,52 @@ void MainWindow::skinJobFinished()
void MainWindow::showInstanceContextMenu(const QPoint &pos)
{
- if (!view->indexAt(pos).isValid())
+ QList<QAction *> actions;
+
+ QAction *actionSep = new QAction("", this);
+ actionSep->setSeparator(true);
+
+ bool onInstance = view->indexAt(pos).isValid();
+ if (onInstance)
{
- return;
- }
+ actions = ui->instanceToolBar->actions();
+
+ QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
+ actionVoid->setEnabled(false);
+
+ QAction *actionRename = new QAction(tr("Rename"), this);
+ actionRename->setToolTip(ui->actionRenameInstance->toolTip());
- QList<QAction *> actions = ui->instanceToolBar->actions();
+ QAction *actionCopyInstance = new QAction(tr("Copy instance"), this);
+ actionCopyInstance->setToolTip(ui->actionCopyInstance->toolTip());
- // HACK: Filthy rename button hack because the instance view is getting rewritten anyway
- QAction *actionRename;
- actionRename = new QAction(tr("Rename"), this);
- actionRename->setToolTip(ui->actionRenameInstance->toolTip());
- connect(actionRename, SIGNAL(triggered(bool)), SLOT(on_actionRenameInstance_triggered()));
+ connect(actionRename, SIGNAL(triggered(bool)), SLOT(on_actionRenameInstance_triggered()));
+ connect(actionCopyInstance, SIGNAL(triggered(bool)), SLOT(on_actionCopyInstance_triggered()));
- actions.replace(1, actionRename);
+ actions.replace(1, actionRename);
+ actions.prepend(actionSep);
+ actions.prepend(actionVoid);
+ actions.append(actionCopyInstance);
+ }
+ else
+ {
+ QAction *actionVoid = new QAction(tr("MultiMC"), this);
+ actionVoid->setEnabled(false);
+ QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
+ actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
+
+ connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
+
+ actions.prepend(actionSep);
+ actions.prepend(actionVoid);
+ actions.append(actionCreateInstance);
+ }
QMenu myMenu;
myMenu.addActions(actions);
- myMenu.setEnabled(m_selectedInstance->canLaunch());
+ if(onInstance)
+ myMenu.setEnabled(m_selectedInstance->canLaunch());
myMenu.exec(view->mapToGlobal(pos));
}