temp update

This commit is contained in:
QuangNguyenMinh123
2025-12-18 13:17:45 +07:00
parent ccdea4f867
commit 1f58fe2bf9
2 changed files with 77 additions and 5 deletions
+67 -4
View File
@@ -5,9 +5,33 @@
#include "SeerRunStatusIndicator.h"
#include <QtWidgets/QApplication>
#include <QtCore/QDebug>
#include <QGroupBox>
#include <QPainter>
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);
}
+10 -1
View File
@@ -6,6 +6,9 @@
#include <QtWidgets/QLabel>
#include <QtCore/QString>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
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;
};