From 5593e3e9bd208f7c5024f7bedebaaf7eb31ad51e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 17 Sep 2015 16:44:10 +0200 Subject: [PATCH] GUI: add basic track properties column to track tree view Implements #1295. --- ChangeLog | 8 ++++++ src/mkvtoolnix-gui/merge/track.cpp | 6 +++++ src/mkvtoolnix-gui/merge/track.h | 2 ++ src/mkvtoolnix-gui/merge/track_model.cpp | 33 +++++++++++++++++++++--- src/mkvtoolnix-gui/merge/track_model.h | 2 ++ 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a243d1f12..98305231c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-09-17 Moritz Bunkus + + * 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 * mkvmerge: enhancement: the verbose identification result for all diff --git a/src/mkvtoolnix-gui/merge/track.cpp b/src/mkvtoolnix-gui/merge/track.cpp index 6012d5abc..e9fde32c7 100644 --- a/src/mkvtoolnix-gui/merge/track.cpp +++ b/src/mkvtoolnix-gui/merge/track.cpp @@ -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(); diff --git a/src/mkvtoolnix-gui/merge/track.h b/src/mkvtoolnix-gui/merge/track.h index 3e4446a87..85be6aaa1 100644 --- a/src/mkvtoolnix-gui/merge/track.h +++ b/src/mkvtoolnix-gui/merge/track.h @@ -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; diff --git a/src/mkvtoolnix-gui/merge/track_model.cpp b/src/mkvtoolnix-gui/merge/track_model.cpp index a0928e6fe..d526a54d2 100644 --- a/src/mkvtoolnix-gui/merge/track_model.cpp +++ b/src/mkvtoolnix-gui/merge/track_model.cpp @@ -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 &tracks) { QList TrackModel::createRow(Track *track) { auto items = QList{}; - 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 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(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(", ")); +} + }}} diff --git a/src/mkvtoolnix-gui/merge/track_model.h b/src/mkvtoolnix-gui/merge/track_model.h index 29c579366..75e8d610d 100644 --- a/src/mkvtoolnix-gui/merge/track_model.h +++ b/src/mkvtoolnix-gui/merge/track_model.h @@ -69,6 +69,8 @@ protected: bool hasUnsetTrackRole(QModelIndex const &idx = QModelIndex{}); void sortTracks(QList &tracks, bool reverse = false); + + static QString summarizeProperties(Track const &track); }; }}}