Implement the beloved right click context menu. Just a copy of the instance toolbar
This commit is contained in:
parent
52bbf07fe5
commit
79158144df
@ -165,6 +165,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
view->setFrameShape(QFrame::NoFrame);
|
view->setFrameShape(QFrame::NoFrame);
|
||||||
view->setModel(proxymodel);
|
view->setModel(proxymodel);
|
||||||
|
|
||||||
|
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(view, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||||
|
this, SLOT(showInstanceContextMenu(const QPoint&)));
|
||||||
|
|
||||||
ui->horizontalLayout->addWidget(view);
|
ui->horizontalLayout->addWidget(view);
|
||||||
}
|
}
|
||||||
// The cat background
|
// The cat background
|
||||||
@ -311,6 +315,29 @@ MainWindow::~MainWindow()
|
|||||||
delete drawer;
|
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()
|
void MainWindow::repopulateAccountsMenu()
|
||||||
{
|
{
|
||||||
accountMenu->clear();
|
accountMenu->clear();
|
||||||
|
@ -145,6 +145,8 @@ slots:
|
|||||||
// called when an icon is changed in the icon model.
|
// called when an icon is changed in the icon model.
|
||||||
void iconUpdated(QString);
|
void iconUpdated(QString);
|
||||||
|
|
||||||
|
void showInstanceContextMenu(const QPoint&);
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void instanceActivated(QModelIndex);
|
void instanceActivated(QModelIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user