From b7320a5f238fe53181ec6210fb8221ef28c79cea Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 8 Oct 2026 15:16:08 +0200 Subject: [PATCH] sam panel: add Clear button for the output log Run and Clear sit in a horizontal row (Run expands, Clear fixed) so Clear costs no extra vertical space. Clear calls the existing clearOutput(). --- src/plugin/sampanel.cpp | 14 +++++++++++++- src/plugin/sampanel.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugin/sampanel.cpp b/src/plugin/sampanel.cpp index 6ec91a6..3aa9aa2 100644 --- a/src/plugin/sampanel.cpp +++ b/src/plugin/sampanel.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -67,7 +68,18 @@ SamPanel::SamPanel(QWidget *parent) m_runButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connect(m_runButton, &QPushButton::clicked, this, [this]() { Q_EMIT runRequested(program()); }); - layout->addWidget(m_runButton); + + m_clearButton = new QPushButton(i18n("Clear"), this); + m_clearButton->setMinimumHeight(28); + m_clearButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + connect(m_clearButton, &QPushButton::clicked, this, [this]() { clearOutput(); }); + + auto *buttonRow = new QHBoxLayout(); + buttonRow->setContentsMargins(0, 0, 0, 0); + buttonRow->setSpacing(4); + buttonRow->addWidget(m_runButton); + buttonRow->addWidget(m_clearButton); + layout->addLayout(buttonRow); m_output = new QTextEdit(this); m_output->setReadOnly(true); diff --git a/src/plugin/sampanel.h b/src/plugin/sampanel.h index 917f923..cf4aca0 100644 --- a/src/plugin/sampanel.h +++ b/src/plugin/sampanel.h @@ -43,6 +43,7 @@ Q_SIGNALS: private: QPlainTextEdit *m_editor = nullptr; QPushButton *m_runButton = nullptr; + QPushButton *m_clearButton = nullptr; QTextEdit *m_output = nullptr; };