forked from musescore/MuseScore
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed musescore#16810: Progress dialog instead of splash screen for n…
…ew instance
- Loading branch information
Showing
14 changed files
with
326 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/appshell/view/internal/splashscreen/loadingscreenview.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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_LOADINGSCREENVIEW_H | ||
#define MU_APPSHELL_LOADINGSCREENVIEW_H | ||
|
||
#include <QWidget> | ||
|
||
#include "modularity/ioc.h" | ||
#include "ui/iuiconfiguration.h" | ||
#include "languages/ilanguagesservice.h" | ||
|
||
class QSvgRenderer; | ||
|
||
namespace mu::appshell { | ||
class LoadingScreenView : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
INJECT(appshell, ui::IUiConfiguration, uiConfiguration) | ||
INJECT(appshell, languages::ILanguagesService, languagesService) | ||
|
||
public: | ||
explicit LoadingScreenView(QWidget* parent = nullptr); | ||
|
||
private: | ||
bool event(QEvent* event) override; | ||
void draw(QPainter* painter); | ||
|
||
QString m_message; | ||
QSvgRenderer* m_backgroundRenderer = nullptr; | ||
}; | ||
} | ||
|
||
#endif // MU_APPSHELL_LOADINGSCREENVIEW_H |
81 changes: 81 additions & 0 deletions
81
src/appshell/view/internal/splashscreen/newinstanceloadingscreenview.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* 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 "newinstanceloadingscreenview.h" | ||
|
||
#include <QApplication> | ||
#include <QPainter> | ||
#include <QScreen> | ||
|
||
#include "translation.h" | ||
|
||
using namespace mu::appshell; | ||
|
||
NewInstanceLoadingScreenView::NewInstanceLoadingScreenView(const QString& openingFileName) | ||
: QWidget(nullptr) | ||
{ | ||
setAttribute(Qt::WA_TranslucentBackground); | ||
|
||
if (openingFileName.isEmpty()) { | ||
m_message = qtrc("appshell", "Loading new score…\u200e"); | ||
m_dialogSize = QSize(288, 80); | ||
} else { | ||
m_message = qtrc("appshell", "Loading \"%1\"…\u200e").arg(openingFileName); | ||
m_dialogSize = QSize(360, 80); | ||
} | ||
|
||
resize(m_dialogSize); | ||
} | ||
|
||
bool NewInstanceLoadingScreenView::event(QEvent* event) | ||
{ | ||
if (event->type() == QEvent::Paint) { | ||
QPainter painter(this); | ||
painter.setLayoutDirection(layoutDirection()); | ||
draw(&painter); | ||
} | ||
|
||
return QWidget::event(event); | ||
} | ||
|
||
void NewInstanceLoadingScreenView::draw(QPainter* painter) | ||
{ | ||
painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); | ||
|
||
// Draw background | ||
QString bgColorStr = uiConfiguration()->currentTheme().values.value(ui::BACKGROUND_PRIMARY_COLOR).toString(); | ||
painter->fillRect(0, 0, width(), height(), QColor(bgColorStr)); | ||
|
||
// Draw message | ||
QFont font(QString::fromStdString(uiConfiguration()->fontFamily())); | ||
font.setPixelSize(uiConfiguration()->fontSize(ui::FontSizeType::BODY_LARGE)); | ||
font.setBold(true); | ||
|
||
painter->setFont(font); | ||
|
||
QString messageColorStr = uiConfiguration()->currentTheme().values.value(ui::FONT_PRIMARY_COLOR).toString(); | ||
QPen pen(messageColorStr); | ||
painter->setPen(pen); | ||
|
||
const QRectF messageRect(m_dialogSize.width() / 2, m_dialogSize.height() / 2, 0, 0); | ||
painter->drawText(messageRect, Qt::AlignCenter | Qt::TextDontClip, m_message); | ||
} |
55 changes: 55 additions & 0 deletions
55
src/appshell/view/internal/splashscreen/newinstanceloadingscreenview.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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_NEWINSTANCELOADINSCREENVIEW_H | ||
#define MU_APPSHELL_NEWINSTANCELOADINSCREENVIEW_H | ||
|
||
#include <QWidget> | ||
|
||
#include "modularity/ioc.h" | ||
#include "ui/iuiconfiguration.h" | ||
#include "languages/ilanguagesservice.h" | ||
|
||
class QSvgRenderer; | ||
|
||
namespace mu::appshell { | ||
class NewInstanceLoadingScreenView : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
INJECT(appshell, ui::IUiConfiguration, uiConfiguration) | ||
INJECT(appshell, languages::ILanguagesService, languagesService) | ||
|
||
public: | ||
explicit NewInstanceLoadingScreenView(const QString& openingFileName); | ||
|
||
private: | ||
bool event(QEvent* event) override; | ||
void draw(QPainter* painter); | ||
|
||
QString m_message; | ||
|
||
QSize m_dialogSize; | ||
}; | ||
} | ||
|
||
#endif // MU_APPSHELL_NEWINSTANCELOADINSCREENVIEW_H |
Oops, something went wrong.