forked from qt-creator/qt-creator
		
	QmlJSEditor: hiding of the context pane
We properly hide the pane if the viewport is scrolled or resized.
This commit is contained in:
		@@ -1352,8 +1352,7 @@ bool QmlJSTextEditor::event(QEvent *e)
 | 
			
		||||
    switch (e->type()) {
 | 
			
		||||
    case QEvent::ShortcutOverride:
 | 
			
		||||
        if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape && m_contextPane) {
 | 
			
		||||
            if ((m_contextPane) && m_contextPane->widget()->isVisible()) {
 | 
			
		||||
                m_contextPane->apply(editableInterface(),  m_semanticInfo.document, m_semanticInfo.snapshot, 0, false);
 | 
			
		||||
            if (hideContextPane()) {
 | 
			
		||||
                e->accept();
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
@@ -1369,11 +1368,28 @@ bool QmlJSTextEditor::event(QEvent *e)
 | 
			
		||||
 | 
			
		||||
void QmlJSTextEditor::wheelEvent(QWheelEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    bool visible = false;
 | 
			
		||||
    if (m_contextPane && m_contextPane->widget()->isVisible())
 | 
			
		||||
        visible = true;
 | 
			
		||||
 | 
			
		||||
    BaseTextEditor::wheelEvent(event);
 | 
			
		||||
    if (m_contextPane)
 | 
			
		||||
        m_contextPane->apply(editableInterface(),  m_semanticInfo.document, m_semanticInfo.snapshot, m_semanticInfo.declaringMember(position()), true);
 | 
			
		||||
 | 
			
		||||
    if (visible)
 | 
			
		||||
        m_contextPane->apply(editableInterface(),  m_semanticInfo.document, m_semanticInfo.snapshot, m_semanticInfo.declaringMemberNoProperties(position()), true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QmlJSTextEditor::resizeEvent(QResizeEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    BaseTextEditor::resizeEvent(event);
 | 
			
		||||
    hideContextPane();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 void QmlJSTextEditor::scrollContentsBy(int dx, int dy)
 | 
			
		||||
 {
 | 
			
		||||
     BaseTextEditor::scrollContentsBy(dx, dy);
 | 
			
		||||
     hideContextPane();
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
void QmlJSTextEditor::unCommentSelection()
 | 
			
		||||
{
 | 
			
		||||
    Utils::unCommentSelection(this);
 | 
			
		||||
@@ -1603,7 +1619,7 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
 | 
			
		||||
        m_semanticInfo.declarations = findDeclarations(doc->ast());
 | 
			
		||||
 | 
			
		||||
        if (m_contextPane) {
 | 
			
		||||
            Node *newNode = m_semanticInfo.declaringMember(position());
 | 
			
		||||
            Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
 | 
			
		||||
            if (newNode) {
 | 
			
		||||
                m_contextPane->apply(editableInterface(), doc, m_semanticInfo.snapshot, newNode, true);
 | 
			
		||||
                m_oldCursorPosition = position();
 | 
			
		||||
@@ -1626,8 +1642,8 @@ void QmlJSTextEditor::onCursorPositionChanged()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (m_contextPane) {
 | 
			
		||||
        Node *newNode = m_semanticInfo.declaringMember(position());
 | 
			
		||||
        Node *oldNode = m_semanticInfo.declaringMember(m_oldCursorPosition);
 | 
			
		||||
        Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
 | 
			
		||||
        Node *oldNode = m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition);
 | 
			
		||||
        if (oldNode != newNode)
 | 
			
		||||
            m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.snapshot, newNode, false);
 | 
			
		||||
        m_oldCursorPosition = position();
 | 
			
		||||
@@ -1658,6 +1674,14 @@ QModelIndex QmlJSTextEditor::indexForPosition(unsigned cursorPosition, const QMo
 | 
			
		||||
    return lastIndex;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QmlJSTextEditor::hideContextPane()
 | 
			
		||||
{
 | 
			
		||||
    bool b = (m_contextPane) && m_contextPane->widget()->isVisible();
 | 
			
		||||
    if (b)
 | 
			
		||||
        m_contextPane->apply(editableInterface(),  m_semanticInfo.document, m_semanticInfo.snapshot, 0, false);
 | 
			
		||||
    return b;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SemanticHighlighter::Source QmlJSTextEditor::currentSource(bool force)
 | 
			
		||||
{
 | 
			
		||||
    int line = 0, column = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -256,6 +256,8 @@ protected:
 | 
			
		||||
    void contextMenuEvent(QContextMenuEvent *e);
 | 
			
		||||
    bool event(QEvent *e);
 | 
			
		||||
    void wheelEvent(QWheelEvent *event);
 | 
			
		||||
    void resizeEvent(QResizeEvent *event);
 | 
			
		||||
    void scrollContentsBy(int dx, int dy);
 | 
			
		||||
    TextEditor::BaseTextEditorEditable *createEditableInterface();
 | 
			
		||||
    void createToolBar(QmlJSEditorEditable *editable);
 | 
			
		||||
    TextEditor::BaseTextEditor::Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true);
 | 
			
		||||
@@ -277,6 +279,7 @@ private:
 | 
			
		||||
 | 
			
		||||
    SemanticHighlighter::Source currentSource(bool force = false);
 | 
			
		||||
    QModelIndex indexForPosition(unsigned cursorPosition, const QModelIndex &rootIndex = QModelIndex()) const;
 | 
			
		||||
    bool hideContextPane();
 | 
			
		||||
 | 
			
		||||
    const Core::Context m_context;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user