LCOV - code coverage report
Current view: top level - src/appshell/internal - appshortcutsscopes.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 57 0
Test Date: 2026-11-19 04:14:36

            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) 2026 MuseScore Limited
       9              :  *
      10              :  * This program is free software: you can redistribute it and 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              : 
      23              : #include "appshortcutsscopes.h"
      24              : 
      25              : using namespace muse;
      26              : using namespace muse::shortcuts;
      27              : using namespace mu::appshell;
      28              : 
      29              : static const QString NOTATION_PANEL_NAME("ScoreView");
      30              : 
      31            0 : void AppShortcutsScopes::init()
      32              : {
      33            0 :     if (!shortcutsResolver()) {
      34            0 :         return;
      35              :     }
      36              : 
      37            0 :     std::shared_ptr<const AppShortcutsScopes> self = shared_from_this();
      38              : 
      39            0 :     auto whenNotationFocused = [self](Condition condition = nullptr) {
      40            0 :         return [self, condition]() {
      41            0 :             return self->isNotationActive(condition);
      42            0 :         };
      43            0 :     };
      44              : 
      45            0 :     IShortcutsResolver* resolver = shortcutsResolver().get();
      46              : 
      47            0 :     resolver->setScope({ "NAVIGATION", TranslatableString("shortcuts", "NAVIGATION"), 1 });
      48            0 :     resolver->setScope({ "PLAYBACK", TranslatableString("shortcuts", "PLAYBACK"), 2 });
      49              : 
      50            0 :     resolver->setScope({ "NOTATION_PAGE", TranslatableString("shortcuts", "NOTATION PAGE"), 3 });
      51            0 :     resolver->setScope({ "NOTATION", TranslatableString("shortcuts", "NOTATION"), 4, whenNotationFocused() });
      52            0 :     resolver->setScope({ "NOTATION_TAB", TranslatableString("shortcuts", "NOTATION: TAB"), 5,
      53            0 :                          whenNotationFocused(&AppShortcutsScopes::isTablatureStaff) });
      54            0 :     resolver->setScope({ "NOTATION_SELECTION", TranslatableString("shortcuts", "NOTATION: SELECTION"), 6,
      55            0 :                          whenNotationFocused(&AppShortcutsScopes::hasSelection) });
      56            0 :     resolver->setScope({ "NOTATION_SINGLE_SELECTION", TranslatableString("shortcuts", "NOTATION: SINGLE SELECTION"), 7,
      57            0 :                          whenNotationFocused(&AppShortcutsScopes::isSingleSelection) });
      58            0 :     resolver->setScope({ "NOTATION_RANGE_SELECTION", TranslatableString("shortcuts", "NOTATION: RANGE SELECTION"), 7,
      59            0 :                          whenNotationFocused(&AppShortcutsScopes::isRangeSelection) });
      60            0 :     resolver->setScope({ "NOTATION_NOTE_INPUT", TranslatableString("shortcuts", "NOTATION: NOTE INPUT"), 8,
      61            0 :                          whenNotationFocused(&AppShortcutsScopes::isNoteInputMode) });
      62            0 :     resolver->setScope({ "NOTATION_TEXT_EDITING", TranslatableString("shortcuts", "NOTATION: TEXT EDITING"), 9,
      63            0 :                          whenNotationFocused(&AppShortcutsScopes::isTextEditing) });
      64              : 
      65            0 :     resolver->setScope({ "PROJECT", TranslatableString("shortcuts", "PROJECT") });
      66            0 :     resolver->setScope({ "APP", TranslatableString("shortcuts", "APP") });
      67            0 :     resolver->setScope({ "PALETTE", TranslatableString("shortcuts", "PALETTE") });
      68            0 :     resolver->setScope({ "INSTRUMENTS", TranslatableString("shortcuts", "INSTRUMENTS") });
      69            0 :     resolver->setScope({ "EXTENSIONS", TranslatableString("shortcuts", "EXTENSIONS") });
      70            0 :     resolver->setScope({ "AUDIO", TranslatableString("shortcuts", "AUDIO") });
      71            0 :     resolver->setScope({ "DOCK", TranslatableString("shortcuts", "DOCK") });
      72            0 :     resolver->setScope({ "WORKSPACE", TranslatableString("shortcuts", "WORKSPACE") });
      73            0 :     resolver->setScope({ "UPDATE", TranslatableString("shortcuts", "UPDATE") });
      74            0 :     resolver->setScope({ "DIAGNOSTICS", TranslatableString("shortcuts", "DIAGNOSTICS") });
      75            0 :     resolver->setScope({ "TESTFLOW", TranslatableString("shortcuts", "TESTFLOW") });
      76            0 : }
      77              : 
      78            0 : bool AppShortcutsScopes::isNotationActive(Condition condition) const
      79              : {
      80            0 :     if (!isNotationFocused()) {
      81            0 :         return false;
      82              :     }
      83              : 
      84            0 :     return !condition || (this->*condition)();
      85              : }
      86              : 
      87            0 : bool AppShortcutsScopes::isNotationFocused() const
      88              : {
      89            0 :     auto activePanel = navigationController()->activePanel();
      90            0 :     return activePanel && activePanel->name() == NOTATION_PANEL_NAME;
      91              : }
      92              : 
      93            0 : bool AppShortcutsScopes::isNoteInputMode() const
      94              : {
      95            0 :     return notationCommandsController()->isNoteInputMode();
      96              : }
      97              : 
      98            0 : bool AppShortcutsScopes::isTablatureStaff() const
      99              : {
     100            0 :     return notationCommandsController()->isTablatureStaff();
     101              : }
     102              : 
     103            0 : bool AppShortcutsScopes::hasSelection() const
     104              : {
     105            0 :     return notationCommandsController()->hasSelection();
     106              : }
     107              : 
     108            0 : bool AppShortcutsScopes::isSingleSelection() const
     109              : {
     110            0 :     return notationCommandsController()->isSingleSelection();
     111              : }
     112              : 
     113            0 : bool AppShortcutsScopes::isRangeSelection() const
     114              : {
     115            0 :     return notationCommandsController()->isRangeSelection();
     116              : }
     117              : 
     118            0 : bool AppShortcutsScopes::isTextEditing() const
     119              : {
     120            0 :     return notationCommandsController()->isTextEditing();
     121              : }
        

Generated by: LCOV version 2.0-1