Commit b0da2476 authored by Konstantin Tokarev's avatar Konstantin Tokarev Committed by Eike Ziller
Browse files

Unified contextMenuEvent implementations of editor widgets.



Change-Id: Ie5dbde8d0443a65a8e96853002c8bdafd2c0d729
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 95c5ab27
...@@ -142,18 +142,7 @@ void CMakeEditorWidget::unCommentSelection() ...@@ -142,18 +142,7 @@ void CMakeEditorWidget::unCommentSelection()
void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e) void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
{ {
QMenu *menu = new QMenu(); showDefaultContextMenu(e, Constants::M_CONTEXT);
Core::ActionContainer *mcontext = Core::ActionManager::actionContainer(Constants::M_CONTEXT);
QMenu *contextMenu = mcontext->menu();
foreach (QAction *action, contextMenu->actions())
menu->addAction(action);
appendStandardContextMenuActions(menu);
menu->exec(e->globalPos());
delete menu;
} }
void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
......
...@@ -196,19 +196,7 @@ TextEditor::BaseTextEditor *ProFileEditorWidget::createEditor() ...@@ -196,19 +196,7 @@ TextEditor::BaseTextEditor *ProFileEditorWidget::createEditor()
void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e) void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
{ {
QMenu *menu = new QMenu(); showDefaultContextMenu(e, Constants::M_CONTEXT);
Core::ActionContainer *mcontext =
Core::ActionManager::actionContainer(Qt4ProjectManager::Constants::M_CONTEXT);
QMenu *contextMenu = mcontext->menu();
foreach (QAction *action, contextMenu->actions())
menu->addAction(action);
appendStandardContextMenuActions(menu);
menu->exec(e->globalPos());
delete menu;
} }
void ProFileEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) void ProFileEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
......
...@@ -4327,6 +4327,14 @@ void BaseTextEditorWidget::dragEnterEvent(QDragEnterEvent *e) ...@@ -4327,6 +4327,14 @@ void BaseTextEditorWidget::dragEnterEvent(QDragEnterEvent *e)
QPlainTextEdit::dragEnterEvent(e); QPlainTextEdit::dragEnterEvent(e);
} }
void BaseTextEditorWidget::showDefaultContextMenu(QContextMenuEvent *e, const Core::Id menuContextId)
{
QMenu menu;
appendMenuActionsFromContext(&menu, menuContextId);
appendStandardContextMenuActions(&menu);
menu.exec(e->globalPos());
}
void BaseTextEditorWidget::extraAreaLeaveEvent(QEvent *) void BaseTextEditorWidget::extraAreaLeaveEvent(QEvent *)
{ {
// fake missing mouse move event from Qt // fake missing mouse move event from Qt
...@@ -6059,6 +6067,15 @@ QMimeData *BaseTextEditorWidget::duplicateMimeData(const QMimeData *source) cons ...@@ -6059,6 +6067,15 @@ QMimeData *BaseTextEditorWidget::duplicateMimeData(const QMimeData *source) cons
return mimeData; return mimeData;
} }
void BaseTextEditorWidget::appendMenuActionsFromContext(QMenu *menu, const Core::Id menuContextId)
{
Core::ActionContainer *mcontext = Core::ActionManager::actionContainer(menuContextId);
QMenu *contextMenu = mcontext->menu();
foreach (QAction *action, contextMenu->actions())
menu->addAction(action);
}
void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu) void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
{ {
menu->addSeparator(); menu->addSeparator();
......
...@@ -166,7 +166,7 @@ public: ...@@ -166,7 +166,7 @@ public:
QString mimeType() const; QString mimeType() const;
virtual void setMimeType(const QString &mt); virtual void setMimeType(const QString &mt);
void appendMenuActionsFromContext(QMenu *menu, const Core::Id menuContextId);
void appendStandardContextMenuActions(QMenu *menu); void appendStandardContextMenuActions(QMenu *menu);
// Works only in conjunction with a syntax highlighter that puts // Works only in conjunction with a syntax highlighter that puts
...@@ -469,6 +469,8 @@ protected: ...@@ -469,6 +469,8 @@ protected:
void dragEnterEvent(QDragEnterEvent *e); void dragEnterEvent(QDragEnterEvent *e);
void showDefaultContextMenu(QContextMenuEvent *e, const Core::Id menuContextId);
public: public:
void indentInsertedText(const QTextCursor &tc); void indentInsertedText(const QTextCursor &tc);
void indent(QTextDocument *doc, const QTextCursor &cursor, QChar typedChar); void indent(QTextDocument *doc, const QTextCursor &cursor, QChar typedChar);
......
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