void QEGenericButton::userReleased()
{
    // Do nothing if not acting on button release, or user confirmation required but not given, or password required but not given
    if( !writeOnRelease ||  !confirmAction() || !checkPassword() )
        return;

    // Determine the string to write
    QString writeText = substituteThis( releaseText );

    // Emit a 'released' signal
    emitReleased( writeText.toInt() );

    // Get the variable to write to
    QEString *qca = (QEString*)getQcaItem(0);

    // If a QCa object is present (if there is a variable to write to) then write the value
    if( qca )
    {
        QString error;
        if( !qca->writeString( writeText, error ) )
        {
            QMessageBox::warning( (QWidget*)getButtonQObject(), QString( "Write failed" ), error, QMessageBox::Cancel );
        }
    }
}
Example #2
0
// Wite the given value to the associated channel.
//
bool QELineEdit::writeData (const QVariant & value, QString& message)
{
    QEString *qca = dynamic_cast <QEString*> ( getQcaItem(0) );

    if( qca ) {
       return qca->writeString( value.toString (), message);
    } else {
        message = "null qca object";
        return false;
    }
}
/*
    Button click event.
*/
void QEGenericButton::userClicked( bool checked )
{
    // Do nothing if nothing to do. (no point asking for confirmation or password)
    // Then keep doing nothing if user confirmation required but not given, or password required but not given
    if(( !writeOnClick && programLauncher.getProgram().isEmpty() && guiName.isEmpty() ) ||  !confirmAction() || !checkPassword() )
        return;

    // Get the variable to write to
    QEString *qca = (QEString*)getQcaItem(0);

    // If the object is set up to write when the user clicks the button
    // emit a signal
    // Also, if a QCa object is present (if there is a variable to write to)
    // then write the value
    if( writeOnClick )
    {
        // Determine the string to write
        QString writeText;
        if( !checked )
        {
            writeText = clickText;
        }
        else
        {
            writeText = clickCheckedText;
        }

        writeText = substituteThis( writeText );

        // Emit a 'clicked' signal
        emitClicked( writeText.toInt() );

        // Write to the variable if present
        if( qca )
        {
            QString error;
            if( !qca->writeString( writeText, error ) )
            {
                QMessageBox::warning( (QWidget*)getButtonQObject(), QString( "Write failed" ), error, QMessageBox::Cancel );
            }
        }
    }

    // If there is a command to run, run it, with substitutions applied to the command and arguments
    programLauncher.launch( (VariableNameManager*)this, getButtonQObject() );

    // If a new GUI is required, start it
    if( !guiName.isEmpty() )
    {

        // Publish the profile this button recieved
        publishOwnProfile();

        // Extend any variable name substitutions with this button's substitutions
        // Like most other macro substitutions, the substitutions already present take precedence.
        addMacroSubstitutions( getVariableNameSubstitutions() );

        // Extend any variable name substitutions with this button's priority substitutions
        // Unlike most other macro substitutions, these macro substitutions take precedence over
        // substitutions already present.
        addPriorityMacroSubstitutions( prioritySubstitutions );

        // Start the GUI
        emitNewGui( QEActionRequests( substituteThis( guiName ), customisationName, creationOption ) );

        // Remove this button's priority macro substitutions now all its children are created
        removePriorityMacroSubstitutions();

        // Remove this button's normal macro substitutions now all its children are created
        removeMacroSubstitutions();

        // Release the profile now all QE widgets have been created
        releaseProfile();
    }
}