diff options
Diffstat (limited to 'gui/MainWindow.cpp')
-rw-r--r-- | gui/MainWindow.cpp | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index ce09c42d..b0e86249 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -35,6 +35,7 @@ #include <QToolButton> #include <QWidgetAction> #include <QProgressDialog> +#include <QShortcut> #include "osutils.h" #include "userutils.h" @@ -116,6 +117,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi // OSX magic. // setUnifiedTitleAndToolBarOnMac(true); + // Global shortcuts + { + //FIXME: This is kinda weird. and bad. We need some kind of managed shutdown. + auto q = new QShortcut(QKeySequence::Quit, this); + connect(q, SIGNAL(activated()), qApp, SLOT(quit())); + } + // The instance action toolbar customizations { // disabled until we have an instance selected @@ -353,25 +361,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)); } @@ -988,6 +1023,11 @@ void MainWindow::on_actionReportBug_triggered() openWebPage(QUrl("https://github.com/MultiMC/MultiMC5/issues")); } +void MainWindow::on_actionPatreon_triggered() +{ + openWebPage(QUrl("http://www.patreon.com/multimc")); +} + void MainWindow::on_actionMoreNews_triggered() { openWebPage(QUrl("http://multimc.org/posts.html")); |