Skip to content

Commit

Permalink
created a context menu for the edit box
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thunder422 committed Jan 26, 2013
1 parent 2f0042f commit f3fe010
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mainwindow.cpp
Expand Up @@ -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<QAction *> 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())
Expand Down

0 comments on commit f3fe010

Please sign in to comment.