mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #335, findParentInfoAreas method to allow nested context menus
This commit is contained in:
committed by
Roland Winklmeier
parent
9452ff10c9
commit
cd7e2f6f72
@@ -62,16 +62,16 @@ namespace BlackGui
|
||||
|
||||
void CDockWidgetInfoArea::addToContextMenu(QMenu *contextMenu) const
|
||||
{
|
||||
Components::CMainInfoAreaComponent *mainWidget = qobject_cast<CMainInfoAreaComponent *>(parentWidget());
|
||||
Q_ASSERT(mainWidget);
|
||||
if (!mainWidget) return;
|
||||
QList<const CInfoArea *> parentInfoAreas = this->findParentInfoAreas();
|
||||
Q_ASSERT(!parentInfoAreas.isEmpty());
|
||||
if (parentInfoAreas.isEmpty()) return;
|
||||
|
||||
// Dockable widget's context menu
|
||||
CDockWidget::addToContextMenu(contextMenu);
|
||||
|
||||
// from main component (info area)
|
||||
contextMenu->addSeparator();
|
||||
mainWidget->addToContextMenu(contextMenu);
|
||||
parentInfoAreas.last()->addToContextMenu(contextMenu);
|
||||
}
|
||||
|
||||
void CDockWidgetInfoArea::initalFloating()
|
||||
@@ -122,4 +122,17 @@ namespace BlackGui
|
||||
QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findChildren<CDockWidgetInfoArea *>();
|
||||
return nestedInfoAreas;
|
||||
}
|
||||
}
|
||||
|
||||
const QList<const CInfoArea *> CDockWidgetInfoArea::findParentInfoAreas() const
|
||||
{
|
||||
QList<const CInfoArea *> parents;
|
||||
QWidget *currentWidget = this->parentWidget();
|
||||
while (currentWidget)
|
||||
{
|
||||
const CInfoArea *ia = qobject_cast<CInfoArea *>(currentWidget);
|
||||
if (ia) { parents.append(ia); }
|
||||
currentWidget = currentWidget->parentWidget();
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -58,6 +58,9 @@ namespace BlackGui
|
||||
//! Nested info areas
|
||||
QList<CDockWidgetInfoArea *> findNestedInfoAreas();
|
||||
|
||||
//! The parent info areas
|
||||
const QList<const CInfoArea *> findParentInfoAreas() const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user