FreeCAD

Форк
0
/
Workbench.cpp 
1295 строк · 43.3 Кб
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 "UserSettings.h"
45
#include "Window.h"
46

47
#include <App/Application.h>
48
#include <App/DocumentObject.h>
49
#include <Base/Interpreter.h>
50
#include <Gui/ComboView.h>
51
#include <Gui/TaskView/TaskView.h>
52
#include <Gui/TaskView/TaskWatcher.h>
53

54
using namespace Gui;
55

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

59
    FreeCAD provides the possibility to have one or more workbenches for a module.
60
    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.
61
    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.
62

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

66
    \subsection newClass Inherit either from Workbench or StdWorkbench
67
    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()".
68

69
    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.
70

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

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

209
Workbench::Workbench() = default;
210

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

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

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

223
void Workbench::setupCustomToolbars(ToolBarItem* root, const char* toolbar) const
224
{
225
    std::string name = this->name();
226
    const auto workbenchGroup {
227
        App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Workbench")
228
    };
229
    // workbench specific custom toolbars
230
    if (workbenchGroup->HasGroup(name.c_str())) {
231
        const auto customGroup = workbenchGroup->GetGroup(name.c_str());
232
        if (customGroup->HasGroup(toolbar)) {
233
            const auto customToolbarGroup = customGroup->GetGroup(toolbar);
234
            setupCustomToolbars(root, customToolbarGroup);
235
        }
236
    }
237

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

243
    // application-wide custom toolbars
244
    if (workbenchGroup->HasGroup("Global")) {
245
        const auto globalGroup = workbenchGroup->GetGroup("Global");
246
        if (globalGroup->HasGroup(toolbar)) {
247
            const auto customToolbarGroup = globalGroup->GetGroup(toolbar);
248
            setupCustomToolbars(root, customToolbarGroup);
249
        }
250
    }
251
}
252

253
void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Reference<ParameterGrp> hGrp) const
254
{
255
    std::vector<Base::Reference<ParameterGrp> > hGrps = hGrp->GetGroups();
256
    CommandManager& rMgr = Application::Instance->commandManager();
257
    std::string separator = "Separator";
258
    for (const auto & it : hGrps) {
259
        bool active = it->GetBool("Active", true);
260
        if (!active) {
261
            // ignore this toolbar
262
            continue;
263
        }
264

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

268
        // get the elements of the subgroups
269
        std::vector<std::pair<std::string,std::string> > items = hGrp->GetGroup(it->GetGroupName())->GetASCIIMap();
270
        for (const auto & item : items) {
271
            if (item.first.substr(0, separator.size()) == separator) {
272
                *bar << "Separator";
273
            }
274
            else if (item.first == "Name") {
275
                bar->setCommand(item.second);
276
            }
277
            else {
278
                Command* pCmd = rMgr.getCommandByName(item.first.c_str());
279
                if (!pCmd) { // unknown command
280
                    // first try the module name as is
281
                    std::string pyMod = item.second;
282
                    try {
283
                        Base::Interpreter().loadModule(pyMod.c_str());
284
                        // Try again
285
                        pCmd = rMgr.getCommandByName(item.first.c_str());
286
                    }
287
                    catch(const Base::Exception&) {
288
                    }
289
                }
290

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

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

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

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

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

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

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

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

342
    auto &rMgr = Application::Instance->commandManager();
343
    const char *cmds[] = {"Std_LinkMakeRelative",nullptr,"Std_LinkUnlink","Std_LinkReplace",
344
        "Std_LinkImport","Std_LinkImportAll",nullptr,"Std_LinkSelectLinked",
345
        "Std_LinkSelectLinkedFinal","Std_LinkSelectAllLinks"};
346
    bool separator = true;
347
    for(const auto & it : cmds) {
348
        if(!it) {
349
            if(separator) {
350
                separator = false;
351
                *linkMenu << "Separator";
352
            }
353
            continue;
354
        }
355
        auto cmd = rMgr.getCommandByName(it);
356
        if(cmd->isActive()) {
357
            separator = true;
358
            *linkMenu << it;
359
        }
360
    }
361
    *item << linkMenu;
362
}
363

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

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

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

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

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

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

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

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

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

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

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

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

430
    setupCustomShortcuts();
431

432
    return true;
433
}
434

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

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

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

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

464
std::list<std::string> Workbench::listToolbars() const
465
{
466
    std::unique_ptr<ToolBarItem> tb(setupToolBars());
467
    std::list<std::string> bars;
468
    QList<ToolBarItem*> items = tb->getItems();
469
    for (const auto & item : items) {
470
        bars.push_back(item->command());
471
    }
472
    return bars;
473
}
474

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

479
    std::list<std::pair<std::string, std::list<std::string>>> itemsList;
480
    QList<ToolBarItem*> items = tb->getItems();
481
    for (const auto & item : items) {
482
        QList<ToolBarItem*> sub = item->getItems();
483
        std::list<std::string> cmds;
484
        for (const auto & jt : sub) {
485
            cmds.push_back(jt->command());
486
        }
487

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

493
std::list<std::string> Workbench::listMenus() const
494
{
495
    std::unique_ptr<MenuItem> mb(setupMenuBar());
496
    std::list<std::string> menus;
497
    QList<MenuItem*> items = mb->getItems();
498
    for (const auto & item : items) {
499
        menus.push_back(item->command());
500
    }
501
    return menus;
502
}
503

504
std::list<std::string> Workbench::listCommandbars() const
505
{
506
    std::unique_ptr<ToolBarItem> cb(setupCommandBars());
507
    std::list<std::string> bars;
508
    QList<ToolBarItem*> items = cb->getItems();
509
    for (const auto & item : items) {
510
        bars.push_back(item->command());
511
    }
512
    return bars;
513
}
514

515
// --------------------------------------------------------------------
516

517
#if 0 // needed for Qt's lupdate utility
518
    qApp->translate("CommandGroup", "File");
519
    qApp->translate("CommandGroup", "Edit");
520
    qApp->translate("CommandGroup", "Help");
521
    qApp->translate("CommandGroup", "Link");
522
    qApp->translate("CommandGroup", "Tools");
523
    qApp->translate("CommandGroup", "View");
524
    qApp->translate("CommandGroup", "Window");
525
    qApp->translate("CommandGroup", "Standard");
526
    qApp->translate("CommandGroup", "Macros");
527
    qApp->translate("CommandGroup", "Macro");
528
    qApp->translate("CommandGroup", "Structure");
529
    qApp->translate("CommandGroup", "Standard-Test");
530
    qApp->translate("CommandGroup", "Standard-View");
531
    qApp->translate("CommandGroup", "TreeView");
532
    qApp->translate("CommandGroup", "Measure");
533

534
    qApp->translate("Workbench", "&File");
535
    qApp->translate("Workbench", "&Edit");
536
    qApp->translate("Workbench", "Edit");
537
    qApp->translate("Workbench", "Clipboard");
538
    qApp->translate("Workbench", "Workbench");
539
    qApp->translate("Workbench", "Structure");
540
    qApp->translate("Workbench", "Standard views");
541
    qApp->translate("Workbench", "Individual views");
542
    qApp->translate("Workbench", "Axonometric");
543
    qApp->translate("Workbench", "&Stereo");
544
    qApp->translate("Workbench", "&Zoom");
545
    qApp->translate("Workbench", "Visibility");
546
    qApp->translate("Workbench", "&View");
547
    qApp->translate("Workbench", "&Tools");
548
    qApp->translate("Workbench", "&Macro");
549
    qApp->translate("Workbench", "&Windows");
550
    qApp->translate("Workbench", "&On-line help");
551
    qApp->translate("Workbench", "&Help");
552
    qApp->translate("Workbench", "Help");
553
    qApp->translate("Workbench", "File");
554
    qApp->translate("Workbench", "Macro");
555
    qApp->translate("Workbench", "View");
556
    qApp->translate("Workbench", "Special Ops");
557
    // needed for Structure toolbar
558
    qApp->translate("Workbench", "Link actions");
559
#endif
560

561
#if 0 // needed for the application menu on OSX
562
    qApp->translate("MAC_APPLICATION_MENU", "Services");
563
    qApp->translate("MAC_APPLICATION_MENU", "Hide %1");
564
    qApp->translate("MAC_APPLICATION_MENU", "Hide Others");
565
    qApp->translate("MAC_APPLICATION_MENU", "Show All");
566
    qApp->translate("MAC_APPLICATION_MENU", "Preferences...");
567
    qApp->translate("MAC_APPLICATION_MENU", "Quit %1");
568
    qApp->translate("MAC_APPLICATION_MENU", "About %1");
569
#endif
570

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

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

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

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

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

590
        *StdViews << "Std_ViewIsometric" << "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight"
591
                  << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft"
592
                  << "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight";
593

594
        auto measure = new MenuItem();
595
        measure->setCommand("Measure");
596
        *measure << "View_Measure_Toggle_All" << "View_Measure_Clear_All";
597

598

599
        *item << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_DrawStyle"
600
              << StdViews << measure << "Separator"
601
              << "Std_ViewDockUndockFullscreen";
602

603
        if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
604
            *item << "Separator" << "Std_SetAppearance" << "Std_ToggleVisibility"
605
                  << "Std_ToggleSelectability" << "Std_TreeSelection"
606
                  << "Std_RandomColor" << "Std_ToggleTransparency" << "Separator" << "Std_Delete"
607
                  << "Std_SendToPythonConsole" << "Std_TransformManip" << "Std_Placement";
608
        }
609
    }
610
    else if (strcmp(recipient,"Tree") == 0)
611
    {
612
        if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
613
            *item  << "Std_ToggleFreeze" << "Separator"
614
                  << "Std_Placement" << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
615
                  << "Std_ToggleSelectability" << "Std_TreeSelectAllInstances" << "Separator"
616
                  << "Std_SetAppearance" << "Std_RandomColor" << "Std_ToggleTransparency" << "Separator"
617
                  << "Std_Cut" << "Std_Copy" << "Std_Paste" << "Std_Delete"
618
                  << "Std_SendToPythonConsole" << "Separator";
619
        }
620
    }
621
}
622

623
void StdWorkbench::createMainWindowPopupMenu(MenuItem* item) const
624
{
625
    *item << "Std_ToggleToolBarLock";
626
    *item << "Std_DlgCustomize";
627
}
628

629
MenuItem* StdWorkbench::setupMenuBar() const
630
{
631
    // Setup the default menu bar
632
    auto menuBar = new MenuItem;
633

634
    // File
635
    auto file = new MenuItem( menuBar );
636
    file->setCommand("&File");
637
    *file << "Std_New" << "Std_Open" << "Std_RecentFiles" << "Separator" << "Std_CloseActiveWindow"
638
          << "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs"
639
          << "Std_SaveCopy" << "Std_SaveAll" << "Std_Revert" << "Separator" << "Std_Import"
640
          << "Std_Export" << "Std_MergeProjects" << "Std_ProjectInfo"
641
          << "Separator" << "Std_Print" << "Std_PrintPreview" << "Std_PrintPdf"
642
          << "Separator" << "Std_Quit";
643

644
    // Edit
645
    auto edit = new MenuItem( menuBar );
646
    edit->setCommand("&Edit");
647
    *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
648
          << "Std_Paste" << "Std_DuplicateSelection" << "Separator"
649
          << "Std_Refresh" << "Std_BoxSelection" << "Std_BoxElementSelection"
650
          << "Std_SelectAll" << "Std_Delete" << "Std_SendToPythonConsole"
651
          << "Separator" << "Std_Placement" << "Std_TransformManip" << "Std_Alignment"
652
          << "Std_Edit" << "Std_Properties" << "Separator" << "Std_UserEditMode" << "Separator" << "Std_DlgPreferences";
653

654
    auto axoviews = new MenuItem;
655
    axoviews->setCommand("Axonometric");
656
    *axoviews << "Std_ViewIsometric"
657
              << "Std_ViewDimetric"
658
              << "Std_ViewTrimetric";
659

660
    // Standard views
661
    auto stdviews = new MenuItem;
662
    stdviews->setCommand("Standard views");
663
    *stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << axoviews
664
              << "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop"
665
              << "Std_ViewRight" << "Std_ViewRear"
666
              << "Std_ViewBottom" << "Std_ViewLeft"
667
              << "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight"
668
              << "Separator" << "Std_StoreWorkingView" << "Std_RecallWorkingView";
669

670
    // stereo
671
    auto view3d = new MenuItem;
672
    view3d->setCommand("&Stereo");
673
    *view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff"
674
            << "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns"
675
            << "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos";
676

677
    // zoom
678
    auto zoom = new MenuItem;
679
    zoom->setCommand("&Zoom");
680
    *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
681

682
    // Visibility
683
    auto visu = new MenuItem;
684
    visu->setCommand("Visibility");
685
    *visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
686
          << "Std_SelectVisibleObjects"
687
          << "Separator" << "Std_ToggleObjects" << "Std_ShowObjects" << "Std_HideObjects"
688
          << "Separator" << "Std_ToggleSelectability"
689
          << "Separator" << "View_Measure_Toggle_All" << "View_Measure_Clear_All";
690

691
    // View
692
    auto view = new MenuItem( menuBar );
693
    view->setCommand("&View");
694
    *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Std_MainFullscreen" << "Separator"
695
          << stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Std_SelBoundingBox"
696
          << "Separator" << view3d << zoom
697
          << "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane"
698
          << "Std_TextureMapping"
699
#ifdef BUILD_VR
700
          << "Std_ViewVR"
701
#endif
702
          << "Separator" << visu
703
          << "Std_ToggleNavigation"
704
          << "Std_SetAppearance"
705
          << "Std_RandomColor"
706
          << "Separator"
707
          << "Std_Workbench"
708
          << "Std_ToolBarMenu"
709
          << "Std_DockViewMenu";
710
    if (DockWindowManager::instance()->isOverlayActivated()) {
711
        *view << "Std_DockOverlay";
712
    }
713
    *view << "Separator"
714
          << "Std_ToggleTransparency"
715
          << "Std_LinkSelectActions"
716
          << "Std_TreeViewActions"
717
          << "Std_ViewStatusBar";
718

719
    // Tools
720
    auto tool = new MenuItem( menuBar );
721
    tool->setCommand("&Tools");
722
    *tool << "Std_DlgParameter"
723
          << "Separator"
724
          << "Std_ViewScreenShot"
725
          << "Std_ViewLoadImage"
726
          << "Std_SceneInspector"
727
          << "Std_DependencyGraph"
728
          << "Std_ExportDependencyGraph"
729
          << "Std_ProjectUtil"
730
          << "Separator"
731
          << "Std_MeasureDistance"
732
          << "Separator"
733
          << "Std_TextDocument"
734
          << "Separator"
735
          << "Std_DemoMode"
736
          << "Std_UnitsCalculator"
737
          << "Separator"
738
          << "Std_DlgCustomize";
739
#ifdef BUILD_ADDONMGR
740
    *tool << "Std_AddonMgr";
741
#endif
742

743
    // Macro
744
    auto macro = new MenuItem( menuBar );
745
    macro->setCommand("&Macro");
746
    *macro << "Std_DlgMacroRecord"
747
           << "Std_DlgMacroExecute"
748
           << "Std_RecentMacros"
749
           << "Separator"
750
           << "Std_DlgMacroExecuteDirect"
751
           << "Std_MacroAttachDebugger"
752
           << "Std_MacroStartDebug"
753
           << "Std_MacroStopDebug"
754
           << "Std_MacroStepOver"
755
           << "Std_MacroStepInto"
756
           << "Std_ToggleBreakpoint";
757

758
    // Windows
759
    auto wnd = new MenuItem( menuBar );
760
    wnd->setCommand("&Windows");
761
    *wnd << "Std_ActivateNextWindow" << "Std_ActivatePrevWindow" << "Separator"
762
         << "Std_TileWindows" << "Std_CascadeWindows" << "Separator"
763
         << "Std_WindowsMenu" << "Std_Windows";
764

765
    // Separator
766
    auto sep = new MenuItem( menuBar );
767
    sep->setCommand( "Separator" );
768

769
    // Help
770
    auto help = new MenuItem( menuBar );
771
    help->setCommand("&Help");
772
    *help << "Std_OnlineHelp" << "Std_FreeCADWebsite" << "Std_FreeCADDonation"
773
          << "Std_FreeCADUserHub" << "Std_FreeCADPowerUserHub"
774
          << "Std_PythonHelp" << "Std_FreeCADForum" << "Std_FreeCADFAQ"
775
          << "Std_ReportBug" << "Std_About" << "Std_WhatsThis";
776

777
    return menuBar;
778
}
779

780
ToolBarItem* StdWorkbench::setupToolBars() const
781
{
782
    auto root = new ToolBarItem;
783

784
    // File
785
    auto file = new ToolBarItem( root );
786
    file->setCommand("File");
787
    *file << "Std_New" << "Std_Open" << "Std_Save";
788

789
    // Edit
790
    auto edit = new ToolBarItem( root );
791
    edit->setCommand("Edit");
792
    *edit << "Std_Undo" << "Std_Redo"
793
          << "Separator" << "Std_Refresh";
794
    
795
    // Clipboard
796
    auto clipboard = new ToolBarItem( root , ToolBarItem::DefaultVisibility::Hidden );
797
    clipboard->setCommand("Clipboard");
798
    *clipboard << "Std_Cut" << "Std_Copy" << "Std_Paste";
799
    
800
    // Workbench switcher
801
    if (WorkbenchSwitcher::isToolbar(WorkbenchSwitcher::getValue())) {
802
        auto wb = new ToolBarItem(root);
803
        wb->setCommand("Workbench");
804
        *wb << "Std_Workbench";
805
    }
806

807
    // Macro
808
    auto macro = new ToolBarItem( root, ToolBarItem::DefaultVisibility::Hidden);
809
    macro->setCommand("Macro");
810
    *macro << "Std_DlgMacroRecord" << "Std_DlgMacroExecute"
811
           << "Std_DlgMacroExecuteDirect";
812

813
    // View
814
    auto view = new ToolBarItem( root );
815
    view->setCommand("View");
816
    *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewGroup"
817
          << "Separator" << "Std_DrawStyle" << "Std_TreeViewActions"
818
          << "Separator" << "Std_MeasureDistance";
819

820
    // Individual views
821
    auto individualViews = new ToolBarItem(root, ToolBarItem::DefaultVisibility::Hidden);
822
    individualViews->setCommand("Individual views");
823
    *individualViews << "Std_ViewIsometric"
824
                     << "Std_ViewFront"
825
                     << "Std_ViewRight"
826
                     << "Std_ViewTop"
827
                     << "Std_ViewRear"
828
                     << "Std_ViewLeft"
829
                     << "Std_ViewBottom";
830

831
    // Structure
832
    auto structure = new ToolBarItem( root );
833
    structure->setCommand("Structure");
834
    *structure << "Std_Part" << "Std_Group" << "Std_LinkActions";
835

836
    // Help
837
    auto help = new ToolBarItem( root );
838
    help->setCommand("Help");
839
    *help << "Std_WhatsThis";
840

841
    return root;
842
}
843

844
ToolBarItem* StdWorkbench::setupCommandBars() const
845
{
846
    auto root = new ToolBarItem;
847

848
    // View
849
    auto view = new ToolBarItem( root );
850
    view->setCommand("Standard views");
851
    *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewIsometric" << "Separator"
852
          << "Std_ViewFront" << "Std_ViewRight" << "Std_ViewTop"
853
          << "Std_ViewRear" << "Std_ViewLeft" << "Std_ViewBottom";
854

855
    // Special Ops
856
    auto macro = new ToolBarItem( root );
857
    macro->setCommand("Special Ops");
858
    *macro << "Std_DlgParameter" << "Std_DlgPreferences" << "Std_DlgMacroRecord"
859
           << "Std_DlgMacroExecute" << "Std_DlgCustomize";
860

861
    return root;
862
}
863

864
DockWindowItems* StdWorkbench::setupDockWindows() const
865
{
866
    auto root = new DockWindowItems();
867
    root->addDockWidget("Std_ToolBox", Qt::RightDockWidgetArea, false, false);
868
    //root->addDockWidget("Std_HelpView", Qt::RightDockWidgetArea, true, false);
869
    root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, true, false);
870
    root->addDockWidget("Std_PropertyView", Qt::LeftDockWidgetArea, true, false);
871
    root->addDockWidget("Std_SelectionView", Qt::LeftDockWidgetArea, false, false);
872
    root->addDockWidget("Std_ComboView", Qt::LeftDockWidgetArea, true, true);
873
    root->addDockWidget("Std_TaskView", Qt::LeftDockWidgetArea, true, true);
874
    root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, true);
875
    root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, true, true);
876

877
    //Dagview through parameter.
878
    ParameterGrp::handle group = App::GetApplication().GetUserParameter().
879
          GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("DockWindows")->GetGroup("DAGView");
880

881
    bool enabled = group->GetBool("Enabled", false);
882
    if (enabled) {
883
      root->addDockWidget("Std_DAGView", Qt::RightDockWidgetArea, false, false);
884
    }
885

886
    return root;
887
}
888

889
// --------------------------------------------------------------------
890

891
TYPESYSTEM_SOURCE(Gui::BlankWorkbench, Gui::Workbench)
892

893
BlankWorkbench::BlankWorkbench()
894
  : Workbench()
895
{
896
}
897

898
BlankWorkbench::~BlankWorkbench() = default;
899

900
void BlankWorkbench::activated()
901
{
902
    QList<QDockWidget*> dw = getMainWindow()->findChildren<QDockWidget*>();
903
    for (auto & it : dw) {
904
        it->toggleViewAction()->setVisible(false);
905
    }
906
    getMainWindow()->statusBar()->hide();
907
}
908

909
void BlankWorkbench::deactivated()
910
{
911
    getMainWindow()->statusBar()->show();
912
}
913

914
void BlankWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const
915
{
916
    Q_UNUSED(recipient);
917
    Q_UNUSED(item);
918
}
919

920
MenuItem* BlankWorkbench::setupMenuBar() const
921
{
922
    return new MenuItem();
923
}
924

925
ToolBarItem* BlankWorkbench::setupToolBars() const
926
{
927
    return new ToolBarItem();
928
}
929

930
ToolBarItem* BlankWorkbench::setupCommandBars() const
931
{
932
    return new ToolBarItem();
933
}
934

935
DockWindowItems* BlankWorkbench::setupDockWindows() const
936
{
937
    return new DockWindowItems();
938
}
939

940
// --------------------------------------------------------------------
941

942
TYPESYSTEM_SOURCE(Gui::NoneWorkbench, Gui::StdWorkbench)
943

944
NoneWorkbench::NoneWorkbench()
945
  : StdWorkbench()
946
{
947
}
948

949
NoneWorkbench::~NoneWorkbench() = default;
950

951
void NoneWorkbench::setupContextMenu(const char* recipient,MenuItem* item) const
952
{
953
    Q_UNUSED(recipient);
954
    Q_UNUSED(item);
955
}
956

957
MenuItem* NoneWorkbench::setupMenuBar() const
958
{
959
    // Setup the default menu bar
960
    auto menuBar = new MenuItem;
961

962
    // File
963
    auto file = new MenuItem( menuBar );
964
    file->setCommand("&File");
965
    *file << "Std_Quit";
966

967
    // Edit
968
    auto edit = new MenuItem( menuBar );
969
    edit->setCommand("&Edit");
970
    *edit << "Std_DlgPreferences";
971

972
    // View
973
    auto view = new MenuItem( menuBar );
974
    view->setCommand("&View");
975
    *view << "Std_Workbench";
976

977
    // Separator
978
    auto sep = new MenuItem( menuBar );
979
    sep->setCommand("Separator");
980

981
    // Help
982
    auto help = new MenuItem( menuBar );
983
    help->setCommand("&Help");
984
    *help << "Std_OnlineHelp" << "Std_About";
985

986
    return menuBar;
987
}
988

989
ToolBarItem* NoneWorkbench::setupToolBars() const
990
{
991
    auto root = new ToolBarItem;
992
    return root;
993
}
994

995
ToolBarItem* NoneWorkbench::setupCommandBars() const
996
{
997
    auto root = new ToolBarItem;
998
    return root;
999
}
1000

1001
DockWindowItems* NoneWorkbench::setupDockWindows() const
1002
{
1003
    auto root = new DockWindowItems();
1004
    root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, false);
1005
    return root;
1006
}
1007

1008
// --------------------------------------------------------------------
1009

1010
TYPESYSTEM_SOURCE(Gui::TestWorkbench, Gui::Workbench)
1011

1012
TestWorkbench::TestWorkbench()
1013
  : StdWorkbench()
1014
{
1015
}
1016

1017
TestWorkbench::~TestWorkbench() = default;
1018

1019
MenuItem* TestWorkbench::setupMenuBar() const
1020
{
1021
    // Setup the default menu bar
1022
    MenuItem* menuBar = StdWorkbench::setupMenuBar();
1023

1024
    MenuItem* item = menuBar->findItem("&Help");
1025
    item->removeItem(item->findItem("Std_WhatsThis"));
1026

1027
    // Test commands
1028
    auto test = new MenuItem;
1029
    menuBar->insertItem( item, test );
1030
    test->setCommand( "Test &Commands" );
1031
    *test << "Std_Test1" << "Std_Test2" << "Std_Test3" << "Std_Test4" << "Std_Test5"
1032
          << "Std_Test6" << "Std_Test7" << "Std_Test8";
1033

1034
    // Inventor View
1035
    auto opiv = new MenuItem;
1036
    menuBar->insertItem( item, opiv );
1037
    opiv->setCommand("&Inventor View");
1038
    *opiv << "Std_ViewExample1" << "Std_ViewExample2" << "Std_ViewExample3";
1039

1040
    return menuBar;
1041
}
1042

1043
ToolBarItem* TestWorkbench::setupToolBars() const
1044
{
1045
    return nullptr;
1046
}
1047

1048
ToolBarItem* TestWorkbench::setupCommandBars() const
1049
{
1050
    return nullptr;
1051
}
1052

1053
// -----------------------------------------------------------------------
1054

1055
TYPESYSTEM_SOURCE_ABSTRACT(Gui::PythonBaseWorkbench, Gui::Workbench)
1056

1057
PythonBaseWorkbench::PythonBaseWorkbench() = default;
1058

1059
PythonBaseWorkbench::~PythonBaseWorkbench()
1060
{
1061
    delete _menuBar;
1062
    delete _contextMenu;
1063
    delete _toolBar;
1064
    delete _commandBar;
1065
    if (_workbenchPy) {
1066
        _workbenchPy->setInvalid();
1067
        _workbenchPy->DecRef();
1068
    }
1069
}
1070

1071
PyObject* PythonBaseWorkbench::getPyObject()
1072
{
1073
    if (!_workbenchPy)
1074
    {
1075
        _workbenchPy = new PythonWorkbenchPy(this);
1076
    }
1077

1078
    // Increment every time when this object is returned
1079
    _workbenchPy->IncRef();
1080

1081
    return _workbenchPy;
1082
}
1083

1084
MenuItem* PythonBaseWorkbench::setupMenuBar() const
1085
{
1086
    return _menuBar->copy();
1087
}
1088

1089
ToolBarItem* PythonBaseWorkbench::setupToolBars() const
1090
{
1091
    return _toolBar->copy();
1092
}
1093

1094
ToolBarItem* PythonBaseWorkbench::setupCommandBars() const
1095
{
1096
    return _commandBar->copy();
1097
}
1098

1099
DockWindowItems* PythonBaseWorkbench::setupDockWindows() const
1100
{
1101
    return new DockWindowItems();
1102
}
1103

1104
void PythonBaseWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
1105
{
1106
    Q_UNUSED(recipient);
1107
    QList<MenuItem*> items = _contextMenu->getItems();
1108
    for (const auto & it : items) {
1109
        item->appendItem(it->copy());
1110
    }
1111
}
1112

1113
void PythonBaseWorkbench::appendMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
1114
{
1115
    if ( menu.empty() || items.empty() ) {
1116
        return;
1117
    }
1118

1119
    auto jt=menu.begin();
1120
    MenuItem* item = _menuBar->findItem( *jt );
1121
    if (!item) {
1122
        item = new MenuItem;
1123
        item->setCommand( *jt );
1124
        Gui::MenuItem* wnd = _menuBar->findItem( "&Windows" );
1125
        if (wnd) {
1126
            _menuBar->insertItem(wnd, item);
1127
        }
1128
        else {
1129
            _menuBar->appendItem(item);
1130
        }
1131
    }
1132

1133
    // create sub menus
1134
    for ( jt++; jt != menu.end(); jt++ )
1135
    {
1136
        MenuItem* subitem = item->findItem( *jt );
1137
        if ( !subitem )
1138
        {
1139
            subitem = new MenuItem(item);
1140
            subitem->setCommand( *jt );
1141
        }
1142
        item = subitem;
1143
    }
1144

1145
    for (const auto & it : items) {
1146
        *item << it;
1147
    }
1148
}
1149

1150
void PythonBaseWorkbench::removeMenu(const std::string& menu) const
1151
{
1152
    MenuItem* item = _menuBar->findItem(menu);
1153
    if ( item ) {
1154
        _menuBar->removeItem(item);
1155
        delete item;
1156
    }
1157
}
1158

1159
void PythonBaseWorkbench::appendContextMenu(const std::list<std::string>& menu, const std::list<std::string>& items) const
1160
{
1161
    MenuItem* item = _contextMenu;
1162
    for (const auto & jt : menu) {
1163
        MenuItem* subitem = item->findItem(jt);
1164
        if (!subitem) {
1165
            subitem = new MenuItem(item);
1166
            subitem->setCommand(jt);
1167
        }
1168
        item = subitem;
1169
    }
1170

1171
    for (const auto & it : items) {
1172
        *item << it;
1173
    }
1174
}
1175

1176
void PythonBaseWorkbench::removeContextMenu(const std::string& menu) const
1177
{
1178
    MenuItem* item = _contextMenu->findItem(menu);
1179
    if (item) {
1180
        _contextMenu->removeItem(item);
1181
        delete item;
1182
    }
1183
}
1184

1185
void PythonBaseWorkbench::clearContextMenu()
1186
{
1187
    _contextMenu->clear();
1188
}
1189

1190
void PythonBaseWorkbench::appendToolbar(const std::string& bar, const std::list<std::string>& items) const
1191
{
1192
    ToolBarItem* item = _toolBar->findItem(bar);
1193
    if (!item) {
1194
        item = new ToolBarItem(_toolBar);
1195
        item->setCommand(bar);
1196
    }
1197

1198
    for (const auto & it : items) {
1199
        *item << it;
1200
    }
1201
}
1202

1203
void PythonBaseWorkbench::removeToolbar(const std::string& bar) const
1204
{
1205
    ToolBarItem* item = _toolBar->findItem(bar);
1206
    if (item) {
1207
        _toolBar->removeItem(item);
1208
        delete item;
1209
    }
1210
}
1211

1212
void PythonBaseWorkbench::appendCommandbar(const std::string& bar, const std::list<std::string>& items) const
1213
{
1214
    ToolBarItem* item = _commandBar->findItem( bar );
1215
    if (!item) {
1216
        item = new ToolBarItem(_commandBar);
1217
        item->setCommand(bar);
1218
    }
1219

1220
    for (const auto & it : items) {
1221
        *item << it;
1222
    }
1223
}
1224

1225
void PythonBaseWorkbench::removeCommandbar(const std::string& bar) const
1226
{
1227
    ToolBarItem* item = _commandBar->findItem(bar);
1228
    if (item) {
1229
        _commandBar->removeItem(item);
1230
        delete item;
1231
    }
1232
}
1233

1234
// -----------------------------------------------------------------------
1235

1236
TYPESYSTEM_SOURCE(Gui::PythonBlankWorkbench, Gui::PythonBaseWorkbench)
1237

1238
PythonBlankWorkbench::PythonBlankWorkbench()
1239
{
1240
    _menuBar = new MenuItem;
1241
    _contextMenu = new MenuItem;
1242
    _toolBar = new ToolBarItem;
1243
    _commandBar = new ToolBarItem;
1244
}
1245

1246
PythonBlankWorkbench::~PythonBlankWorkbench() = default;
1247

1248
// -----------------------------------------------------------------------
1249

1250
TYPESYSTEM_SOURCE(Gui::PythonWorkbench, Gui::PythonBaseWorkbench)
1251

1252
PythonWorkbench::PythonWorkbench()
1253
{
1254
    StdWorkbench wb;
1255
    _menuBar = wb.setupMenuBar();
1256
    _contextMenu = new MenuItem;
1257
    _toolBar = wb.setupToolBars();
1258
    _commandBar = new ToolBarItem;
1259
}
1260

1261
PythonWorkbench::~PythonWorkbench() = default;
1262

1263
MenuItem* PythonWorkbench::setupMenuBar() const
1264
{
1265
    return _menuBar->copy();
1266
}
1267

1268
ToolBarItem* PythonWorkbench::setupToolBars() const
1269
{
1270
    return _toolBar->copy();
1271
}
1272

1273
ToolBarItem* PythonWorkbench::setupCommandBars() const
1274
{
1275
    return _commandBar->copy();
1276
}
1277

1278
DockWindowItems* PythonWorkbench::setupDockWindows() const
1279
{
1280
    StdWorkbench wb;
1281
    return wb.setupDockWindows();
1282
}
1283

1284
void PythonWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
1285
{
1286
    StdWorkbench wb;
1287
    wb.setupContextMenu(recipient, item);
1288
    PythonBaseWorkbench::setupContextMenu(recipient, item);
1289
}
1290

1291
void PythonWorkbench::createMainWindowPopupMenu(MenuItem* item) const
1292
{
1293
    StdWorkbench wb;
1294
    wb.createMainWindowPopupMenu(item);
1295
}
1296

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

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

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

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