Beispiel #1
0
// Slot to receive a click signal from a push button and
// open a dialog.
// This slot sets up the ContainerProfile with the required macro substitutions
// then uses a QEForm to load the contents of the dialog from a .ui file.
void MainWindow::buttonClick( bool )
{
    // Set up the ContainerProfile with the required macro substitutions
    ContainerProfile profile;
    profile.setupProfile( this, QStringList(), "", "BTN=push button" );
    profile.addMacroSubstitutions( applicationMacros );

    // Build the gui and load it into a dialog.
    // Note, this is very similar to the default method that QE push buttons uses
    // to present a gui if the application has not provided a handler to
    // create GUIs through the ContainerProfile.
    QDialog* d = new QDialog;
    QEForm* gui = new QEForm( DIALOG_UI );
    if( gui )
    {
        if( gui->readUiFile())
        {
            gui->setParent( d );
            d->exec();
        }
        else
        {
            delete gui;
            gui = NULL;
        }
    }
    else
    {
        delete d;
    }

    profile.releaseProfile();
}
// Slot for launching a new gui.
// This is the button's default action for launching a gui.
// Normally the button would be within a container, such as a tab on a gui, that will provide a 'launch gui' mechanism.
void QEGenericButton::startGui( const QEActionRequests & request )
{
    // Only handle file open requests
    if( request.getKind() != QEActionRequests::KindOpenFile )
    {
        return;
    }

    // If there is enough arguments, open the file
    if (request.getArguments().count () >= 1)
    {
        // Build the gui
        // Build it in a new window.
        QMainWindow* w = new QMainWindow;
        QEForm* gui = new QEForm( request.getArguments().first() );
        if( gui )
        {
            if( gui->readUiFile())
            {
                w->setCentralWidget( gui );
                w->show();
            }
            else
            {
                delete gui;
                gui = NULL;
            }
        }
        else
        {
            delete w;
        }
    }
}
Beispiel #3
0
// Slot to receive a request to create a window from the QE framework.
// When a QE Push Button has been set up with a GUI file name and it is clicked
// it looks to see if a handler to take window creation requests has been set up
// in the ContainerProfile. This application has set up this slot as a window
// creationhandler.
// This handler does not have to be aware of any context of the widget that
// made the request. All details such as the macro substitutions required are
// provided in the request.
// open a dialog.
// For this application, only one type of request is accepted - open a .ui file.
// It uses a QEForm to load the .ui file and place it in a dialog.
void MainWindow::requestAction( const QEActionRequests& request )
{
    // Only handle file open requests
    if( request.getKind() != QEActionRequests::KindOpenFile )
    {
        return;
    }

    // If there is enough arguments, open the file
    if (request.getArguments().count () >= 1)
    {
        // Build the gui and load it into a dialog.
        // Note, this is very similar to the default method that QE push buttons uses
        // to present a gui if the application has not provided a handler to
        // create GUIs through the ContainerProfile.
        QDialog* d = new QDialog();
        QEForm* gui = new QEForm( request.getArguments().first() );
        if( gui )
        {
            if( gui->readUiFile())
            {
                gui->setParent( d );
                d->exec();
            }
            else
            {
                delete gui;
                gui = NULL;
            }
        }
        else
        {
            delete d;
        }
    }
}