The new Amarok scripting interface only supports Qt script. But with the help of Qt Bindings, you can ultimate the scripting usage. Here’s a simple example of using .ui files in a script.
![]() |
| From My ScreenShot |
A clip from my encoding fixer script, you can grab the full version from amarok/playground/src/script/encoding_fixer/:
Importer.loadQtBinding( “qt.core” );
Importer.loadQtBinding( “qt.gui” );
Importer.loadQtBinding( “qt.uitools” ); //load the qt bindingfunction readConfiguration()
{
if ( Amarok.Script.readConfig( “simple_Chinese”, “false” ) == “false” )
mainWindow.children()[1].children()[1].checked = false; //uncheck the checkbox
else
mainWindow.children()[1].children()[1].checked = true; //check the checkbox
}function onConfigure()
{
mainWindow.show();
}var UIloader = new QUiLoader( this );
var uifile = new QFile ( Amarok.Info.scriptPath() + “/main.ui” );
uifile.open( QIODevice.ReadOnly );
mainWindow = UIloader.load( uifile, this); //load the ui file
uifile.close();readConfiguration();
mainWindow.children()[0].accepted.connect( saveConfiguration ); //when OK button is clicked
mainWindow.children()[0].rejected.connect( readConfiguration ); //call the function when Cancel button is clickedAmarok.Window.addSettingsMenu( “configencoding”, “Encoding Fixer Settings…” ); //add the configuration menu
Amarok.Window.SettingsMenu.configencoding.triggered.connect( onConfigure ); //add a signal
Heads up! Amarok 2.0 is about to release. ![]()
I will be really happy to see more scripts ready on kde-apps.org. And I am impressed that there are 10+ scripts out there already even before the release of our RC version.


Monday, 24. November 2008
uitools is pretty cumbersome to use as you can see there. Someone should write a uic for QtScript.
Monday, 24. November 2008
Great informative blog, Peter. Thanks
PS: You did a fantastic job with the scripting system, but I told you that already.
Monday, 24. November 2008
@Ian if you use my wrapper API for it then it’s a one liner - I’d suggest you should include that binding not rely on the generated one for loading ui files.
Saturday, 6. December 2008
Well, I was trying to make a new version of my Amalyp script for Amarok 2. But I noticed that the function to get the current position in the song in milliseconds is again missing (or not documented). So I’m stuck there.
Sunday, 7. December 2008
@Tim De Graeve: Please use Amarok.Engine.trackPosition()
Tuesday, 28. April 2009
found your post really informative.
can you talk me through how you are referencing objects from the .ui file in your script?
for example is it possible to select objects by name rather than using .children() and the number?
cheers
Wednesday, 6. May 2009
@chris:
the uitools is pretty cumbersome as Ian mentioned.