Merge pull request #409 from epasveer/408-file-menu-doesnt-show

408 file menu doesnt show
This commit is contained in:
Ernie Pasveer
2025-12-21 08:46:37 -06:00
committed by GitHub
4 changed files with 40 additions and 56 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ SeerMainWindow::SeerMainWindow(QWidget* parent) : QMainWindow(parent) {
// Add status bar indicator.
SeerRunStatusIndicator* runStatus = new SeerRunStatusIndicator(this);
statusBar()->addPermanentWidget(runStatus->indicatorBox());
statusBar()->addPermanentWidget(runStatus);
// Add progress spin widget.
QWidget* spacerWidget = new QWidget(this);
+13 -10
View File
@@ -12,6 +12,9 @@
SeerPlainTextEdit::SeerPlainTextEdit(const QString& text, QWidget* parent) : QPlainTextEdit(text, parent) {
// Turn off the widget's cursor. We'll do our own in the paintEvent.
setCursorWidth(0);
_cursorVisible = true;
_cursorTimer = new QTimer(this);
@@ -23,6 +26,9 @@ SeerPlainTextEdit::SeerPlainTextEdit(const QString& text, QWidget* parent) : QPl
SeerPlainTextEdit::SeerPlainTextEdit(QWidget* parent) : QPlainTextEdit(parent) {
// Turn off the widget's cursor. We'll do our own in the paintEvent.
setCursorWidth(0);
_cursorVisible = true;
_cursorTimer = new QTimer(this);
@@ -52,22 +58,19 @@ void SeerPlainTextEdit::paintEvent(QPaintEvent* event) {
// First, let the standard QPlainTextEdit handle its painting.
QPlainTextEdit::paintEvent(event);
// If the widget does not have focus, draw the cursor manually.
// Get our painter.
QPainter painter(viewport());
// Draw the cursor manually.
if (_cursorVisible) {
setCursorWidth(CURSOR_WIDTH);
QRect r = cursorRect();
QPainter p(viewport());
p.fillRect(r, palette().text().color());
}
else
{
setCursorWidth(0);
r.setWidth(CURSOR_WIDTH);
painter.fillRect(r, palette().text().color());
}
// Add margin highlight for current line
QPainter painter(viewport());
QTextCursor cursor = textCursor();
QTextBlock block = cursor.block();
QTextBlock block = cursor.block();
// Get the rectangle of the current line (block)
QRectF rect = blockBoundingGeometry(block).translated(contentOffset());
+26 -39
View File
@@ -3,64 +3,48 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "SeerRunStatusIndicator.h"
#include <QtGui/QFontMetrics>
#include <QtWidgets/QApplication>
#include <QtCore/QDebug>
#include <QGroupBox>
#include <QPainter>
SeerRunStatusIndicator::SeerRunStatusIndicator(QWidget* parent) : QLabel(parent) {
// Create group box
_groupBox = new QGroupBox();
_groupBox->setTitle("");
_groupBox->setFlat(true);
_groupBox->setStyleSheet("QGroupBox { border: none; }");
_statusLabel = new QLabel("Status");
_statusLabel->setAlignment(Qt::AlignCenter);
_statusLabel->setFixedSize(150, 25);
_statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;");
QSize size = fontMetrics().size(Qt::TextSingleLine, "XXXXXXXXXXXXXXXXXX");
// Layout
auto *layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(_statusLabel);
_groupBox->setLayout(layout);
setAlignment(Qt::AlignCenter);
setFixedWidth(size.width());
setText("Status");
setStyleSheet("background-color: lightgray; color: black; font-weight: bold;");
}
SeerRunStatusIndicator::~SeerRunStatusIndicator() {
}
void SeerRunStatusIndicator::setRunStatus (SeerRunStatusIndicator::RunStatus status) {
if (status == RunStatus::Idle) {
_statusLabel->setText("Session Terminated");
_statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;");
setText("Session Terminated");
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;");
setText("Stopped");
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 if (status == RunStatus::Stop_By_Breakpoint) {
setText("Stop by breakpoint");
setStyleSheet("background-color: yellow; color: black; font-weight: bold;");
}
else {
_statusLabel->setText("Unknown");
}else if (status == RunStatus::Running) {
setText("Running");
setStyleSheet("background-color: green; color: black; font-weight: bold;");
}else{
setText("Unknown");
}
emit statusChanged(status);
}
QGroupBox* SeerRunStatusIndicator::indicatorBox() {
return _groupBox;
}
void SeerRunStatusIndicator::handleText (const QString& text) {
if (text.startsWith("*running,thread-id=\"")) {
@@ -99,8 +83,11 @@ void SeerRunStatusIndicator::handleText (const QString& text) {
// handle when program stop/ killed
void SeerRunStatusIndicator::handleSessionTerminated() {
_statusLabel->setText("Session Terminated");
_statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;");
setText("Session Terminated");
setStyleSheet("background-color: lightgray; color: black; font-weight: bold;");
// also tell SeerProgressIndicator to stop spinning
setRunStatus(SeerRunStatusIndicator::Idle);
}
}
-6
View File
@@ -6,8 +6,6 @@
#include <QtWidgets/QLabel>
#include <QtCore/QString>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
class SeerRunStatusIndicator : public QLabel {
@@ -27,7 +25,6 @@ class SeerRunStatusIndicator : public QLabel {
void setRunStatus (SeerRunStatusIndicator::RunStatus status);
SeerRunStatusIndicator::RunStatus runStatus () const;
QGroupBox* indicatorBox ();
signals:
void statusChanged (SeerRunStatusIndicator::RunStatus status);
@@ -39,8 +36,5 @@ class SeerRunStatusIndicator : public QLabel {
protected:
private:
QGroupBox* _groupBox;
QLabel* _statusLabel;
QHBoxLayout* _layout;
};