LCOV - code coverage report
Current view: top level - src/appshell/widgets/splashscreen - splashscreen.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 34 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 "splashscreen.h"
      24              : 
      25              : #include <QApplication>
      26              : #include <QPainter>
      27              : #include <QScreen>
      28              : 
      29              : #include "loadingscreenview.h"
      30              : #include "newinstanceloadingscreenview.h"
      31              : 
      32              : using namespace mu::appshell;
      33              : 
      34              : #ifdef Q_OS_MAC
      35              : // Necessary to remove undesired background, so that we really get our rounded corners
      36              : static constexpr Qt::WindowFlags splashScreenWindowFlags = (Qt::SplashScreen | Qt::FramelessWindowHint) & ~Qt::Sheet | Qt::Window;
      37              : #else
      38              : static constexpr Qt::WindowFlags splashScreenWindowFlags = Qt::SplashScreen | Qt::FramelessWindowHint;
      39              : #endif
      40              : 
      41            0 : SplashScreen::SplashScreen(SplashScreen::SplashScreenType type, bool forNewScore, const QString& openingFileName)
      42            0 :     : QWidget(nullptr, splashScreenWindowFlags)
      43              : {
      44            0 :     setAttribute(Qt::WA_TranslucentBackground);
      45              : 
      46            0 :     switch (type) {
      47            0 :     case SplashScreen::Default:
      48            0 :         m_view = new LoadingScreenView(this);
      49            0 :         break;
      50            0 :     case SplashScreen::ForNewInstance:
      51            0 :         m_view = new NewInstanceLoadingScreenView(forNewScore, openingFileName, this);
      52            0 :         break;
      53              :     }
      54              : 
      55            0 :     setSize(m_view->size());
      56              : 
      57            0 :     repaint();
      58            0 : }
      59              : 
      60            0 : void SplashScreen::repaint()
      61              : {
      62            0 :     QWidget::repaint();
      63            0 :     QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
      64            0 : }
      65              : 
      66            0 : bool SplashScreen::event(QEvent* event)
      67              : {
      68            0 :     if (event->type() == QEvent::Paint) {
      69            0 :         QPainter painter(this);
      70            0 :         painter.setLayoutDirection(layoutDirection());
      71            0 :         draw(&painter);
      72            0 :     }
      73              : 
      74            0 :     return QWidget::event(event);
      75              : }
      76              : 
      77            0 : void SplashScreen::draw(QPainter* painter)
      78              : {
      79            0 :     if (m_view) {
      80            0 :         m_view->render(painter);
      81              :     }
      82            0 : }
      83              : 
      84            0 : void SplashScreen::setSize(const QSize& size)
      85              : {
      86            0 :     if (m_view) {
      87            0 :         resize(m_view->size());
      88              : 
      89            0 :         if (screen()) {
      90            0 :             move(screen()->geometry().center() - QPoint(size.width() / 2, size.height() / 2));
      91              :         }
      92              :     }
      93            0 : }
        

Generated by: LCOV version 2.0-1