Browse Source

SubtitleWriter: update to use new intruments widget

QGC4.4
Willian Galvani 5 years ago committed by Don Gagne
parent
commit
fc61f1a089
  1. 34
      src/VideoManager/SubtitleWriter.cc
  2. 5
      src/VideoManager/SubtitleWriter.h

34
src/VideoManager/SubtitleWriter.cc

@ -17,6 +17,9 @@
#include "SubtitleWriter.h" #include "SubtitleWriter.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "QGCCorePlugin.h" #include "QGCCorePlugin.h"
#include "FactValueGrid.h"
#include "HorizontalFactValueGrid.h"
#include "InstrumentValueData.h"
#include <QDateTime> #include <QDateTime>
#include <QString> #include <QString>
#include <QDate> #include <QDate>
@ -33,11 +36,22 @@ SubtitleWriter::SubtitleWriter(QObject* parent)
void SubtitleWriter::startCapturingTelemetry(const QString& videoFile) void SubtitleWriter::startCapturingTelemetry(const QString& videoFile)
{ {
// Get the facts displayed in the values widget and capture them, removing the "Vehicle." prefix. // Delete facts of last run
QSettings settings; _facts.clear();
settings.beginGroup("ValuesWidget");
_values = settings.value("large").toStringList().replaceInStrings(QStringLiteral("Vehicle."), QString()); // Gather the facts currently displayed into _facts
_values += settings.value("small").toStringList().replaceInStrings(QStringLiteral("Vehicle."), QString()); FactValueGrid* grid = new FactValueGrid();
grid->setProperty("userSettingsGroup", HorizontalFactValueGrid::telemetryBarUserSettingsGroup);
grid->setProperty("defaultSettingsGroup", HorizontalFactValueGrid::telemetryBarDefaultSettingsGroup);
grid->_loadSettings();
for (int colIndex = 0; colIndex < grid->columns()->count(); colIndex++) {
QmlObjectListModel* list = grid->columns()->value<QmlObjectListModel*>(colIndex);
for (int rowIndex = 0; rowIndex < list->count(); rowIndex++) {
InstrumentValueData* value = list->value<InstrumentValueData*>(rowIndex);
_facts += value->fact();
}
}
grid->deleteLater();
// One subtitle always starts where the previous ended // One subtitle always starts where the previous ended
_lastEndTime = QTime(0, 0); _lastEndTime = QTime(0, 0);
@ -102,10 +116,10 @@ void SubtitleWriter::_captureTelemetry()
QStringList valuesStrings; QStringList valuesStrings;
// Make a list of "factname:" strings and other with the values, so one can be aligned left and the other right // Make a list of "factname:" strings and other with the values, so one can be aligned left and the other right
for (const auto& i : _values) { for (const Fact* fact : _facts) {
valuesStrings << QStringLiteral("%2 %3").arg(vehicle->getFact(i)->cookedValueString()) valuesStrings << QStringLiteral("%2 %3").arg(fact->cookedValueString())
.arg(vehicle->getFact(i)->cookedUnits()); .arg(fact->cookedUnits());
namesStrings << QStringLiteral("%1:").arg(vehicle->getFact(i)->shortDescription()); namesStrings << QStringLiteral("%1:").arg(fact->shortDescription());
} }
// The time to start displaying this subtitle text // The time to start displaying this subtitle text
@ -118,7 +132,7 @@ void SubtitleWriter::_captureTelemetry()
// This splits the screen in N parts and uses the N-1 internal parts to align the subtitles to. // This splits the screen in N parts and uses the N-1 internal parts to align the subtitles to.
// Should we try to get the resolution from the pipeline? This seems to work fine with other resolutions too. // Should we try to get the resolution from the pipeline? This seems to work fine with other resolutions too.
static const int rowWidth = (1920 + offsetFactor)/(nRows+1); static const int rowWidth = (1920 + offsetFactor)/(nRows+1);
int nValuesByRow = ceil(_values.length() / nRows); int nValuesByRow = ceil(_facts.length() / nRows);
QList<QStringList> dataColumns; QList<QStringList> dataColumns;
QStringList stringColumns; QStringList stringColumns;

5
src/VideoManager/SubtitleWriter.h

@ -17,6 +17,7 @@
#pragma once #pragma once
#include "QGCLoggingCategory.h" #include "QGCLoggingCategory.h"
#include "Fact.h"
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
@ -42,9 +43,9 @@ private slots:
private: private:
QTimer _timer; QTimer _timer;
QStringList _values; QList<Fact*> _facts;
QTime _lastEndTime; QTime _lastEndTime;
QFile _file; QFile _file;
static const int _sampleRate; static const int _sampleRate; // Sample rate in Hz for getting telemetry data, most players do weird stuff when > 1Hz
}; };

Loading…
Cancel
Save