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 :
39 0 : inline muse::Ret make_ret(Err err)
40 : {
41 0 : std::string text;
42 :
43 0 : switch (err) {
44 0 : case Err::UnknownError:
45 0 : text = muse::trc("notation", "Unknown error");
46 0 : break;
47 0 : case Err::SelectCompleteTupletOrTremolo:
48 0 : text = muse::trc("notation", "Please select the complete tuplet or tremolo and retry");
49 0 : break;
50 0 : case Err::EmptySelection:
51 0 : text = muse::trc("notation", "The selection is empty");
52 0 : break;
53 0 : case Err::Undefined:
54 : case Err::NoError:
55 0 : break;
56 : }
57 :
58 0 : return muse::Ret(static_cast<int>(err), text);
59 0 : }
60 : }
61 :
62 : #endif // MU_NOTATION_NOTATIONERRORS_H
|