LCOV - code coverage report
Current view: top level - src/notation/internal - mscoreerrorscontroller.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 164 0
Test Date: 2026-11-05 04:07:02

            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) 2023 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              : #include "mscoreerrorscontroller.h"
      23              : 
      24              : #include "engraving/dom/mscore.h"
      25              : 
      26              : using namespace muse;
      27              : using namespace mu::engraving;
      28              : using namespace mu::notation;
      29              : 
      30            0 : MScoreErrorsController::MScoreErrorsController(const muse::modularity::ContextPtr& iocCtx)
      31            0 :     : muse::Contextable(iocCtx)
      32              : {
      33            0 : }
      34              : 
      35            0 : void MScoreErrorsController::checkAndShowMScoreError()
      36              : {
      37            0 :     TRACEFUNC;
      38              : 
      39            0 :     MsError err = MScore::_error;
      40            0 :     if (err == MsError::MS_NO_ERROR || err == m_currentDialogError) {
      41            0 :         return;
      42              :     }
      43              : 
      44            0 :     MScore::setError(MsError::MS_NO_ERROR); // reset
      45              : 
      46            0 :     if (!configuration()->needToShowMScoreError(MScore::errorToString(err))) {
      47            0 :         return;
      48              :     }
      49              : 
      50            0 :     std::string title;
      51            0 :     std::string message;
      52              : 
      53            0 :     switch (err) {
      54            0 :     case MsError::MS_NO_ERROR:
      55            0 :         return;
      56            0 :     case MsError::NO_NOTE_SELECTED:
      57            0 :         title = muse::trc("notation", "No note selected");
      58            0 :         message = muse::trc("notation", "Please select a note and retry");
      59            0 :         break;
      60            0 :     case MsError::NO_CHORD_REST_SELECTED:
      61            0 :         title = muse::trc("notation", "No chord/rest selected");
      62            0 :         message = muse::trc("notation", "Please select a chord or rest and retry");
      63            0 :         break;
      64            0 :     case MsError::NO_LYRICS_SELECTED:
      65            0 :         title = muse::trc("notation", "No note or lyrics selected");
      66            0 :         message = muse::trc("notation", "Please select a note or lyrics and retry");
      67            0 :         break;
      68            0 :     case MsError::NO_NOTE_REST_SELECTED:
      69            0 :         title = muse::trc("notation", "No note or rest selected");
      70            0 :         message = muse::trc("notation", "Please select a note or rest and retry");
      71            0 :         break;
      72            0 :     case MsError::NO_FLIPPABLE_SELECTED:
      73            0 :         title = muse::trc("notation", "No flippable element selected");
      74            0 :         message = muse::trc("notation", "Please select an element that can be flipped and retry");
      75            0 :         break;
      76            0 :     case MsError::NO_MEASURE_SELECTED:
      77            0 :         title = muse::trc("notation", "No measure selected");
      78            0 :         message = muse::trc("notation", "Please select a measure and retry");
      79            0 :         break;
      80            0 :     case MsError::NO_STAFF_SELECTED:
      81            0 :         title = muse::trc("notation", "No staff selected");
      82            0 :         message = muse::trc("notation", "Please select one or more staves and retry");
      83            0 :         break;
      84            0 :     case MsError::NO_NOTE_FIGUREDBASS_SELECTED:
      85            0 :         title = muse::trc("notation", "No note or figured bass selected");
      86            0 :         message = muse::trc("notation", "Please select a note or figured bass and retry");
      87            0 :         break;
      88            0 :     case MsError::NO_NOTE_REST_HARMONY_SELECTED:
      89            0 :         title = muse::trc("notation", "No note or rest or chord symbol selected");
      90            0 :         message = muse::trc("notation", "Please select a note or rest or chord symbol and retry");
      91            0 :         break;
      92            0 :     case MsError::CANNOT_INSERT_TUPLET:
      93            0 :         title = muse::trc("notation", "Cannot insert chord/rest in tuplet");
      94            0 :         break;
      95            0 :     case MsError::CANNOT_SPLIT_TUPLET:
      96            0 :         title = muse::trc("notation", "Cannot split tuplet");
      97            0 :         break;
      98            0 :     case MsError::CANNOT_SPLIT_MEASURE_FIRST_BEAT:
      99            0 :         title = muse::trc("notation", "Cannot split measure at the first beat");
     100            0 :         break;
     101            0 :     case MsError::CANNOT_SPLIT_MEASURE_TUPLET:
     102            0 :         title = muse::trc("notation", "Cannot split measure here");
     103            0 :         message = muse::trc("notation", "Cannot split tuplet");
     104            0 :         break;
     105            0 :     case MsError::INSUFFICIENT_MEASURES:
     106            0 :         title = muse::trc("notation", "Cannot create measure repeat here");
     107            0 :         message = muse::trc("notation", "Insufficient or unequal measures");
     108            0 :         break;
     109            0 :     case MsError::CANNOT_SPLIT_MEASURE_REPEAT:
     110            0 :         title = muse::trc("notation", "Cannot split measure repeat");
     111            0 :         message = muse::trc("notation", "Please select a note or rest and retry");
     112            0 :         break;
     113            0 :     case MsError::CANNOT_SPLIT_MEASURE_TOO_SHORT:
     114            0 :         title = muse::trc("notation", "This measure is too short to be split");
     115            0 :         break;
     116            0 :     case MsError::CANNOT_REMOVE_TIME_TUPLET:
     117            0 :         title = muse::trc("notation", "Cannot remove time from tuplet");
     118            0 :         message = muse::trc("notation", "Please select the complete tuplet and retry");
     119            0 :         break;
     120            0 :     case MsError::CANNOT_REMOVE_TIME_MEASURE_REPEAT:
     121            0 :         title = muse::trc("notation", "Cannot remove time from measure repeat");
     122            0 :         message = muse::trc("notation", "Please select the complete measure repeat and retry");
     123            0 :         break;
     124            0 :     case MsError::NO_DEST:
     125            0 :         title = muse::trc("notation", "No destination to paste");
     126            0 :         break;
     127            0 :     case MsError::SOURCE_PARTIAL_TUPLET:
     128            0 :         title = muse::trc("notation", "This selection cannot be copied");
     129            0 :         message = muse::trc("notation", "Please select all notes that are part of this tuplet and try again.");
     130            0 :         break;
     131            0 :     case MsError::DEST_TUPLET:
     132            0 :         title = muse::trc("notation", "Cannot paste into tuplet");
     133            0 :         break;
     134            0 :     case MsError::TUPLET_CROSSES_BAR:
     135            0 :         title = muse::trc("notation", "Tuplet cannot cross barlines");
     136            0 :         break;
     137            0 :     case MsError::DEST_LOCAL_TIME_SIGNATURE:
     138            0 :         title = muse::trc("notation", "Cannot paste between different local time signatures");
     139            0 :         break;
     140            0 :     case MsError::SOURCE_PARTIAL_TREMOLO:
     141            0 :         title = muse::trc("notation", "This selection cannot be copied");
     142            0 :         message = muse::trc("notation", "Please select all notes that are part of this tremolo and try again.");
     143            0 :         break;
     144            0 :     case MsError::DEST_TREMOLO:
     145            0 :         title = muse::trc("notation", "Cannot paste in tremolo");
     146            0 :         break;
     147            0 :     case MsError::NO_MIME:
     148            0 :         title = muse::trc("notation", "Nothing to paste");
     149            0 :         break;
     150            0 :     case MsError::DEST_NO_CR:
     151            0 :         title = muse::trc("notation", "Destination is not a chord or rest");
     152            0 :         break;
     153            0 :     case MsError::CANNOT_CHANGE_LOCAL_TIMESIG_MEASURE_NOT_EMPTY:
     154            0 :         title = muse::trc("notation", "Cannot change local time signature");
     155            0 :         message = muse::trc("notation", "Measure is not empty");
     156            0 :         break;
     157            0 :     case MsError::CANNOT_CHANGE_LOCAL_TIMESIG_HAS_EXCERPTS:
     158            0 :         title = muse::trc("notation", "Cannot change local time signature");
     159            0 :         message = muse::trc("notation", "This score already has part scores. Changing local time "
     160            0 :                                         "signatures while part scores are present is not yet supported.");
     161            0 :         break;
     162            0 :     case MsError::CORRUPTED_MEASURE:
     163            0 :         title = muse::trc("notation", "Cannot change time signature in front of a corrupted measure");
     164            0 :         break;
     165            0 :     case MsError::CANNOT_REMOVE_KEY_SIG:
     166            0 :         title = muse::trc("notation", "This key signature cannot be deleted");
     167            0 :         message = muse::trc("notation", "Please replace it with a key signature from the palettes instead.");
     168            0 :         break;
     169            0 :     case MsError::CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE:
     170            0 :         title = muse::trc("notation", "These measures cannot be joined");
     171            0 :         message = muse::trc("notation", "Please remove the staff type change and retry.");
     172            0 :         break;
     173            0 :     case MsError::CANNOT_REPEAT_SELECTION:
     174            0 :         title = muse::trc("notation", "Can’t repeat this selection");
     175            0 :         message = muse::trc("notation", "Make a list selection of notes or rests on the same beat or any range selection and retry.");
     176            0 :         break;
     177            0 :     case MsError::TRANSPOSE_NO_FRET_DIAGRAM:
     178            0 :         title = muse::trc("notation", "Some fretboard diagrams could not be transposed");
     179            0 :         message = muse::trc("notation",
     180            0 :                             "Fretboard diagrams that could not be transposed have been left blank. You can undo this action if required.");
     181            0 :         break;
     182            0 :     case MsError::CANNOT_EXPLODE_IMPLODE_LOCAL_TIMESIG:
     183            0 :         title = muse::trc("notation", "Can’t explode or implode");
     184            0 :         message = muse::trc("notation", "Cannot explode or implode between different local time signatures");
     185            0 :         break;
     186            0 :     case MsError::NO_SPACE_FOR_TUPLET:
     187            0 :         title = muse::trc("notation", "Cannot create tuplet");
     188            0 :         message = muse::trc("notation", "There isn’t enough space for the tuplet before the end of the measure "
     189            0 :                                         "(or of the tuplet it would be nested in).");
     190            0 :         break;
     191            0 :     case MsError::TUPLET_NOTE_VALUE_TOO_SHORT:
     192            0 :         title = muse::trc("notation", "Cannot create tuplet");
     193            0 :         message = muse::trc("notation", "Note value is too short");
     194            0 :         break;
     195              :     }
     196              : 
     197            0 :     m_currentDialogError = err;
     198              : 
     199            0 :     interactive()->info(title, message, {}, 0,
     200            0 :                         IInteractive::Option::WithIcon | IInteractive::Option::WithDontShowAgainCheckBox)
     201            0 :     .onResolve(this, [this, err](const IInteractive::Result& res) {
     202            0 :         if (!res.showAgain()) {
     203            0 :             configuration()->setNeedToShowMScoreError(MScore::errorToString(err), false);
     204              :         }
     205            0 :         m_currentDialogError = MsError::MS_NO_ERROR;
     206            0 :     });
     207            0 : }
        

Generated by: LCOV version 2.0-1