Commit f5b4668f authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlJsEditor: combine the Quick ToolBar with the toolTip

1000ms after a tooltip is shown we now also show the quick toolbar

Reviewed-by: Erik Verbruggen
parent cb48aad9
......@@ -63,6 +63,7 @@
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/refactoroverlay.h>
#include <texteditor/tooltip/tooltip.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
......@@ -82,7 +83,8 @@
enum {
UPDATE_DOCUMENT_DEFAULT_INTERVAL = 100,
UPDATE_USES_DEFAULT_INTERVAL = 150,
UPDATE_OUTLINE_INTERVAL = 500 // msecs after new semantic info has been arrived / cursor has moved
UPDATE_OUTLINE_INTERVAL = 500, // msecs after new semantic info has been arrived / cursor has moved
TOOLTIP_TIMER_INTERVAL = 1000 // delay after we show the Quick ToolBar after a tooltip
};
using namespace QmlJS;
......@@ -678,7 +680,8 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
m_modelManager(0),
m_contextPane(0),
m_updateSelectedElements(false),
m_findReferences(new FindReferences(this))
m_findReferences(new FindReferences(this)),
m_toolTipPosition(0)
{
qRegisterMetaType<QmlJSEditor::Internal::SemanticInfo>("QmlJSEditor::Internal::SemanticInfo");
......@@ -725,6 +728,11 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
m_cursorPositionTimer->setSingleShot(true);
connect(m_cursorPositionTimer, SIGNAL(timeout()), this, SLOT(updateCursorPositionNow()));
m_ToolTipTimer = new QTimer(this);
m_ToolTipTimer->setInterval(TOOLTIP_TIMER_INTERVAL);
m_ToolTipTimer->setSingleShot(true);
connect(m_ToolTipTimer, SIGNAL(timeout()), this, SLOT(updateToolTipNow()));
baseTextDocument()->setSyntaxHighlighter(new Highlighter(document()));
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<ModelManagerInterface>();
......@@ -750,6 +758,9 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
connect(this, SIGNAL(refactorMarkerClicked(TextEditor::Internal::RefactorMarker)),
SLOT(onRefactorMarkerClicked(TextEditor::Internal::RefactorMarker)));
connect(editableInterface(), SIGNAL(tooltipRequested(TextEditor::ITextEditor*, QPoint, int)),
SLOT(onTooltipRequested(TextEditor::ITextEditor*, QPoint, int)));
setRequestMarkEnabled(true);
}
......@@ -1458,6 +1469,28 @@ void QmlJSTextEditor::performQuickFix(int index)
op->perform();
}
void QmlJSTextEditor::onTooltipRequested(TextEditor::ITextEditor* /* editor */, QPoint /* point */, int position)
{
m_toolTipPosition = position;
if (m_contextPane) {
m_ToolTipTimer->start();
}
}
void QmlJSTextEditor::updateToolTipNow()
{
if (!TextEditor::ToolTip::instance()->isVisible())
return;
if (m_contextPane) {
Node *newNode = m_semanticInfo.declaringMemberNoProperties(m_toolTipPosition);
m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false, true);
m_oldCursorPosition = m_toolTipPosition;
QList<TextEditor::Internal::RefactorMarker> markers;
setRefactorMarkers(markers);
}
}
void QmlJSTextEditor::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = new QMenu();
......
......@@ -279,6 +279,8 @@ private slots:
void onRefactorMarkerClicked(const TextEditor::Internal::RefactorMarker &marker);
void performQuickFix(int index);
void onTooltipRequested(TextEditor::ITextEditor* editor, QPoint point, int position);
void updateToolTipNow();
protected:
void contextMenuEvent(QContextMenuEvent *e);
......@@ -317,6 +319,7 @@ private:
QTimer *m_updateOutlineTimer;
QTimer *m_updateOutlineIndexTimer;
QTimer *m_cursorPositionTimer;
QTimer *m_toolTipTimer;
QComboBox *m_outlineCombo;
QmlOutlineModel *m_outlineModel;
QModelIndex m_outlineModelIndex;
......@@ -333,6 +336,7 @@ private:
QmlJS::IContextPane *m_contextPane;
int m_oldCursorPosition;
bool m_updateSelectedElements;
int m_toolTipPosition;
FindReferences *m_findReferences;
};
......
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