Commit 9cd51273 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Mechanism added to UIMainWindow for the declaration of custom menu actions.

parent b4c68d6b
......@@ -208,10 +208,37 @@ void UIMainWindow::loadRecent()
}
void UIMainWindow::declareCustomMenuAction( const QString& menuName, QAction* action )
{
// Add custom menu actions to the menubar.
QString menuSimplifiedName = menuName;
menuSimplifiedName.remove( '&' );
QMenu *menu = NULL;
for( auto m : ui->menuBar->children() )
if( dynamic_cast<QMenu*>(m) && menuSimplifiedName == ((QMenu*)m)->title().remove('&') )
menu = (QMenu*) m;
if( !menu )
{
menu = new QMenu( menuName );
ui->menuBar->insertMenu( ui->menuHelp->menuAction(), menu );
}
connect( action, SIGNAL(triggered(bool)), this, SLOT(customMenuActionTriggered()) );
menu->addAction( action );
}
void UIMainWindow::init()
{
onDeclaringToolCategories(); // must be called before setupUi(...) because tool categories are required for the AlgorithmSelector widget.
ui->setupUi(this);
onDeclaringCustomMenus();
loadPlugins();
connect( ui->tableCurrentProjContent, SIGNAL(askForReframing()), this, SLOT(reframeScene()) );
......@@ -1664,3 +1691,11 @@ bool UIMainWindow::loadProject( const QString& filename )
QApplication::restoreOverrideCursor();
return true;
}
void UIMainWindow::customMenuActionTriggered()
{
QAction *act = dynamic_cast<QAction*>( sender() );
if( act )
onCustomMenuActionTriggered( act );
}
......@@ -91,11 +91,15 @@ public:
virtual QString mainWindowTitle() const = 0;
virtual QString projectFileExtension() const = 0;
virtual void onInitializingApp() {}
virtual void onReleasingApp() {}
virtual void onInitializingApp() {}
virtual void onReleasingApp() {}
virtual void onDeclaringToolCategories() {}
virtual void onDeclaringCustomMenus() {}
virtual void additionalGLViewerHotkeys( QKeyEvent *evt ) {}
inline void declareToolCategory( int id, const QString& name, const QString &icon ) { ToolCategory::declareCategory(id,name,icon); }
void declareCustomMenuAction( const QString& menuName, QAction* action );
virtual void onCustomMenuActionTriggered( QAction* action ) {}
virtual UIProject* onCreatingProject( const QString &name = QString() ) { return new UIProject(name); }
virtual bool onClosingProject( UIProject *proj ) { return true; }
......@@ -121,6 +125,7 @@ private:
private slots:
void loadRecent();
void keyPressedInGLViewer( QKeyEvent *evt ) { additionalGLViewerHotkeys( evt ); }
void customMenuActionTriggered();
public slots:
void toolExecutionFinished( bool needUpdate );
......
Supports Markdown
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