Sound hinzugefügt und UI aufgeräumt

This commit is contained in:
2026-09-27 02:04:23 +02:00
parent b92d58d812
commit bc564c5371
7 changed files with 341 additions and 68 deletions

View File

@@ -7,10 +7,10 @@
#include <QTabWidget>
#include <QStatusBar>
#include <QToolBar>
#include <QMenuBar>
#include <QMenu>
#include <QLabel>
#include <QAction>
#include <QSpinBox>
#include <QCheckBox>
#include <QSet>
#include "serialworker.h"
@@ -46,11 +46,13 @@ private slots:
void showFormatReference();
void configureTagFilter();
void configureScreenshotDir();
void configureReconnectInterval();
void showAbout();
private:
void setupUi();
void setupToolBar();
void setupMenuBar();
void setupStatusBar();
void clearAllViews();
void doShutdown();
@@ -71,8 +73,8 @@ private:
QLabel *m_stateLabel = nullptr;
QLabel *m_reconnectLabel = nullptr;
QCheckBox *m_autoReconnectCb = nullptr;
QSpinBox *m_reconnectIntervalSb = nullptr;
QAction *m_autoReconnectAction = nullptr;
int m_reconnectIntervalMs = 2000;
QAction *m_connectAction = nullptr;
QAction *m_disconnectAction = nullptr;
@@ -85,5 +87,14 @@ private:
SerialConfig m_lastConfig;
QSet<QString> m_suppressedTags; // tags hidden from Raw view
QString m_screenshotDir; // target folder for [SCREENSHOT] tag captures
// Remembered folders for the *manual* "Screenshot"/"Record" toolbar
// buttons in VideoWidget (distinct from m_screenshotDir above, which is
// only for the firmware-triggered [SCREENSHOT] tag) - so the save
// dialogs reopen wherever the user last saved to instead of always
// resetting to Pictures/Videos.
QString m_lastManualScreenshotDir;
QString m_lastVideoDir;
bool m_shutdownDone = false;
};

View File

@@ -12,6 +12,13 @@
#include "v4l2worker.h"
// A uniform, icon-only push button used for the video toolbar (start/stop,
// freeze, screenshot, record, fullscreen, audio, ...). All toolbar buttons
// share the same fixed square size and font so the row lines up neatly
// instead of every button sizing itself to its own label.
QPushButton *makeToolbarIconButton(const QString &symbol, const QString &tooltip,
QWidget *parent);
// A borderless top-level window that mirrors the live video frame at full
// screen size. Opened from VideoWidget's "⛶" button; closes itself on
// Escape or a double-click anywhere on it.
@@ -59,6 +66,14 @@ public:
// dropping the request).
void setAutoScreenshotDir(const QString &dir) { m_autoScreenshotDir = dir; }
// Folders the manual "Screenshot"/"Record" buttons' save dialogs
// default to. Set by MainWindow from persisted settings on startup;
// VideoWidget reports back via lastScreenshotDirChanged()/
// lastVideoDirChanged() whenever the user picks a new folder so
// MainWindow can persist it for next time.
void setLastScreenshotDir(const QString &dir) { m_lastScreenshotDir = dir; }
void setLastVideoDir(const QString &dir) { m_lastVideoDir = dir; }
public slots:
void onNewFrame(const QImage &frame);
void clearFrame(); // blanks the preview (used on ANSI clear-screen)
@@ -76,13 +91,21 @@ signals:
// firmware-driven triggers.
void autoScreenshotResult(bool success, const QString &message);
// Emitted whenever the user successfully saves via the manual
// "Screenshot"/"Record" buttons, so MainWindow can persist the folder
// for next time (see setLastScreenshotDir()/setLastVideoDir()).
void lastScreenshotDirChanged(const QString &dir);
void lastVideoDirChanged(const QString &dir);
private slots:
void onStartStop();
void onFreeze(bool frozen);
void onScreenshot();
void onRecordToggled(bool checked);
void onFullscreenToggle();
void onAudioToggled(bool checked);
void refreshDeviceList();
void refreshAudioDevices();
protected:
void paintEvent(QPaintEvent *event) override;
@@ -96,6 +119,9 @@ private:
void startRecording();
void stopRecording();
void writeRecordingFrame(const QImage &frame);
void startAudio();
void stopAudio();
static QStringList enumerateAudioDevices();
QThread *m_thread = nullptr;
V4l2Worker *m_worker = nullptr;
@@ -114,6 +140,18 @@ private:
QPushButton *m_fullscreenBtn = nullptr;
QLabel *m_infoLabel = nullptr;
// Audio passthrough: plays the grabber's ALSA capture device (e.g. the
// "USB Audio" card that accompanies a /dev/videoN HDMI/USB grabber)
// straight to the default output, the same way the HDMI viewer does it.
// Implemented by shelling out to `ffplay -f alsa -i <device>` with
// -nodisp (audio only, no extra window) - same approach as recording,
// just piping the other direction (device -> speakers instead of
// frames -> file).
QComboBox *m_audioCombo = nullptr;
QPushButton *m_audioBtn = nullptr;
QProcess *m_audioProcess = nullptr;
bool m_audioActive = false;
// Fullscreen overlay window (nullptr when not open). Owns itself via
// Qt::WA_DeleteOnClose; VideoWidget just tracks whether one currently
// exists and forwards frames to it while it's open.
@@ -131,4 +169,9 @@ private:
// Folder for saveAutoScreenshot() ([SCREENSHOT] tag). Set via
// setAutoScreenshotDir(), persisted/restored by MainWindow.
QString m_autoScreenshotDir;
// Folders the manual Screenshot/Record save dialogs default to (see
// setLastScreenshotDir()/setLastVideoDir() above).
QString m_lastScreenshotDir;
QString m_lastVideoDir;
};