forked from qt-creator/qt-creator
		
	Added TextEditor commands FollowSymbol and JumpToFile.
Most of editors have "jump to file" or "follow symbol" actions. This patch reduces amount of related boilerplate code. New actions are made optional to prevent shortcut clash (both use F2). Change-Id: I2af580ed9d6789df25f4487ba001f3b83887c504 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
		@@ -174,7 +174,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
 | 
			
		||||
    m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
 | 
			
		||||
          TextEditor::TextEditorActionHandler::Format
 | 
			
		||||
        | TextEditor::TextEditorActionHandler::UnCommentSelection
 | 
			
		||||
        | TextEditor::TextEditorActionHandler::UnCollapseAll);
 | 
			
		||||
        | TextEditor::TextEditorActionHandler::UnCollapseAll
 | 
			
		||||
        | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
 | 
			
		||||
    m_actionHandler->initializeActions();
 | 
			
		||||
 | 
			
		||||
    Core::ActionManager *am = Core::ICore::actionManager();
 | 
			
		||||
@@ -185,10 +186,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
 | 
			
		||||
    qmlToolsMenu->addAction(createSeparator(am, this, globalContext, QmlJSEditor::Constants::SEPARATOR3));
 | 
			
		||||
 | 
			
		||||
    Core::Command *cmd;
 | 
			
		||||
    QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
 | 
			
		||||
    cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
 | 
			
		||||
    cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
 | 
			
		||||
    connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
 | 
			
		||||
    cmd = am->command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
 | 
			
		||||
    contextMenu->addAction(cmd);
 | 
			
		||||
    qmlToolsMenu->addAction(cmd);
 | 
			
		||||
 | 
			
		||||
@@ -294,14 +292,6 @@ Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const
 | 
			
		||||
    return m_jsonManager.data();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QmlJSEditorPlugin::followSymbolUnderCursor()
 | 
			
		||||
{
 | 
			
		||||
    Core::EditorManager *em = Core::EditorManager::instance();
 | 
			
		||||
 | 
			
		||||
    if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget()))
 | 
			
		||||
        editor->followSymbolUnderCursor();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QmlJSEditorPlugin::findUsages()
 | 
			
		||||
{
 | 
			
		||||
    Core::EditorManager *em = Core::EditorManager::instance();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user