Merge pull request #12396 from cbjeukendrup/try_splashscreen
Implement Loading Screen
This commit is contained in:
commit
d916c4d402
6 changed files with 149 additions and 0 deletions
|
@ -102,6 +102,8 @@ set(MODULE_SRC
|
|||
${CMAKE_CURRENT_LIST_DIR}/view/internal/iappmenumodelhook.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/view/internal/maintoolbarmodel.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/view/internal/maintoolbarmodel.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/view/internal/splashscreen.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/view/internal/splashscreen.h
|
||||
${DOCKWINDOW_SRC}
|
||||
)
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#ifndef Q_OS_WASM
|
||||
#include <QThreadPool>
|
||||
#endif
|
||||
|
||||
#include "view/internal/splashscreen.h"
|
||||
|
||||
#include "view/dockwindow/docksetup.h"
|
||||
|
||||
#include "modularity/ioc.h"
|
||||
|
@ -127,6 +130,11 @@ int AppShell::run(int argc, char** argv)
|
|||
commandLine.apply();
|
||||
framework::IApplication::RunMode runMode = muapplication()->runMode();
|
||||
|
||||
SplashScreen splashScreen;
|
||||
if (runMode == framework::IApplication::RunMode::Editor) {
|
||||
splashScreen.show();
|
||||
}
|
||||
|
||||
// ====================================================
|
||||
// Setup modules: onInit
|
||||
// ====================================================
|
||||
|
@ -228,6 +236,8 @@ int AppShell::run(int argc, char** argv)
|
|||
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||
|
||||
engine->load(url);
|
||||
|
||||
splashScreen.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,5 +104,6 @@
|
|||
<file>qml/platform/win/AppSystemButtons.qml</file>
|
||||
<file>qml/platform/AppMenuBar.qml</file>
|
||||
<file>qml/platform/AppButtonBackground.qml</file>
|
||||
<file>resources/LoadingScreen.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
1
src/appshell/resources/LoadingScreen.svg
Normal file
1
src/appshell/resources/LoadingScreen.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 7.9 KiB |
83
src/appshell/view/internal/splashscreen.cpp
Normal file
83
src/appshell/view/internal/splashscreen.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
* MuseScore-CLA-applies
|
||||
*
|
||||
* MuseScore
|
||||
* Music Composition & Notation
|
||||
*
|
||||
* Copyright (C) 2022 MuseScore BVBA and others
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "splashscreen.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
using namespace mu::appshell;
|
||||
|
||||
static const QString imagePath(":/resources/LoadingScreen.svg");
|
||||
|
||||
static const QSize splashScreenSize(810, 405);
|
||||
|
||||
static const QColor messageColor("#99FFFFFF");
|
||||
static const QRectF messageRect(splashScreenSize.width() / 2, 269, 0, 0);
|
||||
|
||||
static const QString website("www.musescore.org");
|
||||
static const QRectF websiteRect(splashScreenSize.width() - 48, splashScreenSize.height() - 48, 0, 0);
|
||||
|
||||
static const QColor versionNumberColor("#22A0F4");
|
||||
static constexpr qreal versionNumberSpacing = 5.0;
|
||||
|
||||
SplashScreen::SplashScreen()
|
||||
: QSplashScreen(QPixmap(splashScreenSize)),
|
||||
m_backgroundRenderer(new QSvgRenderer(imagePath, this))
|
||||
{
|
||||
// Can't make translatable, because translation system not yet initialized
|
||||
showMessage("Loading…");
|
||||
}
|
||||
|
||||
void SplashScreen::drawContents(QPainter* painter)
|
||||
{
|
||||
painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
|
||||
// Draw background
|
||||
m_backgroundRenderer->render(painter);
|
||||
|
||||
// Draw message
|
||||
// Can't use font from settings, because that's not yet initialized
|
||||
QFont font(QString::fromStdString(uiConfiguration()->defaultFontFamily()));
|
||||
font.setPixelSize(uiConfiguration()->defaultFontSize());
|
||||
|
||||
painter->setFont(font);
|
||||
|
||||
QPen pen(messageColor);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->drawText(messageRect, Qt::AlignTop | Qt::AlignHCenter | Qt::TextDontClip, message());
|
||||
|
||||
// Draw website URL
|
||||
QRectF websiteBoundingRect;
|
||||
painter->drawText(websiteRect, Qt::AlignBottom | Qt::AlignRight | Qt::TextDontClip, website, &websiteBoundingRect);
|
||||
|
||||
// Draw version number
|
||||
pen.setColor(versionNumberColor);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->drawText(websiteRect.translated(0.0, -websiteBoundingRect.height() - versionNumberSpacing),
|
||||
Qt::AlignBottom | Qt::AlignRight | Qt::TextDontClip,
|
||||
QString("Version %1").arg(QString::fromStdString(framework::Version::fullVersion())));
|
||||
}
|
52
src/appshell/view/internal/splashscreen.h
Normal file
52
src/appshell/view/internal/splashscreen.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
* MuseScore-CLA-applies
|
||||
*
|
||||
* MuseScore
|
||||
* Music Composition & Notation
|
||||
*
|
||||
* Copyright (C) 2022 MuseScore BVBA and others
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MU_APPSHELL_SPLASHSCREEN_H
|
||||
#define MU_APPSHELL_SPLASHSCREEN_H
|
||||
|
||||
#include <QSplashScreen>
|
||||
|
||||
#include "modularity/ioc.h"
|
||||
#include "ui/iuiconfiguration.h"
|
||||
|
||||
class QSvgRenderer;
|
||||
|
||||
namespace mu::appshell {
|
||||
class SplashScreen : public QSplashScreen
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//! The uiConfiguration has not yet been initialized, so we can't use user settings.
|
||||
//! We only use it for querying the default system font
|
||||
INJECT(appshell, ui::IUiConfiguration, uiConfiguration)
|
||||
|
||||
public:
|
||||
SplashScreen();
|
||||
|
||||
private:
|
||||
void drawContents(QPainter* painter) override;
|
||||
|
||||
QSvgRenderer* m_backgroundRenderer = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MU_APPSHELL_SPLASHSCREEN_H
|
Loading…
Reference in a new issue