GUI: add basic track properties column to track tree view

Implements #1295.
This commit is contained in:
Moritz Bunkus 2015-09-17 16:44:10 +02:00
parent c500879798
commit 5593e3e9bd
5 changed files with 48 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2015-09-17 Moritz Bunkus <moritz@bunkus.org>
* MKVToolNix GUI: new merge tool feature: the »tracks« tree view
contains a new column titled »properties« which contains basic
track properties: the pixel dimensions for a video track and
sampling frequency, number of channels and bits per sample for an
audio track. Implements #1295.
2015-09-14 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: enhancement: the verbose identification result for all

View File

@ -92,6 +92,12 @@ Track::isRegular()
return isAudio() || isVideo() || isSubtitles() || isButtons();
}
bool
Track::isPropertySet(QString const &property)
const {
return m_properties.contains(property) && !m_properties.value(property).isEmpty();
}
void
Track::setDefaults() {
auto &settings = Util::Settings::get();

View File

@ -74,6 +74,8 @@ public:
virtual bool isRegular() const;
virtual bool isAppended() const;
virtual bool isPropertySet(QString const &property) const;
virtual void setDefaults();
virtual QString extractAudioDelayFromFileName() const;

View File

@ -40,8 +40,8 @@ TrackModel::~TrackModel() {
void
TrackModel::retranslateUi() {
setHorizontalHeaderLabels( QStringList{} << QY("Codec") << QY("Type") << QY("Mux this") << QY("Language") << QY("Name") << QY("Source file") << QY("ID") << QY("Default track in output"));
Util::setSymbolicColumnNames(*this, QStringList{} << Q("codec") << Q("type") << Q("muxThis") << Q("language") << Q("name") << Q("sourceFile") << Q("id") << Q("defaultTrackFlag"));
setHorizontalHeaderLabels( QStringList{} << QY("Codec") << QY("Type") << QY("Mux this") << QY("Language") << QY("Name") << QY("Source file") << QY("ID") << QY("Default track in output") << QY("Properties"));
Util::setSymbolicColumnNames(*this, QStringList{} << Q("codec") << Q("type") << Q("muxThis") << Q("language") << Q("name") << Q("sourceFile") << Q("id") << Q("defaultTrackFlag") << Q("properties"));
horizontalHeaderItem(6)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -76,7 +76,7 @@ TrackModel::setTracks(QList<Track *> &tracks) {
QList<QStandardItem *>
TrackModel::createRow(Track *track) {
auto items = QList<QStandardItem *>{};
for (int idx = 0; idx < 8; ++idx)
for (int idx = 0; idx < 9; ++idx)
items << new QStandardItem{};
setItemsFromTrack(items, track);
@ -95,6 +95,7 @@ TrackModel::setItemsFromTrack(QList<QStandardItem *> items,
items[5]->setText(QFileInfo{ track->m_file->m_fileName }.fileName());
items[6]->setText(-1 == track->m_id ? Q("") : QString::number(track->m_id));
items[7]->setText(!track->m_effectiveDefaultTrackFlag ? Q("") : *track->m_effectiveDefaultTrackFlag ? QY("yes") : QY("no"));
items[8]->setText(summarizeProperties(*track));
items[0]->setData(QVariant::fromValue(reinterpret_cast<qulonglong>(track)), Util::TrackRole);
items[0]->setCheckable(true);
@ -660,4 +661,30 @@ TrackModel::updateEffectiveDefaultTrackFlags() {
trackUpdated(track);
}
QString
TrackModel::summarizeProperties(Track const &track) {
auto properties = QStringList{};
if (track.isAudio()) {
if (track.isPropertySet("audio_sampling_frequency"))
properties << QY("%1 Hz").arg(track.m_properties.value(Q("audio_sampling_frequency")));
if (track.isPropertySet("audio_channels")) {
auto channels = track.m_properties.value(Q("audio_channels")).toInt();
properties << QNY("%1 channel", "%1 channels", channels).arg(channels);
}
if (track.isPropertySet("audio_bits_per_sample")) {
auto bitsPerSample = track.m_properties.value(Q("audio_bits_per_sample")).toInt();
properties << QNY("%1 bit per sample", "%1 bits per sample", bitsPerSample).arg(bitsPerSample);
}
} else if (track.isVideo()) {
if (track.isPropertySet("pixel_dimensions"))
properties << QY("%1 pixels").arg(track.m_properties.value(Q("pixel_dimensions")));
}
return properties.join(Q(", "));
}
}}}

View File

@ -69,6 +69,8 @@ protected:
bool hasUnsetTrackRole(QModelIndex const &idx = QModelIndex{});
void sortTracks(QList<Track *> &tracks, bool reverse = false);
static QString summarizeProperties(Track const &track);
};
}}}