Skip to content

Commit

Permalink
[Splash] remove duplicated lines
Browse files Browse the repository at this point in the history
  • Loading branch information
mathildemerle committed Nov 23, 2023
1 parent 82aca28 commit 99867b3
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 200 deletions.
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->show();
this->processEvents();
d->splashScreen->repaint();

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);
}

void medApplication::redirectMessageToSplash(const QString &message)
Expand Down
100 changes: 0 additions & 100 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

0 comments on commit 99867b3

Please sign in to comment.