forked from qt-creator/qt-creator
Unified contextMenuEvent implementations of editor widgets.
Change-Id: Ie5dbde8d0443a65a8e96853002c8bdafd2c0d729 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
committed by
Eike Ziller
parent
95c5ab2746
commit
b0da247604
@@ -142,18 +142,7 @@ void CMakeEditorWidget::unCommentSelection()
|
||||
|
||||
void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
QMenu *menu = new QMenu();
|
||||
|
||||
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;
|
||||
showDefaultContextMenu(e, Constants::M_CONTEXT);
|
||||
}
|
||||
|
||||
void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
|
||||
|
||||
@@ -196,19 +196,7 @@ TextEditor::BaseTextEditor *ProFileEditorWidget::createEditor()
|
||||
|
||||
void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
QMenu *menu = new QMenu();
|
||||
|
||||
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;
|
||||
showDefaultContextMenu(e, Constants::M_CONTEXT);
|
||||
}
|
||||
|
||||
void ProFileEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
|
||||
|
||||
@@ -4327,6 +4327,14 @@ void BaseTextEditorWidget::dragEnterEvent(QDragEnterEvent *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 *)
|
||||
{
|
||||
// fake missing mouse move event from Qt
|
||||
@@ -6059,6 +6067,15 @@ QMimeData *BaseTextEditorWidget::duplicateMimeData(const QMimeData *source) cons
|
||||
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)
|
||||
{
|
||||
menu->addSeparator();
|
||||
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
QString mimeType() const;
|
||||
virtual void setMimeType(const QString &mt);
|
||||
|
||||
|
||||
void appendMenuActionsFromContext(QMenu *menu, const Core::Id menuContextId);
|
||||
void appendStandardContextMenuActions(QMenu *menu);
|
||||
|
||||
// Works only in conjunction with a syntax highlighter that puts
|
||||
@@ -469,6 +469,8 @@ protected:
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent *e);
|
||||
|
||||
void showDefaultContextMenu(QContextMenuEvent *e, const Core::Id menuContextId);
|
||||
|
||||
public:
|
||||
void indentInsertedText(const QTextCursor &tc);
|
||||
void indent(QTextDocument *doc, const QTextCursor &cursor, QChar typedChar);
|
||||
|
||||
Reference in New Issue
Block a user