Beispiel #1
0
AgrosSolver::AgrosSolver(int &argc, char **argv)
    : AgrosApplication(argc, argv), m_log(NULL), m_enableLog(false)
{    
    createPythonEngine(new PythonEngineAgros());

    checkForNewVersion(true, true);
}
void ApplicationWindow::init()
{       
    raumserverInstallerObject = new RaumserverInstaller::RaumserverInstaller();

    raumserverInstallerObject->init();
    raumserverInstallerObject->initLogObject(Log::LogType::LOGTYPE_INFO);    
    raumserverInstallerObject->initDiscover();

    settingsManager.setFileName(settingsFileName);
    settingsManager.setLogObject(raumserverInstallerObject->getLogObject());       
    settingsManager.initSettings();
    
    currentVersionInfoWebUrl = settingsManager.getValue(".//RaumserverInstaller//currentVersion");
    #ifdef __linux__ 
        currentVersionBinarySource = settingsManager.getValue(".//RaumserverInstaller//binarySource[@type='linux']");
    #elif _WIN32
        currentVersionBinarySource = settingsManager.getValue(".//RaumserverInstaller//binarySource[@type='windows']");
    #else
        std::runtime_error("");
    #endif    
    currentServerVersionInfoWebUrl = settingsManager.getValue(".//RaumserverInstaller//currentServerVersion");        

    versionInfoLib = raumserverInstallerObject->getVersionInfo();    
    versionInfoServer.loadFromXMLFile("binaries/version.xml");

    connections.connect(raumserverInstallerObject->sigDeviceFoundForInstall, this, &ApplicationWindow::onDeviceFoundForInstall);
    connections.connect(raumserverInstallerObject->sigDeviceRemovedForInstall, this, &ApplicationWindow::onDeviceRemovedForInstall);
    connections.connect(raumserverInstallerObject->sigDeviceInformationChanged, this, &ApplicationWindow::onDeviceInformationChanged);
    connections.connect(raumserverInstallerObject->sigInstallProgressInformation, this, &ApplicationWindow::onInstallProgressInformation);
    connections.connect(raumserverInstallerObject->sigInstallCompleted, this, &ApplicationWindow::onInstallCompleted);

    checkForNewVersion();
    checkForNewServerVersion();
}
KaduExtInfo::KaduExtInfo(bool migrate)
    :ExtInfo(extinfoPath("RExInfo.dat")), chatmenu(NULL), http(NULL), menuBirthday(false),menuNameDay(false)
{
    kdebugf();
    if (migrate)
    {
        extlist.loadFromFile(ggPath("RExInfo.dat"));
        extlist.saveToFile();
        MessageBox::msg(tr("ext_info v") + QString(EXTINFO_VERSION) + tr(" was imported settings from previous version."));
    }
    RegisterInConfigDialog(migrate);
    RegisterSignals();
    Create5ChatButton();
    onApplyConfigDialog();
    if (checkUpdateStable || checkUpdateUnstable)
        checkForNewVersion();
    connect(&timer, SIGNAL(timeout()), this, SLOT(checkAnniversary()));
    restartTimer();
    kdebugf2();
}
void
GuiAppInstance::load(const CLArgs& cl,
                     bool makeEmptyInstance)
{
    if (getAppID() == 0) {
        appPTR->setLoadingStatus( QObject::tr("Creating user interface...") );
    }

    try {
        declareCurrentAppVariable_Python();
    } catch (const std::exception& e) {
        std::cerr << e.what() << std::endl;
    }

    _imp->_gui = new Gui(this);
    _imp->_gui->createGui();

    printAutoDeclaredVariable(_imp->declareAppAndParamsString);

    ///if the app is interactive, build the plugins toolbuttons from the groups we extracted off the plugins.
    const std::list<boost::shared_ptr<PluginGroupNode> > & _toolButtons = appPTR->getTopLevelPluginsToolButtons();
    for (std::list<boost::shared_ptr<PluginGroupNode>  >::const_iterator it = _toolButtons.begin(); it != _toolButtons.end(); ++it) {
        _imp->findOrCreateToolButtonRecursive(*it);
    }
    _imp->_gui->sortAllPluginsToolButtons();

    Q_EMIT pluginsPopulated();

    ///show the gui
    _imp->_gui->show();


    boost::shared_ptr<Settings> nSettings = appPTR->getCurrentSettings();
    QObject::connect( getProject().get(), SIGNAL(formatChanged(Format)), this, SLOT(projectFormatChanged(Format)) );

    {
        QSettings settings( QString::fromUtf8(NATRON_ORGANIZATION_NAME), QString::fromUtf8(NATRON_APPLICATION_NAME) );
        if ( !settings.contains( QString::fromUtf8("checkForUpdates") ) ) {
            StandardButtonEnum reply = Dialogs::questionDialog(tr("Updates").toStdString(),
                                                               tr("Do you want " NATRON_APPLICATION_NAME " to check for updates "
                                                                  "on launch of the application ?").toStdString(), false);
            bool checkForUpdates = reply == eStandardButtonYes;
            nSettings->setCheckUpdatesEnabled(checkForUpdates);
        }

        if ( nSettings->isCheckForUpdatesEnabled() ) {
            appPTR->setLoadingStatus( tr("Checking if updates are available...") );
            checkForNewVersion();
        }
    }

    if ( nSettings->isDefaultAppearanceOutdated() ) {
        StandardButtonEnum reply = Dialogs::questionDialog(tr("Appearance").toStdString(),
                                                           tr(NATRON_APPLICATION_NAME " default appearance changed since last version.\n"
                                                              "Would you like to set the new default appearance?").toStdString(), false);
        if (reply == eStandardButtonYes) {
            nSettings->restoreDefaultAppearance();
        }
    }

    /// Create auto-save dir if it does not exists
    QDir dir = Project::autoSavesDir();
    dir.mkpath( QString::fromUtf8(".") );


    if (getAppID() == 0) {
        appPTR->getCurrentSettings()->doOCIOStartupCheckIfNeeded();

        if ( !appPTR->isShorcutVersionUpToDate() ) {
            StandardButtonEnum reply = questionDialog(tr("Shortcuts").toStdString(),
                                                      tr("Default shortcuts for " NATRON_APPLICATION_NAME " have changed, "
                                                         "would you like to set them to their defaults ? "
                                                         "Clicking no will keep the old shortcuts hence if a new shortcut has been "
                                                         "set to something else than an empty shortcut you won't benefit of it.").toStdString(),
                                                      false,
                                                      StandardButtons(eStandardButtonYes | eStandardButtonNo),
                                                      eStandardButtonNo);
            if (reply == eStandardButtonYes) {
                appPTR->restoreDefaultShortcuts();
            }
        }
    }

    if (makeEmptyInstance) {
        return;
    }

    /// If this is the first instance of the software, try to load an autosave
    if ( (getAppID() == 0) && cl.getScriptFilename().isEmpty() ) {
        if ( findAndTryLoadUntitledAutoSave() ) {
            ///if we successfully loaded an autosave ignore the specified project in the launch args.
            return;
        }
    }


    QFileInfo info( cl.getScriptFilename() );

    if ( cl.getScriptFilename().isEmpty() || !info.exists() ) {
        getProject()->createViewer();
        execOnProjectCreatedCallback();

        const QString& imageFile = cl.getImageFilename();
        if ( !imageFile.isEmpty() ) {
            handleFileOpenEvent( imageFile.toStdString() );
        }
    } else {
        if ( info.suffix() == QString::fromUtf8("py") ) {
            appPTR->setLoadingStatus( tr("Loading script: ") + cl.getScriptFilename() );

            ///If this is a Python script, execute it
            loadPythonScript(info);
            execOnProjectCreatedCallback();
        } else if ( info.suffix() == QString::fromUtf8(NATRON_PROJECT_FILE_EXT) ) {
            ///Otherwise just load the project specified.
            QString name = info.fileName();
            QString path = info.path();
            Global::ensureLastPathSeparator(path);
            appPTR->setLoadingStatus(tr("Loading project: ") + path + name);
            getProject()->loadProject(path, name);
            ///remove any file open event that might have occured
            appPTR->setFileToOpen( QString() );
        } else {
            Dialogs::errorDialog( tr("Invalid file").toStdString(),
                                  tr(NATRON_APPLICATION_NAME " only accepts python scripts or .ntp project files").toStdString() );
            execOnProjectCreatedCallback();
        }
    }

    const QString& extraOnProjectCreatedScript = cl.getDefaultOnProjectLoadedScript();
    if ( !extraOnProjectCreatedScript.isEmpty() ) {
        QFileInfo cbInfo(extraOnProjectCreatedScript);
        if ( cbInfo.exists() ) {
            loadPythonScript(cbInfo);
        }
    }
} // load