Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lp1879656 Track info: Show file name for tracks without artist&title #2807

Merged
merged 5 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions res/skins/Deere/deck_small.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<TooltipId>track_title</TooltipId>
<ObjectName>TitleTextSmall</ObjectName>
<Size>100me,23f</Size>
<Property>title</Property>
<Property>titleInfo</Property>
<Group><Variable name="group"/></Group>
<Alignment>left</Alignment>
<Elide>right</Elide>
Expand All @@ -89,7 +89,7 @@
</Label>
</Children>
</WidgetGroup><!-- TitleGutter -->

<NumberPos>
<TooltipId>track_time</TooltipId>
<ObjectName>PlayPositionTextSmall</ObjectName>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/Deere/deck_text_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<TrackProperty>
<TooltipId>track_title</TooltipId>
<SizePolicy>me,min</SizePolicy>
<Property>title</Property>
<Property>titleInfo</Property>
<Group><Variable name="group"/></Group>
<Elide>right</Elide>
<Connection>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/Deere/sampler_text_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<TrackProperty>
<TooltipId>track_title</TooltipId>
<SizePolicy>me,min</SizePolicy>
<Property>title</Property>
<Property>titleInfo</Property>
<Group><Variable name="group"/></Group>
<Elide>right</Elide>
</TrackProperty>
Expand Down
4 changes: 2 additions & 2 deletions res/skins/LateNight/deck_mini.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
<TooltipId>track_title</TooltipId>
<ObjectName>TitleTextSmall</ObjectName>
<Size>100me,23f</Size>
<Property>title</Property>
<Property>titleInfo</Property>
<Alignment>left</Alignment>
<Elide>right</Elide>
<Channel><Variable name="channum"/></Channel>
</TrackProperty>

<NumberPos>
<TooltipId>track_time</TooltipId>
<ObjectName>PlayPositionTextSmall</ObjectName>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/LateNight/deck_row_2_3_TitleArtistTime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ObjectName>TitleText</ObjectName>
<Size>0me,22f</Size>
<TooltipId>track_title</TooltipId>
<Property>title</Property>
<Property>titleInfo</Property>
<Alignment>Left</Alignment>
<Elide>right</Elide>
<Channel><Variable name="channum"/></Channel>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/LateNight/sampler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<TooltipId>track_title</TooltipId>
<ObjectName>SamplerTitle</ObjectName>
<SizePolicy>me,me</SizePolicy>
<Property>title</Property>
<Property>titleInfo</Property>
<Group><Variable name="group"/></Group>
<Elide>right</Elide>
</TrackProperty>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/LateNight/sampler_mini.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<TooltipId>track_title</TooltipId>
<ObjectName>SamplerTitleSmall</ObjectName>
<SizePolicy>me,min</SizePolicy>
<Property>title</Property>
<Property>titleInfo</Property>
<Group><Variable name="group"/></Group>
<Elide>right</Elide>
</TrackProperty>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/Shade/deck.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
padding-top: 4px;
}
</Style>
<Property>title</Property>
<Property>titleInfo</Property>
<Channel><Variable name="channum"/></Channel>
<Size>0e,20f</Size>
<Elide>right</Elide>
Expand Down
5 changes: 2 additions & 3 deletions res/skins/Shade/deck_small.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
padding: 0px 2px;
}
</Style>
<Property>title</Property>
<Property>titleInfo</Property>
<Channel><Variable name="channum"/></Channel>
<SizePolicy>me,f</SizePolicy>
<MinimumSize>50,19</MinimumSize>
Expand Down Expand Up @@ -184,7 +184,7 @@
<Size>1f,38f</Size>
<BackPath>style/style_component_border.png</BackPath>
</WidgetGroup>

<!-- Play -->
<WidgetGroup>
<Size>41f,38f</Size>
Expand Down Expand Up @@ -246,4 +246,3 @@
</Children>
</WidgetGroup>
</Template>

3 changes: 1 addition & 2 deletions res/skins/Shade/sampler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
text-align: left;
padding-left: 1px; }
</Style>
<Property>title</Property>
<Property>titleInfo</Property>
<Group><Variable name="group"/></Group>
<SizePolicy>me,max</SizePolicy>
<Elide>right</Elide>
Expand Down Expand Up @@ -405,4 +405,3 @@
</Children>
</WidgetGroup>
</Template>

3 changes: 1 addition & 2 deletions res/skins/Shade/samplersmall.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
text-align: left;
padding-left: 1px; }
</Style>
<Property>title</Property>
<Property>titleInfo</Property>
<Group>[Sampler<Variable name="samplernum"/>]</Group>
<SizePolicy>me,max</SizePolicy>
<Elide>right</Elide>
Expand Down Expand Up @@ -172,4 +172,3 @@
</Children>
</WidgetGroup>
</Template>

4 changes: 2 additions & 2 deletions res/skins/Tango/deck_left_mini.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Description:
A minimal deck container, visible when the library is maximized
A minimal deck container, visible when the library is maximized
| loop | Play/ | Cover/ | track title |
| indicator | Pasue | Spinny | BPM | Key | elapsed/remaining |
Variables:
Expand Down Expand Up @@ -37,7 +37,7 @@ Variables:
<TooltipId>track_title</TooltipId>
<ObjectName>TrackTitleMini</ObjectName>
<Size>90me,20f</Size>
<Property>title</Property>
<Property>titleInfo</Property>
<Alignment>left</Alignment>
<Elide>right</Elide>
<Channel><Variable name="chanNum"/></Channel>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/Tango/deck_right_mini.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Variables:
<TooltipId>track_title</TooltipId>
<ObjectName>TrackTitleMini</ObjectName>
<Size>100me,20f</Size>
<Property>title</Property>
<Property>titleInfo</Property>
<Alignment>right</Alignment>
<Elide>right</Elide>
<Channel><Variable name="chanNum"/></Channel>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/Tango/deck_row_text_left.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Variables:
<TrackProperty>
<TooltipId>track_title</TooltipId>
<ObjectName>TrackTitle</ObjectName>
<Property>title</Property>
<Property>titleInfo</Property>
<Alignment>Left</Alignment>
<Elide>right</Elide>
<Size>1me,22f</Size>
Expand Down
2 changes: 1 addition & 1 deletion res/skins/Tango/deck_row_text_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Variables:
<TrackProperty>
<TooltipId>track_title</TooltipId>
<ObjectName>TrackTitle</ObjectName>
<Property>title</Property>
<Property>titleInfo</Property>
<Alignment>right</Alignment>
<Elide>right</Elide>
<Size>1me,22f</Size>
Expand Down
6 changes: 3 additions & 3 deletions res/skins/Tango/sampler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Variables:
<TooltipId>text</TooltipId>
<Size>i,14f</Size>
<Group><Variable name="group"/></Group>
<Property>title</Property>
<Property>titleInfo</Property>
</TrackProperty>

<WidgetGroup><!-- Sync, CF assign, Volume -->
Expand Down Expand Up @@ -165,7 +165,7 @@ Variables:
<TooltipId>text</TooltipId>
<Size>i,18f</Size>
<Group><Variable name="group"/></Group>
<Property>title</Property>
<Property>titleInfo</Property>
<Elide>right</Elide>
</TrackProperty>

Expand Down Expand Up @@ -228,7 +228,7 @@ Variables:

</Children>
</WidgetGroup><!-- /Title + [Play / Overview] -->

<SliderComposed>
<ObjectName>SamplerPitchSlider</ObjectName>
<TooltipId>rate</TooltipId>
Expand Down
2 changes: 1 addition & 1 deletion src/library/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void DlgTrackInfo::loadPrevTrack() {
}

void DlgTrackInfo::populateFields(const Track& track) {
setWindowTitle(track.getArtist() % " - " % track.getTitle());
setWindowTitle(track.getInfo());

// Editable fields
txtTrackName->setText(track.getTitle());
Expand Down
20 changes: 18 additions & 2 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,25 @@ bool Track::isMetadataSynchronized() const {
QString Track::getInfo() const {
QMutexLocker lock(&m_qMutex);
if (m_record.getMetadata().getTrackInfo().getArtist().trimmed().isEmpty()) {
return m_record.getMetadata().getTrackInfo().getTitle();
if (m_record.getMetadata().getTrackInfo().getTitle().trimmed().isEmpty()) {
return m_fileInfo.fileName();
} else {
return m_record.getMetadata().getTrackInfo().getTitle();
}
} else {
return m_record.getMetadata().getTrackInfo().getArtist() + ", " + m_record.getMetadata().getTrackInfo().getTitle();
return m_record.getMetadata().getTrackInfo().getArtist() +
QStringLiteral(" - ") +
m_record.getMetadata().getTrackInfo().getTitle();
}
}

QString Track::getTitleInfo() const {
QMutexLocker lock(&m_qMutex);
if (m_record.getMetadata().getTrackInfo().getArtist().trimmed().isEmpty() &&
m_record.getMetadata().getTrackInfo().getTitle().trimmed().isEmpty()) {
return m_fileInfo.fileName();
} else {
return m_record.getMetadata().getTrackInfo().getTitle();
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class Track : public QObject {
Q_PROPERTY(QString durationFormatted READ getDurationTextSeconds STORED false)
Q_PROPERTY(QString durationFormattedCentiseconds READ getDurationTextCentiseconds STORED false)
Q_PROPERTY(QString durationFormattedMilliseconds READ getDurationTextMilliseconds STORED false)
Q_PROPERTY(QString info READ getInfo STORED false)
Q_PROPERTY(QString titleInfo READ getTitleInfo STORED false)

TrackFile getFileInfo() const {
// Copying TrackFile/QFileInfo is thread-safe (implicit sharing), no locking needed.
Expand Down Expand Up @@ -233,9 +235,13 @@ class Track : public QObject {
// Set URL for track
void setURL(const QString& url);

// Output a formatted string with artist and title.
/// Formatted string with artist and title.
QString getInfo() const;

/// The filename if BOTH artist AND title are empty, e.g. for tracks without
/// any metadata in file tags. Otherwise just the title (even if it is empty).
QString getTitleInfo() const;

ConstWaveformPointer getWaveform() const;
void setWaveform(ConstWaveformPointer pWaveform);

Expand Down