Пример #1
0
void QgsColorSwatchGrid::keyPressEvent( QKeyEvent *event )
{
  //handle keyboard navigation
  if ( event->key() == Qt::Key_Right )
  {
    mCurrentFocusBox = std::min( mCurrentFocusBox + 1, mColors.length() - 1 );
  }
  else if ( event->key() == Qt::Key_Left )
  {
    mCurrentFocusBox = std::max( mCurrentFocusBox - 1, 0 );
  }
  else if ( event->key() == Qt::Key_Up )
  {
    int currentRow = mCurrentFocusBox / NUMBER_COLORS_PER_ROW;
    int currentColumn = mCurrentFocusBox % NUMBER_COLORS_PER_ROW;
    currentRow--;

    if ( currentRow >= 0 )
    {
      mCurrentFocusBox = currentRow * NUMBER_COLORS_PER_ROW + currentColumn;
    }
    else
    {
      //moved above first row
      focusPreviousChild();
    }
  }
  else if ( event->key() == Qt::Key_Down )
  {
    int currentRow = mCurrentFocusBox / NUMBER_COLORS_PER_ROW;
    int currentColumn = mCurrentFocusBox % NUMBER_COLORS_PER_ROW;
    currentRow++;
    int box = currentRow * NUMBER_COLORS_PER_ROW + currentColumn;

    if ( box < mColors.length() )
    {
      mCurrentFocusBox = box;
    }
    else
    {
      //moved below first row
      focusNextChild();
    }
  }
  else if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space )
  {
    //color clicked
    emit colorChanged( mColors.at( mCurrentFocusBox ).first );
  }
  else
  {
    //some other key, pass it on
    QWidget::keyPressEvent( event );
    return;
  }

  repaint();
}
Пример #2
0
void ListBox::keyPressEvent(QKeyEvent* event)
{
    int key = event->key();
    if (key == Qt::Key_Escape)
    {
		focusPreviousChild();
		deleteLater();
		event->accept();
    }
    else
    {
		QListWidget::keyPressEvent(event);
    }
}
Пример #3
0
void XQListWidget::keyPressEvent(QKeyEvent* event)
{
    switch (event->key()) {
        case Qt::Key_Left: {
            focusPreviousChild();
            break;
        }
        case Qt::Key_Right: {
            focusNextChild();
            break;
        }
        default: {
            QListWidget::keyPressEvent(event);
        }
    }
}
Пример #4
0
bool DhQGLWidget::DvhfocusPreviousChild() {
  return focusPreviousChild();
}
Пример #5
0
bool DhQPushButton::DvhfocusPreviousChild() {
  return focusPreviousChild();
}
Пример #6
0
bool DhQAbstractSpinBox::DvhfocusPreviousChild() {
  return focusPreviousChild();
}
Пример #7
0
bool DhQGroupBox::DvhfocusPreviousChild() {
  return focusPreviousChild();
}
Пример #8
0
void KComboEdit::keyPressEvent(QKeyEvent *e)
{
    int count = 0;
    int row = 0;

    if((NULL==e)
        || (NULL==dropDown)
        || (NULL==buttonLeft)
        || (NULL==buttonRight))
    {
        return;
    }

    buttonLeft->setChecked(false);
    buttonRight->setChecked(false);

    count = dropDown->count();
    row = dropDown->currentRow();

    switch(e->key())
    {
        case Qt::Key_Up:
            if(!dropDown->isHidden())
            {
                row -= 1;
                if (row < 0) {
                    row = count - 1;
                }
                setRow(row);
            }
            else
            {
                focusPreviousChild();
            }
            break;
        case Qt::Key_Down:
            if(!dropDown->isHidden())
            {
                row += 1;;
                if (row >= count) {
                    row = 0;
                }
                setRow(row);
            }
            else
            {
                focusNextChild();
            }
            break;
        case Qt::Key_Left:
            if(dropDown->isHidden())
            {
                row -= 1;
                if (row < 0) {
                    row = count - 1;
                }
                setRow(row);
                buttonLeft->setChecked(true);
                buttonRight->setChecked(false);
            }
            break;
        case Qt::Key_Right:
            if(dropDown->isHidden())
            {
                row += 1;
                if (row >= count) {
                    row = 0;
                }
                setRow(row);
                buttonLeft->setChecked(false);
                buttonRight->setChecked(true);
            }
            break;
        case Qt::Key_Return:
        case Qt::Key_Enter:
            if(dropDown->isHidden())
            {
                dropDown->show();
            }
            else
            {
                dropDown->hide();
            }
            break;
        default:
            QLineEdit::keyPressEvent(e);
            break;
    }
}
Пример #9
0
bool DhQSlider::DvhfocusPreviousChild() {
  return focusPreviousChild();
}
Пример #10
0
bool DhQScrollArea::DvhfocusPreviousChild() {
  return focusPreviousChild();
}
Пример #11
0
bool DhQStackedWidget::DvhfocusPreviousChild() {
    return focusPreviousChild();
}