@@ -111,18 +111,19 @@ DlgPrefLibrary::DlgPrefLibrary(
111111
112112 updateSearchLineEditHistoryOptions ();
113113
114- comboBox_dateFormat->addItem (tr (" Native (System Default)" ),
115- static_cast <int >(mixxx::DateFormat::Native));
116- comboBox_dateFormat->addItem (tr (" YYYY-MM-DD" ),
117- static_cast <int >(mixxx::DateFormat::ISO8601 ));
118- comboBox_dateFormat->addItem (tr (" DD/MM/YYYY" ),
119- static_cast <int >(mixxx::DateFormat::DayMonthYear));
120- comboBox_dateFormat->addItem (tr (" MM/DD/YYYY" ),
121- static_cast <int >(mixxx::DateFormat::MonthDayYear));
122- comboBox_dateFormat->addItem (tr (" YYYY/MM/DD" ),
123- static_cast <int >(mixxx::DateFormat::YearMonthDay));
114+ comboBox_dateFormat->setEditable (true );
115+ // Use empty string data for Native to invoke QLocale default
116+ comboBox_dateFormat->addItem (tr (" Native (System Default)" ), QString ());
117+ comboBox_dateFormat->addItem (tr (" ISO 8601 (yyyy-MM-dd)" ), QStringLiteral (" yyyy-MM-dd" ));
118+ comboBox_dateFormat->addItem (tr (" Regional Short (d/M/yy)" ), QStringLiteral (" d/M/yy" ));
119+ comboBox_dateFormat->addItem (tr (" Regional Long (dd.MM.yyyy)" ), QStringLiteral (" dd.MM.yyyy" ));
120+ // Custom option is handled by the edit behavior
121+
122+ // Update preview initially
123+ slotDateFormatChanged (comboBox_dateFormat->currentText ());
124+
124125 connect (comboBox_dateFormat,
125- QOverload< int >:: of ( &QComboBox::currentIndexChanged) ,
126+ &QComboBox::currentTextChanged ,
126127 this ,
127128 &DlgPrefLibrary::slotDateFormatChanged);
128129
@@ -283,10 +284,13 @@ void DlgPrefLibrary::slotResetToDefaults() {
283284 comboBox_search_bpm_fuzzy_range->setCurrentIndex (
284285 comboBox_search_bpm_fuzzy_range->findData (kDefaultFuzzyRateRangePercent ));
285286
286- int defaultDateFormat = static_cast <int >(BaseTrackTableModel::kDateFormatDefault );
287- int dateIndex = comboBox_dateFormat->findData (defaultDateFormat);
287+ int dateIndex = comboBox_dateFormat->findData (BaseTrackTableModel::kDateFormatDefault );
288288 if (dateIndex != -1 ) {
289289 comboBox_dateFormat->setCurrentIndex (dateIndex);
290+ } else {
291+ // Fallback or custom default? Default is usually Native (empty string)
292+ // which should be found.
293+ comboBox_dateFormat->setCurrentIndex (0 );
290294 }
291295
292296 checkBox_show_rhythmbox->setChecked (true );
@@ -331,15 +335,18 @@ void DlgPrefLibrary::slotUpdate() {
331335 checkBox_show_serato->setChecked (m_pConfig->getValue (
332336 ConfigKey (" [Library]" , " ShowSeratoLibrary" ), true ));
333337
334- int dateFormat = m_pConfig->getValue (
338+ QString dateFormat = m_pConfig->getValue (
335339 kDateFormatConfigKey ,
336- static_cast < int >( BaseTrackTableModel::kDateFormatDefault ) );
340+ BaseTrackTableModel::kDateFormatDefault );
337341 int dateIndex = comboBox_dateFormat->findData (dateFormat);
338342 if (dateIndex != -1 ) {
339343 comboBox_dateFormat->setCurrentIndex (dateIndex);
344+ } else {
345+ // Custom format string
346+ comboBox_dateFormat->setCurrentText (dateFormat);
340347 }
341348 // Ensure the static member is updated on startup/load
342- BaseTrackTableModel::setDateFormat (static_cast <mixxx::DateFormat>( dateFormat) );
349+ BaseTrackTableModel::setDateFormat (dateFormat);
343350
344351 switch (m_pConfig->getValue <int >(
345352 kTrackDoubleClickActionConfigKey ,
@@ -747,9 +754,25 @@ void DlgPrefLibrary::setSeratoMetadataEnabled(bool shouldSyncTrackMetadata) {
747754 }
748755}
749756
750- void DlgPrefLibrary::slotDateFormatChanged (int index) {
751- int formatInt = comboBox_dateFormat->itemData (index).toInt ();
752- mixxx::DateFormat format = static_cast <mixxx::DateFormat>(formatInt);
753- m_pConfig->setValue (kDateFormatConfigKey , formatInt);
757+ void DlgPrefLibrary::slotDateFormatChanged (const QString& text) {
758+ QString format = text;
759+ // Check if the text matches a predefined item (like "Native (...)")
760+ int index = comboBox_dateFormat->findText (text);
761+ if (index != -1 ) {
762+ // Use the underlying data (e.g. empty string for Native, or "yyyy-MM-dd" for ISO)
763+ format = comboBox_dateFormat->itemData (index).toString ();
764+ }
765+
766+ // Update Preview
767+ QDate exampleDate = QDate::currentDate ();
768+ QString previewStr;
769+ if (format.isEmpty ()) {
770+ previewStr = QLocale ().toString (exampleDate, QLocale::ShortFormat);
771+ } else {
772+ previewStr = exampleDate.toString (format);
773+ }
774+ label_dateFormatPreview->setText (previewStr);
775+
776+ m_pConfig->setValue (kDateFormatConfigKey , format);
754777 BaseTrackTableModel::setDateFormat (format);
755778}
0 commit comments