Skip to content

Commit

Permalink
Merge pull request medInria#1145 from mathildemerle/splashSpeed
Browse files Browse the repository at this point in the history
[SplashScreen] speeds up launch removing txt on splashscreen
  • Loading branch information
mathildemerle committed Nov 22, 2023
1 parent eb05287 commit b4be876
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 95 deletions.
10 changes: 1 addition & 9 deletions src/app/medInria/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ int main(int argc,char* argv[])
bool show_splash = false;
#endif

medSettingsManager* mnger = medSettingsManager::instance();

QStringList posargs;
for (int i=1;i<application.arguments().size();++i)
{
Expand Down Expand Up @@ -201,12 +199,7 @@ int main(int argc,char* argv[])

if (show_splash)
{
QObject::connect(medPluginManager::instance(),SIGNAL(loaded(QString)),
&application,SLOT(redirectMessageToSplash(QString)) );
QObject::connect(&application,SIGNAL(showMessage(const QString&)),
&splash,SLOT(showMessage(const QString&)) );
splash.show();
splash.showMessage("Loading plugins...");
}

medDataManager::instance()->setDatabaseLocation();
Expand Down Expand Up @@ -292,8 +285,7 @@ int main(int argc,char* argv[])
QGLFormat::setDefaultFormat(format);
}

if (show_splash)
splash.finish(mainwindow);
splash.close();

#if(USE_PYTHON)
if(!pythonErrorMessage.isEmpty())
Expand Down
51 changes: 0 additions & 51 deletions src/app/medInria/medSplashScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ class medSplashScreenPrivate
{
public:
QPixmap pixmap;
QString message;
int alignment;
QColor color;
};


////////////////////////////////////////////////////////////////////////////
medSplashScreen::medSplashScreen(const QPixmap& thePixmap)
: QWidget(0, Qt::SplashScreen |Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint)
Expand Down Expand Up @@ -91,61 +89,12 @@ medSplashScreen::~medSplashScreen()
d = nullptr;
}

////////////////////////////////////////////////////////////////////////////
void medSplashScreen::clearMessage()
{
d->message.clear();
repaint();
}

////////////////////////////////////////////////////////////////////////////
void medSplashScreen::showMessage(const QString& message)
{
const dtkPlugin* plugin = medPluginManager::instance()->plugin(message);
if (plugin)
{
d->message = QString("Loading: ") + plugin->name();
}
else
{
d->message = QString("Loading: ") + message;
}

repaint();
}

void medSplashScreen::repaint()
{
QWidget::repaint();
QApplication::flush();
qApp->processEvents(QEventLoop::AllEvents);
}

void medSplashScreen::finish(QWidget *mainWin)

{
if (mainWin)
{
#if defined(Q_OS_LINUX)
Q_UNUSED(QTest::qWaitForWindowExposed(mainWin));
#endif
}
close();
}

////////////////////////////////////////////////////////////////////////////
void medSplashScreen::paintEvent(QPaintEvent* pe)
{
Q_UNUSED(pe);

QRect aTextRect(rect());
aTextRect.setRect(aTextRect.x() + 120,
aTextRect.y() + 5,
aTextRect.width() - 10,
aTextRect.height() - 10);

QPainter aPainter(this);
aPainter.drawPixmap(rect(), d->pixmap);
aPainter.setPen(d->color);
aPainter.drawText(aTextRect, d->alignment, d->message);
}
36 changes: 1 addition & 35 deletions src/app/medInria/medSplashScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class medSplashScreenPrivate;

/**
* @brief create SplaScreen widget with translucent background.
* @brief create Splashcreen widget with translucent background.
*
* not based on QSplashScreen which does not support this feature.
Almost all features from the QSplashscreen are replicated, including messages refreshed before a QApplication event loop is running.
Expand All @@ -38,41 +38,7 @@ class medSplashScreen : public QWidget
medSplashScreen(const QPixmap& pixmap);
~medSplashScreen();

/**
* @brief hides the splashscreen when w is shown.
*
* @param w
*/
void finish(QWidget *w);

/**
* @brief Repaints the widget without the need of an event loop;
*
*/
void repaint();

public slots:
/**
* @brief Clears the message.
*
*/
void clearMessage();

/**
* @brief Shows a message with the desired alignment and color.
*
* @param theMessage
* @param theAlignment
* @param theColor
*/
void showMessage(const QString& theMessage);

private:
/**
* @brief
*
* @param pe
*/
void paintEvent(QPaintEvent* pe);

medSplashScreenPrivate * d;
Expand Down

0 comments on commit b4be876

Please sign in to comment.