2008/10/2 Chris Cannam <[EMAIL PROTECTED]>:
> Here's one suggestion.  We reduce each of the "static" action
> constructors (not necessarily the ones that are created on the fly
> like the note radio buttons, but at least the basic menu functions) to
> a one-liner that creates an action, assigns it an action name, and
> connects it to a slot:
>
>   connect(newAction("filter_selection"), SIGNAL(triggered()), this,
> SLOT(slotFilterSelection()));
>

Why not put the connect statement and the whole action definition in
the external file too ??

I imagine a function, that reads the xml-file and sets up the whole
action stuff.

If "isToggle" was true in the actions property settings ,
the function would connect to a toggled() slot,
otherwise to a triggered() slot.

All actions would have the same QWidget (or QMainWindow)
as parent, so they can easily be found.

The function for setting up the action would look about like this:

int
install_action( parsed_action_object, target_widget ){
        
        ac = parsed_action_object;
        
        IconLoader il;
        QIcon icon;
        icon = il.load( ac.icon_name );
        
        QAction *tac = new QAction( global_actions_parent_widget );  // or
target_widget
        tac->setIcon( icon );
        tac->setObjectName( ac.id );
        tac->setLabel( ac.label );
        tac->setShortcut( ac.shortcut );
        
        QString slot_togg_name = "slot_toggled_" + ac.id + "()";
        QString slot_trig_name = "slot_triggered_" + ac.id + "()";
        
        if( ac.isToggle == "true" ){
                connect( tac, SIGNAL(toggled()),
                                        target_widget, SLOT(slot_togg_name));   
        }else{
                connect( tac, SIGNAL(triggered()),
                                        target_widget, SLOT(slot_trig_name));   
        }
        
}
// **************************************************

Would that work ?


>
> XML or something else?  Advantages of XML: (1) we already have the
> basic structure for the file; (2) Qt contains an XML parser.  I'm not
> very fond of it to edit either, but we shouldn't have to edit it too
> often.
>

I don't want to convince at     all costs,
but I've found a Qt only solution for json.
It is surprisingly small and simple !!
I will send you the files, so you can
look at it yourself.



>
> Objections?
>

I would agree, if we did it from scratch.

But since a lot of work has already been done,
I don't see a deep requirement to move
the actions already ported to xml, not now.

Don't underestimate the work of creating
the external definitions !



My suggestion:

We use two xml-files for one QMainWindow:
one with the menu-structure
and one with the action-definitions.

Why two ?
Because it's more clearly arranged and simplifies editing.

I will create a scheme for the files
and send it to you, so you can verify it.


The files will be parsed and applied like this:

1. If the Action-ObjectName has been found and text() != "",
we assume, the action definition was hardcoded and don't apply
(all) action property definitions, but
we add the actions to the menus, almost as this was done before.

2. If the Action-ObjectName has NOT been found,
the whole action and connections will be created.

3. any third case here ??


I will send the files today or friday.


Emanuel

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to