Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion muse_deps
65 changes: 59 additions & 6 deletions src/app/internal/guiapp.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include "guiapp.h"

#include <QQuickWindow>
#include <QTimer>

#include "modularity/ioc.h"
#include "appshell/internal/istartupscenario.h"
#include "dockwindow/idockwindowprovider.h"
#include "dockwindow/idockwindow.h"

#include "commandlineparser.h"

Expand Down Expand Up @@ -125,18 +130,66 @@ void MuseScoreGuiApp::doStartupScenario(const muse::modularity::ContextPtr& ctxI
startupScenario->runOnSplashScreen();

QMetaObject::invokeMethod(qApp, [this, ctxId, startupScenario]() {
#ifdef MUE_ENABLE_SPLASHSCREEN
if (m_splashScreen) {
m_splashScreen->close();
delete m_splashScreen;
m_splashScreen = nullptr;
auto dockWindowProvider = muse::modularity::ioc(ctxId)->resolve<muse::dock::IDockWindowProvider>("app");
muse::dock::IDockWindow* dockWindow = dockWindowProvider ? dockWindowProvider->window() : nullptr;
if (dockWindow) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
dockWindow->currentPageChanged().onNotify(this, [this, ctxId, dockWindow]() {
dockWindow->currentPageChanged().disconnect(this);

QMetaObject::invokeMethod(qApp, [this, ctxId]() {
showMainWindowAndCloseSplash(ctxId);
}, Qt::QueuedConnection);
});
} else {
//! NOTE No dock window - no page loading to wait for
showMainWindowAndCloseSplash(ctxId);
}
#endif

startupScenario->runAfterSplashScreen();
}, Qt::QueuedConnection);
}

void MuseScoreGuiApp::showMainWindowAndCloseSplash(const muse::modularity::ContextPtr& ctxId)
{
auto it = m_windows.find(ctxId->id);
QQuickWindow* window = it != m_windows.end() ? it->second : nullptr;
if (!window) {
closeSplash();
return;
}

//! NOTE Close the splash only after the window has rendered its first frame,
//! so that the empty window is never visible
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = QObject::connect(window, &QQuickWindow::frameSwapped, qApp, [this, conn]() {
QObject::disconnect(*conn);
closeSplash();
}, Qt::QueuedConnection);

//! NOTE Safety net for the case when the window never renders a frame;
//! long enough so that it cannot fire before the first frame of a healthy startup
static constexpr int SPLASH_CLOSE_TIMEOUT_MS = 10000;
QTimer::singleShot(SPLASH_CLOSE_TIMEOUT_MS, qApp, [this]() {
if (m_splashScreen) {
LOGW() << "the main window has not rendered any frame, closing the splash screen forcibly";
closeSplash();
}
});

window->setVisible(true);
}

void MuseScoreGuiApp::closeSplash()
{
#ifdef MUE_ENABLE_SPLASHSCREEN
if (m_splashScreen) {
m_splashScreen->close();
delete m_splashScreen;
m_splashScreen = nullptr;
}
#endif
}

void MuseScoreGuiApp::applyCommandLineOptions(const std::shared_ptr<CmdOptions>& opt)
{
GuiApplication::applyCommandLineOptions(opt);
Expand Down
5 changes: 4 additions & 1 deletion src/app/internal/guiapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ui/internal/guiapplication.h"
#include "../cmdoptions.h"

#include "async/asyncable.h"
#include "modularity/ioc.h"
#include "multiwindows/imultiwindowsprovider.h"
#include "appshell/iappshellconfiguration.h"
Expand All @@ -16,7 +17,7 @@
class QQuickWindow;

namespace mu::app {
class MuseScoreGuiApp : public muse::ui::GuiApplication
class MuseScoreGuiApp : public muse::ui::GuiApplication, public muse::async::Asyncable
{
muse::GlobalInject<muse::mi::IMultiWindowsProvider> multiwindowsProvider;
muse::GlobalInject<appshell::IAppShellConfiguration> appshellConfiguration;
Expand All @@ -26,6 +27,7 @@ class MuseScoreGuiApp : public muse::ui::GuiApplication
MuseScoreGuiApp(const std::shared_ptr<MuseScoreCmdOptions>& options);

void showSplash() override;
void closeSplash() override;

private:

Expand All @@ -43,6 +45,7 @@ class MuseScoreGuiApp : public muse::ui::GuiApplication
void showContextSplash(const muse::modularity::ContextPtr& ctxId) override;
QString mainWindowQmlPath(const QString& platform) const override;
void doStartupScenario(const muse::modularity::ContextPtr& ctxId) override;
void showMainWindowAndCloseSplash(const muse::modularity::ContextPtr& ctxId);

appshell::SplashScreen* m_splashScreen = nullptr;
};
Expand Down
1 change: 1 addition & 0 deletions src/appshell/qml/MuseScore/AppShell/WindowContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ DockWindow {

onPageLoaded: {
console.log("WindowContent::onPageLoaded")

interactiveProvider.onPageOpened()
}

Expand Down
Loading