add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
authorkoda
Thu, 27 Dec 2012 17:01:02 +0100
changeset 8337 bf237f7f1d94
parent 8335 bc948db1273a
child 8339 2154732c65f1
add a splashscreen while the main interface is loading (enabled on all platforms, disable if it doesn'n't look good
QTfrontend/hedgewars.qrc
QTfrontend/main.cpp
QTfrontend/res/splash.png
misc/winutils/Hedgewars.lnk
--- a/QTfrontend/hedgewars.qrc	Thu Dec 27 15:56:02 2012 +0100
+++ b/QTfrontend/hedgewars.qrc	Thu Dec 27 17:01:02 2012 +0100
@@ -146,6 +146,7 @@
         <file>res/chat/serveradmin_gray.png</file>
         <file>res/chat/lamp_off.png</file>
         <file>res/chat/ingame.png</file>
-	<file>res/html/about.html</file>
+        <file>res/splash.png</file>
+        <file>res/html/about.html</file>
     </qresource>
 </RCC>
--- a/QTfrontend/main.cpp	Thu Dec 27 15:56:02 2012 +0100
+++ b/QTfrontend/main.cpp	Thu Dec 27 17:01:02 2012 +0100
@@ -27,6 +27,8 @@
 #include <QSettings>
 #include <QStringListModel>
 #include <QDate>
+#include <QDesktopWidget>
+#include <QLabel>
 
 #include "hwform.h"
 #include "hwconsts.h"
@@ -136,6 +138,19 @@
 
     HWApplication app(argc, argv);
 
+    QLabel *splash = NULL;
+#ifdef Q_WS_WIN | Q_WS_X11 | Q_WS_MAC //enabled on all platforms, disable if it doesn't look good
+    QPixmap pixmap(":res/splash.png");
+    splash = new QLabel(0, Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
+    splash->setAttribute(Qt::WA_TranslucentBackground);
+    const QRect deskSize = QApplication::desktop()->screenGeometry(-1);
+    QPoint splashCenter = QPoint( (deskSize.width() - pixmap.width())/2,
+                                  (deskSize.height() - pixmap.height())/2 );
+    splash->move(splashCenter);
+    splash->setPixmap(pixmap);
+    splash->show();
+#endif
+
     FileEngineHandler engine(argv[0]);
 
     app.setAttribute(Qt::AA_DontShowIconsInMenus,false);
@@ -305,6 +320,7 @@
             break;
         default :
             fname = "qt.css";
+            break;
     }
 
     // load external stylesheet if there is any
@@ -319,5 +335,7 @@
 
     app.form = new HWForm(NULL, style);
     app.form->show();
+    if(splash)
+        splash->close();
     return app.exec();
 }
Binary file QTfrontend/res/splash.png has changed
Binary file misc/winutils/Hedgewars.lnk has changed