Update pluginmenu.cpp

note this change omits adding menu for plugins w/o commands
This commit is contained in:
Garux 2023-07-21 12:05:35 +06:00
parent 06f34d4fc5
commit 50a4ff6f3e

View File

@ -42,61 +42,59 @@ void PlugInMenu_Add( QMenu* plugin_menu, IPlugIn* pPlugIn ){
MenuStack menuStack; MenuStack menuStack;
std::size_t nCount = pPlugIn->getCommandCount(); std::size_t nCount = pPlugIn->getCommandCount();
{
globalErrorStream() << pPlugIn->getMenuName() << " count: " << nCount << "\n";
if (nCount > 1) {
menu = plugin_menu->addMenu( pPlugIn->getMenuName() );
menu->setTearOffEnabled( g_Layout_enableDetachableMenus.m_value ); if ( nCount > 1 ) { // create submenu
while ( nCount > 0 ) menu = plugin_menu->addMenu( pPlugIn->getMenuName() );
{
menuText = pPlugIn->getCommandTitle( --nCount );
if ( menuText != 0 && strlen( menuText ) > 0 ) { menu->setTearOffEnabled( g_Layout_enableDetachableMenus.m_value );
if ( plugin_menu_separator( menuText ) ) { while ( nCount > 0 )
menu->addSeparator(); {
}
else if ( plugin_submenu_in( menuText ) ) {
menuText = pPlugIn->getCommandTitle( --nCount );
if ( plugin_menu_special( menuText ) ) {
globalErrorStream() << pPlugIn->getMenuName() << " Invalid title (" << menuText << ") for submenu.\n";
continue;
}
menuStack.push( menu );
menu = menu->addMenu( menuText );
menu->setTearOffEnabled( g_Layout_enableDetachableMenus.m_value );
continue;
}
else if ( plugin_submenu_out( menuText ) ) {
if ( !menuStack.empty() ) {
menu = menuStack.top();
menuStack.pop();
}
else
{
globalErrorStream() << pPlugIn->getMenuName() << ": Attempt to end non-existent submenu ignored.\n";
}
continue;
}
else
{
create_menu_item_with_mnemonic( menu, menuText, pPlugIn->getGlobalCommand( nCount ) );
}
}
}
if ( !menuStack.empty() ) {
globalErrorStream() << pPlugIn->getMenuName() << " mismatched > <. " << menuStack.size() << " submenu(s) not closed.\n";
}
} else if (nCount == 1) {
menuText = pPlugIn->getCommandTitle( --nCount ); menuText = pPlugIn->getCommandTitle( --nCount );
if ( menuText != 0 && strlen( menuText ) > 0 ) { if ( menuText != 0 && strlen( menuText ) > 0 ) {
create_menu_item_with_mnemonic( plugin_menu, menuText, pPlugIn->getGlobalCommand( nCount ) ); if ( plugin_menu_separator( menuText ) ) {
menu->addSeparator();
}
else if ( plugin_submenu_in( menuText ) ) {
menuText = pPlugIn->getCommandTitle( --nCount );
if ( plugin_menu_special( menuText ) ) {
globalErrorStream() << pPlugIn->getMenuName() << " Invalid title (" << menuText << ") for submenu.\n";
continue;
}
menuStack.push( menu );
menu = menu->addMenu( menuText );
menu->setTearOffEnabled( g_Layout_enableDetachableMenus.m_value );
continue;
}
else if ( plugin_submenu_out( menuText ) ) {
if ( !menuStack.empty() ) {
menu = menuStack.top();
menuStack.pop();
}
else
{
globalErrorStream() << pPlugIn->getMenuName() << ": Attempt to end non-existent submenu ignored.\n";
}
continue;
}
else
{
create_menu_item_with_mnemonic( menu, menuText, pPlugIn->getGlobalCommand( nCount ) );
}
} }
} }
if ( !menuStack.empty() ) {
globalErrorStream() << pPlugIn->getMenuName() << " mismatched > <. " << menuStack.size() << " submenu(s) not closed.\n";
}
}
else if ( nCount == 1 ) { // add only command directly
menuText = pPlugIn->getCommandTitle( --nCount );
if ( menuText != 0 && strlen( menuText ) > 0 ) {
create_menu_item_with_mnemonic( plugin_menu, menuText, pPlugIn->getGlobalCommand( nCount ) );
}
} }
} }