From 90b72798c42838b960addc815fb2604027d30333 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 22 Jan 2013 12:42:07 +0100 Subject: [PATCH] OP-786 Implemented progress label drawing. Added timer to close splash window 5 seconds after main window opens if not clicked. --- .../openpilotgcs/src/app/gcssplashscreen.cpp | 18 ++++++++++++++---- ground/openpilotgcs/src/app/gcssplashscreen.h | 4 +++- ground/openpilotgcs/src/app/main.cpp | 11 +++++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/app/gcssplashscreen.cpp b/ground/openpilotgcs/src/app/gcssplashscreen.cpp index fb577625f..9a7b032d9 100644 --- a/ground/openpilotgcs/src/app/gcssplashscreen.cpp +++ b/ground/openpilotgcs/src/app/gcssplashscreen.cpp @@ -33,6 +33,7 @@ const QChar CopyrightSymbol(0x00a9); GCSSplashScreen::GCSSplashScreen() : QSplashScreen(), m_pixmap(0), m_painter(0) { + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); m_pixmap = new QPixmap(":/app/splash.png"); m_painter = new QPainter(m_pixmap); @@ -57,10 +58,19 @@ GCSSplashScreen::~GCSSplashScreen() { } -void GCSSplashScreen::showPluginLoadingProgress(ExtensionSystem::PluginSpec *pluginSpec) +void GCSSplashScreen::drawMessageText(const QString &message) { + QPixmap pix(*m_pixmap); + QPainter progressPainter(&pix); + progressPainter.setPen(Qt::lightGray); QFont font("Tahoma", 13); - m_painter->setFont(font); - m_painter->drawText(170, 385, pluginSpec->name()); - setPixmap(*m_pixmap); + progressPainter.setFont(font); + progressPainter.drawText(170, 385, message); + setPixmap(pix); +} + +void GCSSplashScreen::showPluginLoadingProgress(ExtensionSystem::PluginSpec *pluginSpec) +{ + QString message(tr("Loading ") + pluginSpec->name() + " plugin..."); + drawMessageText(message); } diff --git a/ground/openpilotgcs/src/app/gcssplashscreen.h b/ground/openpilotgcs/src/app/gcssplashscreen.h index 579edcceb..dd26077b1 100644 --- a/ground/openpilotgcs/src/app/gcssplashscreen.h +++ b/ground/openpilotgcs/src/app/gcssplashscreen.h @@ -42,11 +42,13 @@ public: public slots: void showPluginLoadingProgress(ExtensionSystem::PluginSpec *pluginSpec); + void showProgressMessage(const QString &message) { drawMessageText(message); } private: QPixmap *m_pixmap; QPainter *m_painter; - + void drawMessageText(const QString &message); + }; #endif // GCSSPLASHSCREEN_H diff --git a/ground/openpilotgcs/src/app/main.cpp b/ground/openpilotgcs/src/app/main.cpp index 3d0161d0f..63dd5c510 100644 --- a/ground/openpilotgcs/src/app/main.cpp +++ b/ground/openpilotgcs/src/app/main.cpp @@ -287,6 +287,8 @@ int main(int argc, char **argv) } app.setProperty("qtc_locale", locale); // Do we need this? + splash.showProgressMessage(QObject::tr("Application starting...")); + // Load ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QLatin1String("pluginspec")); @@ -356,11 +358,14 @@ int main(int argc, char **argv) QObject::connect(&pluginManager, SIGNAL(pluginAboutToBeLoaded(ExtensionSystem::PluginSpec*)), &splash, SLOT(showPluginLoadingProgress(ExtensionSystem::PluginSpec*))); + pluginManager.loadPlugins(); + if (coreplugin->hasError()) { displayError(msgCoreLoadFailure(coreplugin->errorString())); return 1; } + { QStringList errors; foreach (ExtensionSystem::PluginSpec *p, pluginManager.plugins()) @@ -384,7 +389,9 @@ int main(int argc, char **argv) // Do this after the event loop has started QTimer::singleShot(100, &pluginManager, SLOT(startTests())); - //Close splashscreen - splash.close(); + //Close splashscreen after 5 seconds + QTimer::singleShot(5 * 1000, &splash, SLOT(close())); + splash.showProgressMessage(QObject::tr("Application started.")); + return app.exec(); }