@@ -42,6 +42,7 @@ DlgPrefLibrary::DlgPrefLibrary(
4242 m_pRateRangeDeck1(make_parented<ControlProxy>(
4343 QStringLiteral (" [Channel1]" ), QStringLiteral(" rateRange" ), this)) {
4444 setupUi (this );
45+ gridLayout_track_table_view->setColumnStretch (1 , 1 );
4546
4647 connect (pushButton_add_dir,
4748 &QPushButton::clicked,
@@ -205,11 +206,12 @@ void DlgPrefLibrary::slotHide() {
205206 QMessageBox msgBox;
206207 msgBox.setIcon (QMessageBox::Warning);
207208 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?" ));
209+ msgBox.setText (tr (
210+ " You added one or more music directories. The tracks in "
211+ " these directories won't be available until you rescan "
212+ " your library. Would you like to rescan now?" ));
211213 QPushButton* scanButton = msgBox.addButton (
212- tr (" Scan" ), QMessageBox::AcceptRole);
214+ tr (" Scan" ), QMessageBox::AcceptRole);
213215 msgBox.addButton (QMessageBox::Cancel);
214216 msgBox.setDefaultButton (scanButton);
215217 msgBox.exec ();
@@ -777,3 +779,66 @@ void DlgPrefLibrary::setSeratoMetadataEnabled(bool shouldSyncTrackMetadata) {
777779 checkBox_serato_metadata_export->setChecked (false );
778780 }
779781}
782+
783+ void DlgPrefLibrary::slotDateFormatIndexChanged (int index) {
784+ auto type = comboBox_dateFormat->itemData (index)
785+ .value <BaseTrackTableModel::DateFormat>();
786+
787+ if (type == BaseTrackTableModel::DateFormat::Custom) {
788+ // Enable editing for Custom
789+ if (!comboBox_dateFormat->isEditable ()) {
790+ comboBox_dateFormat->setEditable (true );
791+ comboBox_dateFormat->setEditText (m_lastCustomDateFormat);
792+ }
793+ } else {
794+ // Disable editing for Presets
795+ comboBox_dateFormat->setEditable (false );
796+
797+ QString format;
798+ switch (type) {
799+ case BaseTrackTableModel::DateFormat::Native:
800+ format = QString ();
801+ break ;
802+ case BaseTrackTableModel::DateFormat::ISO8601 :
803+ format = QStringLiteral (" yyyy-MM-dd" );
804+ break ;
805+ case BaseTrackTableModel::DateFormat::RegionalShort:
806+ format = QStringLiteral (" d/M/yy" );
807+ break ;
808+ case BaseTrackTableModel::DateFormat::RegionalLong:
809+ format = QStringLiteral (" dd.MM.yyyy" );
810+ break ;
811+ case BaseTrackTableModel::DateFormat::Custom:
812+ // Should not happen here given the if/else above
813+ break ;
814+ }
815+ slotDateFormatChanged (format);
816+ }
817+ }
818+
819+ void DlgPrefLibrary::slotDateFormatChanged (const QString& text) {
820+ QString format = text;
821+ // If not editable, we are in a Preset mode, but 'text' might be the Item
822+ // Label (e.g. "Native ...") depending on how this was called. However, our
823+ // slotDateFormatIndexChanged calls this explicitly with the correct format
824+ // string. The editTextChanged signal only fires when editable. So 'text'
825+ // should be the correct format string in all valid cases.
826+
827+ if (comboBox_dateFormat->isEditable ()) {
828+ int index = comboBox_dateFormat->currentIndex ();
829+ if (index >= 0 ) {
830+ auto type = comboBox_dateFormat->itemData (index)
831+ .value <BaseTrackTableModel::DateFormat>();
832+ if (type == BaseTrackTableModel::DateFormat::Custom) {
833+ m_lastCustomDateFormat = format;
834+ }
835+ }
836+ }
837+
838+ // Update Preview
839+ const QString previewStr = mixxx::formatDate (QDate::currentDate (), format);
840+ label_dateFormatPreview->setText (previewStr);
841+
842+ m_pConfig->setValue (kDateFormatConfigKey , format);
843+ BaseTrackTableModel::setDateFormat (format);
844+ }
0 commit comments