File indexing completed on 2025-01-05 04:26:51

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Peter ZHOU <peterzhoulei@gmail.com>                               *
0003  * Copyright (c) 2008 Mark Kretschmann <kretschmann@kde.org>                            *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef AMAROK_SCRIPT_H
0019 #define AMAROK_SCRIPT_H
0020 
0021 #include <QStringList>
0022 #include <QObject>
0023 
0024 class QJSEngine;
0025 
0026 namespace AmarokScript
0027 {
0028     // SCRIPTDOX: Amarok
0029     class AmarokScript : public QObject
0030     {
0031         Q_OBJECT
0032 
0033         public:
0034             AmarokScript( const QString &name, QJSEngine *engine );
0035 
0036             /** Shuts down Amarok completely. */
0037             Q_INVOKABLE void quitAmarok();
0038 
0039             /** 
0040              * Print debug output to the shell. Only printed if amarok is started with --debug.
0041              * @param text The text to print.
0042              */
0043             Q_INVOKABLE void debug( const QString& text ) const;
0044 
0045             /**
0046               * Show an information dialog in Amarok.
0047               * @param text The text to display.
0048               * @param type Type of the dialog. See KMessageBox docs.
0049               */
0050             Q_INVOKABLE int alert( const QString& text, const QString& type = QStringLiteral("information") ) const;
0051 
0052             /** Signals Amarok that this script has ended. */
0053             Q_INVOKABLE void end();
0054 
0055             /**
0056               * Start another Amarok script.
0057               * @name Name of the script to start.
0058               */
0059             Q_INVOKABLE bool runScript( const QString& name ) const;
0060 
0061             /**
0062               * Stop another Amarok script.
0063               * @name Name of the script to stop.
0064               */
0065             Q_INVOKABLE bool stopScript( const QString& name ) const;
0066 
0067             /**
0068              * A list of names of the currently running scripts.
0069              * Does not list scripts running in the scriptconsole!
0070              */
0071             Q_INVOKABLE QStringList listRunningScripts() const;
0072 
0073         Q_SIGNALS:
0074             /**
0075              * Emitted when this script is uninstalled.
0076              */
0077             void uninstalled();
0078 
0079             // TODO: actually Q_EMIT this signal
0080             void configured();
0081 
0082         private:
0083             QString m_name;
0084     };
0085 }
0086 
0087 #endif