- TAG [uartscopeclean] eingefügt, über den alle Logs gelöscht werden
- Pauseknopf und Eingabezeile hinzugefügt, um Kommandos an den Pi zu schicken
This commit is contained in:
78
include/sendbar.h
Normal file
78
include/sendbar.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QPoint>
|
||||
|
||||
// SendBar sits below the Raw/Table view and the HDMI preview and lets the
|
||||
// user talk BACK to the firmware over UART/TCP, for debugging:
|
||||
//
|
||||
// [ Pause ] [ ...free-text input...................... ] [Senden] [ending v]
|
||||
//
|
||||
// - The left button sends a fixed, user-configurable byte sequence (right-
|
||||
// click it to change the label and the code - e.g. a single control byte
|
||||
// or a short command string). Handy for a "pause"/"step" command that's
|
||||
// sent identically every time.
|
||||
// - The input line sends whatever is typed the moment Enter is pressed
|
||||
// (or the "Senden" button is clicked), with a selectable line ending
|
||||
// appended.
|
||||
//
|
||||
// SendBar itself never touches the serial device - it only emits
|
||||
// sendRequested() with the raw bytes to write; MainWindow forwards those to
|
||||
// SerialWorker::writeData().
|
||||
class SendBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SendBar(QWidget *parent = nullptr);
|
||||
|
||||
// Persisted configuration accessors, used by MainWindow::save/restoreSettings.
|
||||
QString buttonLabel() const { return m_buttonLabel; }
|
||||
QString buttonCode() const { return m_buttonCode; } // raw, as typed (with escapes)
|
||||
int lineEndingIndex() const;
|
||||
|
||||
void setButtonLabel(const QString &label);
|
||||
void setButtonCode(const QString &code);
|
||||
void setLineEndingIndex(int index);
|
||||
|
||||
// Turns C-style escapes (\n \r \t \0 \\ and \xHH) in `text` into the
|
||||
// actual bytes they represent. Exposed as static so it can be reused/
|
||||
// unit-tested independently of the widget.
|
||||
static QByteArray unescape(const QString &text);
|
||||
|
||||
public slots:
|
||||
// Enables/disables the send controls - there is no point letting the
|
||||
// user try to send anything while nothing is connected.
|
||||
void setConnected(bool connected);
|
||||
|
||||
signals:
|
||||
// Raw bytes ready to be written to the serial/network device.
|
||||
void sendRequested(const QByteArray &data);
|
||||
// The button label/code or the line-ending choice changed - MainWindow
|
||||
// listens to this to persist it immediately, consistent with how the
|
||||
// Tag filter and Screenshot folder dialogs already behave.
|
||||
void configChanged();
|
||||
|
||||
private slots:
|
||||
void onPauseClicked();
|
||||
void onPauseContextMenu(const QPoint &pos);
|
||||
void onSendClicked();
|
||||
void configureButton();
|
||||
|
||||
private:
|
||||
void setupUi();
|
||||
void updatePauseButtonUi();
|
||||
void sendInputLine();
|
||||
|
||||
QPushButton *m_pauseBtn = nullptr;
|
||||
QLineEdit *m_inputEdit = nullptr;
|
||||
QPushButton *m_sendBtn = nullptr;
|
||||
QComboBox *m_endingCombo = nullptr;
|
||||
|
||||
QString m_buttonLabel = tr("Pause");
|
||||
QString m_buttonCode = QStringLiteral("PAUSE\\n");
|
||||
};
|
||||
Reference in New Issue
Block a user