@@ -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 ();
@@ -777,3 +778,66 @@ void DlgPrefLibrary::setSeratoMetadataEnabled(bool shouldSyncTrackMetadata) {
777778 checkBox_serato_metadata_export->setChecked (false );
778779 }
779780}
781+
782+ void DlgPrefLibrary::slotDateFormatIndexChanged (int index) {
783+ auto type = comboBox_dateFormat->itemData (index)
784+ .value <BaseTrackTableModel::DateFormat>();
785+
786+ if (type == BaseTrackTableModel::DateFormat::Custom) {
787+ // Enable editing for Custom
788+ if (!comboBox_dateFormat->isEditable ()) {
789+ comboBox_dateFormat->setEditable (true );
790+ comboBox_dateFormat->setEditText (m_lastCustomDateFormat);
791+ }
792+ } else {
793+ // Disable editing for Presets
794+ comboBox_dateFormat->setEditable (false );
795+
796+ QString format;
797+ switch (type) {
798+ case BaseTrackTableModel::DateFormat::Native:
799+ format = QString ();
800+ break ;
801+ case BaseTrackTableModel::DateFormat::ISO8601 :
802+ format = QStringLiteral (" yyyy-MM-dd" );
803+ break ;
804+ case BaseTrackTableModel::DateFormat::RegionalShort:
805+ format = QStringLiteral (" d/M/yy" );
806+ break ;
807+ case BaseTrackTableModel::DateFormat::RegionalLong:
808+ format = QStringLiteral (" dd.MM.yyyy" );
809+ break ;
810+ case BaseTrackTableModel::DateFormat::Custom:
811+ // Should not happen here given the if/else above
812+ break ;
813+ }
814+ slotDateFormatChanged (format);
815+ }
816+ }
817+
818+ void DlgPrefLibrary::slotDateFormatChanged (const QString& text) {
819+ QString format = text;
820+ // If not editable, we are in a Preset mode, but 'text' might be the Item
821+ // Label (e.g. "Native ...") depending on how this was called. However, our
822+ // slotDateFormatIndexChanged calls this explicitly with the correct format
823+ // string. The editTextChanged signal only fires when editable. So 'text'
824+ // should be the correct format string in all valid cases.
825+
826+ if (comboBox_dateFormat->isEditable ()) {
827+ int index = comboBox_dateFormat->currentIndex ();
828+ if (index >= 0 ) {
829+ auto type = comboBox_dateFormat->itemData (index)
830+ .value <BaseTrackTableModel::DateFormat>();
831+ if (type == BaseTrackTableModel::DateFormat::Custom) {
832+ m_lastCustomDateFormat = format;
833+ }
834+ }
835+ }
836+
837+ // Update Preview
838+ const QString previewStr = mixxx::formatDate (QDate::currentDate (), format);
839+ label_dateFormatPreview->setText (previewStr);
840+
841+ m_pConfig->setValue (kDateFormatConfigKey , format);
842+ BaseTrackTableModel::setDateFormat (format);
843+ }
0 commit comments