File indexing completed on 2025-03-09 04:25:12
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Peter ZHOU <peterzhoulei@gmail.com> * 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 "AmarokOSDScript.h" 0018 0019 #include "App.h" 0020 #include "amarokconfig.h" 0021 #include "widgets/Osd.h" 0022 0023 #include <QJSEngine> 0024 0025 using namespace AmarokScript; 0026 0027 AmarokOSDScript::AmarokOSDScript( QJSEngine *engine ) 0028 : QObject( engine ) 0029 { 0030 QJSValue scriptObject = engine->newQObject( this) ; 0031 QJSValue windowObject = engine->globalObject().property( QStringLiteral("Amarok") ).property( QStringLiteral("Window") ); 0032 windowObject.setProperty( QStringLiteral("OSD"), scriptObject ); 0033 } 0034 0035 void 0036 AmarokOSDScript::showCurrentTrack() 0037 { 0038 Amarok::OSD::instance()->forceToggleOSD(); 0039 } 0040 0041 void 0042 AmarokOSDScript::show() 0043 { 0044 Amarok::OSD::instance()->show(); 0045 } 0046 0047 void 0048 AmarokOSDScript::setDuration( int ms ) 0049 { 0050 Amarok::OSD::instance()->setDuration( ms ); 0051 } 0052 0053 void 0054 AmarokOSDScript::setTextColor( const QColor &color ) 0055 { 0056 Amarok::OSD::instance()->setTextColor( color ); 0057 } 0058 0059 void 0060 AmarokOSDScript::setOffset( int y ) 0061 { 0062 Amarok::OSD::instance()->setYOffset( y ); 0063 } 0064 0065 void 0066 AmarokOSDScript::setImage( const QImage &image ) 0067 { 0068 Amarok::OSD::instance()->setImage( image ); 0069 } 0070 0071 void 0072 AmarokOSDScript::setScreen( int screen ) 0073 { 0074 Amarok::OSD::instance()->setScreen( screen ); 0075 } 0076 0077 void 0078 AmarokOSDScript::setText( const QString &text ) 0079 { 0080 Amarok::OSD::instance()->setText( text ); 0081 } 0082 0083 void 0084 AmarokOSDScript::setRating( const short rating ) 0085 { 0086 Amarok::OSD::instance()->setRating( rating ); 0087 } 0088 0089 void 0090 AmarokOSDScript::setOsdEnabled( bool enable ) 0091 { 0092 Amarok::OSD::instance()->setEnabled( enable ); 0093 AmarokConfig::setOsdEnabled( enable ); 0094 } 0095 0096 bool 0097 AmarokOSDScript::osdEnabled() 0098 { 0099 return AmarokConfig::osdEnabled(); 0100 }