svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=906371
This commit is contained in:
Aaron J. Seigo 2009-01-06 02:40:30 +00:00
parent 599cffec5b
commit ddc7609369

View File

@ -1,8 +1,9 @@
// set up the engine, player and controller
engine = dataEngine("nowplaying"); engine = dataEngine("nowplaying");
players = engine.sources; watchingPlayer = engine.sources[0];
watchingPlayer = players[0];
controller = service("nowplaying", watchingPlayer); controller = service("nowplaying", watchingPlayer);
// define a few functions
plasmoid.dataUpdate = function(a, b) plasmoid.dataUpdate = function(a, b)
{ {
label.text = "Playing " + b.Title + " by " + b.Artist + ". time: " + label.text = "Playing " + b.Title + " by " + b.Artist + ". time: " +
@ -34,6 +35,7 @@ plasmoid.setProgress = function(progress)
print("set progress to " + progress); print("set progress to " + progress);
} }
// Set up the UI
layout = new LinearLayout(plasmoid); layout = new LinearLayout(plasmoid);
layout.setOrientation(QtVertical); layout.setOrientation(QtVertical);
label = new Label(); label = new Label();
@ -43,15 +45,16 @@ stop = new PushButton();
stop.text = "Stop"; stop.text = "Stop";
layout.addItem(stop); layout.addItem(stop);
controller.associateWidget(stop, "stop");
stop["clicked()"].connect(plasmoid.stop);
progress = new Slider(); progress = new Slider();
progress.orientation = QtHorizontal; progress.orientation = QtHorizontal;
layout.addItem(progress); layout.addItem(progress);
controller.associateWidget(progress, "progress");
// Glue things together
stop["clicked()"].connect(plasmoid.stop);
progress["sliderMoved(int)"].connect(plasmoid.setProgress); progress["sliderMoved(int)"].connect(plasmoid.setProgress);
controller.associateWidget(stop, "stop");
controller.associateWidget(progress, "progress");
engine.connectSource(watchingPlayer, plasmoid, 500); engine.connectSource(watchingPlayer, plasmoid, 500);