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

[SplashScreen] speeds up launch removing txt on splashscreen #1145

Merged
merged 1 commit into from
Oct 12, 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
10 changes: 1 addition & 9 deletions src/app/medInria/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,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 @@ -178,12 +176,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 @@ -253,8 +246,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 @@ -69,61 +67,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