diff options
-rw-r--r-- | gui/MainWindow.cpp | 27 | ||||
-rw-r--r-- | gui/MainWindow.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 2b911b2c..75ebefe4 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -165,6 +165,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi view->setFrameShape(QFrame::NoFrame); view->setModel(proxymodel); + view->setContextMenuPolicy(Qt::CustomContextMenu); + connect(view, SIGNAL(customContextMenuRequested(const QPoint&)), + this, SLOT(showInstanceContextMenu(const QPoint&))); + ui->horizontalLayout->addWidget(view); } // The cat background @@ -311,6 +315,29 @@ MainWindow::~MainWindow() delete drawer; } +void MainWindow::showInstanceContextMenu(const QPoint& pos) +{ + if(!view->indexAt(pos).isValid()) + { + return; + } + + QList<QAction *> actions = ui->instanceToolBar->actions(); + + // 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())); + + actions.replace(1, actionRename); + + QMenu myMenu; + myMenu.addActions(actions); + myMenu.exec(view->mapToGlobal(pos)); +} + void MainWindow::repopulateAccountsMenu() { accountMenu->clear(); diff --git a/gui/MainWindow.h b/gui/MainWindow.h index f2315ee6..ca11b380 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -145,6 +145,8 @@ slots: // called when an icon is changed in the icon model. void iconUpdated(QString); + void showInstanceContextMenu(const QPoint&); + public slots: void instanceActivated(QModelIndex); |