| 2937 | } |
| 2938 | |
| 2939 | void MainWin::updateNotebookActions() { |
| 2940 | // auto* menu = static_cast<QMenu*>(factory()->container(QLatin1String("new_notebook"), this)); |
| 2941 | unplugActionList(QLatin1String("backends_list")); |
| 2942 | QList<QAction*> newBackendActions; |
| 2943 | m_newNotebookMenu->clear(); |
| 2944 | for (auto* backend : Cantor::Backend::availableBackends()) { |
| 2945 | if (!backend->isEnabled()) |
| 2946 | continue; |
| 2947 | |
| 2948 | auto* action = new QAction(QIcon::fromTheme(backend->icon()), backend->name(), this); |
| 2949 | action->setData(backend->name()); |
| 2950 | action->setWhatsThis(i18n("Creates a new %1 notebook", backend->name())); |
| 2951 | actionCollection()->addAction(QLatin1String("notebook_") + backend->name(), action); |
| 2952 | connect(action, &QAction::triggered, this, &MainWin::newNotebook); |
| 2953 | newBackendActions << action; |
| 2954 | m_newNotebookMenu->addAction(action); |
| 2955 | } |
| 2956 | |
| 2957 | plugActionList(QLatin1String("backends_list"), newBackendActions); |
| 2958 | |
| 2959 | m_newNotebookMenu->addSeparator(); |
| 2960 | m_newNotebookMenu->addAction(m_configureNotebookAction); |
| 2961 | |
| 2962 | // we just updated the notebook action list. its possible that the defaultAction isn't in the list anymore |
| 2963 | if (m_tbNotebook && !m_newNotebookMenu->actions().contains(m_tbNotebook->defaultAction())) |
| 2964 | m_tbNotebook->setDefaultAction(m_newNotebookMenu->actions().first()); |
| 2965 | } |
| 2966 | #endif |