LCOV - code coverage report
Current view: top level - src/preferences/qml/MuseScore/Preferences - percussionpreferencesmodel.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 75 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) 2024 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              : 
      23              : #include "percussionpreferencesmodel.h"
      24              : 
      25              : #include "translation.h"
      26              : 
      27              : using namespace mu::notation;
      28              : 
      29            0 : PercussionPreferencesModel::PercussionPreferencesModel(QObject* parent)
      30            0 :     : QObject(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
      31              : {
      32            0 : }
      33              : 
      34            0 : void PercussionPreferencesModel::init()
      35              : {
      36            0 :     configuration()->percussionPanelAutoShowModeChanged().onNotify(this, [this]() {
      37            0 :         emit percussionPanelAutoShowModeChanged();
      38            0 :     });
      39              : 
      40            0 :     configuration()->autoClosePercussionPanelChanged().onNotify(this, [this]() {
      41            0 :         emit autoClosePercussionPanelChanged();
      42            0 :     });
      43              : 
      44            0 :     configuration()->showPercussionPanelPadSwapDialogChanged().onNotify(this, [this]() {
      45            0 :         emit showPercussionPanelPadSwapDialogChanged();
      46            0 :     });
      47              : 
      48            0 :     configuration()->percussionPanelMoveMidiNotesAndShortcutsChanged().onNotify(this, [this]() {
      49            0 :         emit percussionPanelMoveMidiNotesAndShortcutsChanged();
      50            0 :     });
      51            0 : }
      52              : 
      53            0 : QVariantList PercussionPreferencesModel::autoShowModes() const
      54              : {
      55              :     static const QVariantList modes {
      56            0 :         QVariantMap {
      57            0 :             { QStringLiteral("title"), muse::qtrc("notation/percussion", "When an unpitched percussion staff is selected") },
      58            0 :             { QStringLiteral("value"), int(PercussionPanelAutoShowMode::UNPITCHED_STAFF) }
      59            0 :         },
      60              : 
      61            0 :         QVariantMap {
      62            0 :             { QStringLiteral("title"), muse::qtrc("notation/percussion", "When inputting notation on an unpitched percussion staff") },
      63            0 :             { QStringLiteral("value"), int(PercussionPanelAutoShowMode::UNPITCHED_STAFF_NOTE_INPUT) }
      64            0 :         },
      65              : 
      66            0 :         QVariantMap {
      67            0 :             { QStringLiteral("title"), muse::qtrc("notation/percussion", "Never") },
      68            0 :             { QStringLiteral("value"), int(PercussionPanelAutoShowMode::NEVER) }
      69            0 :         },
      70            0 :     };
      71              : 
      72            0 :     return modes;
      73            0 : }
      74              : 
      75            0 : int PercussionPreferencesModel::autoShowMode() const
      76              : {
      77            0 :     return static_cast<int>(configuration()->percussionPanelAutoShowMode());
      78              : }
      79              : 
      80            0 : bool PercussionPreferencesModel::neverAutoShow() const
      81              : {
      82            0 :     return configuration()->percussionPanelAutoShowMode() == PercussionPanelAutoShowMode::NEVER;
      83              : }
      84              : 
      85            0 : void PercussionPreferencesModel::setAutoShowMode(int mode)
      86              : {
      87            0 :     if (mode == autoShowMode()) {
      88            0 :         return;
      89              :     }
      90              : 
      91            0 :     configuration()->setPercussionPanelAutoShowMode(static_cast<PercussionPanelAutoShowMode>(mode));
      92              : }
      93              : 
      94            0 : bool PercussionPreferencesModel::autoClosePercussionPanel() const
      95              : {
      96            0 :     return configuration()->autoClosePercussionPanel();
      97              : }
      98              : 
      99            0 : void PercussionPreferencesModel::setAutoClosePercussionPanel(bool autoClose)
     100              : {
     101            0 :     configuration()->setAutoClosePercussionPanel(autoClose);
     102            0 : }
     103              : 
     104            0 : bool PercussionPreferencesModel::showPercussionPanelPadSwapDialog() const
     105              : {
     106            0 :     return configuration()->showPercussionPanelPadSwapDialog();
     107              : }
     108              : 
     109            0 : void PercussionPreferencesModel::setShowPercussionPanelPadSwapDialog(bool show)
     110              : {
     111            0 :     configuration()->setShowPercussionPanelPadSwapDialog(show);
     112            0 : }
     113              : 
     114            0 : bool PercussionPreferencesModel::percussionPanelMoveMidiNotesAndShortcuts() const
     115              : {
     116            0 :     return configuration()->percussionPanelMoveMidiNotesAndShortcuts();
     117              : }
     118              : 
     119            0 : void PercussionPreferencesModel::setPercussionPanelMoveMidiNotesAndShortcuts(bool move)
     120              : {
     121            0 :     configuration()->setPercussionPanelMoveMidiNotesAndShortcuts(move);
     122            0 : }
     123              : 
     124            0 : QList<PercussionPreferencesModel::AutoShowMode> PercussionPreferencesModel::allAutoShowModes() const
     125              : {
     126              :     const QMap<PercussionPanelAutoShowMode, QString> modeTitles {
     127            0 :         { PercussionPanelAutoShowMode::UNPITCHED_STAFF,
     128            0 :           muse::qtrc("notation/percussion", "When an unpitched percussion staff is selected") },
     129              : 
     130            0 :         { PercussionPanelAutoShowMode::UNPITCHED_STAFF_NOTE_INPUT,
     131            0 :           muse::qtrc("notation/percussion", "When inputting notation on an unpitched percussion staff") },
     132              : 
     133            0 :         { PercussionPanelAutoShowMode::NEVER,
     134            0 :           muse::qtrc("notation/percussion", "Never") },
     135            0 :     };
     136              : 
     137            0 :     const PercussionPanelAutoShowMode currentMode = configuration()->percussionPanelAutoShowMode();
     138              : 
     139            0 :     QList<AutoShowMode> modes;
     140              : 
     141            0 :     for (PercussionPanelAutoShowMode type : modeTitles.keys()) {
     142            0 :         AutoShowMode mode;
     143            0 :         mode.type = type;
     144            0 :         mode.title = modeTitles[type];
     145            0 :         mode.checked = currentMode == type;
     146              : 
     147            0 :         modes << mode;
     148            0 :     }
     149              : 
     150            0 :     return modes;
     151            0 : }
        

Generated by: LCOV version 2.0-1