1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/****************************************************************************
4
* Copyright (c) 2024 The FreeCAD Project Association AISBL *
6
* This file is part of FreeCAD. *
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. *
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. *
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/>. *
22
***************************************************************************/
24
#include "PreCompiled.h"
26
#include <QCoreApplication>
27
#include <QCoreApplication>
31
#include "Manipulator.h"
34
#include <Gui/Application.h>
35
#include <Gui/Command.h>
36
#include <Gui/MainWindow.h>
37
#include <Gui/MenuManager.h>
39
#include <gsl/pointers>
44
: Command("Start_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";
55
void CmdStart::activated(int iMsg)
58
auto mw = Gui::getMainWindow();
59
auto existingView = mw->findChild<StartGui::StartView*>(QLatin1String("StartView"));
61
existingView = gsl::owner<StartGui::StartView*>(new StartGui::StartView(mw));
62
mw->addWindow(existingView); // Transfers ownership
64
Gui::getMainWindow()->setActiveWindow(existingView);
68
void StartGui::Manipulator::modifyMenuBar(Gui::MenuItem* menuBar)
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
76
Gui::MenuItem* helpMenu = menuBar->findItem("&Help");
77
Gui::MenuItem* loadStart = new Gui::MenuItem();
78
loadStart->setCommand("Start_Start");
79
helpMenu->appendItem(loadStart);