From 1f58fe2bf98f03675fce3eb1ff2a0b5e2b602f86 Mon Sep 17 00:00:00 2001 From: QuangNguyenMinh123 <100016403+QuangNguyenMinh123@users.noreply.github.com> Date: Thu, 18 Dec 2025 13:17:45 +0700 Subject: [PATCH] temp update --- src/SeerRunStatusIndicator.cpp | 71 ++++++++++++++++++++++++++++++++-- src/SeerRunStatusIndicator.h | 11 +++++- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/SeerRunStatusIndicator.cpp b/src/SeerRunStatusIndicator.cpp index ee9dc3a..d61b8f2 100644 --- a/src/SeerRunStatusIndicator.cpp +++ b/src/SeerRunStatusIndicator.cpp @@ -5,9 +5,33 @@ #include "SeerRunStatusIndicator.h" #include #include +#include +#include SeerRunStatusIndicator::SeerRunStatusIndicator(QWidget* parent) : QLabel(parent) { _runStatus = RunStatus::Idle; + + // Create group box + _groupBox = new QGroupBox(); + _groupBox->setTitle(""); + // --- Create two fixed-size labels --- + _coreLabel = new QLabel("Core"); + _coreLabel->setAlignment(Qt::AlignCenter); + _coreLabel->setFixedSize(80, 25); + _coreLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + + _statusLabel = new QLabel("Status"); + _statusLabel->setAlignment(Qt::AlignCenter); + _statusLabel->setFixedSize(150, 25); + _statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + + // --- Layout with spacing --- + auto *layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->addWidget(_coreLabel); + layout->addWidget(_statusLabel); + _groupBox->setLayout(layout); } SeerRunStatusIndicator::~SeerRunStatusIndicator() { @@ -40,6 +64,29 @@ void SeerRunStatusIndicator::setRunStatus (SeerRunStatusIndicator::RunStatus sta setText("Unknown"); } + // + if (status == RunStatus::Idle) { + _statusLabel->setText("Idle"); + _statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + + }else if (status == RunStatus::Stopped) { + _statusLabel->setText("Stopped"); + _statusLabel->setStyleSheet("background-color: red; color: black; font-weight: bold;"); + + } + else if (status == RunStatus::Stop_By_Breakpoint) { + _statusLabel->setText("Stop by breakpoint"); + _statusLabel->setStyleSheet("background-color: yellow; color: black; font-weight: bold;"); + } + else if (status == RunStatus::Running) { + _statusLabel->setText("Running"); + _statusLabel->setStyleSheet("background-color: green; color: black; font-weight: bold;"); + + } + else { + _statusLabel->setText("Unknown"); + } + emit statusChanged(status); } @@ -56,9 +103,11 @@ void SeerRunStatusIndicator::handleText (const QString& text) { setRunStatus(SeerRunStatusIndicator::Running); }else if (text.startsWith("*stopped")) { - - //^connected,frame={level=\"0\",addr=\"0x00007f48351f80c1\",func=\"read\",args=[],from=\"/lib64/libc.so.6\",arch=\"i386:x86-64\"}" - setRunStatus(SeerRunStatusIndicator::Stopped); + if (text.startsWith("*stopped,reason=\"breakpoint-hit\"")) + setRunStatus(SeerRunStatusIndicator::Stop_By_Breakpoint); + else + //^connected,frame={level=\"0\",addr=\"0x00007f48351f80c1\",func=\"read\",args=[],from=\"/lib64/libc.so.6\",arch=\"i386:x86-64\"}" + setRunStatus(SeerRunStatusIndicator::Stopped); }else if (text.startsWith("=thread-exited")) { @@ -70,9 +119,23 @@ void SeerRunStatusIndicator::handleText (const QString& text) { //=thread-group-exited,id="i1" setRunStatus(SeerRunStatusIndicator::Stopped); - }else{ + } + else if (text.startsWith("^done,stack")) { + // When finish command is invoked + setRunStatus(SeerRunStatusIndicator::Stopped); + } + else{ // All other text is ignored by this widget. // qDebug() << text; } } +// handle when program stop/ killed +void SeerRunStatusIndicator::handleTerminate() { + _coreLabel->setText("Core"); + _coreLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + _statusLabel->setText("Status"); + _statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + // also tell SeerProgressIndicator to stop spinning + setRunStatus(SeerRunStatusIndicator::Stopped); +} \ No newline at end of file diff --git a/src/SeerRunStatusIndicator.h b/src/SeerRunStatusIndicator.h index 5309b70..ba6bb80 100644 --- a/src/SeerRunStatusIndicator.h +++ b/src/SeerRunStatusIndicator.h @@ -6,6 +6,9 @@ #include #include +#include +#include +#include class SeerRunStatusIndicator : public QLabel { @@ -15,7 +18,8 @@ class SeerRunStatusIndicator : public QLabel { enum RunStatus { Idle = 0, Stopped = 1, - Running = 2 + Stop_By_Breakpoint = 2, + Running = 3, }; explicit SeerRunStatusIndicator(QWidget* parent = 0); @@ -29,10 +33,15 @@ class SeerRunStatusIndicator : public QLabel { public slots: void handleText (const QString& text); + void handleTerminate (); protected: private: SeerRunStatusIndicator::RunStatus _runStatus; + QGroupBox *_groupBox; + QLabel *_coreLabel; + QLabel *_statusLabel; + QHBoxLayout *_layout; };