00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Guillaume Martres <smarter@ubuntu.com> 00004 * Copyright (c) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef GLUON_ENGINE_SOUNDLISTENERCOMPONENT_H 00022 #define GLUON_ENGINE_SOUNDLISTENERCOMPONENT_H 00023 00024 #include <core/gluonvarianttypes.h> 00025 #include <engine/component.h> 00026 #include <engine/gluon_engine_export.h> 00027 00028 namespace GluonEngine 00029 { 00030 00031 class GLUON_ENGINE_EXPORT SoundListenerComponent : public Component 00032 { 00033 Q_OBJECT 00034 GLUON_OBJECT( GluonEngine::SoundListenerComponent ) 00035 Q_PROPERTY( bool active READ isActive WRITE setActive ) 00036 Q_PROPERTY( bool effectsEnabled READ effectsEnabled WRITE setEffectsEnabled ) 00037 00038 Q_INTERFACES( GluonEngine::Component ) 00039 00040 public: 00041 Q_INVOKABLE SoundListenerComponent( QObject* parent = 0 ); 00042 SoundListenerComponent( const SoundListenerComponent& other ); 00043 virtual QString category() const; 00044 00045 virtual void start(); 00046 virtual void draw( int timeLapse = 0 ); 00047 00048 void setActive( bool active ); 00049 bool isActive() 00050 { 00051 return m_activeInstance == this; 00052 } 00053 00054 void setEffectsEnabled( bool enable ); 00055 bool effectsEnabled() 00056 { 00057 return m_effectsEnabled; 00058 } 00059 00060 static SoundListenerComponent* activeInstance(); 00061 00062 private: 00063 bool m_effectsEnabled; 00064 00065 static SoundListenerComponent* m_activeInstance; 00066 }; 00067 00068 } 00069 00070 Q_DECLARE_METATYPE( GluonEngine::SoundListenerComponent ) 00071 Q_DECLARE_METATYPE( GluonEngine::SoundListenerComponent* ) 00072 00073 #endif // GLUON_ENGINE_SOUNDLISTENERCOMPONENT_H