LCOV - code coverage report
Current view: top level - src/appshell/widgets/splashscreen - newinstanceloadingscreenview.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 36 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) 2022 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 "newinstanceloadingscreenview.h"
      24              : 
      25              : #include <QApplication>
      26              : #include <QPainter>
      27              : #include <QScreen>
      28              : #include <QFontDatabase>
      29              : 
      30              : #include "translation.h"
      31              : 
      32              : using namespace mu::appshell;
      33              : 
      34            0 : NewInstanceLoadingScreenView::NewInstanceLoadingScreenView(bool forNewScore, const QString& openingFileName, QWidget* parent)
      35            0 :     : QWidget(parent)
      36              : {
      37            0 :     setAttribute(Qt::WA_TranslucentBackground);
      38              : 
      39            0 :     if (forNewScore) {
      40              :         // When a new instance is being opened because a new score has to be created
      41            0 :         m_message = muse::qtrc("appshell", "Loading new score…\u200e");
      42            0 :         m_dialogSize = QSize(288, 80);
      43            0 :     } else if (!openingFileName.isEmpty()) {
      44              :         // When a new instance is being opened because a score has to be opened, of which the name is known
      45            0 :         m_message = muse::qtrc("appshell", "Loading “%1”…\u200e").arg(openingFileName);
      46            0 :         m_dialogSize = QSize(360, 80);
      47              :     } else {
      48              :         // When a new instance is being opened because a score has to be opened, of which the name is not known
      49              :         // This is the case when opening a score from the file manager or from MuseScore.com on non-macOS systems,
      50              :         // because then a new instance is launched by the OS, which doesn't tell MuseScore about the name of the score.
      51            0 :         m_message = muse::qtrc("appshell", "Loading score…\u200e");
      52            0 :         m_dialogSize = QSize(288, 80);
      53              :     }
      54              : 
      55            0 :     resize(m_dialogSize);
      56            0 : }
      57              : 
      58            0 : bool NewInstanceLoadingScreenView::event(QEvent* event)
      59              : {
      60            0 :     if (event->type() == QEvent::Paint) {
      61            0 :         QPainter painter(this);
      62            0 :         painter.setLayoutDirection(layoutDirection());
      63            0 :         draw(&painter);
      64            0 :     }
      65              : 
      66            0 :     return QWidget::event(event);
      67              : }
      68              : 
      69            0 : void NewInstanceLoadingScreenView::draw(QPainter* painter)
      70              : {
      71            0 :     painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
      72              : 
      73              :     // Draw background
      74            0 :     QString bgColorStr = "#00081C";
      75            0 :     painter->fillRect(0, 0, width(), height(), QColor(bgColorStr));
      76              : 
      77              :     // Draw message
      78            0 :     QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
      79            0 :     font.setBold(true);
      80            0 :     painter->setFont(font);
      81              : 
      82            0 :     QString messageColorStr = "#F1F1EE";
      83            0 :     QPen pen(messageColorStr);
      84            0 :     painter->setPen(pen);
      85              : 
      86            0 :     QFontMetrics fontMetrics(font);
      87            0 :     QRectF messageRectangle(0, 0, m_dialogSize.width(), m_dialogSize.height());
      88            0 :     messageRectangle -= QMargins(8, 8, 8, 8);
      89              : 
      90            0 :     QString elidedText = fontMetrics.elidedText(m_message, Qt::ElideMiddle, messageRectangle.width());
      91            0 :     painter->drawText(messageRectangle, Qt::AlignCenter | Qt::TextDontClip, elidedText);
      92            0 : }
        

Generated by: LCOV version 2.0-1