Skip to content

Commit e344ac3

Browse files
committed
Add lyrics overlay
1 parent 6d2e617 commit e344ac3

12 files changed

Lines changed: 1017 additions & 240 deletions

‎src/plugins/visualeditor/internal/EditorPreference.cpp‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace VisualEditor::Internal {
3535
EditorPreference::NoteEditPitchCurveDisplayMode noteEditPitchCurveDisplayMode{};
3636
double autoPitchCurveDisplayPixelDensityThreshold{kDefaultAutoPitchCurveDisplayPixelDensityThreshold};
3737
bool displayPronunciationBelowNote{};
38+
bool showLyricOverlay{};
39+
int lyricPhraseGapThreshold{240};
3840
bool warnOfOverlappingNotes{true};
3941
bool trackCursorPosition{true};
4042
bool showSingerBackground{true};
@@ -108,6 +110,8 @@ namespace VisualEditor::Internal {
108110
Q_EMIT autoPitchCurveDisplayPixelDensityThresholdChanged();
109111
d->displayPronunciationBelowNote = settings->value("displayPronunciationBelowNote", false).toBool();
110112
emit displayPronunciationBelowNoteChanged();
113+
setLyricPhraseGapThreshold(settings->value("lyricPhraseGapThreshold", 240).toInt());
114+
setShowLyricOverlay(settings->value("showLyricOverlay", false).toBool());
111115
d->warnOfOverlappingNotes = settings->value("warnOfOverlappingNotes", true).toBool();
112116
emit warnOfOverlappingNotesChanged();
113117
d->trackCursorPosition = settings->value("trackCursorPosition", true).toBool();
@@ -157,6 +161,8 @@ namespace VisualEditor::Internal {
157161
settings->setValue("noteEditPitchCurveDisplayMode", static_cast<int>(d->noteEditPitchCurveDisplayMode));
158162
settings->setValue("autoPitchCurveDisplayPixelDensityThreshold", d->autoPitchCurveDisplayPixelDensityThreshold);
159163
settings->setValue("displayPronunciationBelowNote", d->displayPronunciationBelowNote);
164+
settings->setValue("showLyricOverlay", d->showLyricOverlay);
165+
settings->setValue("lyricPhraseGapThreshold", d->lyricPhraseGapThreshold);
160166
settings->setValue("warnOfOverlappingNotes", d->warnOfOverlappingNotes);
161167
settings->setValue("trackCursorPosition", d->trackCursorPosition);
162168
settings->setValue("showSingerBackground", d->showSingerBackground);
@@ -413,6 +419,33 @@ namespace VisualEditor::Internal {
413419
emit m_instance->displayPronunciationBelowNoteChanged();
414420
}
415421

422+
bool EditorPreference::showLyricOverlay() {
423+
M_INSTANCE_D;
424+
return d->showLyricOverlay;
425+
}
426+
427+
void EditorPreference::setShowLyricOverlay(bool showLyricOverlay) {
428+
M_INSTANCE_D;
429+
if (d->showLyricOverlay == showLyricOverlay)
430+
return;
431+
d->showLyricOverlay = showLyricOverlay;
432+
Q_EMIT m_instance->showLyricOverlayChanged();
433+
}
434+
435+
int EditorPreference::lyricPhraseGapThreshold() {
436+
M_INSTANCE_D;
437+
return d->lyricPhraseGapThreshold;
438+
}
439+
440+
void EditorPreference::setLyricPhraseGapThreshold(int lyricPhraseGapThreshold) {
441+
M_INSTANCE_D;
442+
lyricPhraseGapThreshold = qBound(1, lyricPhraseGapThreshold, 1920);
443+
if (d->lyricPhraseGapThreshold == lyricPhraseGapThreshold)
444+
return;
445+
d->lyricPhraseGapThreshold = lyricPhraseGapThreshold;
446+
Q_EMIT m_instance->lyricPhraseGapThresholdChanged();
447+
}
448+
416449
bool EditorPreference::warnOfOverlappingNotes() {
417450
M_INSTANCE_D;
418451
return d->warnOfOverlappingNotes;

‎src/plugins/visualeditor/internal/EditorPreference.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ namespace VisualEditor::Internal {
4242
Q_PROPERTY(EditorPreference::NoteEditPitchCurveDisplayMode noteEditPitchCurveDisplayMode READ noteEditPitchCurveDisplayMode WRITE setNoteEditPitchCurveDisplayMode NOTIFY noteEditPitchCurveDisplayModeChanged)
4343
Q_PROPERTY(double autoPitchCurveDisplayPixelDensityThreshold READ autoPitchCurveDisplayPixelDensityThreshold WRITE setAutoPitchCurveDisplayPixelDensityThreshold NOTIFY autoPitchCurveDisplayPixelDensityThresholdChanged)
4444
Q_PROPERTY(bool displayPronunciationBelowNote READ displayPronunciationBelowNote WRITE setDisplayPronunciationBelowNote NOTIFY displayPronunciationBelowNoteChanged)
45+
Q_PROPERTY(bool showLyricOverlay READ showLyricOverlay WRITE setShowLyricOverlay NOTIFY showLyricOverlayChanged)
46+
Q_PROPERTY(int lyricPhraseGapThreshold READ lyricPhraseGapThreshold WRITE setLyricPhraseGapThreshold NOTIFY lyricPhraseGapThresholdChanged)
4547
Q_PROPERTY(bool warnOfOverlappingNotes READ warnOfOverlappingNotes WRITE setWarnOfOverlappingNotes NOTIFY warnOfOverlappingNotesChanged)
4648
Q_PROPERTY(bool trackCursorPosition READ trackCursorPosition WRITE setTrackCursorPosition NOTIFY trackCursorPositionChanged)
4749
Q_PROPERTY(bool showSingerBackground READ showSingerBackground WRITE setShowSingerBackground NOTIFY showSingerBackgroundChanged)
@@ -159,6 +161,12 @@ namespace VisualEditor::Internal {
159161
static bool displayPronunciationBelowNote();
160162
static void setDisplayPronunciationBelowNote(bool displayPronunciationBelowNote);
161163

164+
static bool showLyricOverlay();
165+
static void setShowLyricOverlay(bool showLyricOverlay);
166+
167+
static int lyricPhraseGapThreshold();
168+
static void setLyricPhraseGapThreshold(int lyricPhraseGapThreshold);
169+
162170
static bool warnOfOverlappingNotes();
163171
static void setWarnOfOverlappingNotes(bool warnOfOverlappingNotes);
164172

@@ -211,6 +219,8 @@ namespace VisualEditor::Internal {
211219
void noteEditPitchCurveDisplayModeChanged();
212220
void autoPitchCurveDisplayPixelDensityThresholdChanged();
213221
void displayPronunciationBelowNoteChanged();
222+
void showLyricOverlayChanged();
223+
void lyricPhraseGapThresholdChanged();
214224
void warnOfOverlappingNotesChanged();
215225
void trackCursorPositionChanged();
216226
void showSingerBackgroundChanged();

0 commit comments

Comments
 (0)