Skip to content

Commit

Permalink
Changed file duration to be displayed in human readable format instea…
Browse files Browse the repository at this point in the history
…d of milliseconds.
  • Loading branch information
Dimi1010 committed May 25, 2020
1 parent 8a8f1fc commit 346238c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 10 additions & 1 deletion MediaPlayer/FileMetadataDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ FileMetadataDetails::FileMetadataDetails(const QMediaPlayer* player, QWidget *pa
auto row_idx = ui.tableWidget->rowCount();
ui.tableWidget->insertRow(row_idx);
ui.tableWidget->setItem(row_idx, 0, new QTableWidgetItem(key));
ui.tableWidget->setItem(row_idx, 1, new QTableWidgetItem(player->metaData(key).toString()));
QString value;
if (key == QMediaMetaData::Duration) {
auto data = player->metaData(key);
qint64 msecs = data.toLongLong();
value = QTime::fromMSecsSinceStartOfDay(msecs).toString();
}
else {
value = player->metaData(key).toString();
}
ui.tableWidget->setItem(row_idx, 1, new QTableWidgetItem(value));
}
}
}
Expand Down
13 changes: 3 additions & 10 deletions MediaPlayer/FileMetadataDetails.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="rowCount">
<number>0</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
Expand All @@ -40,11 +43,6 @@
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<row>
<property name="text">
<string>Titles</string>
</property>
</row>
<column>
<property name="text">
<string>Name</string>
Expand All @@ -55,11 +53,6 @@
<string>Value</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>Metadata</string>
</property>
</item>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down

0 comments on commit 346238c

Please sign in to comment.