Skip to content

Commit

Permalink
DlgTrackInfo: apply pending changes also when saving via hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Dec 11, 2021
1 parent b0f6257 commit 234005a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/library/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void DlgTrackInfo::init() {
btnPrev->hide();
}

// QDialog buttons
connect(btnApply,
&QPushButton::clicked,
this,
Expand All @@ -92,6 +93,7 @@ void DlgTrackInfo::init() {
this,
&DlgTrackInfo::slotCancel);

// BPM edit buttons
connect(bpmDouble,
&QPushButton::clicked,
this,
Expand Down Expand Up @@ -203,6 +205,7 @@ void DlgTrackInfo::init() {
txtTrackNumber->text().trimmed());
});

// Import and file browser buttons
connect(btnImportMetadataFromFile,
&QPushButton::clicked,
this,
Expand All @@ -218,6 +221,7 @@ void DlgTrackInfo::init() {
this,
&DlgTrackInfo::slotOpenInFileBrowser);

// Cover art
CoverArtCache* pCache = CoverArtCache::instance();
if (pCache) {
connect(pCache,
Expand Down Expand Up @@ -483,6 +487,18 @@ void DlgTrackInfo::saveTrack() {
return;
}

// In case Apply is triggered by hotkey AND a QLineEdit with pending changes
// is focused AND the user did not hit Enter to finish editing,
// the content of that focused line edit would be reset to the last confirmed state.
// This hack emits the editingFinished() signal for the focused QLineEdit.
if (this == QApplication::activeWindow()) {
auto focusWidget = QApplication::focusWidget();
QLineEdit* focusedLineEdit = qobject_cast<QLineEdit*>(focusWidget);
if (focusedLineEdit) {
emit focusedLineEdit->editingFinished();
}
}

// First, disconnect the track changed signal. Otherwise we signal ourselves
// and repopulate all these fields.
const QSignalBlocker signalBlocker(this);
Expand Down

0 comments on commit 234005a

Please sign in to comment.