コード例 #1
0
ファイル: pwchangedialog.cpp プロジェクト: dschulz/exampleapp
bool PasswordChangeDialog::eventFilter(QObject *obj, QEvent *event)
{
    if(event->type()==QEvent::KeyPress){

        if(obj==lineCurPas){
            QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
            int key = keyEvent->key();
            if((key==Qt::Key_Enter) || (key==Qt::Key_Return)){
                focusNextChild();
            }
        }

        if(obj==linePass1){
            QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
            int key = keyEvent->key();
            if((key==Qt::Key_Enter) || (key==Qt::Key_Return)){
                focusNextChild();
            }
        }

        if(obj==linePass2){
            QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
            int key = keyEvent->key();
            if((key==Qt::Key_Enter) || (key==Qt::Key_Return)){
                if(btnConfirm->isEnabled()){
                    btnConfirm->animateClick(200);
                }
            }
        }
    }


    return QWidget::eventFilter(obj,event);
}
コード例 #2
0
void AutoDialog::keyPressEvent(QKeyEvent *k)
{
    k->accept();
    switch(k->key())
    {
    case Qt::Key_Down:
        focusNextChild();
        break;
    case Qt::Key_Up:
        focusPreviousChild();
        break;
    case Qt::Key_F2:
        finished(1);
        break;
    case Qt::Key_F1:
    case Qt::Key_F3:
    case Qt::Key_F4:
    case Qt::Key_F5:
    case Qt::Key_F6:
    case Qt::Key_F7:
    case Qt::Key_F8:
        finished(0);
        break;
    case Qt::Key_Return:
    case Qt::Key_Enter:
        focusNextChild();
        break;
    default:
        break;
    }
}
コード例 #3
0
void SpinBox::keyPressEvent(QKeyEvent *event)
{
    int steps = 1;

    if ((event->key() >= Qt::Key_0) && (event->key() <= Qt::Key_9))
        return;
    if ((event->key() >= Qt::Key_A) && (event->key() <= Qt::Key_Z))
        return;

    switch (event->key()) {
    case Qt::Key_Left:
        focusPreviousChild();
        break;
    case Qt::Key_Right:
        focusNextChild();
        break;
    case Qt::Key_F2:
    case Qt::Key_F4: {
        event->accept();
        const bool up = (event->key() == Qt::Key_F2);
        if (!(stepEnabled() & (up ? StepUpEnabled : StepDownEnabled)))
            return;
        if (!up)
            steps *= -1;
        stepBy(steps);
        return;
    }
    default:
        QSpinBox::keyPressEvent(event);
    }
}
コード例 #4
0
void QgsAttributeDialog::init( QgsVectorLayer* layer, QgsFeature* feature, const QgsAttributeEditorContext &context )
{
  setWindowTitle( tr( "%1 - Feature Attributes" ).arg( layer->name() ) );
  setLayout( new QGridLayout() );
  layout()->setMargin( 0 );
  mAttributeForm = new QgsAttributeForm( layer, *feature, context, this );
  mAttributeForm->disconnectButtonBox();
  layout()->addWidget( mAttributeForm );
  QDialogButtonBox* buttonBox = mAttributeForm->findChild<QDialogButtonBox*>();
  connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
  connect( layer, SIGNAL( layerDeleted() ), this, SLOT( close() ) );

  QgsActionMenu* menu = new QgsActionMenu( layer, &mAttributeForm->feature(), this );
  if ( !menu->actions().isEmpty() )
  {
    QMenuBar* menuBar = new QMenuBar( this );
    menuBar->addMenu( menu );
    layout()->setMenuBar( menuBar );
  }
  else
  {
    delete menu;
  }

  restoreGeometry();
  focusNextChild();
}
コード例 #5
0
ファイル: checkoption.cpp プロジェクト: marxsu/IFMA
void CheckOption::keyPressEvent(QKeyEvent *event)
{
    if(event->key()==Qt::Key_Enter)
    {
        focusNextChild();
    }
}
コード例 #6
0
bool SystemInfo::eventFilter(QObject *obj, QEvent *event) {
    //qDebug()<<"SystemInfo::eventFilter(QObject *obj, QEvent *event)";


    if (event->type() == QEvent::KeyRelease ) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *> (event);
        //        if(keyEvent->key() == Qt::Key_F8){
        //            slotScanSystem();
        //        }
        //        if(keyEvent->key() == Qt::Key_F5){
        //            slotUploadSystemInfo();
        //        }
        //        if(keyEvent->key() == Qt::Key_F9){
        //            slotQuerySystemInfo();
        //        }
        if(keyEvent->key() == Qt::Key_Return){
            focusNextChild();
        }
        if(keyEvent->key() == Qt::Key_Escape){
            slotResetAllInfo();
        }
        return true;
    }


    return QObject::eventFilter(obj, event);

}
コード例 #7
0
ファイル: qgsattributedialog.cpp プロジェクト: CS-SI/QGIS
void QgsAttributeDialog::init( QgsVectorLayer *layer, QgsFeature *feature, const QgsAttributeEditorContext &context, bool showDialogButtons )
{
  QgsAttributeEditorContext trackedContext = context;
  setWindowTitle( tr( "%1 - Feature Attributes" ).arg( layer->name() ) );
  setLayout( new QGridLayout() );
  layout()->setMargin( 0 );
  mTrackedVectorLayerTools.setVectorLayerTools( trackedContext.vectorLayerTools() );
  trackedContext.setVectorLayerTools( &mTrackedVectorLayerTools );
  if ( showDialogButtons )
    trackedContext.setFormMode( QgsAttributeEditorContext::StandaloneDialog );

  mAttributeForm = new QgsAttributeForm( layer, *feature, trackedContext, this );
  mAttributeForm->disconnectButtonBox();
  layout()->addWidget( mAttributeForm );
  QDialogButtonBox *buttonBox = mAttributeForm->findChild<QDialogButtonBox *>();
  connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsAttributeDialog::reject );
  connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsAttributeDialog::accept );
  connect( layer, &QObject::destroyed, this, &QWidget::close );

  mMenu = new QgsActionMenu( layer, mAttributeForm->feature(), QStringLiteral( "Feature" ), this );
  if ( !mMenu->actions().isEmpty() )
  {
    QMenuBar *menuBar = new QMenuBar( this );
    menuBar->addMenu( mMenu );
    layout()->setMenuBar( menuBar );
  }

  restoreGeometry();
  focusNextChild();
}
コード例 #8
0
ファイル: wdocument.cpp プロジェクト: q4a/ananas-labs-qt4
/*!
 *\~english
 *\~russian
 *\~
 *\param - \~english \~russian \~
 */
void
wDocument::initObject( aDatabase *adb )
{
    aWidget::initObject( adb );
    QObject *obj;
    QObjectList lb = this->queryList( "wDBField" );
    QListIterator<QObject*> itb( lb ); // iterate over the buttons
    while ( itb.hasNext() )
    {
        obj = itb.next();
//		if ( (wActionButtton*) obj )->isActionUpdate() )
        connect( (wDBField *)obj, SIGNAL(valueChanged( const QVariant & )),
                 this, SLOT(valueChanged( const QVariant & )) );
    }
    //--delete lb; // delete the list, not the objects
    lb = this->queryList( "wDBTable" );
    QListIterator<QObject*> itb1( lb ); // iterate over the buttons
    while ( itb1.hasNext() )
    {
        obj = itb1.next();
//		if ( (wActionButtton*) obj )->isActionUpdate() )
        connect( this, SIGNAL(changeObj(const QString &)),
                 (wDBTable *)obj, SLOT(newFilter(const QString &)));
        connect( this, SIGNAL(changeObjId(const qulonglong)),
                 (wDBTable *)obj, SLOT(newDataId(const qulonglong)));
    }
    //--delete lb; // delete the list, not the objects
    //--focusData()->next()->setFocus();
    focusNextChild();
}
コード例 #9
0
ファイル: KoZoomInput.cpp プロジェクト: ChrisJong/krita
void KoZoomInput::keyPressEvent(QKeyEvent* event)
{
    if (event->key() == Qt::Key_Return ||
        event->key() == Qt::Key_Enter)
    {
        focusNextChild();
    }
}
コード例 #10
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();
}
コード例 #11
0
void FindBar::onKeyDown(PolyKEY key, wchar_t charCode) {
	if(key == KEY_TAB) {
		focusNextChild();
	}
	
	if(key == KEY_ESCAPE) {
	
	}	
}
コード例 #12
0
void ColorBandComboBox::keyPressEvent(QKeyEvent * event)
{
    int key = event->key();
    for(int index=0; index< model()->rowCount(); ++index) {
        QVariant var = itemData(index, ShortcutRole);
        if(var.isValid() && var.toInt()==key) {
            setCurrentIndex(index);
            focusNextChild();
            return;
        }
    }
    QComboBox::keyPressEvent(event);
}
コード例 #13
0
ファイル: KeySequenceWidget.cpp プロジェクト: 335/synergy
void KeySequenceWidget::stopRecording()
{
	if (!keySequence().valid())
	{
		keySequence() = backupSequence();
		updateOutput();
	}

	setDown(false);
	focusNextChild();
	releaseKeyboard();
	setStatus(Stopped);
	emit keySequenceChanged();
}
コード例 #14
0
ファイル: KoZoomInput.cpp プロジェクト: ChrisJong/krita
bool KoZoomInput::eventFilter(QObject* watched, QEvent* event)
{
    if(watched == d->combo->view() && event->type() == QEvent::Hide)
    {
        focusNextChild();
        setCurrentIndex(0);
    }
    else if (watched == d->combo && event->type() == QEvent::FocusOut &&
            (d->combo->view() && !d->combo->view()->hasFocus()) && !d->inside)
    {
        setCurrentIndex(0);
    }
    return false;
}
コード例 #15
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);
        }
    }
}
コード例 #16
0
void SyntaxLineEdit::completionKeyPressEvent(QKeyEvent *event)
{
    // Forward to the completer if needed...
    if (completer_ && completer_->popup()->isVisible()) {
        switch (event->key()) {
        case Qt::Key_Enter:
        case Qt::Key_Return:
        case Qt::Key_Tab:
            focusNextChild();
            break;
        case Qt::Key_Escape:
        case Qt::Key_Backtab:
            event->ignore();
            return;
        default:
            break;
        }
    }

    // ...otherwise process the key ourselves.
    SyntaxLineEdit::keyPressEvent(event);

    if (!completer_ || !completion_model_) return;

    // Do nothing on bare shift.
    if ((event->modifiers() & Qt::ShiftModifier) && event->text().isEmpty()) return;

    if (event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)) {
        completer_->popup()->hide();
        return;
    }

    QPoint token_coords(getTokenUnderCursor());

    QString token_word = text().mid(token_coords.x(), token_coords.y());
    buildCompletionList(token_word);

    if (completion_model_->stringList().length() < 1) {
        completer_->popup()->hide();
        return;
    }

    QRect cr = cursorRect();
    cr.setWidth(completer_->popup()->sizeHintForColumn(0)
                + completer_->popup()->verticalScrollBar()->sizeHint().width());
    completer_->complete(cr);
}
コード例 #17
0
ファイル: menu_favormanager.cpp プロジェクト: galiqt/galiqt
void MenuFavorManager::keyPressEvent(QKeyEvent *event)
{
    switch (event->key())
    {
    case Qt::Key_Menu:
        break;
    case Qt::Key_Escape:
        break;
    case Qt::Key_Right:
    case Qt::Key_Left:
        focusNextChild();
        break;
    default:
        QWidget::keyPressEvent(event);
        break;
    }
}
コード例 #18
0
ファイル: hospitalisationpay.cpp プロジェクト: histest/his
bool HospitalisationPay::eventFilter(QObject*obj,QEvent*event)
{
	/* if(obj == ui.nameEdit)
	{
	if(event->type() == QEvent::KeyPress)
	{
	QKeyEvent*keyEvent=static_cast<QKeyEvent*>(event);
	if(keyEvent->key() == Qt::Key_Return)
	{

	QString strname = ui.nameEdit->text();
	QSqlQuery query(*sql.db);		
	query.exec("select * from zy_patientinfo where patientname= '"+strname+"'");
	while(query.next())
	{
	ui.nameEdit->setText(query.value(4).toString());
	ui.registrydateEdit->setText(query.value(2).toString());
	ui.bedEdit->setText(query.value(17).toString());
	ui.hospitalNocomboBox->setCurrentIndex(query.value(0).toInt()-1);
	}
	return  true;
	}
	else
	{
	return  false;
	}
	}
	else
	{
	return  false;
	}

	}*/
	 if(obj == this)
	 {
		 if(event->type() == QEvent::KeyPress)
		 {
			 QKeyEvent*keyEvent=static_cast<QKeyEvent*>(event);
			 if(keyEvent->key() == Qt::Key_Return)
			 {
				 focusNextChild();
				 return true;
			 }
		 }
	 }
}
コード例 #19
0
ファイル: QGLWidget_DhClass.cpp プロジェクト: uduki/hsQt
bool DhQGLWidget::DvhfocusNextChild() {
  return focusNextChild();
}
コード例 #20
0
ファイル: QPushButton_DhClass.cpp プロジェクト: bennofs/hsQt
bool DhQPushButton::DvhfocusNextChild() {
  return focusNextChild();
}
コード例 #21
0
bool DhQAbstractSpinBox::DvhfocusNextChild() {
  return focusNextChild();
}
コード例 #22
0
bool BATCH_KERNEL::eventFilter ( QObject *obj, QEvent *event )
{
    //FIXME FORM DADA VAR AYNISI
    if ( event->type() EQ QEvent::MouseButtonPress ) {
        QMouseEvent * mouse_event = static_cast <QMouseEvent *>(event);

        if ( obj->metaObject()->className() EQ QLineEdit::staticMetaObject.className() AND mouse_event->button() EQ Qt::LeftButton ) {
            QLineEdit * line_edit = static_cast<QLineEdit *> (obj);
            if ( line_edit->hasFocus() EQ true AND line_edit->selectedText() NE line_edit->text() ) {
                if (line_edit->cursorPosition() EQ 0 ) {
                    line_edit->selectAll();
                    return true;
                }
            }
        }
    }

    //--------------------- USER VE RESIZE EVENTS

    if  ( event->type() EQ QEvent::User OR event->type() EQ QEvent::Resize ) {
         return BASE_KERNEL::eventFilter ( obj,event );
    }

    // ---------------------------- KEY PRESS

    if ( event->type() EQ QEvent::KeyPress ) {
         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);

         if ( obj->metaObject()->className() EQ QTextEdit::staticMetaObject.className() OR
              obj->metaObject()->className() EQ QPlainTextEdit::staticMetaObject.className() OR
              obj->metaObject()->className() EQ QLimitedTextEdit::staticMetaObject.className() ) {
             if ( keyEvent->key() EQ Qt::Key_Tab ) {
                 focusNextChild();
                 return true;
             }
             return false;
         }

        if ( keyEvent->key() EQ Qt::Key_Escape ) {
            ADAK_CLOSE();
            return true;
        }

        if ( obj->metaObject()->className() EQ QComboBox::staticMetaObject.className() ) {
            if ( event->type() EQ QEvent::Wheel ) {
                 return true;
            }
        }
        // run_bacth_button focus eklendi cunku run_batch cagrilmadan once focuslanmasi gerekiyor
        // boylece adakdate yapilan degisikligi daha once yapmis oluyor..
        if (  ( keyEvent->key() EQ Qt::Key_Enter OR keyEvent->key() EQ Qt::Key_Return) AND p_run_batch_on_enter ) {
            run_batch_button->setFocus();
            SLOT_RUN_BATCH_BUTTON();
            return true;
        }
    }

    // ---------------------------- CLOSE EVENT

    if ( event->type() EQ QEvent::Close ) {
        return BASE_KERNEL::eventFilter(obj,event);
    }

    if ( close_event_started EQ true) {
         return false;
    }

    // ---------------------------- FOCUS IN EVENT

    if ( event->type() EQ QEvent::FocusIn ) {
        QFocusEvent * focus_event = static_cast<QFocusEvent *>(event);

        bool return_value = CHECK_VAR_CONTROL ( obj );

        //FIXME FORM DADA VAR AYNISI
        if (focus_event->reason() EQ Qt::MouseFocusReason ) {
            if ( obj->metaObject()->className() EQ QLineEdit::staticMetaObject.className()) {
                QLineEdit * line_edit = static_cast<QLineEdit *> (obj);
                line_edit->setCursorPosition(0);
            }
        }

        return return_value;
    }

    return BASE_EVENT_KERNEL::eventFilter(obj,event);
}
コード例 #23
0
ファイル: QGroupBox_DhClass.cpp プロジェクト: bennofs/hsQt
bool DhQGroupBox::DvhfocusNextChild() {
  return focusNextChild();
}
コード例 #24
0
ファイル: widget_combo_edit.cpp プロジェクト: galiqt/galiqt
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;
    }
}
コード例 #25
0
bool DhQStackedWidget::DvhfocusNextChild() {
    return focusNextChild();
}
コード例 #26
0
ファイル: CustomComboBox.cpp プロジェクト: anchowee/LAN_IM
/*************************************************
Function Name: focusInEvent
Description: receive focus events (focus received) for the widget
*************************************************/
void CustomComboBox::focusInEvent(QFocusEvent *event)
{
    showPopup();
    QComboBox::focusInEvent(event);
    focusNextChild();
}
コード例 #27
0
ファイル: QSlider_DhClass.cpp プロジェクト: bennofs/hsQt
bool DhQSlider::DvhfocusNextChild() {
  return focusNextChild();
}
コード例 #28
0
ファイル: QScrollArea_DhClass.cpp プロジェクト: bennofs/hsQt
bool DhQScrollArea::DvhfocusNextChild() {
  return focusNextChild();
}