Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Splash] use directly QSplashScreen & update splash MSC logos #800

Merged
merged 3 commits into from
Nov 29, 2023
Merged
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
51 changes: 2 additions & 49 deletions src/app/medInria/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#include <medMainWindow.h>
#include <medApplication.h>
#include <medSplashScreen.h>

#include <medPluginManager.h>
#include <medDataIndex.h>
#include <medDataManager.h>
Expand Down Expand Up @@ -90,38 +88,10 @@ int main(int argc,char* argv[])
fmt.setAlphaBufferSize(1);
fmt.setStereo(false);
fmt.setSamples(0);

QSurfaceFormat::setDefaultFormat(fmt);

// this needs to be done before creating the QApplication object, as per the
// Qt doc, otherwise there are some edge cases where the style is not fully applied
//QApplication::setStyle("plastique");
medApplication application(argc,argv);

// Themes
QVariant themeChosen = medSettingsManager::instance().value("startup","theme");
int themeIndex = themeChosen.toInt();
QPixmap splashLogo;
switch (themeIndex)
{
case 0:
case 1:
case 2:
default:
{
splashLogo.load(":MUSICardio_logo_darkbackground_notext.png");
break;
}
case 3:
case 4:
{
splashLogo.load(":MUSICardio_logo_lightbackground_notext.png");
break;
}
}
splashLogo = splashLogo.scaled(914, 147, Qt::KeepAspectRatio, Qt::SmoothTransformation);
medSplashScreen splash(splashLogo);

setlocale(LC_NUMERIC, "C");
QLocale::setDefault(QLocale("C"));

Expand All @@ -139,16 +109,6 @@ int main(int argc,char* argv[])
return 1;
}

// Do not show the splash screen in debug builds because it hogs the
// foreground, hiding all other windows. This makes debugging the startup
// operations difficult.

#if !defined(_DEBUG)
bool show_splash = true;
#else
bool show_splash = false;
#endif

QStringList posargs;
for (int i=1;i<application.arguments().size();++i)
{
Expand Down Expand Up @@ -184,8 +144,8 @@ int main(int argc,char* argv[])
const bool DirectView = dtkApplicationArgumentsContain(&application,"--view") || posargs.size()!=0;

int runningMedInria = 0;
if (DirectView) {
show_splash = false;
if (DirectView)
{
for (QStringList::const_iterator i=posargs.constBegin();i!=posargs.constEnd();++i) {
const QString& message = QString("/open ")+*i;
runningMedInria = application.sendMessage(message);
Expand All @@ -197,11 +157,6 @@ int main(int argc,char* argv[])
if (runningMedInria)
return 0;

if (show_splash)
{
splash.show();
}

medDataManager::instance().setDatabaseLocation();

#if(USE_PYTHON)
Expand Down Expand Up @@ -285,8 +240,6 @@ int main(int argc,char* argv[])
QGLFormat::setDefaultFormat(format);
}

splash.close();

#if(USE_PYTHON)
if(!pythonErrorMessage.isEmpty())
{
Expand Down
36 changes: 32 additions & 4 deletions src/app/medInria/medApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class medApplicationPrivate
public:
medMainWindow *mainWindow;
QStringList systemOpenInstructions;
QSplashScreen *splashScreen;
};

// /////////////////////////////////////////////////////////////////
Expand All @@ -49,6 +50,34 @@ medApplication::medApplication(int & argc, char**argv) :
{
d->mainWindow = nullptr;

// Themes
QVariant themeChosen = medSettingsManager::instance().value("startup","theme");
int themeIndex = themeChosen.toInt();
QPixmap splashLogo;
switch (themeIndex)
{
case 0:
case 1:
case 2:
default:
{
splashLogo.load(":MUSICardio-2023-lightfont-notext-darkback-margin10.png");
break;
}
case 3:
case 4:
{
splashLogo.load(":MUSICardio-2023-darkfont-notext-whiteback-margin10.png");
break;
}
}
splashLogo = splashLogo.scaled(914, 147, Qt::KeepAspectRatio, Qt::SmoothTransformation);
d->splashScreen = new QSplashScreen(splashLogo,
Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
d->splashScreen->setAttribute(Qt::WA_DeleteOnClose, true);
d->splashScreen->show();
this->processEvents();

this->setApplicationName(PROJECT_NAME); /*Beware, change database path*/
this->setApplicationVersion(MEDINRIA_VERSION);
this->setOrganizationName("INRIA_IHU-LIRYC"); /*Beware, change database path*/
Expand Down Expand Up @@ -80,10 +109,6 @@ medApplication::medApplication(int & argc, char**argv) :
::exit(1);
}

// Themes
QVariant themeChosen = medSettingsManager::instance().value("startup","theme");
int themeIndex = themeChosen.toInt();

QString qssFile;
switch (themeIndex)
{
Expand Down Expand Up @@ -146,6 +171,9 @@ void medApplication::setMainWindow(medMainWindow *mw)
QVariant var = QVariant::fromValue((QObject*)d->mainWindow);
this->setProperty("MainWindow",var);
d->systemOpenInstructions.clear();

// Wait until the app is displayed to close itself
d->splashScreen->finish(d->mainWindow);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The close function will be called on the splash screen, but this does not delete the widget unless the attribute Qt::WA_DeleteOnClose is set.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, i added a line and rebased the PR

}

void medApplication::redirectMessageToSplash(const QString &message)
Expand Down
98 changes: 0 additions & 98 deletions src/app/medInria/medSplashScreen.cpp

This file was deleted.

45 changes: 0 additions & 45 deletions src/app/medInria/medSplashScreen.h

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/app/medInria/resources/medInria.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@

<file>../../../../LICENSE_MUSICardio.txt</file>
<file>../../../../LICENSES_EXT.txt</file>
<file>MUSICardio_logo_lightbackground_notext.png</file>
<file>MUSICardio_logo_darkbackground_notext.png</file>
<file>MUSICardio-2023-lightfont-notext-darkback-margin10.png</file>
<file>MUSICardio-2023-darkfont-notext-whiteback-margin10.png</file>
<file>MUSICardio_logo_light.png</file>
<file>MUSICardio_logo_small_light.png</file>
<file>MUSICardio_logo_dark.png</file>
Expand Down