From f3fe01028ed4c087a0fbbc0f3c641ee51ca6c846 Mon Sep 17 00:00:00 2001 From: Thunder422 Date: Sat, 26 Jan 2013 15:23:56 -0500 Subject: [PATCH] created a context menu for the edit box this was necessary to be able to catch the context menu actions, something not possible with the built-in context menu; and as a side benefit, the context menu actions now have icons --- mainwindow.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index f304b84..d728d4d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -79,6 +79,22 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_editBox, SIGNAL(copyAvailable(bool)), ui->actionDelete, SLOT(setEnabled(bool))); + // create actions for edit box context menu + QList actions; + actions.append(ui->actionUndo); + actions.append(ui->actionRedo); + actions.append(new QAction(m_editBox)); + actions.last()->setSeparator(true); + actions.append(ui->actionCut); + actions.append(ui->actionCopy); + actions.append(ui->actionPaste); + actions.append(ui->actionDelete); + actions.append(new QAction(m_editBox)); + actions.last()->setSeparator(true); + actions.append(ui->actionSelectAll); + m_editBox->addActions(actions); + m_editBox->setContextMenuPolicy(Qt::ActionsContextMenu); + // if a file name was specified on the command line // then it overrides the restored program if (!m_commandLine->fileName().isEmpty())