Commit 34ca0650 authored by Jan Möbius's avatar Jan Möbius

Added an algorithms menu that is not visible by default.

Updated documentation of menuinterface with an example on how to create toplevel menus.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14005 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ddb60982
......@@ -56,6 +56,8 @@
/// The Menu will be added inside the Tools Menu
#define TOOLSMENU tr("Tools")
/// The Menu will be added inside the Algorithms Menu
#define ALGORITHMMENU tr("Algorithms")
/** \file MenuInterface.hh
*
......@@ -141,7 +143,7 @@ void PrintPlugin::pluginsInitialized()
// Set an icon for this submenu
printMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png"));
// Add the new submenu to OpenFlippers menus
// Add the new submenu to OpenFlippers file menu
emit addMenubarAction(printMenu->menuAction(), FILEMENU );
// Create an action to be added to the submenu
......@@ -161,6 +163,15 @@ void PrintPlugin::pluginsInitialized()
}
\endcode
If you want to create a toplevel menu you can use the following code snippet:
\code
//Pointer to the new menu
QMenu *topLevelMenu;
// This function checks if a menu called "Toplevel" exists and returns it in the pointer.
// If it does not exist, it is automatically created.
emit getMenubarMenu(tr("Toplevel"), topLevelMenu, true );
\endcode
Signals and slots of your menus (e.g. from an action inside it) can be directly connected to signals and slots in
your plugin. Therefore the embedding of your menus into the OpenFlippers menu list is fully transparent.
......
......@@ -1042,6 +1042,7 @@ void CoreWidget::setForceNativeCursor ( bool _state )
bool CoreWidget::event( QEvent *_event )
{
//WhatsThisClicked event for hyperlinks in 'whats this' boxes
if( _event->type() == QEvent::WhatsThisClicked )
{
......
......@@ -636,6 +636,9 @@ public:
/// QMenu containing the recently opened files
QMenu* recentFilesMenu_;
/// Algorithms Menu
QMenu* algorithmMenu_;
/// Help Menu
QMenu* helpMenu_;
......
......@@ -63,16 +63,23 @@
void CoreWidget::slotAddMenubarAction( QAction* _action , QString _name ) {
if (!menus_.contains (_name))
if (!menus_.contains(_name))
return;
if (_name == FILEMENU)
{
if (_name == FILEMENU) {
fileMenu_->insertSeparator(fileMenuEnd_);
fileMenu_->insertAction( fileMenuEnd_ , _action );
fileMenu_->insertAction(fileMenuEnd_, _action);
} else if (_name == ALGORITHMMENU) {
// We insert the algorithms menu if it is not available yet
if ( menuBar()->actions().contains(helpMenu_->menuAction()) )
menuBar()->insertMenu(helpMenu_->menuAction(), algorithmMenu_);
menus_[_name]->addAction(_action);
} else {
menus_[_name]->addAction(_action);
}
else
menus_[_name]->addAction (_action);
}
//=============================================================================
......@@ -220,7 +227,6 @@ void CoreWidget::setupMenuBar()
connect(AC_exit, SIGNAL(triggered()), this, SIGNAL(exit()));
fileMenu_->addAction(AC_exit);
// ======================================================================
// View Menu
// ======================================================================
......@@ -478,6 +484,12 @@ void CoreWidget::setupMenuBar()
windowMenu_->addAction(AC_ShowToolbox_);
// ======================================================================
// Algorithms Menu
// ======================================================================
algorithmMenu_ = new QMenu( ALGORITHMMENU );
menus_[tr("Algorithms")] = algorithmMenu_;
// ======================================================================
// help Menu
// ======================================================================
......@@ -526,6 +538,7 @@ void CoreWidget::setupMenuBar()
viewMenu_->installEventFilter(this);
toolsMenu_->installEventFilter(this);
windowMenu_->installEventFilter(this);
algorithmMenu_->installEventFilter(this);
helpMenu_->installEventFilter(this);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment