File indexing completed on 2025-01-19 04:25:17

0001 /****************************************************************************************
0002  * Copyright (c) 2011 Kevin Funk <krf@electrostorm.net>                                 *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "AmarokKNotifyScript.h"
0018 
0019 #include "amarokconfig.h"
0020 #include "App.h"
0021 #include "KNotificationBackend.h"
0022 
0023 #include <QJSEngine>
0024 
0025 #define kNotify Amarok::KNotificationBackend::instance()
0026 
0027 using namespace AmarokScript;
0028 
0029 AmarokKNotifyScript::AmarokKNotifyScript( QJSEngine *engine )
0030     : QObject( engine )
0031 {
0032     QJSValue scriptObject = engine->newQObject( this );
0033     QJSValue windowObject = engine->globalObject().property( QStringLiteral("Amarok") ).property( QStringLiteral("Window") );
0034     windowObject.setProperty( QStringLiteral("KNotify"), scriptObject );
0035 }
0036 
0037 bool
0038 AmarokKNotifyScript::kNotifyEnabled()
0039 {
0040     return AmarokConfig::kNotifyEnabled();
0041 }
0042 
0043 void
0044 AmarokKNotifyScript::setKNotifyEnabled( bool enable )
0045 {
0046     AmarokConfig::setKNotifyEnabled( enable );
0047 }
0048 
0049 void
0050 AmarokKNotifyScript::show( const QString &title, const QString &body, const QPixmap &pixmap )
0051 {
0052     kNotify->show( title, body, pixmap );
0053 }
0054 
0055 
0056 void
0057 AmarokKNotifyScript::showCurrentTrack()
0058 {
0059     kNotify->showCurrentTrack( true );
0060 }