1 /****************************************************************************************
2  * Copyright (c) 2008 Peter ZHOU <peterzhoulei@gmail.com>                               *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU General Public License as published by the Free Software        *
6  * Foundation; either version 2 of the License, or (at your option) any later           *
7  * version.                                                                             *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU General Public License along with         *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 
17 #include "AmarokScriptConfig.h"
18 
19 #include "core/support/Amarok.h"
20 
21 #include <KConfigGroup>
22 #include <KSharedConfig>
23 
24 #include <QJSEngine>
25 
26 using namespace AmarokScript;
27 
AmarokScriptConfig(const QString & name,QJSEngine * engine)28 AmarokScriptConfig::AmarokScriptConfig( const QString &name, QJSEngine *engine )
29     : QObject( engine )
30     , m_name( name )
31 {
32     QJSValue scriptObject = engine->newQObject( this );
33     //better name?
34     engine->globalObject().property( QStringLiteral("Amarok") ).setProperty( QStringLiteral("Script"), scriptObject );
35 }
36 
37 QVariant
readConfig(const QString & name,const QVariant & defaultValue) const38 AmarokScriptConfig::readConfig( const QString &name, const QVariant &defaultValue ) const
39 {
40     return Amarok::config( m_name ).readEntry( name, defaultValue );
41 }
42 
43 void
writeConfig(const QString & name,const QVariant & content)44 AmarokScriptConfig::writeConfig( const QString &name, const QVariant &content )
45 {
46     Amarok::config( m_name ).writeEntry( name, content );
47 }
48