| 53 | } |
| 54 | |
| 55 | void AreaDisplay::newArea(Sublime::Area* area) |
| 56 | { |
| 57 | if(m_button->menu()) |
| 58 | m_button->menu()->deleteLater(); |
| 59 | |
| 60 | Sublime::Area* currentArea = m_mainWindow->area(); |
| 61 | |
| 62 | m_button->setText(currentArea->title()); |
| 63 | m_button->setIcon(QIcon::fromTheme(currentArea->iconName())); |
| 64 | |
| 65 | auto* m = new QMenu(m_button); |
| 66 | m->addActions(area->actions()); |
| 67 | if (currentArea->objectName() != QLatin1String("code")) { |
| 68 | if(!m->actions().isEmpty()) |
| 69 | m->addSeparator(); |
| 70 | m->addAction(QIcon::fromTheme(QStringLiteral("document-edit")), i18nc("@action:inmenu", "Back to Code"), |
| 71 | QKeySequence(Qt::AltModifier | Qt::Key_Backspace), this, &AreaDisplay::backToCode); |
| 72 | } |
| 73 | m_button->setMenu(m); |
| 74 | |
| 75 | //remove the additional widgets we might have added for the last area |
| 76 | auto* l = qobject_cast<QBoxLayout*>(layout()); |
| 77 | if(l->count()>=4) { |
| 78 | QLayoutItem* item = l->takeAt(0); |
| 79 | delete item->widget(); |
| 80 | delete item; |
| 81 | } |
| 82 | QWidget* w = Core::self()->workingSetControllerInternal()->createSetManagerWidget(m_mainWindow, area); |
| 83 | w->installEventFilter(this); |
| 84 | m_separator->setVisible(w->isVisible()); |
| 85 | l->insertWidget(0, w); |
| 86 | } |
| 87 | |
| 88 | bool AreaDisplay::eventFilter(QObject* obj, QEvent* event) |
| 89 | { |
nothing calls this directly
no test coverage detected