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