LCOV - code coverage report
Current view: top level - muse/framework/toast/qml/Muse/Toast/dev - toasttestsmodel.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 44 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) 2026 MuseScore Limited
       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 "toasttestsmodel.h"
      23              : 
      24              : #include "log.h"
      25              : #include "toast/toasttypes.h"
      26              : 
      27              : using namespace muse::toast;
      28              : using namespace muse;
      29              : 
      30            0 : ToastTestsModel::ToastTestsModel(QObject* parent)
      31            0 :     : QObject(parent), Contextable(muse::iocCtxForQmlObject(this))
      32              : {
      33            0 : }
      34              : 
      35            0 : void ToastTestsModel::showToastWithTimeout(const QString& title, const QString& message, int iconCode, int timeoutSeconds, bool dismissible)
      36              : {
      37            0 :     toastService()->showWithTimeout(
      38            0 :         title.toStdString(),
      39            0 :         message.toStdString(),
      40            0 :         std::chrono::seconds(timeoutSeconds),
      41              :         static_cast<muse::ui::IconCode::Code>(iconCode),
      42              :         dismissible
      43              :         );
      44            0 : }
      45              : 
      46            0 : void ToastTestsModel::showSuccess(const QString& title, const QString& message)
      47              : {
      48            0 :     toastService()->showSuccess(title.toStdString(), message.toStdString());
      49            0 : }
      50              : 
      51            0 : void ToastTestsModel::showError(const QString& title, const QString& message)
      52              : {
      53            0 :     toastService()->showError(title.toStdString(), message.toStdString());
      54            0 : }
      55              : 
      56            0 : void ToastTestsModel::showInfo(const QString& title, const QString& message)
      57              : {
      58            0 :     toastService()->showInfo(title.toStdString(), message.toStdString());
      59            0 : }
      60              : 
      61            0 : void ToastTestsModel::showWarning(const QString& title, const QString& message)
      62              : {
      63            0 :     toastService()->showWarning(title.toStdString(), message.toStdString());
      64            0 : }
      65              : 
      66            0 : void ToastTestsModel::showToastWithAction(const QString& title, const QString& message, int iconCode)
      67              : {
      68            0 :     toastService()->show(
      69            0 :         title.toStdString(),
      70            0 :         message.toStdString(),
      71              :         static_cast<muse::ui::IconCode::Code>(iconCode),
      72              :         true,
      73              :     {
      74              :         { "Open info dialog", ToastActionCode::Custom },
      75            0 :     }).onResolve(this, [this](const ToastResult& result) {
      76            0 :         if (result.isCode(ToastActionCode::Custom)) {
      77            0 :             interactive()->info("Info Dialog", "Info dialog action triggered from toast");
      78              :         }
      79            0 :     });
      80            0 : }
      81              : 
      82            0 : void ToastTestsModel::showWithProgress(const QString& title, const QString& message, int iconCode, bool dismissible, bool showProgressInfo)
      83              : {
      84            0 :     if (m_progress) {
      85              :         //Just to make things easy on testing
      86            0 :         m_progress->progress(100, 100, "Completed old process");
      87              :     }
      88              : 
      89            0 :     m_progress = std::make_shared<muse::Progress>();
      90              : 
      91            0 :     toastService()->showWithProgress(
      92            0 :         title.toStdString(),
      93            0 :         message.toStdString(),
      94            0 :         m_progress,
      95              :         static_cast<muse::ui::IconCode::Code>(iconCode),
      96              :         dismissible,
      97              :         {},
      98              :         showProgressInfo
      99              :         );
     100              : 
     101            0 :     m_progress->start();
     102            0 : }
     103              : 
     104            0 : void ToastTestsModel::updateProgress(int progress)
     105              : {
     106            0 :     if (m_progress) {
     107            0 :         m_progress->progress(progress, 100, "Processing...");
     108              :     }
     109            0 : }
        

Generated by: LCOV version 2.0-1