MCPcopy Create free account
hub / github.com/KDE/labplot / activateSubWindowForAspect

Method activateSubWindowForAspect

src/frontend/MainWin.cpp:2163–2237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2161}
2162
2163void MainWin::activateSubWindowForAspect(const AbstractAspect* aspect) {
2164 Q_ASSERT(aspect);
2165 Q_ASSERT(m_dockManagerContent);
2166 const auto* part = dynamic_cast<const AbstractPart*>(aspect);
2167 if (part) {
2168 ContentDockWidget* win{nullptr};
2169
2170 // for aspects being children of a Workbook, we show workbook's window, otherwise the window of the selected part
2171 const auto* workbook = dynamic_cast<const Workbook*>(aspect->parentAspect());
2172 auto* datapicker = dynamic_cast<const Datapicker*>(aspect->parentAspect());
2173 if (!datapicker)
2174 datapicker = dynamic_cast<const Datapicker*>(aspect->parentAspect()->parentAspect());
2175
2176 if (workbook)
2177 win = workbook->dockWidget();
2178 else if (datapicker)
2179 win = datapicker->dockWidget();
2180 else
2181 win = part->dockWidget();
2182
2183 auto* dock = m_dockManagerContent->findDockWidget(win->objectName());
2184 if (dock == nullptr) {
2185 // Add new dock if not found
2186 ads::CDockAreaWidget* areaWidget{nullptr};
2187 // when a dock area is empty, it is deleted and becomes invalid (for example after all its dock widgets are hidden/unpinned)
2188 // so we also need to check that the dock area of the current aspect is valid
2189 if (m_dockManagerContent->dockWidgetsMap().isEmpty() || !m_currentAspectDock || !m_currentAspectDockArea) {
2190 // If only project explorer and properties dock exist place it right to the project explorer
2191 areaWidget = m_dockManagerContent->addDockWidget(ads::CenterDockWidgetArea, win);
2192 } else {
2193 // Add dock on top of the current aspect, so it is directly visible
2194 areaWidget = m_dockManagerContent->addDockWidget(ads::CenterDockWidgetArea, win, m_currentAspectDock->dockAreaWidget());
2195 }
2196
2197 // the dock area for the content widgets should be stretched to take the whole free space
2198 auto policy = areaWidget->sizePolicy();
2199 policy.setHorizontalStretch(1);
2200 areaWidget->setSizePolicy(policy);
2201
2202 win->show();
2203
2204 // Qt provides its own "system menu" for every sub-window. The shortcut for the close-action
2205 // in this menu collides with our global m_closeAction.
2206 // remove the shortcuts in the system menu to avoid this collision.
2207 for (QAction* action : win->titleBarActions())
2208 action->setShortcut(QKeySequence());
2209 } else
2210 dock->toggleView(true);
2211
2212 m_currentAspectDock = win;
2213 m_currentAspectDockArea = m_currentAspectDock->dockAreaWidget();
2214 m_dockManagerContent->setDockWidgetFocused(win);
2215 } else {
2216 // activate the mdiView of the parent, if a child was selected
2217 const AbstractAspect* parent = aspect->parentAspect();
2218 if (parent) {
2219 activateSubWindowForAspect(parent);
2220

Callers

nothing calls this directly

Calls 12

parentAspectMethod · 0.80
findDockWidgetMethod · 0.80
dockWidgetsMapMethod · 0.80
showMethod · 0.80
titleBarActionsMethod · 0.80
dockWidgetMethod · 0.45
isEmptyMethod · 0.45
addDockWidgetMethod · 0.45
dockAreaWidgetMethod · 0.45
toggleViewMethod · 0.45
setDockWidgetFocusedMethod · 0.45
childSelectedMethod · 0.45

Tested by

no test coverage detected