[Kde-bindings] Qt::ScriptEngine context

Han Holl han.holl at pobox.com
Tue Mar 2 21:41:45 UTC 2010


Hi,
In KDE3 I had an application that displayed photographs on the background with 
captions from the EXIF headers.
I now try to rebuild this for KDE4.4, and have several problems.
Because under KDE4 hiding the panel is cumbersome I try to do this from a 
program. There is no dbus interface for this, but the following Javascript 
works (in the desktop shell scripting console).

var p = panelById(panelIds[0]);
hiding = p.hiding; 
if (hiding == 'none') {
  p.hiding = 'autohide';
} else {
  p.hiding = 'none';
}

Question: how to run this from a ruby script ?
The following does _not_ work: (ReferenceError: Can't find variable: 
panelById)

#!/usr/bin/ruby -w
require 'Qt4'
require 'qtscript'

a = Qt::Application.new(ARGV)
eng = Qt::ScriptEngine.new(a)
script = %q{
var p = panelById(panelIds[0]);
hiding = p.hiding; 
if (hiding == 'none') {
  p.hiding = 'autohide';
} else {
  p.hiding = 'none';
}
}
v = eng.evaluate script
puts v.toString


I suspect that it is a question of the correct Qt::ScriptContext, but I've no 
idea how set the correct context.
Any help with this, or suggestions about how to hide the panel from a program 
would be much appreciated.

Cheers,

Han Holl



More information about the Kde-bindings mailing list