forked from qt-creator/qt-creator
QmlJSEditor: add shortcut for Qt Quick Helper (ctrl+alt+space)
This shortcut forces the Qt Quick Helper to be shown if available. The action is also registered in the context menu so it is discoverable. Reviewed-by: Christian Kamm
This commit is contained in:
@@ -1338,6 +1338,15 @@ void QmlJSTextEditor::followSymbolUnderCursor()
|
||||
openLink(findLinkAt(textCursor()));
|
||||
}
|
||||
|
||||
void QmlJSTextEditor::showContextPane()
|
||||
{
|
||||
if (m_contextPane) {
|
||||
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
|
||||
m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, newNode, false, true);
|
||||
m_oldCursorPosition = position();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSTextEditor::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
QMenu *menu = new QMenu();
|
||||
@@ -1654,8 +1663,6 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
||||
|
||||
void QmlJSTextEditor::onCursorPositionChanged()
|
||||
{
|
||||
|
||||
|
||||
if (m_contextPane) {
|
||||
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
|
||||
Node *oldNode = m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition);
|
||||
|
||||
@@ -227,6 +227,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void followSymbolUnderCursor();
|
||||
void showContextPane();
|
||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||
|
||||
signals:
|
||||
|
||||
@@ -45,6 +45,7 @@ const char * const C_QMLJSEDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Edi
|
||||
const char * const TASK_INDEX = "QmlJSEditor.TaskIndex";
|
||||
|
||||
const char * const FOLLOW_SYMBOL_UNDER_CURSOR = "QmlJSEditor.FollowSymbolUnderCursor";
|
||||
const char * const SHOW_QT_QUICK_HELPER = "QmlJSEditor.ShowQtQuickHelper";
|
||||
|
||||
const char * const QML_MIMETYPE = "application/x-qml";
|
||||
const char * const JS_MIMETYPE = "application/javascript";
|
||||
|
||||
@@ -155,6 +155,12 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
|
||||
connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
|
||||
contextMenu->addAction(cmd);
|
||||
|
||||
QAction *showQuickToolbar = new QAction(tr("Show Qt Quick helper"), this);
|
||||
cmd = am->registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space));
|
||||
connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane()));
|
||||
contextMenu->addAction(cmd);
|
||||
|
||||
cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
|
||||
contextMenu->addAction(cmd);
|
||||
|
||||
@@ -242,6 +248,15 @@ void QmlJSEditorPlugin::followSymbolUnderCursor()
|
||||
editor->followSymbolUnderCursor();
|
||||
}
|
||||
|
||||
void QmlJSEditorPlugin::showContextPane()
|
||||
{
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
|
||||
if (QmlJSTextEditor *editor = qobject_cast<QmlJSTextEditor*>(em->currentEditor()->widget()))
|
||||
editor->showContextPane();
|
||||
|
||||
}
|
||||
|
||||
Core::Command *QmlJSEditorPlugin::addToolAction(QAction *a, Core::ActionManager *am,
|
||||
Core::Context &context, const QString &name,
|
||||
Core::ActionContainer *c1, const QString &keySequence)
|
||||
|
||||
@@ -89,6 +89,7 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void followSymbolUnderCursor();
|
||||
void showContextPane();
|
||||
|
||||
private Q_SLOTS:
|
||||
void openPreview();
|
||||
|
||||
Reference in New Issue
Block a user