mirror of https://github.com/CGAL/cgal
Fix the fix for operations order in menu
This commit is contained in:
parent
f510bee3d3
commit
eca8f57ddd
|
|
@ -383,6 +383,29 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren
|
||||||
connect(ui->menuOperations, SIGNAL(aboutToShow()), this, SLOT(filterOperations()));
|
connect(ui->menuOperations, SIGNAL(aboutToShow()), this, SLOT(filterOperations()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addActionToMenu(QAction* action, QMenu* menu)
|
||||||
|
{
|
||||||
|
auto it = menu->actions().begin();
|
||||||
|
for(;it != menu->actions().end();++it)
|
||||||
|
{
|
||||||
|
QString atxt = action->text().remove("&"),
|
||||||
|
btxt = (*it)->text().remove("&");
|
||||||
|
int i = 0;
|
||||||
|
while(atxt[i] == btxt[i]
|
||||||
|
&& i < atxt.size()
|
||||||
|
&& i < btxt.size())
|
||||||
|
++i;
|
||||||
|
bool res = (atxt[i] < btxt[i]);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
menu->insertAction(*it, action);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(it==menu->actions().end())
|
||||||
|
menu->addAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
//Recursive function that do a pass over a menu and its sub-menus(etc.) and hide them when they are empty
|
//Recursive function that do a pass over a menu and its sub-menus(etc.) and hide them when they are empty
|
||||||
void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here)
|
void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here)
|
||||||
{
|
{
|
||||||
|
|
@ -407,7 +430,8 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menu->addAction(submenu->menuAction());
|
//menu->addAction(submenu->menuAction());
|
||||||
|
addActionToMenu(submenu->menuAction(), menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filterMenuOperations(submenu, filter, keep);
|
filterMenuOperations(submenu, filter, keep);
|
||||||
|
|
@ -415,13 +439,14 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here)
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(action->text().contains(filter, Qt::CaseInsensitive)){
|
else if(action->text().contains(filter, Qt::CaseInsensitive)){
|
||||||
menu->addAction(action);
|
//menu->addAction(action);
|
||||||
|
addActionToMenu(action, menu);
|
||||||
}
|
}
|
||||||
buffer.removeAll(action);
|
buffer.removeAll(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> sorted_actions;
|
/*QList<QAction*> sorted_actions;
|
||||||
for(QAction* action : menu->actions())
|
for(QAction* action : menu->actions())
|
||||||
{
|
{
|
||||||
if(action->isVisible() && !action->objectName().isEmpty())
|
if(action->isVisible() && !action->objectName().isEmpty())
|
||||||
|
|
@ -434,14 +459,14 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here)
|
||||||
btxt = b->text().remove("&");
|
btxt = b->text().remove("&");
|
||||||
int i =0;
|
int i =0;
|
||||||
while(atxt[i] == btxt[i]
|
while(atxt[i] == btxt[i]
|
||||||
&& i < a->text().size()
|
&& i < atxt.size()
|
||||||
&& i < b->text().size())
|
&& i < btxt.size())
|
||||||
++i;
|
++i;
|
||||||
bool res = (atxt[i] < btxt[i]);
|
bool res = (atxt[i] < btxt[i]);
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
menu->addActions(sorted_actions);
|
menu->addActions(sorted_actions);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::filterOperations()
|
void MainWindow::filterOperations()
|
||||||
|
|
@ -458,8 +483,10 @@ void MainWindow::filterOperations()
|
||||||
|
|
||||||
Q_FOREACH(QAction* action, action_menu_map.keys())
|
Q_FOREACH(QAction* action, action_menu_map.keys())
|
||||||
{
|
{
|
||||||
action_menu_map[action]->addAction(action);
|
QMenu* menu = action_menu_map[action];
|
||||||
|
addActionToMenu(action, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filter=operationSearchBar.text();
|
QString filter=operationSearchBar.text();
|
||||||
Q_FOREACH(const PluginNamePair& p, plugins) {
|
Q_FOREACH(const PluginNamePair& p, plugins) {
|
||||||
Q_FOREACH(QAction* action, p.first->actions()) {
|
Q_FOREACH(QAction* action, p.first->actions()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue