Example #1
0
int main(int argc, char** argv) {

    QApplication app(argc, argv);

    GUI::MainWindow mainWindow;
    mainWindow.resize(640, 480);
    mainWindow.show();

    return app.exec();
}
int main(int argc, char *argv[]) {
	av_register_all();
	avcodec_register_all();
	avfilter_register_all();

	QApplication a(argc, argv);
	GUI::MainWindow mw;
	mw.show();

	return a.exec();
}
Example #3
0
//TODO: code is duplicated in Command and CommandCreateDims
TechDraw::DrawPage* _findPageCD(Gui::Command* cmd)
{
    TechDraw::DrawPage* page = 0;
    //check if a DrawPage is currently displayed
    Gui::MainWindow* w = Gui::getMainWindow();
    Gui::MDIView* mv = w->activeWindow();
    MDIViewPage* mvp = dynamic_cast<MDIViewPage*>(mv);
    if (mvp) {
        QGVPage* qp = mvp->getQGVPage();
        page = qp->getDrawPage();
    } else {
        //DrawPage not displayed, check Selection and/or Document for a DrawPage
        std::vector<App::DocumentObject*> selPages = cmd->getSelection().getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
        if (selPages.empty()) {                                            //no page in selection
            selPages = cmd->getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
            if (selPages.empty()) {                                        //no page in document
                QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No page found"),
                                     QObject::tr("Create a page first."));
                return page;
            } else if (selPages.size() > 1) {                              //multiple pages in document
                QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Too many pages"),
                                     QObject::tr("Can not determine correct page."));
                return page;
            } else {                                                       //use only page in document
                page = dynamic_cast<TechDraw::DrawPage*>(selPages.front());
            }
        } else if (selPages.size() > 1) {                                  //multiple pages in selection
            QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Too many pages"),
                                 QObject::tr("Select exactly 1 page."));
            return page;
        } else {                                                           //use only page in selection
            page = dynamic_cast<TechDraw::DrawPage*>(selPages.front());
        }
    }
    return page;
}
static
QWidget* setupMainWindow()
{
    if (!Gui::Application::Instance) {
        static Gui::Application *app = new Gui::Application(true);
        Q_UNUSED(app);
    }

    if (!Gui::MainWindow::getInstance()) {
        PyObject* input = PySys_GetObject("stdin");
        Gui::MainWindow *mw = new Gui::MainWindow();
        QIcon icon = qApp->windowIcon();
        if (icon.isNull())
            qApp->setWindowIcon(Gui::BitmapFactory().pixmap(App::Application::Config()["AppIcon"].c_str()));
        mw->setWindowIcon(qApp->windowIcon());
        QString appName = qApp->applicationName();
        if (!appName.isEmpty())
            mw->setWindowTitle(appName);
        else
            mw->setWindowTitle(QString::fromAscii(App::Application::Config()["ExeName"].c_str()));

        if (!SoDB::isInitialized()) {
            // init the Inventor subsystem
            SoDB::init();
            SoQt::init(mw);
            Gui::SoFCDB::init();
        }

        static bool init = false;
        if (!init) {
            try {
                Base::Interpreter().runString(Base::ScriptFactory().ProduceScript("FreeCADGuiInit"));
            }
            catch (const Base::Exception& e) {
                PyErr_Format(PyExc_Exception, "Error in FreeCADGuiInit.py: %s\n", e.what());
                return 0;
            }
            init = true;
        }

        qApp->setActiveWindow(mw);

        // Activate the correct workbench
        std::string start = App::Application::Config()["StartWorkbench"];
        Base::Console().Log("Init: Activating default workbench %s\n", start.c_str());
        start = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
                               GetASCII("AutoloadModule", start.c_str());
        // if the auto workbench is not visible then force to use the default workbech
        // and replace the wrong entry in the parameters
        QStringList wb = Gui::Application::Instance->workbenches();
        if (!wb.contains(QString::fromAscii(start.c_str()))) {
            start = App::Application::Config()["StartWorkbench"];
            App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
                                  SetASCII("AutoloadModule", start.c_str());
        }

        Gui::Application::Instance->activateWorkbench(start.c_str());
        mw->loadWindowSettings();
        PySys_SetObject("stdin", input);
    }
    else {
        Gui::getMainWindow()->show();
    }

    return Gui::getMainWindow();
}