FreeCAD

Форк
0
/
Manipulator.cpp 
80 строк · 3.3 Кб
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/****************************************************************************
3
 *                                                                          *
4
 *   Copyright (c) 2024 The FreeCAD Project Association AISBL               *
5
 *                                                                          *
6
 *   This file is part of FreeCAD.                                          *
7
 *                                                                          *
8
 *   FreeCAD is free software: you can redistribute it and/or modify it     *
9
 *   under the terms of the GNU Lesser General Public License as            *
10
 *   published by the Free Software Foundation, either version 2.1 of the   *
11
 *   License, or (at your option) any later version.                        *
12
 *                                                                          *
13
 *   FreeCAD is distributed in the hope that it will be useful, but         *
14
 *   WITHOUT ANY WARRANTY; without even the implied warranty of             *
15
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU       *
16
 *   Lesser General Public License for more details.                        *
17
 *                                                                          *
18
 *   You should have received a copy of the GNU Lesser General Public       *
19
 *   License along with FreeCAD. If not, see                                *
20
 *   <https://www.gnu.org/licenses/>.                                       *
21
 *                                                                          *
22
 ***************************************************************************/
23

24
#include "PreCompiled.h"
25
#ifndef _PreComp_
26
#include <QCoreApplication>
27
#include <QCoreApplication>
28
#include <QLayout>
29
#endif
30

31
#include "Manipulator.h"
32
#include "StartView.h"
33

34
#include <Gui/Application.h>
35
#include <Gui/Command.h>
36
#include <Gui/MainWindow.h>
37
#include <Gui/MenuManager.h>
38

39
#include <gsl/pointers>
40

41
DEF_STD_CMD(CmdStart)
42

43
CmdStart::CmdStart()
44
    : Command("Start_Start")
45
{
46
    sAppModule = "Start";
47
    sGroup = QT_TR_NOOP("Start");
48
    sMenuText = QT_TR_NOOP("Start");
49
    sToolTipText = QT_TR_NOOP("Displays the Start in an MDI view");
50
    sWhatsThis = "Start_Start";
51
    sStatusTip = sToolTipText;
52
    sPixmap = "StartCommandIcon";
53
}
54

55
void CmdStart::activated(int iMsg)
56
{
57
    Q_UNUSED(iMsg);
58
    auto mw = Gui::getMainWindow();
59
    auto existingView = mw->findChild<StartGui::StartView*>(QLatin1String("StartView"));
60
    if (!existingView) {
61
        existingView = gsl::owner<StartGui::StartView*>(new StartGui::StartView(mw));
62
        mw->addWindow(existingView);  // Transfers ownership
63
    }
64
    Gui::getMainWindow()->setActiveWindow(existingView);
65
    existingView->show();
66
}
67

68
void StartGui::Manipulator::modifyMenuBar(Gui::MenuItem* menuBar)
69
{
70
    Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
71
    if (!rcCmdMgr.getCommandByName("Start_Start")) {
72
        auto newCommand = gsl::owner<CmdStart*>(new CmdStart);
73
        rcCmdMgr.addCommand(newCommand);  // Transfer ownership
74
    }
75

76
    Gui::MenuItem* helpMenu = menuBar->findItem("&Help");
77
    Gui::MenuItem* loadStart = new Gui::MenuItem();
78
    loadStart->setCommand("Start_Start");
79
    helpMenu->appendItem(loadStart);
80
}
81

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

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

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

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