LCOV - code coverage report
Current view: top level - muse/framework/extensions/api/v1 - messagedialog.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 69 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-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              : #include "messagedialog.h"
      23              : 
      24              : using namespace muse::extensions::apiv1;
      25              : 
      26            0 : MessageDialog::MessageDialog(QObject* parent)
      27            0 :     : QObject(parent), Contextable(muse::iocCtxForQmlObject(this)) {}
      28              : 
      29            0 : void MessageDialog::doOpen(const QString& contentTitle, const QString& text, const QString& detailed, const QVariantList& buttons)
      30              : {
      31              :     //! NOTE Minimum compatibility for the current ones to work.
      32              :     //! It would be nice to change a lot of things.
      33              : 
      34            0 :     IInteractive::Buttons btns;
      35            0 :     for (const QVariant& b : buttons) {
      36            0 :         btns.push_back(static_cast<IInteractive::Button>(b.toInt()));
      37              :     }
      38              : 
      39              :     // info
      40            0 :     if (btns.size() <= 1) {
      41            0 :         IInteractive::Text t;
      42            0 :         t.text = text.toStdString();
      43            0 :         t.detailedText = detailed.toStdString();
      44            0 :         interactive()->error(contentTitle.toStdString(), t).onResolve(this, [this](const IInteractive::Result&) {
      45            0 :             emit accepted();
      46            0 :         });
      47            0 :     }
      48              :     //
      49              :     else {
      50            0 :         std::string txt = text.toStdString();
      51            0 :         if (!detailed.isEmpty()) {
      52            0 :             txt += "\n\n";
      53            0 :             txt += detailed.toStdString();
      54              :         }
      55              : 
      56            0 :         auto promise = interactive()->question(contentTitle.toStdString(), txt, btns);
      57            0 :         promise.onResolve(this, [this](const IInteractive::Result& res) {
      58            0 :             if (res.isButton(IInteractive::Button::Ok)) {
      59            0 :                 emit accepted();
      60              :             } else {
      61            0 :                 emit rejected();
      62              :             }
      63            0 :         });
      64            0 :     }
      65            0 : }
      66              : 
      67            0 : void MessageDialog::open()
      68              : {
      69            0 :     setVisible(true);
      70            0 : }
      71              : 
      72            0 : void MessageDialog::close()
      73              : {
      74            0 :     setVisible(false);
      75            0 : }
      76              : 
      77            0 : QString MessageDialog::text() const
      78              : {
      79            0 :     return m_text;
      80              : }
      81              : 
      82            0 : void MessageDialog::setText(const QString& newText)
      83              : {
      84            0 :     if (m_text == newText) {
      85            0 :         return;
      86              :     }
      87            0 :     m_text = newText;
      88            0 :     emit textChanged();
      89              : }
      90              : 
      91            0 : bool MessageDialog::visible() const
      92              : {
      93            0 :     return m_visible;
      94              : }
      95              : 
      96            0 : void MessageDialog::setVisible(bool newVisible)
      97              : {
      98            0 :     if (m_visible == newVisible) {
      99            0 :         return;
     100              :     }
     101            0 :     m_visible = newVisible;
     102            0 :     emit visibleChanged();
     103              : 
     104            0 :     if (m_visible) {
     105            0 :         doOpen(m_title, m_text, m_detailedText, m_standardButtons);
     106              :     }
     107              : }
     108              : 
     109            0 : QString MessageDialog::title() const
     110              : {
     111            0 :     return m_title;
     112              : }
     113              : 
     114            0 : void MessageDialog::setTitle(const QString& newTitle)
     115              : {
     116            0 :     if (m_title == newTitle) {
     117            0 :         return;
     118              :     }
     119            0 :     m_title = newTitle;
     120            0 :     emit titleChanged();
     121              : }
     122              : 
     123            0 : QString MessageDialog::detailedText() const
     124              : {
     125            0 :     return m_detailedText;
     126              : }
     127              : 
     128            0 : void MessageDialog::setDetailedText(const QString& newDetailedText)
     129              : {
     130            0 :     if (m_detailedText == newDetailedText) {
     131            0 :         return;
     132              :     }
     133            0 :     m_detailedText = newDetailedText;
     134            0 :     emit detailedTextChanged();
     135              : }
     136              : 
     137            0 : QVariantList MessageDialog::standardButtons() const
     138              : {
     139            0 :     return m_standardButtons;
     140              : }
     141              : 
     142            0 : void MessageDialog::setStandardButtons(const QVariantList& newStandardButtons)
     143              : {
     144            0 :     if (m_standardButtons == newStandardButtons) {
     145            0 :         return;
     146              :     }
     147            0 :     m_standardButtons = newStandardButtons;
     148            0 :     emit standardButtonsChanged();
     149              : }
        

Generated by: LCOV version 2.0-1