| 154 | } |
| 155 | |
| 156 | void 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 | |
| 199 | bool MainWindowPrivate::eventFilter(QObject* obj, QEvent* event) |
| 200 | { |
nothing calls this directly
no test coverage detected