mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +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
|
void CDockWidgetInfoArea::addToContextMenu(QMenu *contextMenu) const
|
||||||
{
|
{
|
||||||
Components::CMainInfoAreaComponent *mainWidget = qobject_cast<CMainInfoAreaComponent *>(parentWidget());
|
QList<const CInfoArea *> parentInfoAreas = this->findParentInfoAreas();
|
||||||
Q_ASSERT(mainWidget);
|
Q_ASSERT(!parentInfoAreas.isEmpty());
|
||||||
if (!mainWidget) return;
|
if (parentInfoAreas.isEmpty()) return;
|
||||||
|
|
||||||
// Dockable widget's context menu
|
// Dockable widget's context menu
|
||||||
CDockWidget::addToContextMenu(contextMenu);
|
CDockWidget::addToContextMenu(contextMenu);
|
||||||
|
|
||||||
// from main component (info area)
|
// from main component (info area)
|
||||||
contextMenu->addSeparator();
|
contextMenu->addSeparator();
|
||||||
mainWidget->addToContextMenu(contextMenu);
|
parentInfoAreas.last()->addToContextMenu(contextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidgetInfoArea::initalFloating()
|
void CDockWidgetInfoArea::initalFloating()
|
||||||
@@ -122,4 +122,17 @@ namespace BlackGui
|
|||||||
QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findChildren<CDockWidgetInfoArea *>();
|
QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findChildren<CDockWidgetInfoArea *>();
|
||||||
return nestedInfoAreas;
|
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
|
//! Nested info areas
|
||||||
QList<CDockWidgetInfoArea *> findNestedInfoAreas();
|
QList<CDockWidgetInfoArea *> findNestedInfoAreas();
|
||||||
|
|
||||||
|
//! The parent info areas
|
||||||
|
const QList<const CInfoArea *> findParentInfoAreas() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user