Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #ifndef MU_NOTATION_NOTATIONERRORS_H
23 : #define MU_NOTATION_NOTATIONERRORS_H
24 :
25 : #include "types/ret.h"
26 : #include "translation.h"
27 :
28 : namespace mu::notation {
29 : enum class Err {
30 : Undefined = int(muse::Ret::Code::Undefined),
31 : NoError = int(muse::Ret::Code::Ok),
32 : UnknownError = int(muse::Ret::Code::NotationFirst),
33 :
34 : // selection
35 : SelectCompleteTupletOrTremolo = 1050,
36 : EmptySelection,
37 :
38 : // note input
39 : NoteInputRemovesMeasureRepeat = 1060,
40 :
41 : // measure repeats
42 : MeasureRepeatReplacesContents = 1070,
43 : };
44 :
45 0 : inline muse::Ret make_ret(Err err)
46 : {
47 0 : std::string text;
48 :
49 0 : switch (err) {
50 0 : case Err::UnknownError:
51 0 : text = muse::trc("notation", "Unknown error");
52 0 : break;
53 0 : case Err::SelectCompleteTupletOrTremolo:
54 0 : text = muse::trc("notation", "Please select the complete tuplet or tremolo and retry");
55 0 : break;
56 0 : case Err::EmptySelection:
57 0 : text = muse::trc("notation", "The selection is empty");
58 0 : break;
59 0 : case Err::NoteInputRemovesMeasureRepeat:
60 0 : text = muse::trc("engraving", "Note input will remove measure repeat");
61 0 : text += "\n\n";
62 0 : text += muse::trc("engraving", "This measure contains a measure repeat."
63 : " If you enter notes here, it will be deleted."
64 0 : " Do you want to continue?");
65 0 : break;
66 0 : case Err::MeasureRepeatReplacesContents:
67 0 : text = muse::trc("engraving", "Current contents of measures will be replaced");
68 0 : text += "\n\n";
69 0 : text += muse::trc("engraving", "Continue with inserting measure repeat?");
70 0 : break;
71 0 : case Err::Undefined:
72 : case Err::NoError:
73 0 : break;
74 : }
75 :
76 0 : return muse::Ret(static_cast<int>(err), text);
77 0 : }
78 : }
79 :
80 : #endif // MU_NOTATION_NOTATIONERRORS_H
|