From 38c9d8525e6f08773e1fe1350d4a8fde4d8db8d9 Mon Sep 17 00:00:00 2001 From: Evan Dekker Date: Tue, 17 Mar 2020 11:17:18 +1100 Subject: [PATCH 1/5] Store RGB hotcue colors --- src/library/rekordbox/rekordboxfeature.cpp | 50 +--------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index a2da47e3a8f..1a100ff4170 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -793,7 +793,7 @@ void clearDeviceTables(QSqlDatabase& database, TreeItem* child) { transaction.commit(); } -void setHotCue(TrackPointer track, double position, int id, QString label, int /*colorCode*/, int /*colorRed*/, int /*colorGreen*/, int /*colorBlue*/) { +void setHotCue(TrackPointer track, double position, int id, QString label, int colorCode, int colorRed, int colorGreen, int colorBlue) { CuePointer pCue; bool hotCueFound = false; @@ -813,53 +813,7 @@ void setHotCue(TrackPointer track, double position, int id, QString label, int / pCue->setStartPosition(position); pCue->setHotCue(id); pCue->setLabel(label); - - /* - TODO(ehendrikd): - Update setting hotcue colors once proposed PR is merged - allowing custom hotcue colors/palette - See: - https://github.com/mixxxdj/mixxx/pull/2119 - https://github.com/mixxxdj/mixxx/pull/2345 - - // Map 17 possible Rekordbox hotcue colors to closest Mixxx hotcue colors - switch (colorCode) { - case 38: - case 42: - pCue->setColor(Color::kPredefinedColorsSet.red); - break; - case 0: - case 14: - case 18: - case 22: - case 26: - pCue->setColor(Color::kPredefinedColorsSet.green); - break; - case 30: - case 32: - pCue->setColor(Color::kPredefinedColorsSet.yellow); - break; - case 1: - case 5: - case 62: - pCue->setColor(Color::kPredefinedColorsSet.blue); - break; - case 9: - pCue->setColor(Color::kPredefinedColorsSet.cyan); - break; - case 56: - case 60: - pCue->setColor(Color::kPredefinedColorsSet.magenta); - break; - case 45: - case 49: - pCue->setColor(Color::kPredefinedColorsSet.pink); - break; - default: - pCue->setColor(Color::kPredefinedColorsSet.noColor); - break; - } -*/ + pCue->setColor(*mixxx::RgbColor::fromQColor(QColor(colorRed, colorGreen, colorBlue))); } void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool ignoreBeatsAndLegacyCues, QString anlzPath) { From d199927b07c5a195d9ae397e3536b2f4c126e3be Mon Sep 17 00:00:00 2001 From: Evan Dekker Date: Tue, 17 Mar 2020 11:39:40 +1100 Subject: [PATCH 2/5] Remove unused colorCode --- src/library/rekordbox/rekordboxfeature.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index 1a100ff4170..129271d437f 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -71,7 +71,6 @@ constexpr mixxx::RgbColor kTrackColorPurple(0x9808F8); struct memory_cue_t { double position; QString comment; - int colorCode; int colorRed; int colorGreen; int colorBlue; @@ -793,7 +792,7 @@ void clearDeviceTables(QSqlDatabase& database, TreeItem* child) { transaction.commit(); } -void setHotCue(TrackPointer track, double position, int id, QString label, int colorCode, int colorRed, int colorGreen, int colorBlue) { +void setHotCue(TrackPointer track, double position, int id, QString label, int colorRed, int colorGreen, int colorBlue) { CuePointer pCue; bool hotCueFound = false; @@ -884,7 +883,6 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i case rekordbox_anlz_t::CUE_ENTRY_TYPE_MEMORY_CUE: { memory_cue_t memoryCue; memoryCue.position = position; - memoryCue.colorCode = -1; memoryCue.colorRed = -1; memoryCue.colorGreen = -1; memoryCue.colorBlue = -1; @@ -909,7 +907,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i if (hotCueIndex > lastHotCueIndex) { lastHotCueIndex = hotCueIndex; } - setHotCue(track, position, hotCueIndex, QString(), -1, -1, -1, -1); + setHotCue(track, position, hotCueIndex, QString(), -1, -1, -1); } break; } } @@ -932,7 +930,6 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i memory_cue_t memoryCue; memoryCue.position = position; memoryCue.comment = toUnicode((*cueExtendedEntry)->comment()); - memoryCue.colorCode = static_cast((*cueExtendedEntry)->color_code()); memoryCue.colorRed = static_cast((*cueExtendedEntry)->color_red()); memoryCue.colorGreen = static_cast((*cueExtendedEntry)->color_green()); memoryCue.colorBlue = static_cast((*cueExtendedEntry)->color_blue()); @@ -957,7 +954,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i if (hotCueIndex > lastHotCueIndex) { lastHotCueIndex = hotCueIndex; } - setHotCue(track, position, hotCueIndex, toUnicode((*cueExtendedEntry)->comment()), static_cast((*cueExtendedEntry)->color_code()), static_cast((*cueExtendedEntry)->color_red()), static_cast((*cueExtendedEntry)->color_green()), static_cast((*cueExtendedEntry)->color_blue())); + setHotCue(track, position, hotCueIndex, toUnicode((*cueExtendedEntry)->comment()), static_cast((*cueExtendedEntry)->color_red()), static_cast((*cueExtendedEntry)->color_green()), static_cast((*cueExtendedEntry)->color_blue())); } break; } } @@ -981,7 +978,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i // Add remaining memory cues as hot cues (after actual found hotcues) as Mixxx can only have 1 cue for (int memoryCueIndex = 1; memoryCueIndex < memoryCues.size(); memoryCueIndex++) { memory_cue_t memoryCue = memoryCues[memoryCueIndex]; - setHotCue(track, memoryCue.position, lastHotCueIndex + memoryCueIndex, memoryCue.comment, memoryCue.colorCode, memoryCue.colorRed, memoryCue.colorGreen, memoryCue.colorBlue); + setHotCue(track, memoryCue.position, lastHotCueIndex + memoryCueIndex, memoryCue.comment, memoryCue.colorRed, memoryCue.colorGreen, memoryCue.colorBlue); } } From f2b7fbe62eaa2e58e18fdd594419c0efbb6ba0bb Mon Sep 17 00:00:00 2001 From: Evan Dekker Date: Wed, 18 Mar 2020 09:30:54 +1100 Subject: [PATCH 3/5] correct QColor conversion --- src/library/rekordbox/rekordboxfeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index 129271d437f..d81bb5dab39 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -812,7 +812,7 @@ void setHotCue(TrackPointer track, double position, int id, QString label, int c pCue->setStartPosition(position); pCue->setHotCue(id); pCue->setLabel(label); - pCue->setColor(*mixxx::RgbColor::fromQColor(QColor(colorRed, colorGreen, colorBlue))); + pCue->setColor(mixxx::RgbColor(qRgb(colorRed, colorGreen, colorBlue))); } void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool ignoreBeatsAndLegacyCues, QString anlzPath) { From b020ece97af78e3836704d90714384e976844854 Mon Sep 17 00:00:00 2001 From: Evan Dekker Date: Fri, 20 Mar 2020 10:09:34 +1100 Subject: [PATCH 4/5] Change RGB ints to RgbColor --- src/library/rekordbox/rekordboxfeature.cpp | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index d81bb5dab39..564b5907ab4 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -71,9 +71,7 @@ constexpr mixxx::RgbColor kTrackColorPurple(0x9808F8); struct memory_cue_t { double position; QString comment; - int colorRed; - int colorGreen; - int colorBlue; + mixxx::RgbColor::optional_t color; }; bool createLibraryTable(QSqlDatabase& database, const QString& tableName) { @@ -792,7 +790,7 @@ void clearDeviceTables(QSqlDatabase& database, TreeItem* child) { transaction.commit(); } -void setHotCue(TrackPointer track, double position, int id, QString label, int colorRed, int colorGreen, int colorBlue) { +void setHotCue(TrackPointer track, double position, int id, QString label, mixxx::RgbColor::optional_t color) { CuePointer pCue; bool hotCueFound = false; @@ -812,7 +810,9 @@ void setHotCue(TrackPointer track, double position, int id, QString label, int c pCue->setStartPosition(position); pCue->setHotCue(id); pCue->setLabel(label); - pCue->setColor(mixxx::RgbColor(qRgb(colorRed, colorGreen, colorBlue))); + if (color != mixxx::RgbColor::nullopt()) { + pCue->setColor(*color); + } } void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool ignoreBeatsAndLegacyCues, QString anlzPath) { @@ -883,9 +883,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i case rekordbox_anlz_t::CUE_ENTRY_TYPE_MEMORY_CUE: { memory_cue_t memoryCue; memoryCue.position = position; - memoryCue.colorRed = -1; - memoryCue.colorGreen = -1; - memoryCue.colorBlue = -1; + memoryCue.color = mixxx::RgbColor::nullopt(); memoryCues << memoryCue; } break; case rekordbox_anlz_t::CUE_ENTRY_TYPE_LOOP: { @@ -907,7 +905,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i if (hotCueIndex > lastHotCueIndex) { lastHotCueIndex = hotCueIndex; } - setHotCue(track, position, hotCueIndex, QString(), -1, -1, -1); + setHotCue(track, position, hotCueIndex, QString(), mixxx::RgbColor::nullopt()); } break; } } @@ -930,9 +928,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i memory_cue_t memoryCue; memoryCue.position = position; memoryCue.comment = toUnicode((*cueExtendedEntry)->comment()); - memoryCue.colorRed = static_cast((*cueExtendedEntry)->color_red()); - memoryCue.colorGreen = static_cast((*cueExtendedEntry)->color_green()); - memoryCue.colorBlue = static_cast((*cueExtendedEntry)->color_blue()); + memoryCue.color = mixxx::RgbColor(qRgb(static_cast((*cueExtendedEntry)->color_red()), static_cast((*cueExtendedEntry)->color_green()), static_cast((*cueExtendedEntry)->color_blue()))); memoryCues << memoryCue; } break; case rekordbox_anlz_t::CUE_ENTRY_TYPE_LOOP: { @@ -954,7 +950,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i if (hotCueIndex > lastHotCueIndex) { lastHotCueIndex = hotCueIndex; } - setHotCue(track, position, hotCueIndex, toUnicode((*cueExtendedEntry)->comment()), static_cast((*cueExtendedEntry)->color_red()), static_cast((*cueExtendedEntry)->color_green()), static_cast((*cueExtendedEntry)->color_blue())); + setHotCue(track, position, hotCueIndex, toUnicode((*cueExtendedEntry)->comment()), mixxx::RgbColor(qRgb(static_cast((*cueExtendedEntry)->color_red()), static_cast((*cueExtendedEntry)->color_green()), static_cast((*cueExtendedEntry)->color_blue())))); } break; } } @@ -978,7 +974,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i // Add remaining memory cues as hot cues (after actual found hotcues) as Mixxx can only have 1 cue for (int memoryCueIndex = 1; memoryCueIndex < memoryCues.size(); memoryCueIndex++) { memory_cue_t memoryCue = memoryCues[memoryCueIndex]; - setHotCue(track, memoryCue.position, lastHotCueIndex + memoryCueIndex, memoryCue.comment, memoryCue.colorRed, memoryCue.colorGreen, memoryCue.colorBlue); + setHotCue(track, memoryCue.position, lastHotCueIndex + memoryCueIndex, memoryCue.comment, memoryCue.color); } } From 1463107108e602936c0d1d934fac01030acb37d5 Mon Sep 17 00:00:00 2001 From: Evan Dekker Date: Fri, 20 Mar 2020 10:29:05 +1100 Subject: [PATCH 5/5] Nullopt check update --- src/library/rekordbox/rekordboxfeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index 564b5907ab4..9d24d838077 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -810,7 +810,7 @@ void setHotCue(TrackPointer track, double position, int id, QString label, mixxx pCue->setStartPosition(position); pCue->setHotCue(id); pCue->setLabel(label); - if (color != mixxx::RgbColor::nullopt()) { + if (color) { pCue->setColor(*color); } }