Commit c27c9a31 authored by Tim Jenssen's avatar Tim Jenssen Committed by Thomas Hartmann

QmlDesigner: fix gotoCode in error/warning case

The QmlDesignerPlugin::hideDesigner() jumped again to selected node,
which came after the DocumentWarningWidget already set it.

Change-Id: I6e84342208c6405e8b25b516cd411b30bc48fcdb
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent 9a9c29dd
......@@ -319,6 +319,7 @@ void DesignModeWidget::setup()
m_warningWidget->setVisible(false);
connect(m_warningWidget.data(), &DocumentWarningWidget::gotoCodeClicked, [=]
(const QString &filePath, int codeLine, int codeColumn) {
Q_UNUSED(filePath);
QTC_ASSERT(textEditor(), return;);
......@@ -570,6 +571,13 @@ void DesignModeWidget::showWarningMessageBox(const QList<RewriterError> &warning
m_warningWidget->setVisible(true);
}
bool DesignModeWidget::gotoCodeWasClicked()
{
if (m_warningWidget)
return m_warningWidget->gotoCodeWasClicked();
return false;
}
CrumbleBar *DesignModeWidget::crumbleBar() const
{
return m_crumbleBar;
......
......@@ -79,6 +79,7 @@ public:
void disableWidgets();
void showErrorMessageBox(const QList<RewriterError> &errors);
void showWarningMessageBox(const QList<RewriterError> &warnings);
bool gotoCodeWasClicked();
CrumbleBar* crumbleBar() const;
......
......@@ -65,9 +65,8 @@ DocumentWarningWidget::DocumentWarningWidget(QWidget *parent)
connect(m_navigateLabel, &QLabel::linkActivated, this, [=](const QString &link) {
if (link == QLatin1String("goToCode")) {
RewriterError message = m_messages.at(m_currentMessage);
hide();
emit gotoCodeClicked(message.url().toLocalFile(), message.line(), message.column() - 1);
emitGotoCodeClicked(m_messages.at(m_currentMessage));
} else if (link == QLatin1String("previous")) {
--m_currentMessage;
refreshContent();
......@@ -79,10 +78,8 @@ DocumentWarningWidget::DocumentWarningWidget(QWidget *parent)
connect(m_continueButton, &QPushButton::clicked, this, [=]() {
hide();
if (m_mode == ErrorMode) {
RewriterError message = m_messages.at(m_currentMessage);
emit gotoCodeClicked(message.url().toLocalFile(), message.line(), message.column() - 1);
}
if (m_mode == ErrorMode)
emitGotoCodeClicked(m_messages.at(m_currentMessage));
});
connect(m_ignoreWarningsCheckBox, &QCheckBox::toggled, this, &DocumentWarningWidget::ignoreCheckBoxToggled);
......@@ -173,11 +170,23 @@ bool DocumentWarningWidget::eventFilter(QObject *object, QEvent *event)
void DocumentWarningWidget::showEvent(QShowEvent *event)
{
m_gotoCodeWasClicked = false;
moveToParentCenter();
refreshContent();
Utils::FakeToolTip::showEvent(event);
}
bool DocumentWarningWidget::gotoCodeWasClicked()
{
return m_gotoCodeWasClicked;
}
void DocumentWarningWidget::emitGotoCodeClicked(const RewriterError &message)
{
m_gotoCodeWasClicked = true;
emit gotoCodeClicked(message.url().toLocalFile(), message.line(), message.column() - 1);
}
bool DocumentWarningWidget::warningsEnabled() const
{
DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
......
......@@ -54,6 +54,8 @@ public:
void setWarnings(const QList<RewriterError> &warnings);
bool warningsEnabled() const;
bool gotoCodeWasClicked();
void emitGotoCodeClicked(const RewriterError &message);
signals:
void gotoCodeClicked(const QString filePath, int codeLine, int codeColumn);
protected:
......@@ -74,6 +76,7 @@ private:
QList<RewriterError> m_messages;
int m_currentMessage = 0;
Mode m_mode = NoMode;
bool m_gotoCodeWasClicked = false;
};
} // namespace Internal
......
......@@ -347,10 +347,11 @@ void QmlDesignerPlugin::showDesigner()
void QmlDesignerPlugin::hideDesigner()
{
if (currentDesignDocument()
&& currentModel()
&& !currentDesignDocument()->hasQmlParseErrors())
jumpTextCursorToSelectedModelNode();
if (currentDesignDocument() && currentModel()) {
// the message box handle the cursor jump itself
if (mainWidget()->gotoCodeWasClicked() == false)
jumpTextCursorToSelectedModelNode();
}
if (d->documentManager.hasCurrentDesignDocument()) {
deactivateAutoSynchronization();
......
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