Show track durations in the CD ripper dialog.
The duration in seconds is computed using integer division which should be close enough.
This commit is contained in:
parent
d51a1add86
commit
41d7d792ae
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "ripper/ripcddialog.h"
|
#include "ripper/ripcddialog.h"
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -44,6 +43,7 @@ bool ComparePresetsByName(const TranscoderPreset& left,
|
||||||
const int kCheckboxColumn = 0;
|
const int kCheckboxColumn = 0;
|
||||||
const int kTrackNumberColumn = 1;
|
const int kTrackNumberColumn = 1;
|
||||||
const int kTrackTitleColumn = 2;
|
const int kTrackTitleColumn = 2;
|
||||||
|
const int kTrackDurationColumn = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* RipCDDialog::kSettingsGroup = "Transcoder";
|
const char* RipCDDialog::kSettingsGroup = "Transcoder";
|
||||||
|
@ -271,6 +271,10 @@ void RipCDDialog::BuildTrackListTable() {
|
||||||
track_names_.append(line_edit_track_title_i);
|
track_names_.append(line_edit_track_title_i);
|
||||||
ui_->tableWidget->setCellWidget(i - 1, kTrackTitleColumn,
|
ui_->tableWidget->setCellWidget(i - 1, kTrackTitleColumn,
|
||||||
line_edit_track_title_i);
|
line_edit_track_title_i);
|
||||||
|
QString track_duration =
|
||||||
|
Utilities::PrettyTime(ripper_->TrackDurationSecs(i));
|
||||||
|
ui_->tableWidget->setCellWidget(i - 1, kTrackDurationColumn,
|
||||||
|
new QLabel(track_duration));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,19 @@ int Ripper::TracksOnDisc() const {
|
||||||
return number_of_tracks;
|
return number_of_tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Ripper::TrackDurationSecs(int track) const {
|
||||||
|
Q_ASSERT(track <= TracksOnDisc());
|
||||||
|
|
||||||
|
int first_frame = cdio_get_track_lsn(cdio_, track);
|
||||||
|
int last_frame = cdio_get_track_last_lsn(cdio_, track);
|
||||||
|
if (first_frame != CDIO_INVALID_LSN && last_frame != CDIO_INVALID_LSN) {
|
||||||
|
return (last_frame - first_frame + 1) / CDIO_CD_FRAMES_PER_SEC;
|
||||||
|
} else {
|
||||||
|
qLog(Error) << "Could not compute duration of track" << track;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Ripper::AddedTracks() const { return tracks_.length(); }
|
int Ripper::AddedTracks() const { return tracks_.length(); }
|
||||||
|
|
||||||
void Ripper::ClearTracks() { tracks_.clear(); }
|
void Ripper::ClearTracks() { tracks_.clear(); }
|
||||||
|
|
|
@ -55,6 +55,8 @@ class Ripper : public QObject {
|
||||||
Song::FileType type);
|
Song::FileType type);
|
||||||
// Returns the number of audio tracks on the disc.
|
// Returns the number of audio tracks on the disc.
|
||||||
int TracksOnDisc() const;
|
int TracksOnDisc() const;
|
||||||
|
// Returns the duration of the track or 0 on error.
|
||||||
|
int TrackDurationSecs(int track) const;
|
||||||
// Returns the number of tracks added to the rip list.
|
// Returns the number of tracks added to the rip list.
|
||||||
int AddedTracks() const;
|
int AddedTracks() const;
|
||||||
// Clears the rip list.
|
// Clears the rip list.
|
||||||
|
|
Loading…
Reference in New Issue