GCI task: ping
authorbovi
Sun, 15 Jan 2012 22:57:49 +0100
changeset 6572 0d0af531c1c7
parent 6571 da5cfded818b
child 6573 632fa142c2cf
GCI task: ping
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/ui/page/AbstractPage.cpp
QTfrontend/ui/widget/qpushbuttonwithsound.cpp
QTfrontend/ui/widget/qpushbuttonwithsound.h
project_files/hedgewars.pro
--- a/QTfrontend/hwform.cpp	Sun Jan 15 22:48:34 2012 +0100
+++ b/QTfrontend/hwform.cpp	Sun Jan 15 22:57:49 2012 +0100
@@ -43,6 +43,7 @@
 #include <QPropertyAnimation>
 #include <QGraphicsEffect>
 #include <QParallelAnimationGroup>
+#include <QSettings>
 
 #include "hwform.h"
 #include "game.h"
@@ -101,6 +102,9 @@
 bool frontendEffects = true;
 QString playerHash;
 
+GameUIConfig* HWForm::config = NULL;
+QSettings* HWForm::gameSettings = NULL;
+
 HWForm::HWForm(QWidget *parent, QString styleSheet)
   : QMainWindow(parent)
   , game(0)
@@ -131,7 +135,6 @@
 
     config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
 
-
 #ifdef __APPLE__
     panel = new M3Panel;
 
--- a/QTfrontend/hwform.h	Sun Jan 15 22:48:34 2012 +0100
+++ b/QTfrontend/hwform.h	Sun Jan 15 22:57:49 2012 +0100
@@ -60,8 +60,8 @@
 public:
     HWForm(QWidget *parent = 0, QString styleSheet = "");
     Ui_HWForm ui;
-    GameUIConfig * config;
-    QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage.  Needs sync() calls if you want to get GameUIConfig changes though
+    static GameUIConfig * config;
+    static QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage.  Needs sync() calls if you want to get GameUIConfig changes though
     void updateXfire();
     void PlayDemoQuick(const QString & demofilename);
     void exit();
--- a/QTfrontend/ui/page/AbstractPage.cpp	Sun Jan 15 22:48:34 2012 +0100
+++ b/QTfrontend/ui/page/AbstractPage.cpp	Sun Jan 15 22:57:49 2012 +0100
@@ -25,6 +25,8 @@
 #include <QLabel>
 #include <QSize>
 #include <QFontMetricsF>
+#include <qpushbuttonwithsound.h>
+#include <QMessageBox>
 
 AbstractPage::AbstractPage(QWidget* parent)
 {
@@ -71,7 +73,7 @@
 
 QPushButton * AbstractPage::formattedButton(const QString & name, bool hasIcon)
 {
-    QPushButton * btn = new QPushButton(this);
+    QPushButtonWithSound * btn = new QPushButtonWithSound(this);
 
     if (hasIcon)
     {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp	Sun Jan 15 22:57:49 2012 +0100
@@ -0,0 +1,33 @@
+#include "qpushbuttonwithsound.h"
+#include <QMessageBox>
+#include <HWDataManager.h>
+#include <QDir>
+#include <SDLInteraction.h>
+#include <hwform.h>
+#include <QSettings>
+#include <gameuiconfig.h>
+
+QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) :
+    QPushButton(parent)
+{
+    connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+}
+
+void QPushButtonWithSound::buttonClicked()
+{
+    if (!HWForm::config->isFrontendSoundEnabled())
+        return;
+
+    HWDataManager & dataMgr = HWDataManager::instance();
+
+    QString soundsDir = QString("Sounds/");
+
+    QStringList list = dataMgr.entryList(
+            soundsDir,
+            QDir::Files,
+            QStringList() <<
+                "shotgunreload.ogg"
+            );
+    if(!list.empty())
+        SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead(soundsDir + "/" + list[0]));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/ui/widget/qpushbuttonwithsound.h	Sun Jan 15 22:57:49 2012 +0100
@@ -0,0 +1,20 @@
+#ifndef QPUSHBUTTONWITHSOUND_H
+#define QPUSHBUTTONWITHSOUND_H
+
+#include <QPushButton>
+
+class QPushButtonWithSound : public QPushButton
+{
+    Q_OBJECT
+public:
+    explicit QPushButtonWithSound(QWidget *parent = 0);
+
+signals:
+    
+public slots:
+private slots:
+    void buttonClicked();
+    
+};
+
+#endif // QPUSHBUTTONWITHSOUND_H
--- a/project_files/hedgewars.pro	Sun Jan 15 22:48:34 2012 +0100
+++ b/project_files/hedgewars.pro	Sun Jan 15 22:57:49 2012 +0100
@@ -96,7 +96,9 @@
 	../QTfrontend/KB.h \
     ../QTfrontend/hwconsts.h \
     ../QTfrontend/sdlkeys.h \
-    ../QTfrontend/ui/mouseoverfilter.h
+    ../QTfrontend/ui/mouseoverfilter.h \
+    ../QTfrontend/ui/qpushbuttonwithsound.h \
+    ../QTfrontend/ui/widget/qpushbuttonwithsound.h
 
 SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \
     ../QTfrontend/model/themesmodel.cpp \
@@ -171,7 +173,8 @@
     ../QTfrontend/team.cpp \
     ../QTfrontend/ui_hwform.cpp \
     ../QTfrontend/hwconsts.cpp \
-    ../QTfrontend/ui/mouseoverfilter.cpp
+    ../QTfrontend/ui/mouseoverfilter.cpp \
+    ../QTfrontend/ui/widget/qpushbuttonwithsound.cpp
 
 win32 {
 	SOURCES += ../QTfrontend/xfire.cpp