Skip to content

Commit 4ed4592

Browse files
committed
Update language-not-supported warning
1 parent b51c91c commit 4ed4592

5 files changed

Lines changed: 90 additions & 8 deletions

File tree

‎src/plugins/coreplugin/project/scenarios/EditSourcesScenario.cpp‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@
1616
#include <QVariant>
1717

1818
#include <CoreApi/runtimeinterface.h>
19+
#include <opendspx/mixedsinger.h>
20+
#include <opendspx/singlesinger.h>
21+
#include <SVSCraftQuick/MessageBox.h>
1922

2023
#include <dspxmodelORM/DynamicMixingAnchor.h>
2124
#include <dspxmodelORM/DynamicMixingAnchorSequence.h>
2225
#include <dspxmodelORM/Model.h>
26+
#include <dspxmodelORM/Note.h>
27+
#include <dspxmodelORM/NoteSequence.h>
2328
#include <dspxmodelORM/Singer.h>
2429
#include <dspxmodelORM/SingerList.h>
2530
#include <dspxmodelORM/SingingClip.h>
2631
#include <dspxmodelORM/Sources.h>
2732

33+
#include <coreplugin/CoreInterface.h>
2834
#include <coreplugin/DspxDocument.h>
35+
#include <coreplugin/SingerInfo.h>
36+
#include <coreplugin/SingerRegistry.h>
2937
#include <coreplugin/SourcesPickerModel.h>
3038

3139
#include <transactional/TransactionController.h>
@@ -95,6 +103,24 @@ namespace Core {
95103
return result;
96104
}
97105

106+
QString firstSingerId(const std::vector<opendspx::SingerRef> &singers) {
107+
for (const auto &singer : singers) {
108+
if (!singer)
109+
continue;
110+
if (singer->type == opendspx::Singer::Type::Single) {
111+
const auto &single = static_cast<const opendspx::SingleSinger &>(*singer);
112+
if (!single.id.empty())
113+
return QString::fromStdString(single.id);
114+
} else if (singer->type == opendspx::Singer::Type::Mixed) {
115+
const auto &mixed = static_cast<const opendspx::MixedSinger &>(*singer);
116+
const auto id = firstSingerId(mixed.singers);
117+
if (!id.isEmpty())
118+
return id;
119+
}
120+
}
121+
return {};
122+
}
123+
98124
QList<QPointer<dspx::SingingClip>> guardedClips(const QList<dspx::SingingClip *> &clips) {
99125
QList<QPointer<dspx::SingingClip>> result;
100126
result.reserve(clips.size());
@@ -171,19 +197,35 @@ namespace Core {
171197

172198
bool EditSourcesScenarioPrivate::applySourcesImpl(
173199
SourcesPickerModel *model, const QList<QPointer<dspx::SingingClip>> &clips) const {
200+
Q_Q(const EditSourcesScenario);
174201
if (!model)
175202
return false;
176203

177204
const QString architectureId = model->architectureId();
178205
const auto singers = toSingerVector(model->singers());
206+
const auto *registry = CoreInterface::singerRegistry();
207+
const auto languages = registry ? registry->singerInfo(architectureId, firstSingerId(singers)).languages() : SingerInfo::LanguageMap{};
208+
bool hasUnsupportedLanguage = false;
179209
bool applied = false;
180210
for (const auto &guardedClip : clips) {
181211
auto *clip = guardedClip.data();
182212
if (!clip)
183213
continue;
184214
updateSources(clip, architectureId, singers);
215+
if (!languages.isEmpty() && !hasUnsupportedLanguage) {
216+
hasUnsupportedLanguage = std::ranges::any_of(clip->notes()->asRange(), [&languages](const dspx::Note *note) {
217+
return !languages.contains(note->language());
218+
});
219+
}
185220
applied = true;
186221
}
222+
if (hasUnsupportedLanguage) {
223+
SVS::MessageBox::warning(
224+
RuntimeInterface::qmlEngine(), window,
225+
q->tr("Unsupported Note Languages"),
226+
q->tr("Some notes use languages that the selected singer does not support. Synthesis may fail. Change the note languages to languages supported by the singer.")
227+
);
228+
}
187229
return applied;
188230
}
189231

‎src/plugins/coreplugin/res/translations/org.diffscope.core_en_US.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,8 +2811,18 @@
28112811
<context>
28122812
<name>Core::EditSourcesScenario</name>
28132813
<message>
2814-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="247"/>
2815-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="265"/>
2814+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="225"/>
2815+
<source>Unsupported Note Languages</source>
2816+
<translation type="unfinished"></translation>
2817+
</message>
2818+
<message>
2819+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="226"/>
2820+
<source>Some notes use languages that the selected singer does not support. Synthesis may fail. Change the note languages to languages supported by the singer.</source>
2821+
<translation type="unfinished"></translation>
2822+
</message>
2823+
<message>
2824+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="290"/>
2825+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="308"/>
28162826
<source>Editing sources</source>
28172827
<translation type="unfinished">Editing sources</translation>
28182828
</message>

‎src/plugins/coreplugin/res/translations/org.diffscope.core_ja_JP.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,8 +2807,18 @@
28072807
<context>
28082808
<name>Core::EditSourcesScenario</name>
28092809
<message>
2810-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="247"/>
2811-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="265"/>
2810+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="225"/>
2811+
<source>Unsupported Note Languages</source>
2812+
<translation type="unfinished"></translation>
2813+
</message>
2814+
<message>
2815+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="226"/>
2816+
<source>Some notes use languages that the selected singer does not support. Synthesis may fail. Change the note languages to languages supported by the singer.</source>
2817+
<translation type="unfinished"></translation>
2818+
</message>
2819+
<message>
2820+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="290"/>
2821+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="308"/>
28122822
<source>Editing sources</source>
28132823
<translation type="unfinished"></translation>
28142824
</message>

‎src/plugins/coreplugin/res/translations/org.diffscope.core_zh_CN.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,8 +2834,18 @@
28342834
<context>
28352835
<name>Core::EditSourcesScenario</name>
28362836
<message>
2837-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="247"/>
2838-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="265"/>
2837+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="225"/>
2838+
<source>Unsupported Note Languages</source>
2839+
<translation type="unfinished"></translation>
2840+
</message>
2841+
<message>
2842+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="226"/>
2843+
<source>Some notes use languages that the selected singer does not support. Synthesis may fail. Change the note languages to languages supported by the singer.</source>
2844+
<translation type="unfinished"></translation>
2845+
</message>
2846+
<message>
2847+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="290"/>
2848+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="308"/>
28392849
<source>Editing sources</source>
28402850
<translation type="unfinished">编辑声源</translation>
28412851
</message>

‎src/plugins/coreplugin/res/translations/org.diffscope.core_zh_TW.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,8 +2807,18 @@
28072807
<context>
28082808
<name>Core::EditSourcesScenario</name>
28092809
<message>
2810-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="247"/>
2811-
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="265"/>
2810+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="225"/>
2811+
<source>Unsupported Note Languages</source>
2812+
<translation type="unfinished"></translation>
2813+
</message>
2814+
<message>
2815+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="226"/>
2816+
<source>Some notes use languages that the selected singer does not support. Synthesis may fail. Change the note languages to languages supported by the singer.</source>
2817+
<translation type="unfinished"></translation>
2818+
</message>
2819+
<message>
2820+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="290"/>
2821+
<location filename="../../project/scenarios/EditSourcesScenario.cpp" line="308"/>
28122822
<source>Editing sources</source>
28132823
<translation type="unfinished"></translation>
28142824
</message>

0 commit comments

Comments
 (0)