Skip to content

Commit

Permalink
Merge pull request #278 from epasveer/266-mouse-hover-doesnt-display-…
Browse files Browse the repository at this point in the history
…variable-value-reliably

266 mouse hover doesnt display variable value reliably
  • Loading branch information
epasveer authored Dec 27, 2024
2 parents 54172ea + 74d6252 commit 8d4e2a7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
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

0 comments on commit 8d4e2a7

Please sign in to comment.