diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index ed0e7c4c9..12ab51677 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -18,6 +18,7 @@ set( libSources pipeline.cpp aclsystem.cpp + actioncollection.cpp artist.cpp album.cpp collection.cpp diff --git a/src/libtomahawk/actioncollection.cpp b/src/libtomahawk/actioncollection.cpp new file mode 100644 index 000000000..679703a22 --- /dev/null +++ b/src/libtomahawk/actioncollection.cpp @@ -0,0 +1,54 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "actioncollection.h" + +ActionCollection* ActionCollection::s_instance = 0; +ActionCollection* ActionCollection::instance() +{ + return s_instance; +} + + +ActionCollection::ActionCollection() +{ + s_instance = this; + initActions(); +} + + +void +ActionCollection::initActions() +{ + +} + + +ActionCollection::~ActionCollection() +{ + s_instance = 0; + foreach( QString key, m_actionCollection.keys() ) + delete m_actionCollection[ key ]; +} + + +QAction* +ActionCollection::getAction( const QString& name ) +{ + return m_actionCollection.contains( name ) ? m_actionCollection[ name ] : 0; +} diff --git a/src/libtomahawk/actioncollection.h b/src/libtomahawk/actioncollection.h new file mode 100644 index 000000000..7118f7bfa --- /dev/null +++ b/src/libtomahawk/actioncollection.h @@ -0,0 +1,46 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TOMAHAWKACTIONCOLLECTION_H +#define TOMAHAWKACTIONCOLLECTION_H + +#include "dllmacro.h" + +#include + + +class DLLEXPORT ActionCollection +{ + +public: + static ActionCollection* instance(); + + ActionCollection(); + ~ActionCollection(); + + void initActions(); + + QAction* getAction( const QString &name ); + +private: + static ActionCollection* s_instance; + + QHash< QString, QAction* > m_actionCollection; +}; + +#endif diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index dc9dba5da..e42cb75b4 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -32,6 +32,7 @@ #include #include +#include "actioncollection.h" #include "artist.h" #include "album.h" #include "collection.h" @@ -160,6 +161,8 @@ TomahawkApp::init() new TomahawkSettings( this ); TomahawkSettings* s = TomahawkSettings::instance(); + new ActionCollection(); + tDebug( LOGINFO ) << "Setting NAM."; #ifdef LIBLASTFM_FOUND TomahawkUtils::setNam( lastfm::nam() ); @@ -317,6 +320,8 @@ TomahawkApp::~TomahawkApp() delete AtticaManager::instance(); #endif + delete ActionCollection::instance(); + tLog() << "Finished shutdown."; }