53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
/*
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
*
|
|
* SamPanel — the tool-view widget for running sam commands.
|
|
*
|
|
* Layout: a multi-line command editor on top, a Run button, and a read-only
|
|
* output/log area below. The widget is pure UI: it emits runRequested() with
|
|
* the program text; SamView does the document work (snapshot, engine, apply
|
|
* in an EditingTransaction) and calls showOutput()/showError() to report back.
|
|
*/
|
|
#ifndef DEFT_SAMPANEL_H
|
|
#define DEFT_SAMPANEL_H
|
|
|
|
#include <QWidget>
|
|
|
|
class QPlainTextEdit;
|
|
class QPushButton;
|
|
class QTextEdit;
|
|
|
|
namespace deft
|
|
{
|
|
|
|
class SamPanel : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit SamPanel(QWidget *parent = nullptr);
|
|
|
|
/*! The current program text. */
|
|
QString program() const;
|
|
|
|
/*! Append a normal (non-error) line to the output log. */
|
|
void showOutput(const QString &text);
|
|
/*! Append an error line (rendered emphasised) to the output log. */
|
|
void showError(const QString &text);
|
|
/*! Clear the output log. */
|
|
void clearOutput();
|
|
|
|
Q_SIGNALS:
|
|
/*! The user asked to run the program (Run button or Ctrl+Return). */
|
|
void runRequested(const QString &program);
|
|
|
|
private:
|
|
QPlainTextEdit *m_editor = nullptr;
|
|
QPushButton *m_runButton = nullptr;
|
|
QPushButton *m_clearButton = nullptr;
|
|
QTextEdit *m_output = nullptr;
|
|
};
|
|
|
|
} // namespace deft
|
|
|
|
#endif
|