MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / showDialog

Method showDialog

src/Gui/TaskView/TaskView.cpp:632–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630/// @endcond
631
632bool TaskView::showDialog(TaskDialog* dlg, App::Document* doc)
633{
634 auto foundTaskInfo = std::ranges::find(taskInfos, doc, &TaskInfo::Document);
635 // if trying to open the same dialog twice nothing needs to be done
636 if (foundTaskInfo != taskInfos.end() && foundTaskInfo->ActiveDialog == dlg) {
637 return false;
638 }
639 assert(foundTaskInfo == taskInfos.end());
640
641 TaskInfo outInfo {.Document = doc};
642 // first create the control element, set it up and wire it:
643 outInfo.ActiveCtrl = new TaskEditControl(this);
644 outInfo.ActiveCtrl->buttonBox->setStandardButtons(dlg->getStandardButtons());
645 TaskDialogAttorney::setButtonBox(dlg, outInfo.ActiveCtrl->buttonBox);
646
647 const std::vector<QWidget*>& cont = dlg->getDialogContent();
648
649 // give to task dialog to customize the button box
650 dlg->modifyStandardButtons(outInfo.ActiveCtrl->buttonBox);
651
652 outInfo.taskPanel = new TaskPanel(this);
653 if (dlg->buttonPosition() == TaskDialog::North) {
654 // Add button box to the top of the main layout
655 outInfo.taskPanel->dialogLayout->insertWidget(0, outInfo.ActiveCtrl);
656 for (const auto& it : cont) {
657 outInfo.taskPanel->actionPanel->addWidget(it);
658 }
659 }
660 else {
661 for (const auto& it : cont) {
662 outInfo.taskPanel->actionPanel->addWidget(it);
663 }
664 // Add button box to the bottom of the main layout
665 outInfo.taskPanel->dialogLayout->addWidget(outInfo.ActiveCtrl);
666 }
667
668 outInfo.taskPanel->actionPanel->setScheme(QSint::ActionPanelScheme::defaultScheme());
669
670 if (!dlg->needsFullSpace()) {
671 outInfo.taskPanel->actionPanel->addStretch();
672 }
673
674 // set as active Dialog
675 outInfo.ActiveDialog = dlg;
676 outInfo.ActiveDialog->open();
677
678 // clang-format off
679 // make connection to the needed signals
680 connect(outInfo.ActiveCtrl->buttonBox, &QDialogButtonBox::accepted,
681 this, [doc, this]{ accept(doc); });
682 connect(outInfo.ActiveCtrl->buttonBox, &QDialogButtonBox::rejected,
683 this, [doc, this]{ reject(doc); });
684 connect(outInfo.ActiveCtrl->buttonBox, &QDialogButtonBox::helpRequested,
685 this, [doc, this]{ helpRequested(doc); });
686 connect(outInfo.ActiveCtrl->buttonBox, &QDialogButtonBox::clicked,
687 this, [doc, this](QAbstractButton *button) { clicked(button, doc); });
688 // clang-format on
689

Callers 1

browseMethod · 0.45

Calls 15

acceptFunction · 0.85
setStandardButtonsMethod · 0.80
getDialogContentMethod · 0.80
addStretchMethod · 0.80
findFunction · 0.50
connectFunction · 0.50
getMainWindowFunction · 0.50
instanceFunction · 0.50
endMethod · 0.45
getStandardButtonsMethod · 0.45
modifyStandardButtonsMethod · 0.45
insertWidgetMethod · 0.45

Tested by

no test coverage detected