mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
refs #933, allow to explicitly add separator as menu action
(a bit of a hack, but unproblematic and sometimes useful)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
2d56167e65
commit
54219966ac
@@ -120,7 +120,11 @@ namespace BlackGui
|
||||
std::reverse(myActions.begin(), myActions.end()); // the order is reverse because of the insert multi value
|
||||
for (const CMenuAction &action : myActions)
|
||||
{
|
||||
if (action.isSubMenu() || !action.getQAction())
|
||||
if (action.isSeparator())
|
||||
{
|
||||
actions.append(action);
|
||||
}
|
||||
else if (action.isSubMenu() || !action.getQAction())
|
||||
{
|
||||
menus.append(action);
|
||||
}
|
||||
@@ -188,6 +192,12 @@ namespace BlackGui
|
||||
return this->addMenu(QIcon(), title, path);
|
||||
}
|
||||
|
||||
void CMenuActions::addSeparator(const QString &path)
|
||||
{
|
||||
static const CMenuAction separatorDummy(QIcon(), "_SEP_", path);
|
||||
this->addAction(separatorDummy);
|
||||
}
|
||||
|
||||
CMenuAction CMenuActions::addMenu(const QIcon &icon, const QString &title, const QString &path)
|
||||
{
|
||||
const QList<CMenuAction> exisitingMenu(this->getMenuActions(path));
|
||||
@@ -348,7 +358,14 @@ namespace BlackGui
|
||||
currentMenu = currentMenuForAction(menu, menuAction, menus, subMenus, key, pathDepth);
|
||||
}
|
||||
Q_ASSERT_X(currentMenu, Q_FUNC_INFO, "Missing menu");
|
||||
Q_ASSERT_X(!menuAction.isSubMenu() && menuAction.getQAction(), Q_FUNC_INFO, "Wrong menu type");
|
||||
Q_ASSERT_X(menuAction.isSubMenu() || menuAction.isSeparator() || menuAction.getQAction(), Q_FUNC_INFO, "Wrong type");
|
||||
|
||||
if (menuAction.isSeparator())
|
||||
{
|
||||
if (menu.isEmpty()) continue;
|
||||
currentMenu->addSeparator();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (menuAction.hasNoPath())
|
||||
{
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace BlackGui
|
||||
//! Is menu?
|
||||
bool isSubMenu() const { return m_isMenu; }
|
||||
|
||||
//! Is separator
|
||||
bool isSeparator() const { return m_title == "_SEP_"; }
|
||||
|
||||
//! Is menu?
|
||||
void setSubMenu(bool menu) { m_isMenu = menu; }
|
||||
|
||||
@@ -112,6 +115,9 @@ namespace BlackGui
|
||||
//! No key
|
||||
static const QString &pathNone() { static const QString p("_NONE"); return p; }
|
||||
|
||||
//! Path converter into separator
|
||||
static const QString &pathSeparator() { static const QString p("_SEPARATOR"); return p; }
|
||||
|
||||
//! Model set
|
||||
static const QString &pathModelSet() { static const QString p("Custom.10.Model/Model set"); return p; }
|
||||
|
||||
@@ -237,6 +243,9 @@ namespace BlackGui
|
||||
//! Add a sub menu
|
||||
CMenuAction addMenu(const QString &title, const QString &path);
|
||||
|
||||
//! Add a separator
|
||||
void addSeparator(const QString &path);
|
||||
|
||||
//! Add a sub menu
|
||||
CMenuAction addMenu(const QIcon &icon, const QString &title, const QString &path);
|
||||
|
||||
@@ -327,6 +336,9 @@ namespace BlackGui
|
||||
//! Model set menu
|
||||
CMenuAction addMenuModelSet();
|
||||
|
||||
//! Add ModelConverterX menu (optional)
|
||||
CMenuAction addMenuModelConverterX();
|
||||
|
||||
//! @}
|
||||
|
||||
//! Predfefined sub menus
|
||||
|
||||
Reference in New Issue
Block a user