LCOV - code coverage report
Current view: top level - src/notationscene/widgets - breaksdialog.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 45 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) 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              : 
      23              : #include "breaksdialog.h"
      24              : 
      25              : #include "notation/inotation.h"
      26              : #include "notation/inotationinteraction.h"
      27              : #include "notation/inotationselection.h"
      28              : 
      29              : using namespace mu::notation;
      30              : 
      31              : static constexpr int DEFAULT_INTERVAL = 4;
      32              : 
      33              : //---------------------------------------------------------
      34              : //   BreaksDialog
      35              : //---------------------------------------------------------
      36              : 
      37            0 : BreaksDialog::BreaksDialog(QWidget* parent)
      38            0 :     : muse::ui::WidgetDialog(parent)
      39              : {
      40            0 :     setupUi(this);
      41            0 :     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
      42            0 :     intervalButton->setChecked(true);
      43            0 :     intervalBox->setValue(DEFAULT_INTERVAL);
      44              : 
      45              :     //: `%1` will be replaced with a number input field.
      46              :     //: Text before it will appear before that number field, text after will appear after the field.
      47            0 :     QString text = muse::qtrc("notation/add-remove-system-breaks", "Lock layout with %1 measure(s) per system");
      48            0 :     QStringList pieces = text.split(QStringLiteral("%1"));
      49              : 
      50            0 :     IF_ASSERT_FAILED(pieces.size() >= 2) {
      51            0 :         return;
      52              :     }
      53              : 
      54            0 :     QString part1 = pieces[0].trimmed();
      55            0 :     QString part2 = pieces[1].trimmed();
      56            0 :     intervalButton->setText(part1);
      57            0 :     intervalLabel2->setText(part2);
      58            0 : }
      59              : 
      60            0 : void BreaksDialog::componentComplete()
      61              : {
      62            0 : }
      63              : 
      64              : //---------------------------------------------------------
      65              : //   accept
      66              : //---------------------------------------------------------
      67              : 
      68            0 : void BreaksDialog::accept()
      69              : {
      70            0 :     INotationPtr notation = context()->currentNotation();
      71            0 :     if (!notation) {
      72            0 :         return;
      73              :     }
      74              : 
      75            0 :     INotationInteractionPtr interaction = notation->interaction();
      76              : 
      77            0 :     int interval = intervalButton->isChecked() ? intervalBox->value() : 0;
      78            0 :     AddRemoveSystemLockType intervalType = AddRemoveSystemLockType::MeasuresInterval;
      79              : 
      80            0 :     if (removeButton->isChecked()) {
      81            0 :         intervalType = AddRemoveSystemLockType::None;
      82            0 :     } else if (lockButton->isChecked()) {
      83            0 :         intervalType = AddRemoveSystemLockType::AfterEachSystem;
      84              :     }
      85              : 
      86            0 :     interaction->addRemoveSystemLocks(intervalType, interval);
      87              : 
      88            0 :     if (_allSelected) {
      89            0 :         interaction->clearSelection();
      90              :     }
      91              : 
      92            0 :     QDialog::accept();
      93            0 : }
      94              : 
      95              : //---------------------------------------------------------
      96              : //   showEvent
      97              : //---------------------------------------------------------
      98              : 
      99            0 : void BreaksDialog::showEvent(QShowEvent* ev)
     100              : {
     101            0 :     INotationPtr notation = context()->currentNotation();
     102            0 :     if (!notation) {
     103            0 :         return;
     104              :     }
     105              : 
     106            0 :     INotationInteractionPtr interaction = notation->interaction();
     107            0 :     INotationSelectionPtr selection = interaction->selection();
     108              : 
     109            0 :     if (!selection->isRange()) {
     110            0 :         interaction->select(SelectionTarget::All);
     111            0 :         _allSelected = true;
     112              :     } else {
     113            0 :         _allSelected = false;
     114              :     }
     115              : 
     116            0 :     QWidget::showEvent(ev);
     117            0 : }
        

Generated by: LCOV version 2.0-1