Skip to content

Commit

Permalink
Merge pull request #166 from epasveer/157-ux-bug-or-flaw-seer-executi…
Browse files Browse the repository at this point in the history
…on-messages-popup-is-getting-in-the-way-a-lot

Add 'raise mode' to raise message tab depending on message type.
  • Loading branch information
epasveer authored Oct 8, 2023
2 parents c8e02e7 + c7269f6 commit 81bb388
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/SeerGdbWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
// Connect things.
QObject::connect(logsTabWidget->tabBar(), &QTabBar::tabMoved, this, &SeerGdbWidget::handleLogsTabMoved);
QObject::connect(logsTabWidget->tabBar(), &QTabBar::currentChanged, this, &SeerGdbWidget::handleLogsTabChanged);
QObject::connect(_messagesBrowserWidget, &SeerMessagesBrowserWidget::showMessages, this, &SeerGdbWidget::handleRaiseMessageTab);

QObject::connect(manualCommandComboBox->lineEdit(), &QLineEdit::returnPressed, this, &SeerGdbWidget::handleManualCommandExecute);

Expand Down Expand Up @@ -706,6 +707,17 @@ void SeerGdbWidget::handleLogsTabChanged (int index) {
writeLogsSettings();
}

void SeerGdbWidget::handleRaiseMessageTab () {

int idx = logsTabWidget->indexOf(_messagesBrowserWidget);

if (idx < 0) {
return;
}

logsTabWidget->setCurrentIndex(idx);
}

void SeerGdbWidget::writeLogsSettings () {

// Write tab order to settings.
Expand Down
1 change: 1 addition & 0 deletions src/SeerGdbWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm {
public slots:
void handleLogsTabMoved (int from, int to);
void handleLogsTabChanged (int index);
void handleRaiseMessageTab ();

void handleText (const QString& text);
void handleManualCommandExecute ();
Expand Down
90 changes: 83 additions & 7 deletions src/SeerMessagesBrowserWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include "SeerMessagesBrowserWidget.h"
#include <QtWidgets/QTreeWidget>
#include <QtWidgets/QTreeWidgetItemIterator>
#include <QtWidgets/QMessageBox>
#include <QtCore/QSettings>
#include <QtCore/QTime>
#include <QtCore/QDebug>

SeerMessagesBrowserWidget::SeerMessagesBrowserWidget (QWidget* parent) : QWidget(parent) {

_raiseMode = "any"; // Default. Raise message tab on any message.
_raiseMenu = 0;

// Construct the UI.
setupUi(this);

Expand All @@ -26,6 +29,19 @@ SeerMessagesBrowserWidget::SeerMessagesBrowserWidget (QWidget* parent) : QWidget
messagesTreeWidget->resizeColumnToContents(1); // message type icon
messagesTreeWidget->resizeColumnToContents(2); // message


_raiseMenu = new QMenu("Raise Messages Tab");

QMenu* menu = new QMenu();
menu->addMenu(_raiseMenu);

_anyMessageAction = _raiseMenu->addAction("Any message");
_importanMessagesAction = _raiseMenu->addAction("Important messages");
_neverMessagesAction = _raiseMenu->addAction("Never");

preferencesToolButton->setMenu(menu);
preferencesToolButton->setPopupMode(QToolButton::InstantPopup);

// Get icons.
_informationIcon = QIcon(":/seer/resources/RelaxLightIcons/data-information.svg");
_warningIcon = QIcon(":/seer/resources/RelaxLightIcons/data-warning.svg");
Expand All @@ -35,22 +51,21 @@ SeerMessagesBrowserWidget::SeerMessagesBrowserWidget (QWidget* parent) : QWidget

// Connect things.
QObject::connect(deleteMessagesToolButton, &QToolButton::clicked, this, &SeerMessagesBrowserWidget::handleDeleteToolButton);
QObject::connect(_raiseMenu, &QMenu::aboutToShow, this, &SeerMessagesBrowserWidget::handleRaiseMenuShow);
QObject::connect(_raiseMenu, &QMenu::triggered, this, &SeerMessagesBrowserWidget::handleRaiseMenuTriggered);

// Clear messages
clearMessages();

// Read the default settings.
readSettings();
}

SeerMessagesBrowserWidget::~SeerMessagesBrowserWidget () {
}

void SeerMessagesBrowserWidget::addMessage (const QString& message, QMessageBox::Icon messageType) {

// Give this dialog the focus.
//setFocus(Qt::OtherFocusReason);

// Show messages any time a messaged is added.
emit showMessages();

// Create an entry with our message.
QTreeWidgetItem* item = new QTreeWidgetItem;
item->setText(0, QTime::currentTime().toString(Qt::TextDate));
Expand Down Expand Up @@ -93,16 +108,77 @@ void SeerMessagesBrowserWidget::addMessage (const QString& message, QMessageBox:
messagesTreeWidget->clearSelection();
lastItem->setSelected(true);
}

// Signal that a message was added, depending on the 'raise' mode.
if (_raiseMode == "any") {
emit showMessages();
}else if (_raiseMode == "important") {
if (messageType == QMessageBox::Warning || messageType == QMessageBox::Critical || messageType == QMessageBox::Question) {
emit showMessages();
}else if (message.startsWith("Program started")) {
emit showMessages();
}else if (message.startsWith("Program exited")) {
emit showMessages();
}
}else if (_raiseMode == "never") {
// Do nothing.
}
}

void SeerMessagesBrowserWidget::clearMessages () {

messagesTreeWidget->clear();
}

void SeerMessagesBrowserWidget::writeSettings () {

QSettings settings;

settings.beginGroup("executionmessages"); {
settings.setValue("raisetabmode", _raiseMode);
}settings.endGroup();
}

void SeerMessagesBrowserWidget::readSettings () {

QSettings settings;

settings.beginGroup("executionmessages"); {
_raiseMode = settings.value("raisetabmode", "any").toString();
} settings.endGroup();
}

void SeerMessagesBrowserWidget::handleDeleteToolButton () {

// Delete all messages.
clearMessages();
}

void SeerMessagesBrowserWidget::handleRaiseMenuShow () {

if (_raiseMode == "any") {
_raiseMenu->setDefaultAction(_anyMessageAction);
}else if (_raiseMode == "important") {
_raiseMenu->setDefaultAction(_importanMessagesAction);
}else if (_raiseMode == "never") {
_raiseMenu->setDefaultAction(_neverMessagesAction);
}else{
_raiseMenu->setDefaultAction(_anyMessageAction);
}
}

void SeerMessagesBrowserWidget::handleRaiseMenuTriggered (QAction* action) {

if (action == _anyMessageAction) {
_raiseMode = "any";
}else if (action == _importanMessagesAction) {
_raiseMode = "important";
}else if (action == _neverMessagesAction) {
_raiseMode = "never";
}else{
_raiseMode = "any";
}

writeSettings();
}

11 changes: 11 additions & 0 deletions src/SeerMessagesBrowserWidget.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include <QtWidgets/QMessageBox>
#include <QtWidgets/QMenu>
#include <QtWidgets/QWidget>
#include <QtGui/QIcon>
#include <QtGui/QAction>
#include <QtCore/QString>
#include "ui_SeerMessagesBrowserWidget.h"

Expand All @@ -20,13 +22,22 @@ class SeerMessagesBrowserWidget : public QWidget, protected Ui::SeerMessagesBrow

private slots:
void handleDeleteToolButton ();
void handleRaiseMenuShow ();
void handleRaiseMenuTriggered (QAction* action);

signals:
void showMessages ();

protected:
void writeSettings ();
void readSettings ();

private:
QString _raiseMode;
QMenu* _raiseMenu;
QAction* _anyMessageAction;
QAction* _importanMessagesAction;
QAction* _neverMessagesAction;
QIcon _noIcon;
QIcon _informationIcon;
QIcon _warningIcon;
Expand Down
14 changes: 14 additions & 0 deletions src/SeerMessagesBrowserWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="preferencesToolButton">
<property name="toolTip">
<string>Preferences</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="resource.qrc">
<normaloff>:/seer/resources/RelaxLightIcons/application-menu.svg</normaloff>:/seer/resources/RelaxLightIcons/application-menu.svg</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down
1 change: 1 addition & 0 deletions src/resource.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<file>resources/icons-icons/maximize.png</file>
<file>resources/icons-icons/minimize.png</file>
<file>resources/icons-icons/style.png</file>
<file>resources/RelaxLightIcons/application-menu.svg</file>
<file>resources/RelaxLightIcons/document-new.svg</file>
<file>resources/RelaxLightIcons/document-open.svg</file>
<file>resources/RelaxLightIcons/document-print.svg</file>
Expand Down
13 changes: 13 additions & 0 deletions src/resources/RelaxLightIcons/application-menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/resources/help/BreakpointGdbSeerManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Introduction
This part of Seer shows Breakpoints, GDB log, and Seer log information. In detailed, the information is:

* Messages
* Breakpoints
* Watchpoints
* Catchpoints
Expand All @@ -12,6 +13,21 @@ This part of Seer shows Breakpoints, GDB log, and Seer log information. In detai
* Save and load breakpoints
* Manual GDB commands.

### Messages

Various gdb execution messages are listed in this tab. These occur as you debug the program. The message types are:

* Program startup and completion
* Breakpoint encouters
* Signal encounters
* General gdb errors

The message tab can be raised in various ways when a message is added to the tab:

* Any message
* Important messages (program startup, signal encounters)
* Never

### Breakpoints

Breakpoints sets up a stopping point of the program being debugged when a function and line number is reached.
Expand Down

0 comments on commit 81bb388

Please sign in to comment.