NvUIEventResponse TerrainTessellation::handleReaction(const NvUIReaction& react) {
    switch(react.code) {
    case REACT_QUALITY_MODE:
        // mQuality should have been adjusted already.
        updateQuality();
        return nvuiEventHandled;
    default:
        break;
    }
    return nvuiEventNotHandled;
}
示例#2
0
PinEntryDialog::PinEntryDialog( QWidget* parent, const char* name,
	int timeout, bool modal, bool enable_quality_bar )
  : QDialog( parent, Qt::WindowStaysOnTopHint ), _grabbed( false )
{
  setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );

  if ( modal ) {
    setWindowModality( Qt::ApplicationModal );
  }

  _icon = new QLabel( this );
  _icon->setPixmap( icon() );

  _error = new QLabel( this );
  _error->setWordWrap(true);
  QPalette pal;
  pal.setColor( QPalette::WindowText, Qt::red );
  _error->setPalette( pal );
  _error->hide();

  _desc = new QLabel( this );
  _desc->setWordWrap(true);
  _desc->hide();

  _prompt = new QLabel( this );
  _prompt->hide();

  _edit = new QSecureLineEdit( this );
  _edit->setMaxLength( 256 );

  _prompt->setBuddy( _edit );

  if (enable_quality_bar)
  {
    _quality_bar_label = new QLabel( this );
    _quality_bar_label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    _quality_bar = new QProgressBar( this );
    _quality_bar->setAlignment( Qt::AlignCenter );
    _have_quality_bar = true;
  }
  else
    _have_quality_bar = false;

  QDialogButtonBox* const buttons = new QDialogButtonBox( this );
  buttons->setStandardButtons( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
  _ok = buttons->button( QDialogButtonBox::Ok );
  _cancel = buttons->button( QDialogButtonBox::Cancel );

  _ok->setDefault(true);

  if ( style()->styleHint( QStyle::SH_DialogButtonBox_ButtonsHaveIcons ) )
    {
      _ok->setIcon( style()->standardIcon( QStyle::SP_DialogOkButton ) );
      _cancel->setIcon( style()->standardIcon( QStyle::SP_DialogCancelButton ) );
    }

  if (timeout > 0) {
      _timer = new QTimer(this);
      connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
      _timer->start(timeout*1000);
  }
  else
    _timer = NULL;

  connect( buttons, SIGNAL(accepted()), this, SLOT(accept()) );
  connect( buttons, SIGNAL(rejected()), this, SLOT(reject()) );
  connect( _edit, SIGNAL( textChanged(secqstring) ),
	   this, SLOT( updateQuality(secqstring) ) );

  _edit->setFocus();

  QGridLayout* const grid = new QGridLayout( this );
  grid->addWidget( _icon, 0, 0, 5, 1, Qt::AlignTop|Qt::AlignLeft );
  grid->addWidget( _error, 1, 1, 1, 2 );
  grid->addWidget( _desc,  2, 1, 1, 2 );
  //grid->addItem( new QSpacerItem( 0, _edit->height() / 10, QSizePolicy::Minimum, QSizePolicy::Fixed ), 1, 1 );
  grid->addWidget( _prompt, 3, 1 );
  grid->addWidget( _edit, 3, 2 );
  if( enable_quality_bar )
  {
    grid->addWidget( _quality_bar_label, 4, 1 );
    grid->addWidget( _quality_bar, 4, 2 );
  }
  grid->addWidget( buttons, 5, 0, 1, 3 );

  grid->setSizeConstraint( QLayout::SetFixedSize );
}
示例#3
0
PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
                               int timeout, bool modal, bool enable_quality_bar,
                               const QString &repeatString,
                               const QString &visibilityTT,
                               const QString &hideTT)
    : QDialog(parent, Qt::WindowStaysOnTopHint),
      mRepeat(NULL),
      _grabbed(false),
      mVisibilityTT(visibilityTT),
      mHideTT(hideTT),
      mVisiActionEdit(NULL),
      mVisiCB(NULL)
{
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    if (modal) {
        setWindowModality(Qt::ApplicationModal);
    }

    _icon = new QLabel(this);
    _icon->setPixmap(icon());

    _error = new QLabel(this);
    _error->setWordWrap(true);
    QPalette pal;
    pal.setColor(QPalette::WindowText, Qt::red);
    _error->setPalette(pal);
    _error->hide();

    _desc = new QLabel(this);
    _desc->setWordWrap(true);
    _desc->hide();

    _prompt = new QLabel(this);
    _prompt->hide();

    _edit = new QLineEdit(this);
    _edit->setMaxLength(256);
    _edit->setEchoMode(QLineEdit::Password);

    _prompt->setBuddy(_edit);

    if (enable_quality_bar) {
        _quality_bar_label = new QLabel(this);
        _quality_bar_label->setAlignment(Qt::AlignVCenter);
        _quality_bar = new QProgressBar(this);
        _quality_bar->setAlignment(Qt::AlignCenter);
        _have_quality_bar = true;
    } else {
        _have_quality_bar = false;
    }

    QDialogButtonBox *const buttons = new QDialogButtonBox(this);
    buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    _ok = buttons->button(QDialogButtonBox::Ok);
    _cancel = buttons->button(QDialogButtonBox::Cancel);

    _ok->setDefault(true);

    if (style()->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons)) {
        _ok->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton));
        _cancel->setIcon(style()->standardIcon(QStyle::SP_DialogCancelButton));
    }

    if (timeout > 0) {
        _timer = new QTimer(this);
        connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
        _timer->start(timeout * 1000);
    } else {
        _timer = NULL;
    }

    connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
    connect(_edit, SIGNAL(textChanged(QString)),
            this, SLOT(updateQuality(QString)));
    connect(_edit, SIGNAL(textChanged(QString)),
            this, SLOT(textChanged(QString)));

    _edit->setFocus();

    QGridLayout *const grid = new QGridLayout(this);
    int row = 1;
    grid->addWidget(_error, row++, 1, 1, 2);
    grid->addWidget(_desc,  row++, 1, 1, 2);
    //grid->addItem( new QSpacerItem( 0, _edit->height() / 10, QSizePolicy::Minimum, QSizePolicy::Fixed ), 1, 1 );
    grid->addWidget(_prompt, row, 1);
    grid->addWidget(_edit, row++, 2);
    if (!repeatString.isNull()) {
        mRepeat = new QLineEdit;
        mRepeat->setMaxLength(256);
        mRepeat->setEchoMode(QLineEdit::Password);
        connect(mRepeat, SIGNAL(textChanged(QString)),
                this, SLOT(textChanged(QString)));
        QLabel *repeatLabel = new QLabel(repeatString);
        repeatLabel->setBuddy(mRepeat);
        grid->addWidget(repeatLabel, row, 1);
        grid->addWidget(mRepeat, row++, 2);
        setTabOrder(_edit, mRepeat);
        setTabOrder(mRepeat, _ok);
    }
    if (enable_quality_bar) {
        grid->addWidget(_quality_bar_label, row, 1);
        grid->addWidget(_quality_bar, row++, 2);
    }
    /* Set up the show password action */
    const QIcon visibilityIcon = QIcon::fromTheme(QLatin1String("visibility"));
    const QIcon hideIcon = QIcon::fromTheme(QLatin1String("hint"));
#if QT_VERSION >= 0x050200
    if (!visibilityIcon.isNull() && !hideIcon.isNull()) {
        mVisiActionEdit = _edit->addAction(visibilityIcon, QLineEdit::TrailingPosition);
        mVisiActionEdit->setVisible(false);
        mVisiActionEdit->setToolTip(mVisibilityTT);
        connect(mVisiActionEdit, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
    } else
#endif
    {
        if (!mVisibilityTT.isNull()) {
            mVisiCB = new QCheckBox(mVisibilityTT);
            connect(mVisiCB, SIGNAL(toggled(bool)), this, SLOT(toggleVisibility()));
            grid->addWidget(mVisiCB, row++, 1, 1, 2, Qt::AlignLeft);
        }
    }