24
#include "PreCompiled.h"
26
# include <QDockWidget>
31
#include "WorkbenchManipulator.h"
32
#include "WorkbenchPy.h"
34
#include "Application.h"
37
#include "DockWindowManager.h"
38
#include "MainWindow.h"
39
#include "MenuManager.h"
40
#include "PythonWorkbenchPy.h"
42
#include "ToolBarManager.h"
43
#include "ToolBoxManager.h"
46
#include <App/Application.h>
47
#include <App/DocumentObject.h>
48
#include <Base/Interpreter.h>
49
#include <Gui/ComboView.h>
50
#include <Gui/TaskView/TaskView.h>
51
#include <Gui/TaskView/TaskWatcher.h>
206
TYPESYSTEM_SOURCE_ABSTRACT(Gui::Workbench, Base::BaseClass)
208
Workbench::Workbench() = default;
210
Workbench::~Workbench() = default;
212
std::string Workbench::name() const
217
void Workbench::setName(const std::string& name)
222
void Workbench::setupCustomToolbars(ToolBarItem* root, const char* toolbar) const
224
std::string name = this->name();
225
const auto workbenchGroup {
226
App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Workbench")
229
if (workbenchGroup->HasGroup(name.c_str())) {
230
const auto customGroup = workbenchGroup->GetGroup(name.c_str());
231
if (customGroup->HasGroup(toolbar)) {
232
const auto customToolbarGroup = customGroup->GetGroup(toolbar);
233
setupCustomToolbars(root, customToolbarGroup);
238
if (is<NoneWorkbench>()) {
243
if (workbenchGroup->HasGroup("Global")) {
244
const auto globalGroup = workbenchGroup->GetGroup("Global");
245
if (globalGroup->HasGroup(toolbar)) {
246
const auto customToolbarGroup = globalGroup->GetGroup(toolbar);
247
setupCustomToolbars(root, customToolbarGroup);
252
void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Reference<ParameterGrp> hGrp) const
254
std::vector<Base::Reference<ParameterGrp> > hGrps = hGrp->GetGroups();
255
CommandManager& rMgr = Application::Instance->commandManager();
256
std::string separator = "Separator";
257
for (const auto & it : hGrps) {
258
bool active = it->GetBool("Active", true);
264
auto bar = new ToolBarItem(root);
265
bar->setCommand("Custom");
268
std::vector<std::pair<std::string,std::string> > items = hGrp->GetGroup(it->GetGroupName())->GetASCIIMap();
269
for (const auto & item : items) {
270
if (item.first.substr(0, separator.size()) == separator) {
273
else if (item.first == "Name") {
274
bar->setCommand(item.second);
277
Command* pCmd = rMgr.getCommandByName(item.first.c_str());
280
std::string pyMod = item.second;
282
Base::Interpreter().loadModule(pyMod.c_str());
284
pCmd = rMgr.getCommandByName(item.first.c_str());
286
catch(const Base::Exception&) {
293
std::string pyMod = item.second + "Gui";
295
Base::Interpreter().loadModule(pyMod.c_str());
297
pCmd = rMgr.getCommandByName(item.first.c_str());
299
catch(const Base::Exception&) {
311
void Workbench::setupCustomShortcuts() const
316
void Workbench::createContextMenu(const char* recipient, MenuItem* item) const
318
setupContextMenu(recipient, item);
319
WorkbenchManipulator::changeContextMenu(recipient, item);
322
void Workbench::setupContextMenu(const char* recipient,MenuItem* item) const
328
void Workbench::createMainWindowPopupMenu(MenuItem*) const
332
void Workbench::createLinkMenu(MenuItem *item) {
333
if(!item || !App::GetApplication().getActiveDocument()) {
337
auto linkMenu = new MenuItem;
338
linkMenu->setCommand("Link actions");
339
*linkMenu << "Std_LinkMakeGroup" << "Std_LinkMake";
341
auto &rMgr = Application::Instance->commandManager();
342
const char *cmds[] = {"Std_LinkMakeRelative",nullptr,"Std_LinkUnlink","Std_LinkReplace",
343
"Std_LinkImport","Std_LinkImportAll",nullptr,"Std_LinkSelectLinked",
344
"Std_LinkSelectLinkedFinal","Std_LinkSelectAllLinks"};
345
bool separator = true;
346
for(const auto & it : cmds) {
350
*linkMenu << "Separator";
354
auto cmd = rMgr.getCommandByName(it);
355
if(cmd->isActive()) {
363
std::vector<std::pair<std::string, std::string>> Workbench::staticMenuItems;
365
void Workbench::addPermanentMenuItem(const std::string& cmd, const std::string& after)
367
staticMenuItems.emplace_back(cmd, after);
370
void Workbench::removePermanentMenuItem(const std::string& cmd)
372
auto it = std::find_if(staticMenuItems.begin(), staticMenuItems.end(), [cmd](const std::pair<std::string, std::string>& pmi) {
373
return (pmi.first == cmd);
376
if (it != staticMenuItems.end()) {
377
staticMenuItems.erase(it);
381
void Workbench::addPermanentMenuItems(MenuItem* mb) const
383
for (const auto& it : staticMenuItems) {
384
MenuItem* par = mb->findParentOf(it.second);
386
Gui::MenuItem* item = par->findItem(it.second);
387
item = par->afterItem(item);
389
auto add = new Gui::MenuItem();
390
add->setCommand(it.first);
391
par->insertItem(item, add);
396
void Workbench::activated()
398
Application::Instance->commandManager().signalPyCmdInitialized();
401
void Workbench::deactivated()
405
bool Workbench::activate()
407
ToolBarItem* tb = setupToolBars();
408
setupCustomToolbars(tb, "Toolbar");
409
WorkbenchManipulator::changeToolBars(tb);
410
ToolBarManager::getInstance()->setup( tb );
418
DockWindowItems* dw = setupDockWindows();
419
WorkbenchManipulator::changeDockWindows(dw);
420
DockWindowManager::instance()->setup( dw );
423
MenuItem* mb = setupMenuBar();
424
addPermanentMenuItems(mb);
425
WorkbenchManipulator::changeMenuBar(mb);
426
MenuManager::getInstance()->setup( mb );
429
setupCustomShortcuts();
434
void Workbench::retranslate() const
436
ToolBarManager::getInstance()->retranslate();
438
DockWindowManager::instance()->retranslate();
439
MenuManager::getInstance()->retranslate();
442
PyObject* Workbench::getPyObject()
444
return new WorkbenchPy(this);
447
void Workbench::addTaskWatcher(const std::vector<Gui::TaskView::TaskWatcher*> &Watcher)
449
Gui::TaskView::TaskView* taskView = Control().taskPanel();
451
taskView->addTaskWatcher(Watcher);
455
void Workbench::removeTaskWatcher()
457
Gui::TaskView::TaskView* taskView = Control().taskPanel();
459
taskView->clearTaskWatcher();
463
std::list<std::string> Workbench::listToolbars() const
465
std::unique_ptr<ToolBarItem> tb(setupToolBars());
466
std::list<std::string> bars;
467
QList<ToolBarItem*> items = tb->getItems();
468
for (const auto & item : items) {
469
bars.push_back(item->command());
474
std::list<std::pair<std::string, std::list<std::string>>> Workbench::getToolbarItems() const
476
std::unique_ptr<ToolBarItem> tb(setupToolBars());
478
std::list<std::pair<std::string, std::list<std::string>>> itemsList;
479
QList<ToolBarItem*> items = tb->getItems();
480
for (const auto & item : items) {
481
QList<ToolBarItem*> sub = item->getItems();
482
std::list<std::string> cmds;
483
for (const auto & jt : sub) {
484
cmds.push_back(jt->command());
487
itemsList.emplace_back(item->command(), cmds);
492
std::list<std::string> Workbench::listMenus() const
494
std::unique_ptr<MenuItem> mb(setupMenuBar());
495
std::list<std::string> menus;
496
QList<MenuItem*> items = mb->getItems();
497
for (const auto & item : items) {
498
menus.push_back(item->command());
503
std::list<std::string> Workbench::listCommandbars() const
505
std::unique_ptr<ToolBarItem> cb(setupCommandBars());
506
std::list<std::string> bars;
507
QList<ToolBarItem*> items = cb->getItems();
508
for (const auto & item : items) {
509
bars.push_back(item->command());
517
qApp->translate("CommandGroup", "File");
518
qApp->translate("CommandGroup", "Edit");
519
qApp->translate("CommandGroup", "Help");
520
qApp->translate("CommandGroup", "Link");
521
qApp->translate("CommandGroup", "Tools");
522
qApp->translate("CommandGroup", "View");
523
qApp->translate("CommandGroup", "Window");
524
qApp->translate("CommandGroup", "Standard");
525
qApp->translate("CommandGroup", "Macros");
526
qApp->translate("CommandGroup", "Macro");
527
qApp->translate("CommandGroup", "Structure");
528
qApp->translate("CommandGroup", "Standard-Test");
529
qApp->translate("CommandGroup", "Standard-View");
530
qApp->translate("CommandGroup", "TreeView");
531
qApp->translate("CommandGroup", "Measure");
533
qApp->translate("Workbench", "&File");
534
qApp->translate("Workbench", "&Edit");
535
qApp->translate("Workbench", "Edit");
536
qApp->translate("Workbench", "Clipboard");
537
qApp->translate("Workbench", "Workbench");
538
qApp->translate("Workbench", "Structure");
539
qApp->translate("Workbench", "Standard views");
540
qApp->translate("Workbench", "Individual views");
541
qApp->translate("Workbench", "Axonometric");
542
qApp->translate("Workbench", "&Stereo");
543
qApp->translate("Workbench", "&Zoom");
544
qApp->translate("Workbench", "Visibility");
545
qApp->translate("Workbench", "&View");
546
qApp->translate("Workbench", "&Tools");
547
qApp->translate("Workbench", "&Macro");
548
qApp->translate("Workbench", "&Windows");
549
qApp->translate("Workbench", "&On-line help");
550
qApp->translate("Workbench", "&Help");
551
qApp->translate("Workbench", "Help");
552
qApp->translate("Workbench", "File");
553
qApp->translate("Workbench", "Macro");
554
qApp->translate("Workbench", "View");
555
qApp->translate("Workbench", "Special Ops");
557
qApp->translate("Workbench", "Link actions");
561
qApp->translate("MAC_APPLICATION_MENU", "Services");
562
qApp->translate("MAC_APPLICATION_MENU", "Hide %1");
563
qApp->translate("MAC_APPLICATION_MENU", "Hide Others");
564
qApp->translate("MAC_APPLICATION_MENU", "Show All");
565
qApp->translate("MAC_APPLICATION_MENU", "Preferences...");
566
qApp->translate("MAC_APPLICATION_MENU", "Quit %1");
567
qApp->translate("MAC_APPLICATION_MENU", "About %1");
570
TYPESYSTEM_SOURCE(Gui::StdWorkbench, Gui::Workbench)
572
StdWorkbench::StdWorkbench()
577
StdWorkbench::~StdWorkbench() = default;
579
void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
581
if (strcmp(recipient,"View") == 0)
583
createLinkMenu(item);
584
*item << "Separator";
586
auto StdViews = new MenuItem;
587
StdViews->setCommand( "Standard views" );
589
*StdViews << "Std_ViewIsometric" << "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight"
590
<< "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft"
591
<< "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight";
593
*item << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_AlignToSelection" << "Std_DrawStyle"
594
<< StdViews << "Separator"
595
<< "Std_ViewDockUndockFullscreen";
597
if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
598
*item << "Separator" << "Std_ToggleVisibility"
599
<< "Std_ToggleSelectability" << "Std_TreeSelection"
600
<< "Std_RandomColor" << "Std_ToggleTransparency" << "Separator" << "Std_Delete"
601
<< "Std_SendToPythonConsole" << "Std_TransformManip" << "Std_Placement";
604
else if (strcmp(recipient,"Tree") == 0)
606
if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
607
*item << "Std_ToggleFreeze" << "Separator"
608
<< "Std_Placement" << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
609
<< "Std_ToggleSelectability" << "Std_TreeSelectAllInstances" << "Separator"
610
<< "Std_RandomColor" << "Std_ToggleTransparency" << "Separator"
611
<< "Std_Cut" << "Std_Copy" << "Std_Paste" << "Std_Delete"
612
<< "Std_SendToPythonConsole" << "Separator";
617
void StdWorkbench::createMainWindowPopupMenu(MenuItem* item) const
619
*item << "Std_ToggleToolBarLock";
620
*item << "Std_DlgCustomize";
623
MenuItem* StdWorkbench::setupMenuBar() const
626
auto menuBar = new MenuItem;
629
auto file = new MenuItem( menuBar );
630
file->setCommand("&File");
631
*file << "Std_New" << "Std_Open" << "Std_RecentFiles" << "Separator" << "Std_CloseActiveWindow"
632
<< "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs"
633
<< "Std_SaveCopy" << "Std_SaveAll" << "Std_Revert" << "Separator" << "Std_Import"
634
<< "Std_Export" << "Std_MergeProjects" << "Std_ProjectInfo"
635
<< "Separator" << "Std_Print" << "Std_PrintPreview" << "Std_PrintPdf"
636
<< "Separator" << "Std_Quit";
639
auto edit = new MenuItem( menuBar );
640
edit->setCommand("&Edit");
641
*edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
642
<< "Std_Paste" << "Std_DuplicateSelection" << "Separator"
643
<< "Std_Refresh" << "Std_BoxSelection" << "Std_BoxElementSelection"
644
<< "Std_SelectAll" << "Std_Delete" << "Std_SendToPythonConsole"
645
<< "Separator" << "Std_Placement" << "Std_TransformManip" << "Std_Alignment"
646
<< "Std_Edit" << "Std_Properties" << "Separator" << "Std_UserEditMode" << "Separator" << "Std_DlgPreferences";
648
auto axoviews = new MenuItem;
649
axoviews->setCommand("Axonometric");
650
*axoviews << "Std_ViewIsometric"
651
<< "Std_ViewDimetric"
652
<< "Std_ViewTrimetric";
655
auto stdviews = new MenuItem;
656
stdviews->setCommand("Standard views");
657
*stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_AlignToSelection" << axoviews
658
<< "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop"
659
<< "Std_ViewRight" << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft"
660
<< "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight" << "Separator"
661
<< "Std_StoreWorkingView" << "Std_RecallWorkingView";
664
auto view3d = new MenuItem;
665
view3d->setCommand("&Stereo");
666
*view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff"
667
<< "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns"
668
<< "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos";
671
auto zoom = new MenuItem;
672
zoom->setCommand("&Zoom");
673
*zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
676
auto visu = new MenuItem;
677
visu->setCommand("Visibility");
678
*visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
679
<< "Std_SelectVisibleObjects"
680
<< "Separator" << "Std_ToggleObjects" << "Std_ShowObjects" << "Std_HideObjects"
681
<< "Separator" << "Std_ToggleSelectability";
684
auto view = new MenuItem( menuBar );
685
view->setCommand("&View");
686
*view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Std_MainFullscreen" << "Separator"
687
<< stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Std_SelBoundingBox"
688
<< "Separator" << view3d << zoom
689
<< "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane"
690
<< "Std_TextureMapping"
694
<< "Separator" << visu
695
<< "Std_ToggleNavigation"
697
<< "Std_ToggleTransparency"
701
<< "Std_DockViewMenu";
702
if (DockWindowManager::instance()->isOverlayActivated()) {
703
*view << "Std_DockOverlay";
706
<< "Std_LinkSelectActions"
707
<< "Std_TreeViewActions"
708
<< "Std_ViewStatusBar";
711
auto tool = new MenuItem( menuBar );
712
tool->setCommand("&Tools");
713
*tool << "Std_DlgParameter"
715
<< "Std_ViewScreenShot"
716
<< "Std_ViewLoadImage"
717
<< "Std_SceneInspector"
718
<< "Std_DependencyGraph"
719
<< "Std_ExportDependencyGraph"
722
<< "Std_TextDocument"
725
<< "Std_UnitsCalculator"
727
<< "Std_DlgCustomize";
729
*tool << "Std_AddonMgr";
733
auto macro = new MenuItem( menuBar );
734
macro->setCommand("&Macro");
735
*macro << "Std_DlgMacroRecord"
736
<< "Std_DlgMacroExecute"
737
<< "Std_RecentMacros"
739
<< "Std_DlgMacroExecuteDirect"
740
<< "Std_MacroAttachDebugger"
741
<< "Std_MacroStartDebug"
742
<< "Std_MacroStopDebug"
743
<< "Std_MacroStepOver"
744
<< "Std_MacroStepInto"
745
<< "Std_ToggleBreakpoint";
748
auto wnd = new MenuItem( menuBar );
749
wnd->setCommand("&Windows");
750
*wnd << "Std_ActivateNextWindow" << "Std_ActivatePrevWindow" << "Separator"
751
<< "Std_TileWindows" << "Std_CascadeWindows" << "Separator"
752
<< "Std_WindowsMenu" << "Std_Windows";
755
auto sep = new MenuItem( menuBar );
756
sep->setCommand( "Separator" );
759
auto help = new MenuItem( menuBar );
760
help->setCommand("&Help");
761
*help << "Std_OnlineHelp" << "Std_FreeCADWebsite" << "Std_FreeCADDonation"
762
<< "Std_FreeCADUserHub" << "Std_FreeCADPowerUserHub"
763
<< "Std_PythonHelp" << "Std_FreeCADForum" << "Std_FreeCADFAQ"
764
<< "Std_ReportBug" << "Std_About" << "Std_WhatsThis";
769
ToolBarItem* StdWorkbench::setupToolBars() const
771
auto root = new ToolBarItem;
774
auto file = new ToolBarItem( root );
775
file->setCommand("File");
776
*file << "Std_New" << "Std_Open" << "Std_Save";
779
auto edit = new ToolBarItem( root );
780
edit->setCommand("Edit");
781
*edit << "Std_Undo" << "Std_Redo"
782
<< "Separator" << "Std_Refresh";
785
auto clipboard = new ToolBarItem( root , ToolBarItem::DefaultVisibility::Hidden );
786
clipboard->setCommand("Clipboard");
787
*clipboard << "Std_Cut" << "Std_Copy" << "Std_Paste";
790
auto wb = new ToolBarItem(root);
791
wb->setCommand("Workbench");
792
*wb << "Std_Workbench";
795
auto macro = new ToolBarItem( root, ToolBarItem::DefaultVisibility::Hidden);
796
macro->setCommand("Macro");
797
*macro << "Std_DlgMacroRecord" << "Std_DlgMacroExecute"
798
<< "Std_DlgMacroExecuteDirect";
801
auto view = new ToolBarItem( root );
802
view->setCommand("View");
803
*view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewGroup" << "Std_AlignToSelection"
804
<< "Separator" << "Std_DrawStyle" << "Std_TreeViewActions";
807
auto individualViews = new ToolBarItem(root, ToolBarItem::DefaultVisibility::Hidden);
808
individualViews->setCommand("Individual views");
809
*individualViews << "Std_ViewIsometric"
818
auto structure = new ToolBarItem( root );
819
structure->setCommand("Structure");
820
*structure << "Std_Part" << "Std_Group" << "Std_LinkActions" << "Std_VarSet";
823
auto help = new ToolBarItem( root );
824
help->setCommand("Help");
825
*help << "Std_WhatsThis";
830
ToolBarItem* StdWorkbench::setupCommandBars() const
832
auto root = new ToolBarItem;
835
auto view = new ToolBarItem( root );
836
view->setCommand("Standard views");
837
*view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewIsometric" << "Separator"
838
<< "Std_ViewFront" << "Std_ViewRight" << "Std_ViewTop"
839
<< "Std_ViewRear" << "Std_ViewLeft" << "Std_ViewBottom";
842
auto macro = new ToolBarItem( root );
843
macro->setCommand("Special Ops");
844
*macro << "Std_DlgParameter" << "Std_DlgPreferences" << "Std_DlgMacroRecord"
845
<< "Std_DlgMacroExecute" << "Std_DlgCustomize";
850
DockWindowItems* StdWorkbench::setupDockWindows() const
852
auto root = new DockWindowItems();
853
root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, true, false);
854
root->addDockWidget("Std_PropertyView", Qt::LeftDockWidgetArea, true, false);
855
root->addDockWidget("Std_SelectionView", Qt::LeftDockWidgetArea, false, false);
856
root->addDockWidget("Std_ComboView", Qt::LeftDockWidgetArea, true, true);
857
root->addDockWidget("Std_TaskView", Qt::LeftDockWidgetArea, true, true);
858
root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, false, true);
859
root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, false, true);
862
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
863
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("DockWindows")->GetGroup("DAGView");
865
bool enabled = group->GetBool("Enabled", false);
867
root->addDockWidget("Std_DAGView", Qt::RightDockWidgetArea, false, false);
875
TYPESYSTEM_SOURCE(Gui::BlankWorkbench, Gui::Workbench)
877
BlankWorkbench::BlankWorkbench()
882
BlankWorkbench::~BlankWorkbench() = default;
884
void BlankWorkbench::activated()
886
QList<QDockWidget*> dw = getMainWindow()->findChildren<QDockWidget*>();
887
for (auto & it : dw) {
888
it->toggleViewAction()->setVisible(false);
890
getMainWindow()->statusBar()->hide();
893
void BlankWorkbench::deactivated()
895
getMainWindow()->statusBar()->show();
898
void BlankWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const
904
MenuItem* BlankWorkbench::setupMenuBar() const
906
return new MenuItem();
909
ToolBarItem* BlankWorkbench::setupToolBars() const
911
return new ToolBarItem();
914
ToolBarItem* BlankWorkbench::setupCommandBars() const
916
return new ToolBarItem();
919
DockWindowItems* BlankWorkbench::setupDockWindows() const
921
return new DockWindowItems();
926
TYPESYSTEM_SOURCE(Gui::NoneWorkbench, Gui::StdWorkbench)
928
NoneWorkbench::NoneWorkbench()
933
NoneWorkbench::~NoneWorkbench() = default;
935
void NoneWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const
941
MenuItem* NoneWorkbench::setupMenuBar() const
944
auto menuBar = new MenuItem;
947
auto file = new MenuItem( menuBar );
948
file->setCommand("&File");
952
auto edit = new MenuItem( menuBar );
953
edit->setCommand("&Edit");
954
*edit << "Std_DlgPreferences";
957
auto view = new MenuItem( menuBar );
958
view->setCommand("&View");
959
*view << "Std_Workbench";
962
auto sep = new MenuItem( menuBar );
963
sep->setCommand("Separator");
966
auto help = new MenuItem( menuBar );
967
help->setCommand("&Help");
968
*help << "Std_OnlineHelp" << "Std_About";
973
ToolBarItem* NoneWorkbench::setupToolBars() const
975
auto root = new ToolBarItem;
979
ToolBarItem* NoneWorkbench::setupCommandBars() const
981
auto root = new ToolBarItem;
985
DockWindowItems* NoneWorkbench::setupDockWindows() const
987
auto root = new DockWindowItems();
988
root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, false);
994
TYPESYSTEM_SOURCE(Gui::TestWorkbench, Gui::Workbench)
996
TestWorkbench::TestWorkbench()
1001
TestWorkbench::~TestWorkbench() = default;
1003
MenuItem* TestWorkbench::setupMenuBar() const
1006
MenuItem* menuBar = StdWorkbench::setupMenuBar();
1008
MenuItem* item = menuBar->findItem("&Help");
1009
item->removeItem(item->findItem("Std_WhatsThis"));
1012
auto test = new MenuItem;
1013
menuBar->insertItem( item, test );
1014
test->setCommand( "Test &Commands" );
1015
*test << "Std_Test1" << "Std_Test2" << "Std_Test3" << "Std_Test4" << "Std_Test5"
1016
<< "Std_Test6" << "Std_Test7" << "Std_Test8";
1019
auto opiv = new MenuItem;
1020
menuBar->insertItem( item, opiv );
1021
opiv->setCommand("&Inventor View");
1022
*opiv << "Std_ViewExample1" << "Std_ViewExample2" << "Std_ViewExample3";
1027
ToolBarItem* TestWorkbench::setupToolBars() const
1032
ToolBarItem* TestWorkbench::setupCommandBars() const
1039
TYPESYSTEM_SOURCE_ABSTRACT(Gui::PythonBaseWorkbench, Gui::Workbench)
1041
PythonBaseWorkbench::PythonBaseWorkbench() = default;
1043
PythonBaseWorkbench::~PythonBaseWorkbench()
1046
delete _contextMenu;
1050
_workbenchPy->setInvalid();
1051
_workbenchPy->DecRef();
1055
PyObject* PythonBaseWorkbench::getPyObject()
1059
_workbenchPy = new PythonWorkbenchPy(this);
1063
_workbenchPy->IncRef();
1065
return _workbenchPy;
1068
MenuItem* PythonBaseWorkbench::setupMenuBar() const
1070
return _menuBar->copy();
1073
ToolBarItem* PythonBaseWorkbench::setupToolBars() const
1075
return _toolBar->copy();
1078
ToolBarItem* PythonBaseWorkbench::setupCommandBars() const
1080
return _commandBar->copy();
1083
DockWindowItems* PythonBaseWorkbench::setupDockWindows() const
1085
return new DockWindowItems();
1088
void PythonBaseWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
1090
Q_UNUSED(recipient);
1091
QList<MenuItem*> items = _contextMenu->getItems();
1092
for (const auto & it : items) {
1093
item->appendItem(it->copy());
1097
void PythonBaseWorkbench::appendMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
1099
if ( menu.empty() || items.empty() ) {
1103
auto jt=menu.begin();
1104
MenuItem* item = _menuBar->findItem( *jt );
1106
item = new MenuItem;
1107
item->setCommand( *jt );
1108
Gui::MenuItem* wnd = _menuBar->findItem( "&Windows" );
1110
_menuBar->insertItem(wnd, item);
1113
_menuBar->appendItem(item);
1118
for ( jt++; jt != menu.end(); jt++ )
1120
MenuItem* subitem = item->findItem( *jt );
1123
subitem = new MenuItem(item);
1124
subitem->setCommand( *jt );
1129
for (const auto & it : items) {
1134
void PythonBaseWorkbench::removeMenu(const std::string& menu) const
1136
MenuItem* item = _menuBar->findItem(menu);
1138
_menuBar->removeItem(item);
1143
void PythonBaseWorkbench::appendContextMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
1145
MenuItem* item = _contextMenu;
1146
for (const auto & jt : menu) {
1147
MenuItem* subitem = item->findItem(jt);
1149
subitem = new MenuItem(item);
1150
subitem->setCommand(jt);
1155
for (const auto & it : items) {
1160
void PythonBaseWorkbench::removeContextMenu(const std::string& menu) const
1162
MenuItem* item = _contextMenu->findItem(menu);
1164
_contextMenu->removeItem(item);
1169
void PythonBaseWorkbench::clearContextMenu()
1171
_contextMenu->clear();
1174
void PythonBaseWorkbench::appendToolbar(const std::string& bar, const std::list<std::string>& items) const
1176
ToolBarItem* item = _toolBar->findItem(bar);
1178
item = new ToolBarItem(_toolBar);
1179
item->setCommand(bar);
1182
for (const auto & it : items) {
1187
void PythonBaseWorkbench::removeToolbar(const std::string& bar) const
1189
ToolBarItem* item = _toolBar->findItem(bar);
1191
_toolBar->removeItem(item);
1196
void PythonBaseWorkbench::appendCommandbar(const std::string& bar, const std::list<std::string>& items) const
1198
ToolBarItem* item = _commandBar->findItem( bar );
1200
item = new ToolBarItem(_commandBar);
1201
item->setCommand(bar);
1204
for (const auto & it : items) {
1209
void PythonBaseWorkbench::removeCommandbar(const std::string& bar) const
1211
ToolBarItem* item = _commandBar->findItem(bar);
1213
_commandBar->removeItem(item);
1220
TYPESYSTEM_SOURCE(Gui::PythonBlankWorkbench, Gui::PythonBaseWorkbench)
1222
PythonBlankWorkbench::PythonBlankWorkbench()
1224
_menuBar = new MenuItem;
1225
_contextMenu = new MenuItem;
1226
_toolBar = new ToolBarItem;
1227
_commandBar = new ToolBarItem;
1230
PythonBlankWorkbench::~PythonBlankWorkbench() = default;
1234
TYPESYSTEM_SOURCE(Gui::PythonWorkbench, Gui::PythonBaseWorkbench)
1236
PythonWorkbench::PythonWorkbench()
1239
_menuBar = wb.setupMenuBar();
1240
_contextMenu = new MenuItem;
1241
_toolBar = wb.setupToolBars();
1242
_commandBar = new ToolBarItem;
1245
PythonWorkbench::~PythonWorkbench() = default;
1247
MenuItem* PythonWorkbench::setupMenuBar() const
1249
return _menuBar->copy();
1252
ToolBarItem* PythonWorkbench::setupToolBars() const
1254
return _toolBar->copy();
1257
ToolBarItem* PythonWorkbench::setupCommandBars() const
1259
return _commandBar->copy();
1262
DockWindowItems* PythonWorkbench::setupDockWindows() const
1265
return wb.setupDockWindows();
1268
void PythonWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
1271
wb.setupContextMenu(recipient, item);
1272
PythonBaseWorkbench::setupContextMenu(recipient, item);
1275
void PythonWorkbench::createMainWindowPopupMenu(MenuItem* item) const
1278
wb.createMainWindowPopupMenu(item);