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

Library: make 'played track color' optional #12912

Merged
merged 1 commit into from
Mar 4, 2024
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
10 changes: 9 additions & 1 deletion src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ void BaseTrackTableModel::setBpmColumnPrecision(int precision) {
}
s_bpmColumnPrecision = precision;
}

bool BaseTrackTableModel::s_bApplyPlayedTrackColor =
kApplyPlayedTrackColorDefault;

void BaseTrackTableModel::setApplyPlayedTrackColor(bool apply) {
s_bApplyPlayedTrackColor = apply;
}

//static
QStringList BaseTrackTableModel::defaultTableColumns() {
return kDefaultTableColumns;
Expand Down Expand Up @@ -460,7 +468,7 @@ QVariant BaseTrackTableModel::data(
DEBUG_ASSERT(m_backgroundColorOpacity <= 1.0);
bgColor.setAlphaF(static_cast<float>(m_backgroundColorOpacity));
return QBrush(bgColor);
} else if (role == Qt::ForegroundRole) {
} else if (role == Qt::ForegroundRole && s_bApplyPlayedTrackColor) {
// Custom text color for played tracks
auto playedRaw = rawSiblingValue(
index,
Expand Down
5 changes: 5 additions & 0 deletions src/library/basetracktablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
static constexpr int kBpmColumnPrecisionMaximum = 10;
static void setBpmColumnPrecision(int precision);

static constexpr bool kApplyPlayedTrackColorDefault = true;
static void setApplyPlayedTrackColor(bool apply);

protected:
static constexpr int defaultColumnWidth() {
return 50;
Expand Down Expand Up @@ -285,4 +288,6 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
mutable QModelIndex m_toolTipIndex;

static int s_bpmColumnPrecision;

static bool s_bApplyPlayedTrackColor;
};
5 changes: 5 additions & 0 deletions src/library/library_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ const ConfigKey mixxx::library::prefs::kBpmColumnPrecisionConfigKey =
mixxx::library::prefs::kConfigGroup,
QStringLiteral("BpmColumnPrecision")};

const ConfigKey mixxx::library::prefs::kApplyPlayedTrackColorConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("ApplyPlayedTrackColor")};

// The "Export" suffix in the key is kept for backward compatibility
const ConfigKey mixxx::library::prefs::kSyncTrackMetadataConfigKey =
ConfigKey{
Expand Down
2 changes: 2 additions & 0 deletions src/library/library_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern const ConfigKey kEnableSearchHistoryShortcutsConfigKey;

extern const ConfigKey kBpmColumnPrecisionConfigKey;

extern const ConfigKey kApplyPlayedTrackColorConfigKey;

extern const ConfigKey kEditMetadataSelectedClickConfigKey;

extern const ConfigKey kHistoryMinTracksToKeepConfigKey;
Expand Down
14 changes: 14 additions & 0 deletions src/preferences/dialog/dlgpreflibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ void DlgPrefLibrary::slotResetToDefaults() {
checkBoxEditMetadataSelectedClicked->setChecked(kEditMetadataSelectedClickDefault);
radioButton_dbclick_deck->setChecked(true);
spinbox_bpm_precision->setValue(BaseTrackTableModel::kBpmColumnPrecisionDefault);
checkbox_played_track_color->setChecked(
BaseTrackTableModel::kApplyPlayedTrackColorDefault);

radioButton_cover_art_fetcher_medium->setChecked(true);

Expand Down Expand Up @@ -325,6 +327,12 @@ void DlgPrefLibrary::slotUpdate() {
kBpmColumnPrecisionConfigKey,
BaseTrackTableModel::kBpmColumnPrecisionDefault);
spinbox_bpm_precision->setValue(bpmColumnPrecision);

const auto applyPlayedTrackColor =
m_pConfig->getValue(
mixxx::library::prefs::kApplyPlayedTrackColorConfigKey,
BaseTrackTableModel::kApplyPlayedTrackColorDefault);
checkbox_played_track_color->setChecked(applyPlayedTrackColor);
}

void DlgPrefLibrary::slotCancel() {
Expand Down Expand Up @@ -523,6 +531,12 @@ void DlgPrefLibrary::slotApply() {
ConfigValue(rowHeight));
}

BaseTrackTableModel::setApplyPlayedTrackColor(
checkbox_played_track_color->isChecked());
m_pConfig->set(
mixxx::library::prefs::kApplyPlayedTrackColorConfigKey,
ConfigValue(checkbox_played_track_color->isChecked()));

// TODO(rryan): Don't save here.
m_pConfig->save();
}
Expand Down
9 changes: 9 additions & 0 deletions src/preferences/dialog/dlgpreflibrarydlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@
</widget>
</item>

<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="checkbox_played_track_color">
<property name="text">
<string>Grey out played tracks</string>
</property>
</widget>
</item>

</layout>
</widget>
</item><!-- Track Table View -->
Expand Down Expand Up @@ -636,6 +644,7 @@
<tabstop>radioButton_dbclick_top</tabstop>
<tabstop>radioButton_dbclick_ignore</tabstop>
<tabstop>spinbox_bpm_precision</tabstop>
<tabstop>checkbox_played_track_color</tabstop>
<tabstop>spinbox_history_track_duplicate_distance</tabstop>
<tabstop>spinbox_history_min_tracks_to_keep</tabstop>
<tabstop>checkBox_use_relative_path</tabstop>
Expand Down
6 changes: 6 additions & 0 deletions src/skin/legacy/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,12 @@ QWidget* LegacySkinParser::parseLibrary(const QDomElement& node) {
BaseTrackTableModel::kBpmColumnPrecisionDefault);
BaseTrackTableModel::setBpmColumnPrecision(bpmColumnPrecision);

const auto applyPlayedTrackColor =
m_pConfig->getValue(
mixxx::library::prefs::kApplyPlayedTrackColorConfigKey,
BaseTrackTableModel::kApplyPlayedTrackColorDefault);
BaseTrackTableModel::setApplyPlayedTrackColor(applyPlayedTrackColor);

// Connect Library search signals to the WLibrary
connect(m_pLibrary,
&Library::search,
Expand Down