Skip to content

Commit

Permalink
DlgTrackInfoMulti/StarRating: Integrate WStarRating into the tab order
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7pt0gr4ph7 committed Oct 31, 2024
1 parent 25c005f commit 033e06c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
18 changes: 5 additions & 13 deletions src/library/dlgtrackinfomulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ DlgTrackInfoMulti::DlgTrackInfoMulti(UserSettingsPointer pUserSettings)
m_pUserSettings(std::move(pUserSettings)),
m_pWCoverArtMenu(make_parented<WCoverArtMenu>(this)),
m_pWCoverArtLabel(make_parented<WCoverArtLabel>(this, m_pWCoverArtMenu)),
m_pWStarRating(make_parented<WStarRating>(this)),
m_starRatingModified(false),
m_newRating(0),
m_colorChanged(false),
Expand Down Expand Up @@ -223,14 +222,7 @@ void DlgTrackInfoMulti::init() {
this,
&DlgTrackInfoMulti::slotColorPicked);

// Insert the star rating widget
starsLayout->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
starsLayout->setSpacing(0);
starsLayout->setContentsMargins(0, 0, 0, 0);
starsLayout->insertWidget(0, m_pWStarRating.get());
// This is necessary to pass on mouseMove events to WStarRating
m_pWStarRating->setMouseTracking(true);
connect(m_pWStarRating,
connect(starRating,
&WStarRating::ratingChangeRequest,
this,
&DlgTrackInfoMulti::slotStarRatingChanged);
Expand Down Expand Up @@ -303,8 +295,8 @@ void DlgTrackInfoMulti::updateFromTracks() {
replaceTrackRecords(trackRecords);

// Collect star ratings and track colors
// If track value differs from the current value, add it to the list.
// If new and current are identical, keep only one.
// Check if all tracks have the same value for the rating (resp. color).
// If yes, show that value, if no, show a placeholder value instead.
int commonRating = m_trackRecords.first().getRating();
for (const auto& rec : std::as_const(m_trackRecords)) {
if (commonRating != rec.getRating()) {
Expand All @@ -313,7 +305,7 @@ void DlgTrackInfoMulti::updateFromTracks() {
}
}
// Update the star widget
m_pWStarRating->slotSetRating(commonRating);
starRating->slotSetRating(commonRating);
m_starRatingModified = false;

// Same procedure for the track color
Expand Down Expand Up @@ -887,7 +879,7 @@ void DlgTrackInfoMulti::trackColorDialogSetColorStyleButton(
void DlgTrackInfoMulti::slotStarRatingChanged(int rating) {
if (!m_pLoadedTracks.isEmpty() && mixxx::TrackRecord::isValidRating(rating)) {
m_starRatingModified = true;
m_pWStarRating->slotSetRating(rating);
starRating->slotSetRating(rating);
m_newRating = rating;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/library/dlgtrackinfomulti.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class DlgTrackInfoMulti : public QDialog, public Ui::DlgTrackInfoMulti {

parented_ptr<WCoverArtMenu> m_pWCoverArtMenu;
parented_ptr<WCoverArtLabel> m_pWCoverArtLabel;
parented_ptr<WStarRating> m_pWStarRating;
bool m_starRatingModified;
int m_newRating;
bool m_colorChanged;
Expand Down
20 changes: 11 additions & 9 deletions src/library/dlgtrackinfomulti.ui
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,22 @@
</item>

<item row="3" column="2" colspan="2">
<widget class="QWidget" name="starsWidget" native="true">
<widget class="WStarRating" name="starRating">
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="upDownChangesFocus">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="starsLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
</layout>
</widget>
</item>

Expand Down Expand Up @@ -744,6 +745,7 @@
<tabstop>txtGenre</tabstop>
<tabstop>txtGrouping</tabstop>
<tabstop>txtComment</tabstop>
<tabstop>starRating</tabstop>
<tabstop>txtYear</tabstop>
<tabstop>txtKey</tabstop>
<tabstop>txtTrackNumber</tabstop>
Expand Down

0 comments on commit 033e06c

Please sign in to comment.