Merge branch 'base'
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 25 Jul 2011 12:31:24 +0000 (15:31 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 25 Jul 2011 12:31:24 +0000 (15:31 +0300)
Vibration menu item is now togglable

Conflicts:
seascene.cpp

seascene.cpp

index 1eec000..7adf58a 100644 (file)
@@ -423,21 +423,17 @@ void SeaScene::handleScreenTapped()
 
     else if (pItem == pSettingsItem_)
     {
-    //Temporary code for settings, likely to be turned into a QML dialog
-          QSettings settings;
-
-          QMessageBox::StandardButton buttonpressed = QMessageBox::question(NULL,"Settings","Do you wish to have vibration effects enabled?", QMessageBox::Yes | QMessageBox::No);
-
-          if (buttonpressed == QMessageBox::Yes)
-          {
-              pVibrateAction_->setChecked(true);
-              settings.setValue("vibration",true);
-          }
-          if (buttonpressed == QMessageBox::No)
-          {
-              pVibrateAction_->setChecked(false);
-              settings.setValue("vibration",false);
-          }
+        pVibrateAction_->toggle();
+
+        QSettings settings;
+        settings.setValue("vibration",pVibrateAction_->isChecked());
+
+        QString text = pSettingsItem_->toHtml();
+        if (pVibrateAction_->isChecked())
+            text.replace(" on"," off"); //don't remove spaces or you get vibratioff...
+        else
+            text.replace(" off"," on");
+        pSettingsItem_->setHtml(text);
     }
 
     else if (pItem == pAboutItem_)
@@ -461,9 +457,10 @@ void SeaScene::handleScreenTapped()
 
     clearSelection();
 
-    //The user propably went to paused state just to access menu, so unpause
-    //unless status bar was requested
-    if (pItem != pMinimizeItem_)
+    //The user propably went to paused state just to access menu, so unpause unless vibration set (so the user sees its changed)
+    //or unless status bar was requested
+    if (pItem != pMinimizeItem_ || pItem != pSettingsItem)
+
     {
         pPauseAction_->setChecked(false);
     }
@@ -499,7 +496,18 @@ void SeaScene::createMenuItems()
     prepareForMenu(pRestartLevelItem_);
 
     pSettingsItem_ = new QGraphicsTextItem;
-    pSettingsItem_->setHtml(tr("Vibration <br> effects").prepend(menufonthtml));
+    QString vibraText(tr("Vibration <br> effects "));
+    QString statusText;
+    if (pVibrateAction_->isChecked())
+    {
+        statusText = "off";
+    }
+    else
+    {
+        statusText = "on";
+    }
+    vibraText.append(statusText);
+    pSettingsItem_->setHtml(vibraText.prepend(menufonthtml));
     prepareForMenu(pSettingsItem_);
 
     pAboutItem_ = new QGraphicsTextItem;