Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

266 mouse hover doesnt display variable value reliably #278

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* Fixed regression when adding commands to a breakpoint.
* Refactored/improved Printpoints. Added 'help' to the
Printpoint create dialog.
* Fixed regression when display variable value when hovering over
the text in the editor window.

## [2.4] - 2024-03-18
* Changed main icon to a more license friendly one.
Expand Down
2 changes: 2 additions & 0 deletions src/SeerEditorWidgetSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit {
void contextMenuEvent (QContextMenuEvent* event);
void mouseReleaseEvent (QMouseEvent* event);
bool event (QEvent* event);
void showExpressionTooltip ();
void hideExpressionTooltip ();

private slots:
void refreshExtraSelections ();
Expand Down
48 changes: 36 additions & 12 deletions src/SeerEditorWidgetSourceAreas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,7 @@ bool SeerEditorWidgetSourceArea::event(QEvent* event) {
QString word = cursor.selectedText();

if (word.isEmpty() == true) {

QToolTip::hideText();

_selectedExpressionCursor = QTextCursor();
_selectedExpressionPosition = QPoint();
_selectedExpressionName = "";
_selectedExpressionValue = "";

hideExpressionTooltip();
break;
}

Expand All @@ -526,19 +519,30 @@ bool SeerEditorWidgetSourceArea::event(QEvent* event) {
// Same word as before? Display the tooltip value.
if (word == _selectedExpressionName) {

QToolTip::showText(helpEvent->globalPos(), _selectedExpressionName + ": " + Seer::elideText(_selectedExpressionValue, Qt::ElideRight, 100));
// If the tooltip is already visible, refreshen it with
// the same value, possibly at a new postion.
if (QToolTip::isVisible()) {
_selectedExpressionPosition = helpEvent->globalPos();

showExpressionTooltip();

// If not already visible, refreshen its value.
}else{
emit evaluateVariableExpression(_selectedExpressionId, _selectedExpressionName); // For the tooltip.
}

// Otherwise, hide any old one.
}else{
QToolTip::hideText();
hideExpressionTooltip();
}

// Otherwise it's a different spot. Create a new request to get the variable's value.
}else{
QToolTip::hideText();

hideExpressionTooltip();

_selectedExpressionCursor = cursor;
_selectedExpressionPosition = helpEvent->pos();
_selectedExpressionPosition = helpEvent->globalPos();
_selectedExpressionName = word;
_selectedExpressionValue = "";

Expand All @@ -555,6 +559,24 @@ bool SeerEditorWidgetSourceArea::event(QEvent* event) {
return QPlainTextEdit::event(event);
}

void SeerEditorWidgetSourceArea::showExpressionTooltip () {

// qDebug() << "Tooltip:" << _selectedExpressionPosition << _selectedExpressionName << _selectedExpressionValue;

QToolTip::hideText();
QToolTip::showText(_selectedExpressionPosition, _selectedExpressionName + ": " + Seer::elideText(_selectedExpressionValue, Qt::ElideRight, 100));
}

void SeerEditorWidgetSourceArea::hideExpressionTooltip () {

QToolTip::hideText();

_selectedExpressionCursor = QTextCursor();
_selectedExpressionPosition = QPoint();
_selectedExpressionName = "";
_selectedExpressionValue = "";
}

void SeerEditorWidgetSourceArea::refreshExtraSelections () {

//
Expand Down Expand Up @@ -1744,6 +1766,8 @@ void SeerEditorWidgetSourceArea::handleText (const QString& text) {
if (id_text.toInt() == _selectedExpressionId) {

_selectedExpressionValue = Seer::filterEscapes(Seer::parseFirst(text, "value=", '"', '"', false));

showExpressionTooltip();
}

return;
Expand Down
20 changes: 20 additions & 0 deletions src/SeerMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,26 @@ void SeerMainWindow::handleText (const QString& text) {
return;
}

if (msg_text.startsWith("\"A syntax error in expression, near")) {
return;
}

if (msg_text.startsWith("\"Invalid character ")) {
return;
}

if (msg_text.startsWith("\"No symbol ")) {
return;
}

if (msg_text.startsWith("\"Problem parsing arguments: data-evaluate-expression")) {
return;
}

if (msg_text == "\"Attempt to use a type name as an expression\"") {
return;
}

gdbWidget->addMessage(Seer::filterEscapes(msg_text), QMessageBox::Warning);

return;
Expand Down
Loading