-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: add setting definition for Traktor S4 MK3 #12995
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
Merged
ywwg
merged 2 commits into
mixxxdj:main
from
acolombier:chore/add-setting-to-traktor-s4mk3
Mar 31, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,9 @@ QWidget* LegacyControllerBooleanSetting::buildWidget( | |
| } | ||
|
|
||
| QWidget* LegacyControllerBooleanSetting::buildInputWidget(QWidget* pParent) { | ||
| auto* pCheckBox = new QCheckBox(label(), pParent); | ||
| auto pWidget = make_parented<QWidget>(pParent); | ||
|
|
||
| auto* pCheckBox = new QCheckBox(pWidget); | ||
| pCheckBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); | ||
| if (m_editedValue) { | ||
| pCheckBox->setCheckState(Qt::Checked); | ||
|
|
@@ -118,7 +120,21 @@ QWidget* LegacyControllerBooleanSetting::buildInputWidget(QWidget* pParent) { | |
| emit changed(); | ||
| }); | ||
|
|
||
| return pCheckBox; | ||
| auto pLabelWidget = make_parented<QLabel>(pWidget); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this change for?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| pLabelWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); | ||
| pLabelWidget->setText(label()); | ||
|
|
||
| QBoxLayout* pLayout = new QHBoxLayout(); | ||
|
|
||
| pLayout->addWidget(pCheckBox); | ||
| pLayout->addWidget(pLabelWidget); | ||
|
|
||
| pLayout->setStretch(0, 3); | ||
| pLayout->setStretch(1, 1); | ||
|
|
||
| pWidget->setLayout(pLayout); | ||
|
|
||
| return pWidget; | ||
| } | ||
|
|
||
| bool LegacyControllerBooleanSetting::match(const QDomElement& element) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/test/controllers/controller_columnid_regression_test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| This test case is used to ensure that hardcoded CO value in the the settings | ||
| definition matches with Mixxx value and will help detecting regression if they | ||
| are ever updated. | ||
|
|
||
| Currently, the S4 MK3 is referencing library column ID in its setting, so this | ||
| test ensure that the value always matches with the Mixxx spec. New controllers | ||
| can be added by duplicated the `ensureS4MK3` case and adapt as needed | ||
| */ | ||
| #include "controllers/legacycontrollermapping.h" | ||
| #include "controllers/legacycontrollermappingfilehandler.h" | ||
| #include "library/trackmodel.h" | ||
| #include "test/mixxxtest.h" | ||
| #include "util/time.h" | ||
|
|
||
| class ControllerLibraryColumnIDRegressionTest : public MixxxTest { | ||
| protected: | ||
| void SetUp() override { | ||
| mixxx::Time::setTestMode(true); | ||
| mixxx::Time::setTestElapsedTime(mixxx::Duration::fromMillis(10)); | ||
| } | ||
|
|
||
| void TearDown() override { | ||
| mixxx::Time::setTestMode(false); | ||
| } | ||
|
|
||
| static QHash<QString, TrackModel::SortColumnId> COLUMN_MAPPING; | ||
| }; | ||
|
|
||
| QHash<QString, TrackModel::SortColumnId> | ||
| ControllerLibraryColumnIDRegressionTest::COLUMN_MAPPING = { | ||
| {"Artist", TrackModel::SortColumnId::Artist}, | ||
| {"Title", TrackModel::SortColumnId::Title}, | ||
| {"Album", TrackModel::SortColumnId::Album}, | ||
| {"Album Artist", TrackModel::SortColumnId::AlbumArtist}, | ||
| {"Year", TrackModel::SortColumnId::Year}, | ||
| {"Genre", TrackModel::SortColumnId::Genre}, | ||
| {"Composer", TrackModel::SortColumnId::Composer}, | ||
| {"Grouping", TrackModel::SortColumnId::Grouping}, | ||
| {"Track Number", TrackModel::SortColumnId::TrackNumber}, | ||
| {"File Type", TrackModel::SortColumnId::FileType}, | ||
| {"Native Location", TrackModel::SortColumnId::NativeLocation}, | ||
| {"Comment", TrackModel::SortColumnId::Comment}, | ||
| {"Duration", TrackModel::SortColumnId::Duration}, | ||
| {"Bitrate", TrackModel::SortColumnId::BitRate}, | ||
| {"BPM", TrackModel::SortColumnId::Bpm}, | ||
| {"Replay Gain", TrackModel::SortColumnId::ReplayGain}, | ||
| {"Datetime Added", TrackModel::SortColumnId::DateTimeAdded}, | ||
| {"Times Played", TrackModel::SortColumnId::TimesPlayed}, | ||
| {"Rating", TrackModel::SortColumnId::Rating}, | ||
| {"Key", TrackModel::SortColumnId::Key}, | ||
| // More mapping can be added here if needed. | ||
| // NOTE: If some of the missing value are referenced in a | ||
| // controller setting, test case will fail. | ||
| }; | ||
|
|
||
| TEST_F(ControllerLibraryColumnIDRegressionTest, ensureS4MK3) { | ||
| std::shared_ptr<LegacyControllerMapping> pMapping = | ||
| LegacyControllerMappingFileHandler::loadMapping( | ||
| QFileInfo("res/controllers/Traktor Kontrol S4 MK3.hid.xml"), QDir()); | ||
| EXPECT_TRUE(pMapping); | ||
| auto settings = pMapping->getSettings(); | ||
| EXPECT_TRUE(!settings.isEmpty()); | ||
|
|
||
| const int expectedSettingCount = 6; // Number of settings using library count. | ||
| int count = 0; | ||
| for (const auto& setting : settings) { | ||
| if (!setting->variableName().startsWith("librarySortableColumns")) { | ||
| continue; | ||
| } | ||
| auto pEnum = std::dynamic_pointer_cast<LegacyControllerEnumSetting>(setting); | ||
| EXPECT_TRUE(pEnum); | ||
| for (const auto& opt : pEnum->options()) { | ||
| EXPECT_EQ(static_cast<int>(COLUMN_MAPPING[std::get<0>(opt)]), std::get<1>(opt).toInt()); | ||
| } | ||
| count++; | ||
| } | ||
| EXPECT_EQ(count, expectedSettingCount); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Uh oh!
There was an error while loading. Please reload this page.