Background for Hedgewars is ready
authordisplacer
Mon, 04 Aug 2008 17:30:58 +0000
changeset 1146 0bc17a69b3d8
parent 1145 ec5073ceb488
child 1147 ce37ebba0806
Background for Hedgewars is ready
QTfrontend/hedgewars.qrc
QTfrontend/main.cpp
--- a/QTfrontend/hedgewars.qrc	Mon Aug 04 17:09:31 2008 +0000
+++ b/QTfrontend/hedgewars.qrc	Mon Aug 04 17:30:58 2008 +0000
@@ -19,5 +19,12 @@
     <file>res/bonus.png</file>
     <file>res/Hedgehog.svg</file>
     <file>res/net.png</file>
+    <file>res/About.png</file>
+    <file>res/Background.png</file>
+    <file>res/Exit.png</file>
+    <file>res/HedgewarsTitle.png</file>
+    <file>res/LocalPlay.png</file>
+    <file>res/Network play.png</file>
+    <file>res/Settings.png</file>
 </qresource>
 </RCC>
--- a/QTfrontend/main.cpp	Mon Aug 04 17:09:31 2008 +0000
+++ b/QTfrontend/main.cpp	Mon Aug 04 17:30:58 2008 +0000
@@ -23,6 +23,8 @@
 #include <QFileInfo>
 #include <QDateTime>
 #include <QTextStream>
+#include <QDesktopWidget>
+
 #include "hwform.h"
 #include "hwconsts.h"
 
@@ -51,6 +53,27 @@
 
 	Q_INIT_RESOURCE(hedgewars);
 
+	QString imgAddr=":/res/Background.png";
+	QImage bgrndIm(imgAddr);
+	QRect deskSz=qApp->desktop()->screenGeometry();
+	bgrndIm=bgrndIm.scaled(deskSz.width()-deskSz.left(), deskSz.height()-deskSz.top(), 
+			       Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+	if (bgrndIm.save(QDir::tempPath()+"/hedgewarsScaledBgrnd.png")) {
+	  imgAddr=QDir::tempPath()+"/hedgewarsScaledBgrnd.png";
+	}
+	
+	qApp->setStyleSheet
+	  (QString(
+		   ".HWForm{"
+		   "background-image: url(\"%1\");"
+		   "background-position: bottom center;"
+		   //" background-origin: content;"
+		   //"background-repeat: no-repeat;"
+		   //"background-color: black;"
+		   "}"
+		   ).arg(imgAddr)
+	   );
+	
 	bindir->cd("bin"); // workaround over NSIS installer
 
 	cfgdir->setPath(cfgdir->homePath());