[Qt-creator] Script manager
Eike Ziller
eike.ziller at nokia.com
Thu Jan 14 10:21:25 CET 2010
Hi,
On Jan 12, 2010, at 12:30 PM, ext Nicolas Arnaud-Cormos wrote:
> On Tuesday 12 January 2010 12:11:53 Eike Ziller wrote:
>>> I would like to create some simple scripts to do some repetitive tasks
>>> for my daily work, and I was thinking of creating a script plugin (where
>>> the user can access the current editor and the actionmanager for
>>> example).
>>
>> Uh, what do you need the action manager for, for "daily work"? :)
>
> We are porting application (from Motif to Qt for example) and porting has a
> lot of repetitive task.
> For example, changing a callback (myCallback) in a slot (mySlot) , which
> involves:
> * renaming it in the header
> * moving it to public slots or whatever
> * removing parameters
> * switching to the source
> * renaming
> * removing parameters
> * ...
>
> With a script interface, it would be easy to do such a thing, I just need to
> be able to access the editor and the actionManager (to switch header).
>
> Im' thinking of a script like (that's just to give you an idea, it would be
> more complicated):
> currentEditor.replace("myCallback", "mySlot");
> actionManager.execute("CppEditor.SwitchHeaderToSource");
Using the action manager for invoking operations is most probably not the best thing to do (though it would probably be the easiest to implement).
E.g. specifically in this example, the "SwitchHeaderToSource" action is disabled if the editor doesn't also has keyboard focus. In other cases the actual action that would be invoked also depends on the current focus, or even a more abstract "context". This can be actions in completely different plugins (described in the API documentation of ActionManager).
So you'd probably want a designated "script" method for switching header/source that has a more consistent behavior (in your case cpptoolsplugin.switchHeaderSource() would do the thing, because it works on the "current" editor. On the other hand we don't guarantee stable API (especially not for these kind of slots), so use at your own risk :)
> ...
>
> We need a lot of these little scripts to help us being productive, and having
> a script plugin would be far way easier than creating a specific C++ plugin.
> Imagine now that I call this script callbackToSlot.qs, put it in a script
> directory (that the plugin know), I could do:
> * shortcut to excute the script (I'm thinking of Alt+space)
> * a combobox with completion is shown
> * "callbackToSlot + Enter
> * the callback is change in a slot, in the header and source file.
>
> Note that's something we are already doing with xemacs, I'm just looking to Qt
> Creator to replace xemacs in my daily work.
> Anyway, if there's nothing yet, I'll start my own one.
>
> Thanks,
> Nicolas
--
Eike Ziller
Software Engineer
Nokia, Qt Development Frameworks
Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori
More information about the Qt-creator-old
mailing list