@@ -205,11 +205,12 @@ void DlgPrefLibrary::slotHide() {
205205 QMessageBox msgBox;
206206 msgBox.setIcon (QMessageBox::Warning);
207207 msgBox.setWindowTitle (tr (" Music Directory Added" ));
208- msgBox.setText (tr (" You added one or more music directories. The tracks in "
209- " these directories won't be available until you rescan "
210- " your library. Would you like to rescan now?" ));
208+ msgBox.setText (tr (
209+ " You added one or more music directories. The tracks in "
210+ " these directories won't be available until you rescan "
211+ " your library. Would you like to rescan now?" ));
211212 QPushButton* scanButton = msgBox.addButton (
212- tr (" Scan" ), QMessageBox::AcceptRole);
213+ tr (" Scan" ), QMessageBox::AcceptRole);
213214 msgBox.addButton (QMessageBox::Cancel);
214215 msgBox.setDefaultButton (scanButton);
215216 msgBox.exec ();
@@ -369,6 +370,8 @@ void DlgPrefLibrary::slotUpdate() {
369370 comboBox_dateFormat->setEditable (false );
370371 }
371372
373+ updateDateFormatPreview (dateFormat);
374+
372375 // Ensure the static member is updated on startup/load
373376 BaseTrackTableModel::setDateFormat (dateFormat);
374377
@@ -777,3 +780,67 @@ void DlgPrefLibrary::setSeratoMetadataEnabled(bool shouldSyncTrackMetadata) {
777780 checkBox_serato_metadata_export->setChecked (false );
778781 }
779782}
783+
784+ void DlgPrefLibrary::slotDateFormatIndexChanged (int index) {
785+ auto type = comboBox_dateFormat->itemData (index)
786+ .value <BaseTrackTableModel::DateFormat>();
787+
788+ if (type == BaseTrackTableModel::DateFormat::Custom) {
789+ // Enable editing for Custom
790+ if (!comboBox_dateFormat->isEditable ()) {
791+ comboBox_dateFormat->setEditable (true );
792+ comboBox_dateFormat->setEditText (m_lastCustomDateFormat);
793+ }
794+ } else {
795+ // Disable editing for Presets
796+ comboBox_dateFormat->setEditable (false );
797+
798+ QString format;
799+ switch (type) {
800+ case BaseTrackTableModel::DateFormat::Native:
801+ format = QString ();
802+ break ;
803+ case BaseTrackTableModel::DateFormat::ISO8601 :
804+ format = QStringLiteral (" yyyy-MM-dd" );
805+ break ;
806+ case BaseTrackTableModel::DateFormat::RegionalShort:
807+ format = QStringLiteral (" d/M/yy" );
808+ break ;
809+ case BaseTrackTableModel::DateFormat::RegionalLong:
810+ format = QStringLiteral (" dd.MM.yyyy" );
811+ break ;
812+ case BaseTrackTableModel::DateFormat::Custom:
813+ // Should not happen here given the if/else above
814+ break ;
815+ }
816+ slotDateFormatChanged (format);
817+ }
818+ }
819+
820+ void DlgPrefLibrary::slotDateFormatChanged (const QString& text) {
821+ QString format = text;
822+ // If not editable, we are in a Preset mode, but 'text' might be the Item
823+ // Label (e.g. "Native ...") depending on how this was called. However, our
824+ // slotDateFormatIndexChanged calls this explicitly with the correct format
825+ // string. The editTextChanged signal only fires when editable. So 'text'
826+ // should be the correct format string in all valid cases.
827+
828+ if (comboBox_dateFormat->isEditable ()) {
829+ int index = comboBox_dateFormat->currentIndex ();
830+ if (index >= 0 ) {
831+ auto type = comboBox_dateFormat->itemData (index)
832+ .value <BaseTrackTableModel::DateFormat>();
833+ if (type == BaseTrackTableModel::DateFormat::Custom) {
834+ m_lastCustomDateFormat = format;
835+ }
836+ }
837+ }
838+ }
839+
840+ void DlgPrefLibrary::updateDateFormatPreview (const QString& format) {
841+ const QString previewStr = mixxx::formatDate (QDate::currentDate (), format);
842+ label_dateFormatPreview->setText (previewStr);
843+
844+ m_pConfig->setValue (kDateFormatConfigKey , format);
845+ BaseTrackTableModel::setDateFormat (format);
846+ }
0 commit comments