diff --git a/README.md b/README.md index 1168e5c..0efa8a4 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,11 @@ To build and install the Arch package: | Space | Record / pause / resume; play / pause while editing | | Enter or Ctrl+Enter | Stop the take and edit it | | Esc | Confirm discarding the clip and start over | +| M | Mirror the picture | | Q | Quit (asks first if the take is still recording or unsaved) | | ? | Keyboard help | -The shutter button records and stops; the round button beside it pauses and resumes. +The shutter button records and stops; the round button beside it pauses and resumes. **Mirror** flips the picture so it moves like a mirror. A take keeps the choice it started with: it plays mirrored in the editor and saves mirrored, so what you save matches what you saw. Saving a mirrored take always re-encodes it. While editing, the timeline shows your take as one or more clips, each framed with a handle at both ends. Whatever falls outside every clip is cut. @@ -61,11 +62,11 @@ Handles catch on pause marks, neighbouring clips, and the playhead. Playback pla ## Storage and settings -Takes are recorded into the application's XDG data directory, normally `~/.local/share/omacom/monologue/recordings/`, one folder per take. Saving an unedited clip copies the original without re-encoding; an edited clip is re-encoded from its clips (H.264 CRF 18, AAC) into a hidden temporary file beside the destination, then renamed into place. Saving into Monologue's own recordings folder is refused. +Takes are recorded into the application's XDG data directory, normally `~/.local/share/omacom/monologue/recordings/`, one folder per take. Saving an unedited clip copies the original without re-encoding; an edited or mirrored clip is re-encoded from its clips (H.264 CRF 18, AAC) into a hidden temporary file beside the destination, then renamed into place. Saving into Monologue's own recordings folder is refused. A take lives only as long as you're working on it: starting a new recording or quitting deletes it. If you haven't saved it since your last change, Monologue asks first, and offers to save. If Monologue is killed or crashes with a take open, the next launch reopens that take in the editor if it was last written less than an hour ago (its edits and pause marks are not kept); an older one is deleted. A take that can't be played back is deleted. Each take holds a lock while in use, so a second Monologue window never mistakes it for an interrupted one. -Device IDs and the last save directory live in the application's Qt settings, normally `~/.config/omacom/monologue.conf`. The theme is read from `~/.local/state/omarchy/current/theme/colors.toml`, as in Omacut. No Omarchy config is changed. +Device IDs, the mirror choice, and the last save directory live in the application's Qt settings, normally `~/.config/omacom/monologue.conf`. The theme is read from `~/.local/state/omarchy/current/theme/colors.toml`, as in Omacut. No Omarchy config is changed. A disconnected source or encoder error stops the take and preserves its files. An unfinalized MP4 after a crash or power loss may not be playable. Maximum resolution is never silently reduced: if the device or encoder cannot sustain it, Monologue reports the problem. diff --git a/src/EditBar.qml b/src/EditBar.qml index 58806d0..7ba35ee 100644 --- a/src/EditBar.qml +++ b/src/EditBar.qml @@ -74,6 +74,7 @@ Item { x: Math.round(index * slot); width: Math.round((index + 1) * slot) - x; height: track.height sourceSize.height: track.height fillMode: Image.PreserveAspectCrop + mirror: backend.takeMirrored asynchronous: true; cache: false source: index < backend.thumbnails.ready ? "image://thumbs/" + backend.thumbnails.revision + "/" + index : "" } diff --git a/src/Main.qml b/src/Main.qml index 972c8b5..8ae7dc8 100644 --- a/src/Main.qml +++ b/src/Main.qml @@ -150,6 +150,7 @@ ApplicationWindow { Shortcut { sequence: "Z"; context: Qt.WindowShortcut; autoRepeat: false; enabled: win.editing; onActivated: editBar.toggleZoom() } Shortcut { sequence: "Ctrl+Z"; context: Qt.WindowShortcut; enabled: win.editing && backend.canUndo; onActivated: backend.undo() } Shortcut { sequences: ["Ctrl+Shift+Z", "Ctrl+Y"]; context: Qt.WindowShortcut; enabled: win.editing && backend.canRedo; onActivated: backend.redo() } + Shortcut { sequence: "M"; context: Qt.WindowShortcut; autoRepeat: false; enabled: !win.finished && !win.busy && !win.overlayOpen && !backend.takeActive && !cameraChoice.popup.visible && !microphoneChoice.popup.visible; onActivated: backend.mirrorPreview = !backend.mirrorPreview } Shortcut { sequence: "Q"; context: Qt.WindowShortcut; autoRepeat: false; enabled: !win.overlayOpen; onActivated: win.closeSafely() } Shortcut { sequence: "?"; context: Qt.WindowShortcut; enabled: !win.overlayOpen; onActivated: helpDialog.open() } @@ -162,6 +163,7 @@ ApplicationWindow { microphone: "M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z M5.5 11a6.5 6.5 0 0 0 13 0 M12 17.5V21", chevron: "M6 9l6 6 6-6", back: "M4 12a8 8 0 1 0 2.4-5.7 M4 4v4.5h4.5", + mirror: "M12 3v18 M9 7L4 17h5z M15 7l5 10h-5z", play: "M8 4.5v15l12.5-7.5z", pause: "M7 4.5h2a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z M15 4.5h2a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z" }) @@ -195,7 +197,7 @@ ApplicationWindow { font.pixelSize: 13; font.weight: Font.DemiBold focusPolicy: Qt.TabFocus implicitHeight: 42 - readonly property color foreground: button.progress >= 0 ? win.textColor : button.primary ? win.accentForeground : button.flat && !button.hovered ? win.dimColor : win.textColor + readonly property color foreground: button.progress >= 0 ? win.textColor : button.primary ? win.accentForeground : button.checked ? win.accent : button.flat && !button.hovered ? win.dimColor : win.textColor contentItem: Item { implicitWidth: label.implicitWidth; implicitHeight: label.implicitHeight Row { @@ -330,9 +332,19 @@ ApplicationWindow { Rectangle { Layout.fillWidth: true; Layout.fillHeight: true; Layout.minimumHeight: 120 color: "black"; clip: true - VideoOutput { id: liveVideo; anchors.fill: parent; visible: !win.finished; fillMode: VideoOutput.PreserveAspectFit; focus: true } + // Mirroring flips the picture on screen; the recording keeps the camera's own orientation until it's saved. + VideoOutput { + id: liveVideo; objectName: "liveVideo" + anchors.fill: parent; visible: !win.finished; fillMode: VideoOutput.PreserveAspectFit; focus: true + transform: Scale { origin.x: liveVideo.width / 2; xScale: backend.mirrorPreview ? -1 : 1 } + } // Hold the last frame at the end of the file rather than clearing to black. - VideoOutput { id: clipVideo; objectName: "clipVideo"; endOfStreamPolicy: VideoOutput.KeepLastFrame; anchors.fill: parent; visible: win.finished; fillMode: VideoOutput.PreserveAspectFit } + VideoOutput { + id: clipVideo; objectName: "clipVideo"; endOfStreamPolicy: VideoOutput.KeepLastFrame + anchors.fill: parent; visible: win.finished; fillMode: VideoOutput.PreserveAspectFit + // A take recorded mirrored plays mirrored, as it will be saved. + transform: Scale { origin.x: clipVideo.width / 2; xScale: backend.takeMirrored ? -1 : 1 } + } MouseArea { anchors.fill: parent; onClicked: { liveVideo.forceActiveFocus(); if (win.finished) win.togglePlayback() } } Column { anchors.centerIn: parent; width: Math.min(400, parent.width-40); spacing: 16 @@ -487,6 +499,17 @@ ApplicationWindow { RowLayout { Layout.fillWidth: true; Layout.preferredWidth: 1; spacing: 8 Item { Layout.fillWidth: true } + ActionButton { + objectName: "mirrorButton" + visible: !win.finished; flat: true + iconPath: win.icons.mirror; text: "Mirror" + checked: backend.mirrorPreview + enabled: !win.busy && !backend.dialogOpen && !backend.takeActive + Accessible.name: "Mirror" + ToolTip.visible: hovered; ToolTip.text: (backend.mirrorPreview ? "Stop mirroring" : "Mirror") + " the picture (M). Takes save as you see them." + // Clicked, not toggled: ActionButton's Return/Enter handling emits clicked(). + onClicked: { backend.mirrorPreview = !backend.mirrorPreview; liveVideo.forceActiveFocus() } + } ActionButton { objectName: "saveButton" readonly property bool saving: backend.state === "saving" @@ -598,7 +621,7 @@ ApplicationWindow { spacing: 40 ShortcutList { Layout.alignment: Qt.AlignTop; heading: "Recording" - rows: [["Space", "Record / pause / resume"], ["Enter", "Stop and edit"], ["Esc", "Discard and start over"], ["Q", "Quit"], ["?", "Show shortcuts"]] + rows: [["Space", "Record / pause / resume"], ["Enter", "Stop and edit"], ["Esc", "Discard and start over"], ["M", "Mirror the picture"], ["Q", "Quit"], ["?", "Show shortcuts"]] } ShortcutList { Layout.alignment: Qt.AlignTop; heading: "Editing" diff --git a/src/backend.cpp b/src/backend.cpp index 9c50603..3caf00b 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -27,6 +27,7 @@ Backend::Backend(FilePicker *picker, bool activateHardware, QObject *parent) m_root = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/recordings"; m_cameraId=m_settings.value("camera/id").toString(); m_audioId=m_settings.value("microphone/id").toString(); + m_mirrorPreview=m_settings.value("preview/mirror",false).toBool(); m_capture.setVideoSink(&m_sink); connect(&m_sink,&QVideoSink::videoFrameChanged,this,&Backend::receiveVideo); if(m_activateHardware) { @@ -53,6 +54,13 @@ Backend::~Backend() { releaseSources(); if(m_export) { m_export->disconnect(this); m_export->kill(); m_export->waitForFinished(); QFile::remove(m_exportPartial); } } +void Backend::setMirrorPreview(bool mirror) { + // A take keeps the choice it started with; it decides how the take saves. + if(mirror==m_mirrorPreview || m_writer) return; + m_mirrorPreview=mirror; + m_settings.setValue("preview/mirror",mirror); + emit mirrorPreviewChanged(); +} int Backend::cameraIndex() const { return indexOf(m_cameras,m_cameraId); } int Backend::microphoneIndex() const { return indexOf(m_microphones,m_audioId); } bool Backend::ready() const { return m_state=="ready" && m_cameraHealthy && (!audioEnabled() || m_audioHealthy); } @@ -250,6 +258,10 @@ void Backend::startTake() { m_clipFileName="Monologue-"+QDateTime::currentDateTime().toString("yyyy-MM-dd-HHmmss")+".mp4"; m_clipPath=directory+"/"+m_clipFileName; m_interruption.clear(); m_duration=0; + // Remembered beside the take, so a recovered take still saves the way it was framed. + m_takeMirrored=m_mirrorPreview; + // Without the marker the take still records and saves mirrored; only recovering it after a crash would not. + if(m_takeMirrored && !QFile(directory+"/.mirrored").open(QIODevice::WriteOnly)) qWarning("Could not mark the take as mirrored."); readAudio(); m_writer=new Writer(this); connect(m_writer,&Writer::finished,this,&Backend::writerFinished,Qt::QueuedConnection); @@ -362,7 +374,8 @@ void Backend::writeTo(const QString &destination) { if(!takes.isEmpty() && (folder==takes || folder.startsWith(takes+"/"))) { m_message="Could not save: choose a folder outside Monologue's working files."; emit changed(); return; } - if(edit::untouched(m_edit,m_duration)) copyTo(destination); + // A mirrored take is flipped on the way out, so it can't be copied as recorded. + if(edit::untouched(m_edit,m_duration) && !m_takeMirrored) copyTo(destination); else exportTo(destination); } void Backend::copyTo(const QString &destination) { @@ -412,7 +425,7 @@ void Backend::exportTo(const QString &destination) { m_export->deleteLater(); m_export=nullptr; saved(destination,"ffmpeg could not be started."); }); - m_export->start("ffmpeg",media::exportArgs(m_clipPath,m_exportPartial,edit::kept(m_edit),m_clipAudio)); + m_export->start("ffmpeg",media::exportArgs(m_clipPath,m_exportPartial,edit::kept(m_edit),m_clipAudio,m_takeMirrored)); } void Backend::saved(const QString &destination,const QString &error) { if(!error.isEmpty() && !m_exportPartial.isEmpty()) QFile::remove(m_exportPartial); @@ -517,7 +530,7 @@ void Backend::deleteTake() { m_takeLock.reset(); QDir(m_root+"/"+m_takeId).removeRecursively(); } - m_takeId.clear(); m_clipPath.clear(); m_clipFileName.clear(); + m_takeId.clear(); m_clipPath.clear(); m_clipFileName.clear(); m_takeMirrored=false; resetEdit({},{}); m_thumbnails.clear(); } void Backend::recoverTake() { @@ -528,6 +541,7 @@ void Backend::recoverTake() { for(const auto &name:QDir(entry.filePath()).entryList({"*.mp4"},QDir::Files)) if(!name.endsWith(".finalizing.mp4")) clip=name; m_takeId=entry.fileName(); + m_takeMirrored=QFile::exists(entry.filePath()+"/.mirrored"); // Only a recent take is worth reopening; anything older is just left over. const QFileInfo file(entry.filePath()+"/"+clip); if(clip.isEmpty() || file.lastModified().secsTo(QDateTime::currentDateTime())>=3600) { deleteTake(); continue; } diff --git a/src/backend.h b/src/backend.h index e8eaceb..230046f 100644 --- a/src/backend.h +++ b/src/backend.h @@ -45,6 +45,10 @@ class Backend : public QObject { Q_PROPERTY(bool canRedo READ canRedo NOTIFY editChanged) // The finished take has not been saved as it is now edited. Q_PROPERTY(bool unsaved READ unsaved NOTIFY editChanged) + // Mirror the picture. New takes record this choice and are flipped when saved. + Q_PROPERTY(bool mirrorPreview READ mirrorPreview WRITE setMirrorPreview NOTIFY mirrorPreviewChanged) + // The take was recorded with a mirrored preview, so it plays and saves mirrored to match. + Q_PROPERTY(bool takeMirrored READ takeMirrored NOTIFY changed) Q_PROPERTY(QObject *thumbnails READ thumbnails CONSTANT) public: explicit Backend(QObject *parent = nullptr); @@ -74,6 +78,9 @@ class Backend : public QObject { bool canUndo() const { return !m_undo.isEmpty(); } bool canRedo() const { return !m_redo.isEmpty(); } bool unsaved() const; + bool mirrorPreview() const { return m_mirrorPreview; } + void setMirrorPreview(bool mirror); + bool takeMirrored() const { return m_takeMirrored; } Thumbnails *thumbnails() { return &m_thumbnails; } edit::Clips currentEdit() const { return m_edit; } Q_INVOKABLE void setPreview(QObject *sink); @@ -104,6 +111,7 @@ class Backend : public QObject { void devicesChanged(); void meterChanged(); void editChanged(); + void mirrorPreviewChanged(); void safeToClose(); void overwriteRequested(const QString &path); private: @@ -170,5 +178,6 @@ class Backend : public QObject { qint64 m_clipUntil = 0, m_peakUntil = 0, m_signalAt = 0; double m_duration = 0, m_level = -60, m_peak = -60, m_pendingPeak = 0, m_fps = 30; bool m_cameraHealthy = false, m_audioHealthy = false, m_dialogOpen = false; + bool m_mirrorPreview = false, m_takeMirrored = false; bool m_hasSaved = false, m_discardAfter = false, m_restartAfter = false, m_probing = false; }; diff --git a/src/mediautils.cpp b/src/mediautils.cpp index 190212f..29003a6 100644 --- a/src/mediautils.cpp +++ b/src/mediautils.cpp @@ -110,7 +110,7 @@ media::Probe media::probe(const QString &path) { if (!result.ok) result.error = "The recording could not be finalized as a playable H.264 MP4."; return result; } -QStringList media::exportArgs(const QString &source, const QString &destination, const QList &kept, bool audio) { +QStringList media::exportArgs(const QString &source, const QString &destination, const QList &kept, bool audio, bool mirror) { QStringList args{"-nostdin", "-v", "error", "-y", "-progress", "pipe:1", "-nostats"}; QString graph; // One seeking input per kept range decodes only what survives the cut. @@ -118,7 +118,8 @@ QStringList media::exportArgs(const QString &source, const QString &destination, args << "-ss" << QString::number(kept[i].start, 'f', 3) << "-t" << QString::number(kept[i].length(), 'f', 3) << "-i" << source; graph += QString("[%1:v:0]").arg(i) + (audio ? QString("[%1:a:0]").arg(i) : QString()); } - graph += QString("concat=n=%1:v=1:a=%2[v]").arg(kept.size()).arg(audio ? 1 : 0) + (audio ? "[a]" : ""); + graph += QString("concat=n=%1:v=1:a=%2").arg(kept.size()).arg(audio ? 1 : 0) + (mirror ? "[joined]" : "[v]") + (audio ? "[a]" : ""); + if (mirror) graph += ";[joined]hflip[v]"; args << "-filter_complex" << graph << "-map" << "[v]"; if (audio) args << "-map" << "[a]" << "-c:a" << "aac" << "-b:a" << "192k"; args << "-c:v" << "libx264" << "-preset" << "veryfast" << "-crf" << "18" << "-pix_fmt" << "yuv420p" diff --git a/src/mediautils.h b/src/mediautils.h index 17645d3..804ea5e 100644 --- a/src/mediautils.h +++ b/src/mediautils.h @@ -18,6 +18,7 @@ QString normalizeMp4(const QString &path, double fps); struct Probe { bool ok = false; QString error; QSize size; double duration = 0; bool audio = false; }; Probe probe(const QString &path); // Re-encodes the kept ranges of a recording into one MP4, reporting progress on stdout. -QStringList exportArgs(const QString &source, const QString &destination, const QList &kept, bool audio); +// mirror flips the picture horizontally, for takes recorded with a mirrored preview. +QStringList exportArgs(const QString &source, const QString &destination, const QList &kept, bool audio, bool mirror = false); QImage thumbnail(const QString &path, double time, int height, const std::atomic *cancel); } diff --git a/tests/backend_tests.cpp b/tests/backend_tests.cpp index 19745fe..2cd2b4e 100644 --- a/tests/backend_tests.cpp +++ b/tests/backend_tests.cpp @@ -75,6 +75,7 @@ private slots: QVERIFY(args.contains("[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[v][a]")); QCOMPARE(args.count("-i"),2); QVERIFY(media::exportArgs("in.mp4","out.mp4",{{0,2}},false).contains("[0:v:0]concat=n=1:v=1:a=0[v]")); + QVERIFY(media::exportArgs("in.mp4","out.mp4",{{0,2}},true,true).contains("[0:v:0][0:a:0]concat=n=1:v=1:a=1[joined][a];[joined]hflip[v]")); } void meterAllChannels() { QAudioFormat f; f.setSampleRate(48000); f.setChannelCount(2); f.setSampleFormat(QAudioFormat::Int16); @@ -179,6 +180,50 @@ private slots: QVERIFY(QFile::copy(directory.filePath("take.mp4"),fixture.filePath("fixture.mp4"))); } } + void mirrorPreviewIsRemembered() { + { + Backend backend(new FakePicker,false); + QVERIFY(!backend.mirrorPreview()); + QSignalSpy changed(&backend,&Backend::mirrorPreviewChanged); + backend.setMirrorPreview(true); backend.setMirrorPreview(true); + QVERIFY(backend.mirrorPreview()); QCOMPARE(changed.count(),1); + } + { + Backend backend(new FakePicker,false); + QVERIFY(backend.mirrorPreview()); + backend.setMirrorPreview(false); + } + Backend backend(new FakePicker,false); + QVERIFY(!backend.mirrorPreview()); + } + void mirroredTakeSavesMirrored() { + // Red on the left, blue on the right; a mirrored take saves blue on the left. + QTemporaryDir source; + QProcess encode; + encode.start("ffmpeg",{"-v","error","-f","lavfi","-i","color=red:s=64x64:r=30:d=1","-f","lavfi","-i","color=blue:s=64x64:r=30:d=1", + "-filter_complex","[0][1]hstack","-c:v","libx264","-pix_fmt","yuv420p",source.filePath("split.mp4")}); + QVERIFY(encode.waitForFinished(20000)); QCOMPARE(encode.exitCode(),0); + const auto directory=leaveTake("00000000-0000-0000-0000-000000000008",source.filePath("split.mp4")); + QVERIFY(!directory.isEmpty()); + { QFile marker(directory+"/.mirrored"); QVERIFY(marker.open(QIODevice::WriteOnly)); } + auto *picker=new FakePicker; + Backend backend(picker,false); + QTRY_COMPARE(backend.state(),QString("finished")); + QVERIFY(backend.takeMirrored()); + const auto saved=source.filePath("mirrored.mp4"); + backend.save(); picker->choose(QUrl::fromLocalFile(saved)); + // Even unedited, it is re-encoded rather than copied. + QCOMPARE(backend.state(),QString("saving")); + QTRY_COMPARE_WITH_TIMEOUT(backend.state(),QString("finished"),30000); + QVERIFY2(backend.message().startsWith("Saved to"),qPrintable(backend.message())); + const auto frame=media::thumbnail(saved,0.5,64,nullptr); + QVERIFY(!frame.isNull()); + const auto left=frame.pixelColor(8,32), right=frame.pixelColor(frame.width()-8,32); + QVERIFY2(left.blue()>180 && left.red()<80,qPrintable(left.name())); + QVERIFY2(right.red()>180 && right.blue()<80,qPrintable(right.name())); + backend.newRecording(); + QVERIFY(!backend.takeMirrored()); QVERIFY(!QDir(directory).exists()); + } void recoveryAndSave() { const auto directory=leaveTake("00000000-0000-0000-0000-000000000001",fixture.filePath("fixture.mp4")); QVERIFY(!directory.isEmpty()); diff --git a/tests/ui_tests.cpp b/tests/ui_tests.cpp index 85371be..3f32d96 100644 --- a/tests/ui_tests.cpp +++ b/tests/ui_tests.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,8 @@ QtObject { property bool canUndo: false property bool canRedo: false property bool unsaved: true + property bool mirrorPreview: false + property bool takeMirrored: false property int newRecordings: 0 property QtObject thumbnails: QtObject { property int count: 12 @@ -96,7 +99,31 @@ QtObject { engine.load(QUrl("qrc:/Main.qml")); QVERIFY(!engine.rootObjects().isEmpty()); auto *window=qobject_cast(engine.rootObjects().first()); QVERIFY(window); QVERIFY(QTest::qWaitForWindowExposed(window)); window->requestActivate(); QTest::qWait(100); + // Mirror flips only the live preview, by key or button, and is off by default. + auto *live=window->findChild("liveVideo"); QVERIFY(live); + auto *mirror=window->findChild("mirrorButton"); QVERIFY(mirror); + const auto liveScale=[&] { QQmlListReference t(live,"transform"); return t.count()==1 ? t.at(0)->property("xScale").toDouble() : 0.0; }; + QVERIFY(mirror->isVisible()); QVERIFY(!mirror->property("checked").toBool()); QCOMPARE(liveScale(),1.0); + QTest::keyClick(window,Qt::Key_M); QVERIFY(backend->property("mirrorPreview").toBool()); + QVERIFY(mirror->property("checked").toBool()); QCOMPARE(liveScale(),-1.0); + window->grabWindow().save("/tmp/monologue-ui-mirrored.png"); + const auto mirrorAt=mirror->mapToScene(QPointF(mirror->width()/2,mirror->height()/2)).toPoint(); + QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,mirrorAt); + QVERIFY(!backend->property("mirrorPreview").toBool()); QCOMPARE(liveScale(),1.0); + QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,mirrorAt); + QVERIFY(backend->property("mirrorPreview").toBool()); + QTest::keyClick(window,Qt::Key_M); QVERIFY(!backend->property("mirrorPreview").toBool()); + // With focus on the button, Return and Enter toggle it like a click. + mirror->forceActiveFocus(); QVERIFY(mirror->hasActiveFocus()); + QTest::keyClick(window,Qt::Key_Return); QVERIFY(backend->property("mirrorPreview").toBool()); + QVERIFY(mirror->property("checked").toBool()); QCOMPARE(liveScale(),-1.0); + mirror->forceActiveFocus(); QTest::keyClick(window,Qt::Key_Enter); QVERIFY(!backend->property("mirrorPreview").toBool()); + QVERIFY(!mirror->property("checked").toBool()); QCOMPARE(liveScale(),1.0); + QTRY_VERIFY(live->hasActiveFocus()); QTest::keyClick(window,Qt::Key_Space); QCOMPARE(backend->property("state").toString(),QString("recording")); + // A take keeps the mirroring it started with. + QVERIFY(!mirror->isEnabled()); + QTest::keyClick(window,Qt::Key_M); QVERIFY(!backend->property("mirrorPreview").toBool()); QTest::keyClick(window,Qt::Key_Space); QCOMPARE(backend->property("state").toString(),QString("paused")); QTest::keyClick(window,Qt::Key_Space); QCOMPARE(backend->property("state").toString(),QString("recording")); QKeyEvent repeat(QEvent::KeyPress,Qt::Key_Space,Qt::NoModifier," ",true); QCoreApplication::sendEvent(window,&repeat); @@ -137,6 +164,14 @@ QtObject { QTest::keyClick(window,Qt::Key_Space); QCOMPARE(backend->property("state").toString(),QString("recording")); QTest::keyClick(window,Qt::Key_Return); QCOMPARE(backend->property("state").toString(),QString("finished")); + // The editor plays the take as it will be saved; mirroring is decided before recording. + QVERIFY(!mirror->isVisible()); + QTest::keyClick(window,Qt::Key_M); QVERIFY(!backend->property("mirrorPreview").toBool()); + auto *clipVideo=window->findChild("clipVideo"); QVERIFY(clipVideo); + const auto clipScale=[&] { QQmlListReference t(clipVideo,"transform"); return t.count()==1 ? t.at(0)->property("xScale").toDouble() : 0.0; }; + QCOMPARE(clipScale(),1.0); + backend->setProperty("takeMirrored",true); QCOMPARE(clipScale(),-1.0); + backend->setProperty("takeMirrored",false); // Split at 10 and 20 s, remove the middle clip, restore the gap with X, then trim to the playhead. auto *bar=window->findChild("editBar"); QVERIFY(bar); auto clips=[&] { return backend->property("clips").toList(); }; @@ -204,7 +239,6 @@ QtObject { const auto red=themeDir.filePath("red.mp4"); QProcess encode; encode.start("ffmpeg",{"-v","error","-f","lavfi","-i","color=red:s=320x240:d=1","-c:v","libx264","-pix_fmt","yuv420p",red}); QVERIFY(encode.waitForFinished(20000)); QCOMPARE(encode.exitCode(),0); - auto *clipVideo=window->findChild("clipVideo"); QVERIFY(clipVideo); auto *sink=clipVideo->property("videoSink").value(); QVERIFY(sink); // Reaching the end of the file must not clear the picture to black. QCOMPARE(clipVideo->property("endOfStreamPolicy").toInt(),1);