Asks for a vibra resource...
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 24 Sep 2011 13:45:46 +0000 (16:45 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 24 Sep 2011 13:45:46 +0000 (16:45 +0300)
...but is denied it.

ghostsoverboard.pro
seascene.cpp
seascene.h

index 039d296..247a8f2 100644 (file)
@@ -100,5 +100,8 @@ unix:!symbian:!maemo5 {
     INSTALLS += icon
 }
 
+#Harmattan specific:
 
+  CONFIG +=  link_pkgconfig
+  PKGCONFIG += libresourceqt1
 
index 753e916..cba81c3 100644 (file)
@@ -35,6 +35,7 @@
 #include <QSettings>
 #include <QPixmap>
 
+
 const QString ghostImageFilename_ = ":/pix/aave.png";
 const QString rockImageFilename_ =":/pix/kari.png";
 const QString octopusImageFilename_= ":/pix/tursas.png";
@@ -101,6 +102,19 @@ SeaScene::SeaScene(QObject *parent) :
     autopauseTimer.setInterval(15*60*1000);
     connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));
 
+    pResourceSet_ = new ResourcePolicy::ResourceSet("gaming",this);
+    ResourcePolicy::VibraResource * pVibraResource = new ResourcePolicy::VibraResource();
+    pVibraResource->setOptional(false); //The only resource of the set, so no sense for it to be optional
+    pResourceSet_->addResourceObject(pVibraResource);
+
+    connect(pResourceSet_,SIGNAL(resourcesGranted(const QList< ResourcePolicy::ResourceType >)),this,SLOT(resourcesAvailable()));
+    connect(pResourceSet_,SIGNAL(lostResources()),this,SLOT(resourcesLost()));
+
+    //To test whether resources were succesfully asked but not given
+    connect(pResourceSet_,SIGNAL(resourcesDenied()),this,SLOT(resourcesLost()));
+    pResourceSet_->setAlwaysReply();
+
+    pResourceSet_->acquire();
 
 }
 
@@ -800,3 +814,14 @@ void SeaScene::createLevelCompletedItems()
     pTapForNextLevelItem->setZValue(1000);
     pTapForNextLevelItem->setHtml("<font size=\"7\" color = darkorange>Tap to start the next level");
 }
+
+void SeaScene::resourcesAvailable()
+{
+    qDebug() << "Resources available";
+}
+
+void SeaScene::resourcesLost()
+{
+    qDebug() << "Resources lost";
+}
+
index c3de5f7..715dfe3 100644 (file)
@@ -32,6 +32,7 @@
 #include <QAction>
 #include <QTimer>
 #include <QTime>
+#include <policy/resource-set.h>
 
 class SeaScene : public QGraphicsScene
 {
@@ -86,6 +87,10 @@ public slots:
 
     void turnPauseOn();
 
+    void resourcesAvailable();
+
+    void resourcesLost();
+
 
 
 protected:
@@ -152,6 +157,9 @@ protected:
     QTime scoreCounter_;
     int totalScore_;
     int levelScore_;
+
+    ResourcePolicy::ResourceSet * pResourceSet_;
+
 };
 
 #endif // SEASCENE_H