Skip to content
Snippets Groups Projects
Commit ea014b84 authored by Jochen Becher's avatar Jochen Becher
Browse files

ModelEditor: Disable menu item if no diagram is open


Change-Id: I95937f4533307364b6eb1fb42ab821c825883346
Task-number: QTCREATORBUG-15853
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 179a28f7
No related branches found
No related tags found
No related merge requests found
......@@ -145,7 +145,7 @@ void ActionHandler::createActions()
menuTools->addMenu(menuModelEditor);
Core::Command *exportDiagramCommand = registerCommand(
Constants::EXPORT_DIAGRAM, [this]() { exportDiagram(); }, Core::Context(), true,
Constants::EXPORT_DIAGRAM, [this]() { exportDiagram(); }, d->context, true,
tr("Export Diagram..."));
menuModelEditor->addAction(exportDiagramCommand);
d->exportDiagramAction = exportDiagramCommand->action();
......
......@@ -596,6 +596,7 @@ void ModelEditor::updateSelectedArea(SelectedArea selectedArea)
bool canSelectAll = false;
bool canCopyDiagram = false;
bool canOpenParentDiagram = false;
bool canExportDiagram = false;
QList<qmt::MElement *> propertiesModelElements;
QList<qmt::DElement *> propertiesDiagramElements;
qmt::MDiagram *propertiesDiagram = 0;
......@@ -604,10 +605,12 @@ void ModelEditor::updateSelectedArea(SelectedArea selectedArea)
switch (d->selectedArea) {
case SelectedArea::Nothing:
canSelectAll = activeDiagram && !activeDiagram->diagramElements().isEmpty();
canExportDiagram = activeDiagram != 0;
break;
case SelectedArea::Diagram:
{
if (activeDiagram) {
canExportDiagram = true;
bool hasSelection = documentController->diagramsManager()->diagramSceneModel(activeDiagram)->hasSelection();
canCutCopyDelete = hasSelection;
canRemove = hasSelection;
......@@ -631,6 +634,7 @@ void ModelEditor::updateSelectedArea(SelectedArea selectedArea)
}
case SelectedArea::TreeView:
{
canExportDiagram = activeDiagram != 0;
bool hasSelection = !d->modelTreeViewServant->selectedObjects().isEmpty();
bool hasSingleSelection = d->modelTreeViewServant->selectedObjects().indices().size() == 1;
canCutCopyDelete = hasSelection && !d->modelTreeViewServant->isRootPackageSelected();
......@@ -658,6 +662,7 @@ void ModelEditor::updateSelectedArea(SelectedArea selectedArea)
d->actionHandler->deleteAction()->setEnabled(canCutCopyDelete);
d->actionHandler->selectAllAction()->setEnabled(canSelectAll);
d->actionHandler->openParentDiagramAction()->setEnabled(canOpenParentDiagram);
d->actionHandler->exportDiagramAction()->setEnabled(canExportDiagram);
if (!propertiesModelElements.isEmpty())
showProperties(propertiesModelElements);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment