From c7269f661ca3feed379e09fe5aa2fdae070af6fc Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sun, 8 Oct 2023 10:54:11 -0500 Subject: [PATCH] Add 'raise mode' to raise message tab depending on message type. --- src/SeerGdbWidget.cpp | 12 +++ src/SeerGdbWidget.h | 1 + src/SeerMessagesBrowserWidget.cpp | 90 +++++++++++++++++-- src/SeerMessagesBrowserWidget.h | 11 +++ src/SeerMessagesBrowserWidget.ui | 14 +++ src/resource.qrc | 1 + .../RelaxLightIcons/application-menu.svg | 13 +++ .../help/BreakpointGdbSeerManager.md | 16 ++++ 8 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 src/resources/RelaxLightIcons/application-menu.svg diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index 4f9a0b7c..751a1863 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -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); @@ -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. diff --git a/src/SeerGdbWidget.h b/src/SeerGdbWidget.h index 1ae7e81a..315facc9 100644 --- a/src/SeerGdbWidget.h +++ b/src/SeerGdbWidget.h @@ -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 (); diff --git a/src/SeerMessagesBrowserWidget.cpp b/src/SeerMessagesBrowserWidget.cpp index 8ed7eea9..90669d1d 100644 --- a/src/SeerMessagesBrowserWidget.cpp +++ b/src/SeerMessagesBrowserWidget.cpp @@ -1,12 +1,15 @@ #include "SeerMessagesBrowserWidget.h" #include #include -#include +#include #include #include SeerMessagesBrowserWidget::SeerMessagesBrowserWidget (QWidget* parent) : QWidget(parent) { + _raiseMode = "any"; // Default. Raise message tab on any message. + _raiseMenu = 0; + // Construct the UI. setupUi(this); @@ -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"); @@ -35,9 +51,14 @@ 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 () { @@ -45,12 +66,6 @@ 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)); @@ -93,6 +108,21 @@ 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 () { @@ -100,9 +130,55 @@ 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(); +} + diff --git a/src/SeerMessagesBrowserWidget.h b/src/SeerMessagesBrowserWidget.h index 140cec5a..03de6772 100644 --- a/src/SeerMessagesBrowserWidget.h +++ b/src/SeerMessagesBrowserWidget.h @@ -1,8 +1,10 @@ #pragma once #include +#include #include #include +#include #include #include "ui_SeerMessagesBrowserWidget.h" @@ -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; diff --git a/src/SeerMessagesBrowserWidget.ui b/src/SeerMessagesBrowserWidget.ui index 86154da2..877ff2c8 100644 --- a/src/SeerMessagesBrowserWidget.ui +++ b/src/SeerMessagesBrowserWidget.ui @@ -57,6 +57,20 @@ + + + + Preferences + + + + + + + :/seer/resources/RelaxLightIcons/application-menu.svg:/seer/resources/RelaxLightIcons/application-menu.svg + + + diff --git a/src/resource.qrc b/src/resource.qrc index dd44f661..e56bd6bf 100644 --- a/src/resource.qrc +++ b/src/resource.qrc @@ -24,6 +24,7 @@ resources/icons-icons/maximize.png resources/icons-icons/minimize.png resources/icons-icons/style.png + resources/RelaxLightIcons/application-menu.svg resources/RelaxLightIcons/document-new.svg resources/RelaxLightIcons/document-open.svg resources/RelaxLightIcons/document-print.svg diff --git a/src/resources/RelaxLightIcons/application-menu.svg b/src/resources/RelaxLightIcons/application-menu.svg new file mode 100644 index 00000000..40f2db64 --- /dev/null +++ b/src/resources/RelaxLightIcons/application-menu.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/src/resources/help/BreakpointGdbSeerManager.md b/src/resources/help/BreakpointGdbSeerManager.md index 8ab455c1..b4e99d92 100644 --- a/src/resources/help/BreakpointGdbSeerManager.md +++ b/src/resources/help/BreakpointGdbSeerManager.md @@ -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 @@ -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.