Ejemplo n.º 1
0
// Create new main windows
void instanceManager::newWindow( const startupParams& params )
{
    // Set up the profile for the new windows
    ContainerProfile profile;

    // If restoring, restore saved configuration
    if( params.restore )
    {
        // Ask the persistance manager to restore a configuration.
        // The persistance manager will signal all interested objects (including this application) that
        // they should collect and apply restore data.
        PersistanceManager* persistanceManager = profile.getPersistanceManager();
        persistanceManager->restore( params.configurationFile, QE_CONFIG_NAME, params.configurationName );

        // If the restoration did not create any windows, warn the user.
        // This is especially important as an .ui file specified on the command line will now be opened,
        // or failing that, an empty window, neither of which will look like the expected configuration
        if( app->getMainWindowCount() == 0 )
        {
            QMessageBox::warning( 0, "Configuration Restore",
                                  QString( "Configuration restoration did not create any windows.\n"
                                           "Looked for configuration named '%1'.").arg( params.configurationName ) );
        }
    }

    // Not restoring, or if restoring didn't create any main windows, open the required guis
    if( !params.restore || app->getMainWindowCount() == 0 )
    {
        profile.setupProfile( NULL, params.pathList, "", params.substitutions );

        // If no files specified, open a single window without a file name
        if( !params.filenameList.count() )
        {
            MainWindow* mw = new MainWindow( app, "", "", params.defaultCustomisationName, QEFormMapper::nullHandle(),  true );
            mw->show();
        }

        // Files have been specified. Open a window for each of them
        else
        {
            for( int i = 0; i < params.filenameList.count(); i++ )
            {
                MainWindow* mw = new MainWindow( app, params.filenameList[i], "", params.startupCustomisationName, QEFormMapper::nullHandle(), true );
                mw->show();
            }
        }

        profile.releaseProfile();
    }

    // Release the profile
}