MCPcopy Create free account
hub / github.com/KDE/kdevelop / toggleConcentrationMode

Method toggleConcentrationMode

kdevplatform/sublime/mainwindow_p.cpp:156–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156void MainWindowPrivate::toggleConcentrationMode(bool concentrationModeOn)
157{
158 QWidget* cornerWidget = nullptr;
159 if (m_concentrateToolBar) {
160 QLayout* l = m_concentrateToolBar->layout();
161 QLayoutItem* li = l->takeAt(1); //ensure the cornerWidget isn't destroyed with the toolbar
162 if (li) {
163 cornerWidget = li->widget();
164 delete li;
165 }
166
167 m_concentrateToolBar->deleteLater();
168 }
169
170 m_mainWindow->menuBar()->setVisible(!concentrationModeOn);
171
172 if (concentrationModeOn) {
173 m_concentrateToolBar = new QToolBar(m_mainWindow);
174 m_concentrateToolBar->setObjectName(QStringLiteral("concentrateToolBar"));
175 m_concentrateToolBar->addAction(m_concentrationModeAction);
176 m_concentrateToolBar->toggleViewAction()->setVisible(false);
177 auto *action = new QWidgetAction(this);
178
179 action->setDefaultWidget(m_mainWindow->menuBar()->cornerWidget(Qt::TopRightCorner));
180 m_concentrateToolBar->addAction(action);
181 m_concentrateToolBar->setMovable(false);
182
183 m_mainWindow->addToolBar(Qt::TopToolBarArea, m_concentrateToolBar);
184 m_mainWindow->menuBar()->setCornerWidget(nullptr, Qt::TopRightCorner);
185 } else if (cornerWidget) {
186 m_mainWindow->menuBar()->setCornerWidget(cornerWidget, Qt::TopRightCorner);
187 cornerWidget->show();
188 }
189
190 if (concentrationModeOn) {
191 idealController->hideToolBars();
192 m_mainWindow->installEventFilter(this);
193 } else {
194 idealController->updateToolBarVisibility();
195 m_mainWindow->removeEventFilter(this);
196 }
197}
198
199bool MainWindowPrivate::eventFilter(QObject* obj, QEvent* event)
200{

Callers

nothing calls this directly

Calls 6

showMethod · 0.80
hideToolBarsMethod · 0.80
widgetMethod · 0.45
setVisibleMethod · 0.45
addActionMethod · 0.45

Tested by

no test coverage detected