|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #include <QString>
|
| #include <QTimer>
|
|
|
|
|
| #include <Base/Console.h>
|
| #include <Base/Interpreter.h>
|
| #include <Base/PyObjectBase.h>
|
| #include <Gui/Language/Translator.h>
|
| #include <Gui/Command.h>
|
| #include <Gui/MainWindow.h>
|
| #include <Gui/WidgetFactory.h>
|
| #include "DlgStartPreferencesImp.h"
|
|
|
|
|
| #include <gsl/pointers>
|
|
|
| #include "Manipulator.h"
|
| #include "StartView.h"
|
|
|
| void loadStartResource()
|
| {
|
|
|
| Q_INIT_RESOURCE(Start);
|
| Q_INIT_RESOURCE(Start_translation);
|
| Gui::Translator::instance()->refresh();
|
| }
|
|
|
| namespace StartGui
|
| {
|
| extern PyObject* initModule();
|
| }
|
|
|
|
|
| namespace StartGui
|
| {
|
| class Module: public Py::ExtensionModule<Module>
|
| {
|
| public:
|
| Module()
|
| : Py::ExtensionModule<Module>("StartGui")
|
| {
|
| initialize("This module is the StartGui module.");
|
| }
|
| };
|
|
|
| class StartLauncher
|
| {
|
| public:
|
| StartLauncher()
|
| {
|
|
|
| QTimer::singleShot(100, [this] { Launch(); });
|
| }
|
|
|
| void Launch()
|
| {
|
| auto hGrp = App::GetApplication().GetParameterGroupByPath(
|
| "User parameter:BaseApp/Preferences/Mod/Start"
|
| );
|
| bool showOnStartup = hGrp->GetBool("ShowOnStartup", true);
|
| if (showOnStartup) {
|
| Gui::Application::Instance->commandManager().runCommandByName("Start_Start");
|
| QTimer::singleShot(100, [this] { EnsureLaunched(); });
|
| }
|
| }
|
|
|
| void EnsureLaunched()
|
| {
|
|
|
|
|
|
|
| auto mw = Gui::getMainWindow();
|
| auto existingView = mw->findChild<StartGui::StartView*>(QLatin1String("StartView"));
|
| if (!existingView) {
|
| Launch();
|
| }
|
| }
|
| };
|
|
|
| PyObject* initModule()
|
| {
|
| auto newModule = gsl::owner<Module*>(new Module);
|
| return Base::Interpreter().addModule(newModule);
|
| }
|
|
|
| }
|
|
|
|
|
| PyMOD_INIT_FUNC(StartGui)
|
| {
|
| static StartGui::StartLauncher* launcher = new StartGui::StartLauncher();
|
| Q_UNUSED(launcher)
|
|
|
| Base::Console().log("Loading GUI of Start module… ");
|
| PyObject* mod = StartGui::initModule();
|
| auto manipulator = std::make_shared<StartGui::Manipulator>();
|
| Gui::WorkbenchManipulator::installManipulator(manipulator);
|
| loadStartResource();
|
| Base::Console().log("done\n");
|
|
|
|
|
| new Gui::PrefPageProducer<StartGui::DlgStartPreferencesImp>(QT_TRANSLATE_NOOP("QObject", "Start"));
|
|
|
| PyMOD_Return(mod);
|
| }
|
|
|