Commit bfed87f9 authored by Eike Ziller's avatar Eike Ziller

Avoid multiple context menus popping up.

On Mac in debug mode, right-clicking on extra text area would first open
the markers menu, and after that the menu where you select which debug
widgets to show (like Stack or Locals and Expressions).
Opening the markers menu in a context menu event on the extra area is
both the more sensible thing to do, and works around the Mac
inconsistency.

Task-number: QTCREATORBUG-4699
Change-Id: I38efaffac80a98773deeeada3d0e3ef4f872c03b
Reviewed-on: http://codereview.qt.nokia.com/2434Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent 1066cf73
......@@ -145,6 +145,9 @@ protected:
void leaveEvent(QEvent *event){
textEdit->extraAreaLeaveEvent(event);
}
void contextMenuEvent(QContextMenuEvent *event) {
textEdit->extraAreaContextMenuEvent(event);
}
void wheelEvent(QWheelEvent *event) {
QCoreApplication::sendEvent(textEdit->viewport(), event);
......@@ -4191,6 +4194,19 @@ void BaseTextEditorWidget::extraAreaLeaveEvent(QEvent *)
extraAreaMouseEvent(&me);
}
void BaseTextEditorWidget::extraAreaContextMenuEvent(QContextMenuEvent *e)
{
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
if (d->m_marksVisible) {
QMenu * contextMenu = new QMenu(this);
emit editor()->markContextMenuRequested(editor(), cursor.blockNumber() + 1, contextMenu);
if (!contextMenu->isEmpty())
contextMenu->exec(e->globalPos());
delete contextMenu;
e->accept();
}
}
void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
{
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
......@@ -4247,13 +4263,6 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
} else {
d->extraAreaToggleMarkBlockNumber = cursor.blockNumber();
}
} else if (d->m_marksVisible && e->button() == Qt::RightButton) {
QMenu * contextMenu = new QMenu(this);
emit editor()->markContextMenuRequested(editor(), cursor.blockNumber() + 1, contextMenu);
if (!contextMenu->isEmpty())
contextMenu->exec(e->globalPos());
delete contextMenu;
e->accept();
}
} else if (d->extraAreaSelectionAnchorBlockNumber >= 0) {
QTextCursor selection = cursor;
......
......@@ -369,6 +369,7 @@ public:
virtual int extraAreaWidth(int *markWidthPtr = 0) const;
virtual void extraAreaPaintEvent(QPaintEvent *);
virtual void extraAreaLeaveEvent(QEvent *);
virtual void extraAreaContextMenuEvent(QContextMenuEvent *);
virtual void extraAreaMouseEvent(QMouseEvent *);
const TabSettings &tabSettings() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment