Skip to content

Commit 9f016d1

Browse files
committed
Add error dialog
1 parent e5ff8bb commit 9f016d1

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

src/engraving/dom/mscore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ bool MScore::svgPrinting = false;
6363
extern void initDrumset();
6464

6565
MsError MScore::_error { MsError::MS_NO_ERROR };
66+
bool MScore::_errorIsWarning = false;
6667

6768
void MScore::registerUiTypes()
6869
{
@@ -118,6 +119,7 @@ std::string MScore::errorToString(MsError err)
118119
case MsError::CANNOT_REMOVE_KEY_SIG: return "CANNOT_REMOVE_KEY_SIG";
119120
case MsError::CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE: return "CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE";
120121
case MsError::CANNOT_REPEAT_SELECTION: return "CANNOT_REPEAT_SELECTION";
122+
case MsError::TRANSPOSE_NO_FRET_DIAGRAM: return "TRANSPOSE_NO_FRET_DIAGRAM";
121123
}
122124

123125
return {};

src/engraving/dom/mscore.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ enum class MsError : unsigned char {
165165
CANNOT_REMOVE_KEY_SIG,
166166
CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE,
167167
CANNOT_REPEAT_SELECTION,
168+
TRANSPOSE_NO_FRET_DIAGRAM,
168169
};
169170

170171
/// \cond PLUGIN_API \private \endcond
@@ -187,6 +188,7 @@ class MScore
187188
public:
188189

189190
static MsError _error;
191+
static bool _errorIsWarning;
190192

191193
static void registerUiTypes();
192194

@@ -230,7 +232,7 @@ class MScore
230232
static double horizontalPageGapEven;
231233
static double horizontalPageGapOdd;
232234

233-
static void setError(MsError e) { _error = e; }
235+
static void setError(MsError e, bool warning = false) { _error = e; _errorIsWarning = warning; }
234236

235237
static std::string errorToString(MsError err);
236238
};

src/engraving/editing/cmd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ void Score::endCmd(bool rollback, bool layoutAllParts)
414414
return;
415415
}
416416

417-
if (readOnly() || MScore::_error != MsError::MS_NO_ERROR) {
417+
if (readOnly() || (MScore::_error != MsError::MS_NO_ERROR && !MScore::_errorIsWarning)) {
418418
rollback = true;
419419
}
420420

src/engraving/editing/transpose.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ void Transpose::transposeFretDiagram(FretDiagram* diagram, Score* score, Interva
574574

575575
std::vector<DiagramInfo> availableDiagrams = diagram->patternsFromHarmony(harmony->plainText());
576576
if (availableDiagrams.empty()) {
577-
LOGI() << "ERROR";
577+
diagram->undoFretClear();
578+
MScore::setError(MsError::TRANSPOSE_NO_FRET_DIAGRAM, true);
578579
return;
579580
}
580581
score->undo(new FretDataChange(diagram, harmony->plainText()));
@@ -585,7 +586,8 @@ void Transpose::transposeFretDiagram(FretDiagram* diagram, Score* score, Interva
585586
String pattern = FretDiagram::patternFromDiagram(diagram);
586587
std::vector<String> names = FretDiagram::harmoniesFromPattern(pattern);
587588
if (names.empty()) {
588-
LOGI() << "ERROR";
589+
diagram->undoFretClear();
590+
MScore::setError(MsError::TRANSPOSE_NO_FRET_DIAGRAM, true);
589591
return;
590592
}
591593

@@ -622,7 +624,8 @@ void Transpose::transposeFretDiagram(FretDiagram* diagram, Score* score, Interva
622624

623625
std::vector<DiagramInfo> availableDiagrams = diagram->patternsFromHarmony(harmony->plainText());
624626
if (availableDiagrams.empty()) {
625-
LOGI() << "ERROR";
627+
diagram->undoFretClear();
628+
MScore::setError(MsError::TRANSPOSE_NO_FRET_DIAGRAM, true);
626629
return;
627630
}
628631
score->undo(new FretDataChange(diagram, harmony->plainText()));

src/notation/internal/mscoreerrorscontroller.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ void MScoreErrorsController::checkAndShowMScoreError()
166166
title = muse::trc("notation", "Can’t repeat this selection");
167167
message = muse::trc("notation", "Make a list selection of notes or rests on the same beat or any range selection and retry.");
168168
break;
169+
case MsError::TRANSPOSE_NO_FRET_DIAGRAM:
170+
title = muse::trc("notation", "Some fretboard diagrams could not be transposed");
171+
message = muse::trc("notation",
172+
"Fretboard diagrams that could not be transposed have been left blank. You can undo this action if required.");
173+
break;
169174
}
170175

171176
interactive()->info(title, message, {}, 0,

src/notation/view/widgets/transposedialog.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "transposedialog.h"
2424

25+
#include "internal/mscoreerrorscontroller.h"
2526
#include "ui/view/widgetstatestore.h"
2627

2728
using namespace mu::notation;
@@ -218,6 +219,8 @@ void TransposeDialog::apply()
218219

219220
interaction()->transpose(options);
220221

222+
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
223+
221224
if (m_allSelected) {
222225
interaction()->clearSelection();
223226
}

0 commit comments

Comments
 (0)