FreeCAD

Форк
0
/
Workbench.cpp 
1279 строк · 42.6 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23

24
#include "PreCompiled.h"
25
#ifndef _PreComp_
26
# include <QDockWidget>
27
# include <QStatusBar>
28
#endif
29

30
#include "Workbench.h"
31
#include "WorkbenchManipulator.h"
32
#include "WorkbenchPy.h"
33
#include "Action.h"
34
#include "Application.h"
35
#include "Command.h"
36
#include "Control.h"
37
#include "DockWindowManager.h"
38
#include "MainWindow.h"
39
#include "MenuManager.h"
40
#include "PythonWorkbenchPy.h"
41
#include "Selection.h"
42
#include "ToolBarManager.h"
43
#include "ToolBoxManager.h"
44
#include "Window.h"
45

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>
52

53
using namespace Gui;
54

55
/** \defgroup workbench Workbench Framework
56
    \ingroup GUI
57

58
    FreeCAD provides the possibility to have one or more workbenches for a module.
59
    A workbench changes the appearance of the main window in that way that it defines toolbars, items in the toolbox, menus or the context menu and dockable windows that are shown to the user.
60
    The idea behind this concept is that the user should see only the functions that are required for the task that they are doing at this moment and not to show dozens of unneeded functions which the user never uses.
61

62
    \section stepbystep Step by step
63
    Here follows a short description of how your own workbench can be added to a module.
64

65
    \subsection newClass Inherit either from Workbench or StdWorkbench
66
    First you have to subclass either \ref Gui::Workbench "Workbench" or \ref Gui::StdWorkbench "StdWorkbench" and reimplement the methods \ref Gui::Workbench::setupMenuBar() "setupMenuBar()", \ref Gui::Workbench::setupToolBars() "setupToolBars()", \ref Gui::Workbench::setupCommandBars() "setupCommandBars()" and \ref Gui::Workbench::setupDockWindows() "setupDockWindows()".
67

68
    The difference between both classes is that these methods of %Workbench are pure virtual while StdWorkbench defines already the standard menus and toolbars, such as the 'File', 'Edit', ..., 'Help' menus with their common functions.
69

70
    If your class derives from %Workbench then you have to define your menus, toolbars and toolbox items from scratch while deriving from StdWorkbench you have the possibility to add your preferred functions or even remove some unneeded functions.
71
 * \code
72
 *
73
 * class MyWorkbench : public StdWorkbench
74
 * {
75
 *  ...
76
 * protected:
77
 *   MenuItem* setupMenuBar() const
78
 *   {
79
 *     MenuItem* root = StdWorkbench::setupMenuBar();
80
 *     // your changes
81
 *     return root;
82
 *   }
83
 *   ToolBarItem* setupToolBars() const
84
 *   {
85
 *     ToolBarItem* root = StdWorkbench::setupToolBars();
86
 *     // your changes
87
 *     return root;
88
 *   }
89
 *   ToolBarItem* setupCommandBars() const
90
 *   {
91
 *     ToolBarItem* root = StdWorkbench::setupCommandBars();
92
 *     // your changes
93
 *     return root;
94
 *   }
95
 * };
96
 *
97
 * \endcode
98
 * or
99
 * \code
100
 *
101
 * class MyWorkbench : public Workbench
102
 * {
103
 *  ...
104
 * protected:
105
 *   MenuItem* setupMenuBar() const
106
 *   {
107
 *     MenuItem* root = new MenuItem;
108
 *     // setup from scratch
109
 *     return root;
110
 *   }
111
 *   ToolBarItem* setupToolBars() const
112
 *   {
113
 *     ToolBarItem* root = new ToolBarItem;
114
 *     // setup from scratch
115
 *     return root;
116
 *   }
117
 *   ToolBarItem* setupCommandBars() const
118
 *   {
119
 *     ToolBarItem* root = new ToolBarItem;
120
 *     // setup from scratch
121
 *     return root;
122
 *   }
123
 * };
124
 *
125
 * \endcode
126
 *
127
 * \subsection customizeWorkbench Customizing the workbench
128
 * If you want to customize your workbench by adding or removing items you can use the ToolBarItem class for customizing toolbars and the MenuItem class
129
 * for menus. Both classes behave basically the same.
130
 * To add a new menu item you can do it as follows
131
 * \code
132
 *   MenuItem* setupMenuBar() const
133
 *   {
134
 *     MenuItem* root = StdWorkbench::setupMenuBar();
135
 *     // create a sub menu
136
 *     MenuItem* mySub = new MenuItem; // note: no parent is given
137
 *     mySub->setCommand( "My &Submenu" );
138
 *     *mySub << "Std_Undo" << "Std_Redo";
139
 *
140
 *     // My menu
141
 *     MenuItem* myMenu = new MenuItem( root );
142
 *     myMenu->setCommand( "&My Menu" );
143
 *     // fill up the menu with some command items
144
 *     *myMenu << mySub << "Separator" << "Std_Cut" << "Std_Copy" << "Std_Paste" << "Separator" << "Std_Undo" << "Std_Redo";
145
 *   }
146
 * \endcode
147
 *
148
 * Toolbars can be customized the same way unless that you shouldn't create subitems (there are no subtoolbars).
149
 *
150
 * \subsection regWorkbench Register your workbench
151
 * Once you have implemented your workbench class you have to register it to make it known to the FreeCAD core system. You must make sure that the step
152
 * of registration is performed only once. A good place to do it is e.g. in the global function initMODULEGui in AppMODULEGui.cpp where MODULE stands
153
 * for the name of your module. Just add the line
154
 * \code
155
 * MODULEGui::MyWorkbench::init();
156
 * \endcode
157
 * somewhere there.
158
 *
159
 * \subsection itemWorkbench Create an item for your workbench
160
 * Though your workbench has been registered now,  at this stage you still cannot invoke it yet. Therefore you must create an item in the list of all visible
161
 * workbenches. To perform this step you must open your InitGui.py (a Python file) and do some adjustments. The file contains already a Python class
162
 * MODULEWorkbench that implements the Activate() method (it imports the needed library). You can also implement the GetIcon() method to set your own icon for
163
 * your workbench, if not, the default FreeCAD icon is taken, and finally the most important method GetClassName(). that represents the link between
164
 * Python and C++. This method must return the name of the associated C++ including namespace. In this case it must the string "ModuleGui::MyWorkbench".
165
 * At the end you can change the line from
166
 * \code
167
 * Gui.addWorkbench("MODULE design",MODULEWorkbench())
168
 * \endcode
169
 * to
170
 * \code
171
 * Gui.addWorkbench("My workbench",MODULEWorkbench())
172
 * \endcode
173
 * or whatever you want.
174
 * \note You must make sure to choose a unique name for your workbench (in this example "My workbench"). Since FreeCAD doesn't provide a mechanism for
175
 * this you have to care on your own.
176
 *
177
 * \section moredetails More details and limitations
178
 * One of the key concepts of the workbench framework is to load a module at runtime when the user needs some function that it
179
 * provides. So, if the user doesn't need a module it never gets loaded into RAM. This speeds up the startup procedure of
180
 * FreeCAD and saves memory.
181
 *
182
 * At startup FreeCAD scans all module directories and invokes InitGui.py. So an item for a workbench gets created. If the user
183
 * clicks on such an item the matching module gets loaded, the C++ workbench gets registered and activated.
184
 *
185
 * The user is able to modify a workbench (Edit|Customize). E.g. they can add new toolbars or items for the toolbox and add their preferred
186
 * functions to them. But the user only has full control over "their" own toolbars, the default workbench items cannot be modified or even removed.
187
 *
188
 * FreeCAD provides also the possibility to define pure Python workbenches. Such workbenches are temporarily only and are lost after exiting
189
 * the FreeCAD session. But if you want to keep your Python workbench you can write a macro and attach it with a user defined button or just
190
 * perform the macro during the next FreeCAD session.
191
 * Here follows a short example of how to create and embed a workbench in Python
192
 * \code
193
 * w=Workbench()                                              # creates a standard workbench (the same as StdWorkbench in C++)
194
 * w.MenuText = "My Workbench"                                # the text that will appear in the combo box
195
 * dir(w)                                                     # lists all available function of the object
196
 * FreeCADGui.addWorkbench(w)                                 # Creates an item for our workbench now
197
 *                                                            # Note: We must first add the workbench to run some initialization code
198
 *                                                            # Then we are ready to customize the workbench
199
 * list = ["Std_Test1", "Std_Test2", "Std_Test3"]             # creates a list of new functions
200
 * w.appendMenu("Test functions", list)                       # creates a new menu with these functions
201
 * w.appendToolbar("Test", list)                              # ... and also a new toolbar
202
 * \endcode
203
 */
204

205
/// @namespace Gui @class Workbench
206
TYPESYSTEM_SOURCE_ABSTRACT(Gui::Workbench, Base::BaseClass)
207

208
Workbench::Workbench() = default;
209

210
Workbench::~Workbench() = default;
211

212
std::string Workbench::name() const
213
{
214
    return _name;
215
}
216

217
void Workbench::setName(const std::string& name)
218
{
219
    _name = name;
220
}
221

222
void Workbench::setupCustomToolbars(ToolBarItem* root, const char* toolbar) const
223
{
224
    std::string name = this->name();
225
    const auto workbenchGroup {
226
        App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Workbench")
227
    };
228
    // workbench specific custom toolbars
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);
234
        }
235
    }
236

237
    // for this workbench global toolbars are not allowed
238
    if (is<NoneWorkbench>()) {
239
        return;
240
    }
241

242
    // application-wide custom toolbars
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);
248
        }
249
    }
250
}
251

252
void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Reference<ParameterGrp> hGrp) const
253
{
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);
259
        if (!active) {
260
            // ignore this toolbar
261
            continue;
262
        }
263

264
        auto bar = new ToolBarItem(root);
265
        bar->setCommand("Custom");
266

267
        // get the elements of the subgroups
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) {
271
                *bar << "Separator";
272
            }
273
            else if (item.first == "Name") {
274
                bar->setCommand(item.second);
275
            }
276
            else {
277
                Command* pCmd = rMgr.getCommandByName(item.first.c_str());
278
                if (!pCmd) { // unknown command
279
                    // first try the module name as is
280
                    std::string pyMod = item.second;
281
                    try {
282
                        Base::Interpreter().loadModule(pyMod.c_str());
283
                        // Try again
284
                        pCmd = rMgr.getCommandByName(item.first.c_str());
285
                    }
286
                    catch(const Base::Exception&) {
287
                    }
288
                }
289

290
                // still not there?
291
                if (!pCmd) {
292
                    // add the 'Gui' suffix
293
                    std::string pyMod = item.second + "Gui";
294
                    try {
295
                        Base::Interpreter().loadModule(pyMod.c_str());
296
                        // Try again
297
                        pCmd = rMgr.getCommandByName(item.first.c_str());
298
                    }
299
                    catch(const Base::Exception&) {
300
                    }
301
                }
302

303
                if (pCmd) {
304
                    *bar << item.first; // command name
305
                }
306
            }
307
        }
308
    }
309
}
310

311
void Workbench::setupCustomShortcuts() const
312
{
313
    // Now managed by ShortcutManager
314
}
315

316
void Workbench::createContextMenu(const char* recipient, MenuItem* item) const
317
{
318
    setupContextMenu(recipient, item);
319
    WorkbenchManipulator::changeContextMenu(recipient, item);
320
}
321

322
void Workbench::setupContextMenu(const char* recipient,MenuItem* item) const
323
{
324
    Q_UNUSED(recipient);
325
    Q_UNUSED(item);
326
}
327

328
void Workbench::createMainWindowPopupMenu(MenuItem*) const
329
{
330
}
331

332
void Workbench::createLinkMenu(MenuItem *item) {
333
    if(!item || !App::GetApplication().getActiveDocument()) {
334
        return;
335
    }
336

337
    auto linkMenu = new MenuItem;
338
    linkMenu->setCommand("Link actions");
339
    *linkMenu << "Std_LinkMakeGroup" << "Std_LinkMake";
340

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) {
347
        if(!it) {
348
            if(separator) {
349
                separator = false;
350
                *linkMenu << "Separator";
351
            }
352
            continue;
353
        }
354
        auto cmd = rMgr.getCommandByName(it);
355
        if(cmd->isActive()) {
356
            separator = true;
357
            *linkMenu << it;
358
        }
359
    }
360
    *item << linkMenu;
361
}
362

363
std::vector<std::pair<std::string, std::string>> Workbench::staticMenuItems;
364

365
void Workbench::addPermanentMenuItem(const std::string& cmd, const std::string& after)
366
{
367
    staticMenuItems.emplace_back(cmd, after);
368
}
369

370
void Workbench::removePermanentMenuItem(const std::string& cmd)
371
{
372
    auto it = std::find_if(staticMenuItems.begin(), staticMenuItems.end(), [cmd](const std::pair<std::string, std::string>& pmi) {
373
        return (pmi.first == cmd);
374
    });
375

376
    if (it != staticMenuItems.end()) {
377
        staticMenuItems.erase(it);
378
    }
379
}
380

381
void  Workbench::addPermanentMenuItems(MenuItem* mb) const
382
{
383
    for (const auto& it : staticMenuItems) {
384
        MenuItem* par = mb->findParentOf(it.second);
385
        if (par) {
386
            Gui::MenuItem* item = par->findItem(it.second);
387
            item = par->afterItem(item);
388

389
            auto add = new Gui::MenuItem();
390
            add->setCommand(it.first);
391
            par->insertItem(item, add);
392
        }
393
    }
394
}
395

396
void Workbench::activated()
397
{
398
    Application::Instance->commandManager().signalPyCmdInitialized();
399
}
400

401
void Workbench::deactivated()
402
{
403
}
404

405
bool Workbench::activate()
406
{
407
    ToolBarItem* tb = setupToolBars();
408
    setupCustomToolbars(tb, "Toolbar");
409
    WorkbenchManipulator::changeToolBars(tb);
410
    ToolBarManager::getInstance()->setup( tb );
411
    delete tb;
412

413
    //ToolBarItem* cb = setupCommandBars();
414
    //setupCustomToolbars(cb, "Toolboxbar");
415
    //ToolBoxManager::getInstance()->setup( cb );
416
    //delete cb;
417

418
    DockWindowItems* dw = setupDockWindows();
419
    WorkbenchManipulator::changeDockWindows(dw);
420
    DockWindowManager::instance()->setup( dw );
421
    delete dw;
422

423
    MenuItem* mb = setupMenuBar();
424
    addPermanentMenuItems(mb);
425
    WorkbenchManipulator::changeMenuBar(mb);
426
    MenuManager::getInstance()->setup( mb );
427
    delete mb;
428

429
    setupCustomShortcuts();
430

431
    return true;
432
}
433

434
void Workbench::retranslate() const
435
{
436
    ToolBarManager::getInstance()->retranslate();
437
    //ToolBoxManager::getInstance()->retranslate();
438
    DockWindowManager::instance()->retranslate();
439
    MenuManager::getInstance()->retranslate();
440
}
441

442
PyObject* Workbench::getPyObject()
443
{
444
    return new WorkbenchPy(this);
445
}
446

447
void Workbench::addTaskWatcher(const std::vector<Gui::TaskView::TaskWatcher*> &Watcher)
448
{
449
    Gui::TaskView::TaskView* taskView = Control().taskPanel();
450
    if (taskView) {
451
        taskView->addTaskWatcher(Watcher);
452
    }
453
}
454

455
void Workbench::removeTaskWatcher()
456
{
457
    Gui::TaskView::TaskView* taskView = Control().taskPanel();
458
    if (taskView) {
459
        taskView->clearTaskWatcher();
460
    }
461
}
462

463
std::list<std::string> Workbench::listToolbars() const
464
{
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());
470
    }
471
    return bars;
472
}
473

474
std::list<std::pair<std::string, std::list<std::string>>> Workbench::getToolbarItems() const
475
{
476
    std::unique_ptr<ToolBarItem> tb(setupToolBars());
477

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());
485
        }
486

487
        itemsList.emplace_back(item->command(), cmds);
488
    }
489
    return itemsList;
490
}
491

492
std::list<std::string> Workbench::listMenus() const
493
{
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());
499
    }
500
    return menus;
501
}
502

503
std::list<std::string> Workbench::listCommandbars() const
504
{
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());
510
    }
511
    return bars;
512
}
513

514
// --------------------------------------------------------------------
515

516
#if 0 // needed for Qt's lupdate utility
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");
532

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");
556
    // needed for Structure toolbar
557
    qApp->translate("Workbench", "Link actions");
558
#endif
559

560
#if 0 // needed for the application menu on OSX
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");
568
#endif
569

570
TYPESYSTEM_SOURCE(Gui::StdWorkbench, Gui::Workbench)
571

572
StdWorkbench::StdWorkbench()
573
  : Workbench()
574
{
575
}
576

577
StdWorkbench::~StdWorkbench() = default;
578

579
void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
580
{
581
    if (strcmp(recipient,"View") == 0)
582
    {
583
        createLinkMenu(item);
584
        *item << "Separator";
585

586
        auto StdViews = new MenuItem;
587
        StdViews->setCommand( "Standard views" );
588

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";
592

593
        *item << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_AlignToSelection" << "Std_DrawStyle"
594
              << StdViews << "Separator"
595
              << "Std_ViewDockUndockFullscreen";
596

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";
602
        }
603
    }
604
    else if (strcmp(recipient,"Tree") == 0)
605
    {
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";
613
        }
614
    }
615
}
616

617
void StdWorkbench::createMainWindowPopupMenu(MenuItem* item) const
618
{
619
    *item << "Std_ToggleToolBarLock";
620
    *item << "Std_DlgCustomize";
621
}
622

623
MenuItem* StdWorkbench::setupMenuBar() const
624
{
625
    // Setup the default menu bar
626
    auto menuBar = new MenuItem;
627

628
    // File
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";
637

638
    // Edit
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";
647

648
    auto axoviews = new MenuItem;
649
    axoviews->setCommand("Axonometric");
650
    *axoviews << "Std_ViewIsometric"
651
              << "Std_ViewDimetric"
652
              << "Std_ViewTrimetric";
653

654
    // Standard views
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";
662

663
    // stereo
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";
669

670
    // zoom
671
    auto zoom = new MenuItem;
672
    zoom->setCommand("&Zoom");
673
    *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
674

675
    // Visibility
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";
682

683
    // View
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"
691
#ifdef BUILD_VR
692
          << "Std_ViewVR"
693
#endif
694
          << "Separator" << visu
695
          << "Std_ToggleNavigation"
696
          << "Std_RandomColor"
697
          << "Std_ToggleTransparency"
698
          << "Separator"
699
          << "Std_Workbench"
700
          << "Std_ToolBarMenu"
701
          << "Std_DockViewMenu";
702
    if (DockWindowManager::instance()->isOverlayActivated()) {
703
        *view << "Std_DockOverlay";
704
    }
705
    *view << "Separator"
706
          << "Std_LinkSelectActions"
707
          << "Std_TreeViewActions"
708
          << "Std_ViewStatusBar";
709

710
    // Tools
711
    auto tool = new MenuItem( menuBar );
712
    tool->setCommand("&Tools");
713
    *tool << "Std_DlgParameter"
714
          << "Separator"
715
          << "Std_ViewScreenShot"
716
          << "Std_ViewLoadImage"
717
          << "Std_SceneInspector"
718
          << "Std_DependencyGraph"
719
          << "Std_ExportDependencyGraph"
720
          << "Std_ProjectUtil"
721
          << "Separator"
722
          << "Std_TextDocument"
723
          << "Separator"
724
          << "Std_DemoMode"
725
          << "Std_UnitsCalculator"
726
          << "Separator"
727
          << "Std_DlgCustomize";
728
#ifdef BUILD_ADDONMGR
729
    *tool << "Std_AddonMgr";
730
#endif
731

732
    // Macro
733
    auto macro = new MenuItem( menuBar );
734
    macro->setCommand("&Macro");
735
    *macro << "Std_DlgMacroRecord"
736
           << "Std_DlgMacroExecute"
737
           << "Std_RecentMacros"
738
           << "Separator"
739
           << "Std_DlgMacroExecuteDirect"
740
           << "Std_MacroAttachDebugger"
741
           << "Std_MacroStartDebug"
742
           << "Std_MacroStopDebug"
743
           << "Std_MacroStepOver"
744
           << "Std_MacroStepInto"
745
           << "Std_ToggleBreakpoint";
746

747
    // Windows
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";
753

754
    // Separator
755
    auto sep = new MenuItem( menuBar );
756
    sep->setCommand( "Separator" );
757

758
    // Help
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";
765

766
    return menuBar;
767
}
768

769
ToolBarItem* StdWorkbench::setupToolBars() const
770
{
771
    auto root = new ToolBarItem;
772

773
    // File
774
    auto file = new ToolBarItem( root );
775
    file->setCommand("File");
776
    *file << "Std_New" << "Std_Open" << "Std_Save";
777

778
    // Edit
779
    auto edit = new ToolBarItem( root );
780
    edit->setCommand("Edit");
781
    *edit << "Std_Undo" << "Std_Redo"
782
          << "Separator" << "Std_Refresh";
783

784
    // Clipboard
785
    auto clipboard = new ToolBarItem( root , ToolBarItem::DefaultVisibility::Hidden );
786
    clipboard->setCommand("Clipboard");
787
    *clipboard << "Std_Cut" << "Std_Copy" << "Std_Paste";
788

789
    // Workbench switcher
790
    auto wb = new ToolBarItem(root);
791
    wb->setCommand("Workbench");
792
    *wb << "Std_Workbench";
793

794
    // Macro
795
    auto macro = new ToolBarItem( root, ToolBarItem::DefaultVisibility::Hidden);
796
    macro->setCommand("Macro");
797
    *macro << "Std_DlgMacroRecord" << "Std_DlgMacroExecute"
798
           << "Std_DlgMacroExecuteDirect";
799

800
    // View
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";
805

806
    // Individual views
807
    auto individualViews = new ToolBarItem(root, ToolBarItem::DefaultVisibility::Hidden);
808
    individualViews->setCommand("Individual views");
809
    *individualViews << "Std_ViewIsometric"
810
                     << "Std_ViewFront"
811
                     << "Std_ViewTop"
812
                     << "Std_ViewRight"
813
                     << "Std_ViewRear"
814
                     << "Std_ViewBottom"
815
                     << "Std_ViewLeft";
816

817
    // Structure
818
    auto structure = new ToolBarItem( root );
819
    structure->setCommand("Structure");
820
    *structure << "Std_Part" << "Std_Group" << "Std_LinkActions" << "Std_VarSet";
821

822
    // Help
823
    auto help = new ToolBarItem( root );
824
    help->setCommand("Help");
825
    *help << "Std_WhatsThis";
826

827
    return root;
828
}
829

830
ToolBarItem* StdWorkbench::setupCommandBars() const
831
{
832
    auto root = new ToolBarItem;
833

834
    // View
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";
840

841
    // Special Ops
842
    auto macro = new ToolBarItem( root );
843
    macro->setCommand("Special Ops");
844
    *macro << "Std_DlgParameter" << "Std_DlgPreferences" << "Std_DlgMacroRecord"
845
           << "Std_DlgMacroExecute" << "Std_DlgCustomize";
846

847
    return root;
848
}
849

850
DockWindowItems* StdWorkbench::setupDockWindows() const
851
{
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);
860

861
    //Dagview through parameter.
862
    ParameterGrp::handle group = App::GetApplication().GetUserParameter().
863
          GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("DockWindows")->GetGroup("DAGView");
864

865
    bool enabled = group->GetBool("Enabled", false);
866
    if (enabled) {
867
      root->addDockWidget("Std_DAGView", Qt::RightDockWidgetArea, false, false);
868
    }
869

870
    return root;
871
}
872

873
// --------------------------------------------------------------------
874

875
TYPESYSTEM_SOURCE(Gui::BlankWorkbench, Gui::Workbench)
876

877
BlankWorkbench::BlankWorkbench()
878
  : Workbench()
879
{
880
}
881

882
BlankWorkbench::~BlankWorkbench() = default;
883

884
void BlankWorkbench::activated()
885
{
886
    QList<QDockWidget*> dw = getMainWindow()->findChildren<QDockWidget*>();
887
    for (auto & it : dw) {
888
        it->toggleViewAction()->setVisible(false);
889
    }
890
    getMainWindow()->statusBar()->hide();
891
}
892

893
void BlankWorkbench::deactivated()
894
{
895
    getMainWindow()->statusBar()->show();
896
}
897

898
void BlankWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const
899
{
900
    Q_UNUSED(recipient);
901
    Q_UNUSED(item);
902
}
903

904
MenuItem* BlankWorkbench::setupMenuBar() const
905
{
906
    return new MenuItem();
907
}
908

909
ToolBarItem* BlankWorkbench::setupToolBars() const
910
{
911
    return new ToolBarItem();
912
}
913

914
ToolBarItem* BlankWorkbench::setupCommandBars() const
915
{
916
    return new ToolBarItem();
917
}
918

919
DockWindowItems* BlankWorkbench::setupDockWindows() const
920
{
921
    return new DockWindowItems();
922
}
923

924
// --------------------------------------------------------------------
925

926
TYPESYSTEM_SOURCE(Gui::NoneWorkbench, Gui::StdWorkbench)
927

928
NoneWorkbench::NoneWorkbench()
929
  : StdWorkbench()
930
{
931
}
932

933
NoneWorkbench::~NoneWorkbench() = default;
934

935
void NoneWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const
936
{
937
    Q_UNUSED(recipient);
938
    Q_UNUSED(item);
939
}
940

941
MenuItem* NoneWorkbench::setupMenuBar() const
942
{
943
    // Setup the default menu bar
944
    auto menuBar = new MenuItem;
945

946
    // File
947
    auto file = new MenuItem( menuBar );
948
    file->setCommand("&File");
949
    *file << "Std_Quit";
950

951
    // Edit
952
    auto edit = new MenuItem( menuBar );
953
    edit->setCommand("&Edit");
954
    *edit << "Std_DlgPreferences";
955

956
    // View
957
    auto view = new MenuItem( menuBar );
958
    view->setCommand("&View");
959
    *view << "Std_Workbench";
960

961
    // Separator
962
    auto sep = new MenuItem( menuBar );
963
    sep->setCommand("Separator");
964

965
    // Help
966
    auto help = new MenuItem( menuBar );
967
    help->setCommand("&Help");
968
    *help << "Std_OnlineHelp" << "Std_About";
969

970
    return menuBar;
971
}
972

973
ToolBarItem* NoneWorkbench::setupToolBars() const
974
{
975
    auto root = new ToolBarItem;
976
    return root;
977
}
978

979
ToolBarItem* NoneWorkbench::setupCommandBars() const
980
{
981
    auto root = new ToolBarItem;
982
    return root;
983
}
984

985
DockWindowItems* NoneWorkbench::setupDockWindows() const
986
{
987
    auto root = new DockWindowItems();
988
    root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, false);
989
    return root;
990
}
991

992
// --------------------------------------------------------------------
993

994
TYPESYSTEM_SOURCE(Gui::TestWorkbench, Gui::Workbench)
995

996
TestWorkbench::TestWorkbench()
997
  : StdWorkbench()
998
{
999
}
1000

1001
TestWorkbench::~TestWorkbench() = default;
1002

1003
MenuItem* TestWorkbench::setupMenuBar() const
1004
{
1005
    // Setup the default menu bar
1006
    MenuItem* menuBar = StdWorkbench::setupMenuBar();
1007

1008
    MenuItem* item = menuBar->findItem("&Help");
1009
    item->removeItem(item->findItem("Std_WhatsThis"));
1010

1011
    // Test commands
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";
1017

1018
    // Inventor View
1019
    auto opiv = new MenuItem;
1020
    menuBar->insertItem( item, opiv );
1021
    opiv->setCommand("&Inventor View");
1022
    *opiv << "Std_ViewExample1" << "Std_ViewExample2" << "Std_ViewExample3";
1023

1024
    return menuBar;
1025
}
1026

1027
ToolBarItem* TestWorkbench::setupToolBars() const
1028
{
1029
    return nullptr;
1030
}
1031

1032
ToolBarItem* TestWorkbench::setupCommandBars() const
1033
{
1034
    return nullptr;
1035
}
1036

1037
// -----------------------------------------------------------------------
1038

1039
TYPESYSTEM_SOURCE_ABSTRACT(Gui::PythonBaseWorkbench, Gui::Workbench)
1040

1041
PythonBaseWorkbench::PythonBaseWorkbench() = default;
1042

1043
PythonBaseWorkbench::~PythonBaseWorkbench()
1044
{
1045
    delete _menuBar;
1046
    delete _contextMenu;
1047
    delete _toolBar;
1048
    delete _commandBar;
1049
    if (_workbenchPy) {
1050
        _workbenchPy->setInvalid();
1051
        _workbenchPy->DecRef();
1052
    }
1053
}
1054

1055
PyObject* PythonBaseWorkbench::getPyObject()
1056
{
1057
    if (!_workbenchPy)
1058
    {
1059
        _workbenchPy = new PythonWorkbenchPy(this);
1060
    }
1061

1062
    // Increment every time when this object is returned
1063
    _workbenchPy->IncRef();
1064

1065
    return _workbenchPy;
1066
}
1067

1068
MenuItem* PythonBaseWorkbench::setupMenuBar() const
1069
{
1070
    return _menuBar->copy();
1071
}
1072

1073
ToolBarItem* PythonBaseWorkbench::setupToolBars() const
1074
{
1075
    return _toolBar->copy();
1076
}
1077

1078
ToolBarItem* PythonBaseWorkbench::setupCommandBars() const
1079
{
1080
    return _commandBar->copy();
1081
}
1082

1083
DockWindowItems* PythonBaseWorkbench::setupDockWindows() const
1084
{
1085
    return new DockWindowItems();
1086
}
1087

1088
void PythonBaseWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
1089
{
1090
    Q_UNUSED(recipient);
1091
    QList<MenuItem*> items = _contextMenu->getItems();
1092
    for (const auto & it : items) {
1093
        item->appendItem(it->copy());
1094
    }
1095
}
1096

1097
void PythonBaseWorkbench::appendMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
1098
{
1099
    if ( menu.empty() || items.empty() ) {
1100
        return;
1101
    }
1102

1103
    auto jt=menu.begin();
1104
    MenuItem* item = _menuBar->findItem( *jt );
1105
    if (!item) {
1106
        item = new MenuItem;
1107
        item->setCommand( *jt );
1108
        Gui::MenuItem* wnd = _menuBar->findItem( "&Windows" );
1109
        if (wnd) {
1110
            _menuBar->insertItem(wnd, item);
1111
        }
1112
        else {
1113
            _menuBar->appendItem(item);
1114
        }
1115
    }
1116

1117
    // create sub menus
1118
    for ( jt++; jt != menu.end(); jt++ )
1119
    {
1120
        MenuItem* subitem = item->findItem( *jt );
1121
        if ( !subitem )
1122
        {
1123
            subitem = new MenuItem(item);
1124
            subitem->setCommand( *jt );
1125
        }
1126
        item = subitem;
1127
    }
1128

1129
    for (const auto & it : items) {
1130
        *item << it;
1131
    }
1132
}
1133

1134
void PythonBaseWorkbench::removeMenu(const std::string& menu) const
1135
{
1136
    MenuItem* item = _menuBar->findItem(menu);
1137
    if ( item ) {
1138
        _menuBar->removeItem(item);
1139
        delete item;
1140
    }
1141
}
1142

1143
void PythonBaseWorkbench::appendContextMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
1144
{
1145
    MenuItem* item = _contextMenu;
1146
    for (const auto & jt : menu) {
1147
        MenuItem* subitem = item->findItem(jt);
1148
        if (!subitem) {
1149
            subitem = new MenuItem(item);
1150
            subitem->setCommand(jt);
1151
        }
1152
        item = subitem;
1153
    }
1154

1155
    for (const auto & it : items) {
1156
        *item << it;
1157
    }
1158
}
1159

1160
void PythonBaseWorkbench::removeContextMenu(const std::string& menu) const
1161
{
1162
    MenuItem* item = _contextMenu->findItem(menu);
1163
    if (item) {
1164
        _contextMenu->removeItem(item);
1165
        delete item;
1166
    }
1167
}
1168

1169
void PythonBaseWorkbench::clearContextMenu()
1170
{
1171
    _contextMenu->clear();
1172
}
1173

1174
void PythonBaseWorkbench::appendToolbar(const std::string& bar, const std::list<std::string>& items) const
1175
{
1176
    ToolBarItem* item = _toolBar->findItem(bar);
1177
    if (!item) {
1178
        item = new ToolBarItem(_toolBar);
1179
        item->setCommand(bar);
1180
    }
1181

1182
    for (const auto & it : items) {
1183
        *item << it;
1184
    }
1185
}
1186

1187
void PythonBaseWorkbench::removeToolbar(const std::string& bar) const
1188
{
1189
    ToolBarItem* item = _toolBar->findItem(bar);
1190
    if (item) {
1191
        _toolBar->removeItem(item);
1192
        delete item;
1193
    }
1194
}
1195

1196
void PythonBaseWorkbench::appendCommandbar(const std::string& bar, const std::list<std::string>& items) const
1197
{
1198
    ToolBarItem* item = _commandBar->findItem( bar );
1199
    if (!item) {
1200
        item = new ToolBarItem(_commandBar);
1201
        item->setCommand(bar);
1202
    }
1203

1204
    for (const auto & it : items) {
1205
        *item << it;
1206
    }
1207
}
1208

1209
void PythonBaseWorkbench::removeCommandbar(const std::string& bar) const
1210
{
1211
    ToolBarItem* item = _commandBar->findItem(bar);
1212
    if (item) {
1213
        _commandBar->removeItem(item);
1214
        delete item;
1215
    }
1216
}
1217

1218
// -----------------------------------------------------------------------
1219

1220
TYPESYSTEM_SOURCE(Gui::PythonBlankWorkbench, Gui::PythonBaseWorkbench)
1221

1222
PythonBlankWorkbench::PythonBlankWorkbench()
1223
{
1224
    _menuBar = new MenuItem;
1225
    _contextMenu = new MenuItem;
1226
    _toolBar = new ToolBarItem;
1227
    _commandBar = new ToolBarItem;
1228
}
1229

1230
PythonBlankWorkbench::~PythonBlankWorkbench() = default;
1231

1232
// -----------------------------------------------------------------------
1233

1234
TYPESYSTEM_SOURCE(Gui::PythonWorkbench, Gui::PythonBaseWorkbench)
1235

1236
PythonWorkbench::PythonWorkbench()
1237
{
1238
    StdWorkbench wb;
1239
    _menuBar = wb.setupMenuBar();
1240
    _contextMenu = new MenuItem;
1241
    _toolBar = wb.setupToolBars();
1242
    _commandBar = new ToolBarItem;
1243
}
1244

1245
PythonWorkbench::~PythonWorkbench() = default;
1246

1247
MenuItem* PythonWorkbench::setupMenuBar() const
1248
{
1249
    return _menuBar->copy();
1250
}
1251

1252
ToolBarItem* PythonWorkbench::setupToolBars() const
1253
{
1254
    return _toolBar->copy();
1255
}
1256

1257
ToolBarItem* PythonWorkbench::setupCommandBars() const
1258
{
1259
    return _commandBar->copy();
1260
}
1261

1262
DockWindowItems* PythonWorkbench::setupDockWindows() const
1263
{
1264
    StdWorkbench wb;
1265
    return wb.setupDockWindows();
1266
}
1267

1268
void PythonWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
1269
{
1270
    StdWorkbench wb;
1271
    wb.setupContextMenu(recipient, item);
1272
    PythonBaseWorkbench::setupContextMenu(recipient, item);
1273
}
1274

1275
void PythonWorkbench::createMainWindowPopupMenu(MenuItem* item) const
1276
{
1277
    StdWorkbench wb;
1278
    wb.createMainWindowPopupMenu(item);
1279
}
1280

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.