[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    context menu for flake tool
From:       Thomas Zander <zander () kde ! org>
Date:       2007-06-23 8:09:26
Message-ID: 200706231009.30811.zander () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


HI,

in previous conversations we concluded that it would be very useful to 
have a set of actions specific for the currently selected tool when the 
user right-clicks on the canvas.
This will allow the text tool to select the font though the context menu, 
or the zoom tool a 'zoom in, zoom out, zoom 100%'.  All next to the 
application wide actions. For application wide think things like copy 
paste. Or for Krita, select all.

This feature request turned out to be quite trivial, really, using an 
XMLGui feature called 'Actionlist'.
In KWord I added a 
 <ActionList name="flake_tool_actions"/>
to the kword.rc in the place of the popup menu where I want the flake 
tools to appear.
Next I altered the KWCanvas::mousePressEvent() to add (after the call to 
the toolProxy):

if(e->button() == Qt::RightButton) {
  m_view->unplugActionList( "flake_tool_actions" );
  m_view->plugActionList( "flake_tool_actions",
    m_toolProxy->popupActionList() );
  QMenu *menu = dynamic_cast<QMenu*> 
    (m_view->factory()->container("FlakePopup", m_view));
  if(menu)
    menu->exec( e->globalPos() );
}

I also added the protected method;
 KoTool::setPopupActionList(const QList<QAction*> &list);
which a tool can use to set the list of actions that he wants to display 
at the list position.
See the constructor of koffice/shapes/text/TextTool for an example of 
that.

I hope all apps will integrate the menus like this, and many tools will 
consider adding actions to the menu.

Cheers!
-- 
Thomas Zander

[Attachment #5 (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic