bool FindToolWindow::event(QEvent *event)
{
    if (event->type() == QEvent::KeyPress) {
        QKeyEvent *ke = static_cast<QKeyEvent *>(event);
        if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)
                && (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::KeypadModifier)) {
            ke->accept();
            if (m_ui.searchButton->isEnabled())
                search();
            return true;
        }
    }
    return QWidget::event(event);
}
Example #2
1
bool QtApp::notify(QObject* object, QEvent* event) {
	if (strcmp(object->metaObject()->className(), "QWidgetWindow") == 0)
		if (event->type() == QEvent::KeyPress) {
			QKeyEvent* Qk = static_cast<QKeyEvent*>(event);
			if (!Qk->isAutoRepeat()) {
				INPUT->registerPressed(Qk->key());
				if (Qk->key() == Qt::Key_Tab && SFML->QWidget::hasFocus()) // No tab while drawing
					return false;
			}
		}
		else if (event->type() == QEvent::KeyRelease) {
			QKeyEvent* Qk = static_cast<QKeyEvent*>(event);
			if (!Qk->isAutoRepeat())
				INPUT->registerReleased(Qk->key());
		}
		
	return QApplication::notify(object, event);
}
Example #3
0
// Reimplemented 
bool QmvList::eventFilter( QObject *o, QEvent *e )
{
    if ( !o || !e )
	return TRUE;

    QmvItem *i = (QmvItem*)currentItem();
    if ( o != this &&e->type() == QEvent::KeyPress )
    {
	QKeyEvent *ke = (QKeyEvent*)e;
	if ( ( ke->key() == Key_Up || ke->key() == Key_Down ) &&
	     ( o != this || o != viewport() ) &&
	     !( ke->state() & ControlButton ) )
        {
	    QApplication::sendEvent( this, (QKeyEvent*)e );
	    return TRUE;
	} else
            if ( ( !o->inherits( "QLineEdit" ) ||
                   ( o->inherits( "QLineEdit" ) && ( (QLineEdit*)o )->isReadOnly() ) ) &&
                 i && i->hasSubItems() )
            {
                if ( !i->isOpen() &&
                     ( ke->key() == Key_Plus ||
                       ke->key() == Key_Right ))
                    i->setOpen( TRUE );
                else
                    if ( i->isOpen() &&
                         ( ke->key() == Key_Minus ||
                           ke->key() == Key_Left ) )
                        i->setOpen( FALSE );
            } else
                if ( ( ke->key() == Key_Return || ke->key() == Key_Enter ) && o->inherits( "QComboBox" ) )
                {
                    QKeyEvent ke2( QEvent::KeyPress, Key_Space, 0, 0 );
                    QApplication::sendEvent( o, &ke2 );
                    return TRUE;
                }
    }
    
    return QListView::eventFilter( o, e );
}
Example #4
0
bool OpenEditorsWidget::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == m_ui.editorList && event->type() == QEvent::KeyPress
            && m_ui.editorList->currentIndex().isValid()) {
        QKeyEvent *ke = static_cast<QKeyEvent*>(event);
        if ((ke->key() == Qt::Key_Return
                || ke->key() == Qt::Key_Enter)
                && ke->modifiers() == 0) {
            activateEditor(m_ui.editorList->currentIndex());
            return true;
        } else if ((ke->key() == Qt::Key_Delete
                   || ke->key() == Qt::Key_Backspace)
                && ke->modifiers() == 0) {
            closeEditor(m_ui.editorList->currentIndex());
        }
    }
    return false;
}
Example #5
0
/**
 * Event filters on the task dialog
 */
bool TodoDialog::eventFilter(QObject *obj, QEvent *event) {
    if (event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);

        if (obj == ui->newItemEdit) {
            // set focus to the task list if Key_Down or Key_Tab
            // were pressed in the new item edit
            if ((keyEvent->key() == Qt::Key_Down) ||
                    (keyEvent->key() == Qt::Key_Tab)) {
                // choose an other selected item if current item is invisible
                QListWidgetItem *item = ui->todoList->currentItem();
                if ((item != NULL) && ui->todoList->currentItem()->isHidden() &&
                    (firstVisibleTodoListRow >= 0)) {
                    ui->todoList->setCurrentRow(firstVisibleTodoListRow);
                }

                // give the keyboard focus to the task list widget
                ui->todoList->setFocus();
                return true;
            }

            return false;
        } else if (obj == ui->todoList) {
            // set focus to the description edit if the tab key is pressed
            if (keyEvent->key() == Qt::Key_Tab) {
                ui->descriptionEdit->setFocus();
                return true;
            } else if ((keyEvent->key() == Qt::Key_Delete) ||
                       (keyEvent->key() == Qt::Key_Backspace)) {
                on_removeButton_clicked();
                return true;
            }

            return false;
        } else if (obj == ui->reminderDateTimeEdit) {
            // store the task and set focus to the description edit if the
            // return key is pressed
            if (keyEvent->key() == Qt::Key_Return) {
                on_saveButton_clicked();
                ui->descriptionEdit->setFocus();
                return true;
            }

            return false;
        }
    }

    return QDialog::eventFilter(obj, event);
}
Example #6
0
bool QAccel::eventFilter( QObject *o, QEvent *e )
{
    if ( e->type() == QEvent::Reparent && d->watch == o ) {
        repairEventFilter();
    } else  if ( d->enabled &&
                 ( e->type() == QEvent::Accel ||
                   e->type() == QEvent::AccelAvailable) &&
                 d->watch && d->watch->isVisible() ) {
        QKeyEvent *k = (QKeyEvent *)e;
        int key = k->key();
        if ( k->state() & ShiftButton )
            key |= SHIFT;
        if ( k->state() & ControlButton )
            key |= CTRL;
        if ( k->state() & AltButton )
            key |= ALT;
        QAccelItem *item = find_key( d->aitems, key, k->text()[0] );
        if ( key == Key_unknown )
            item = 0;
#ifndef QT_NO_WHATSTHIS
        bool b = QWhatsThis::inWhatsThisMode();
#else
        bool b = FALSE;
#endif
        if ( item && ( item->enabled || b )) {
            if (e->type() == QEvent::Accel) {
                if ( b && !d->ignorewhatsthis ) {
#ifndef QT_NO_WHATSTHIS
                    QWhatsThis::leaveWhatsThisMode( item->whatsthis );
#endif
                }
                else if ( item->enabled ) {
                    if ( item->signal )
                        item->signal->activate();
                    else
                        emit activated( item->id );
                }
            }
            k->accept();
            return TRUE;
        }
    }
    return QObject::eventFilter( o, e );
}
 bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
 {
	  if (event->type() == QEvent::KeyPress) {
			QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
			//printf("Ate key press %d. repeat %d. mod: %d\n", keyEvent->key(),(int)keyEvent->isAutoRepeat(),(int)keyEvent->modifiers());
			if(!keyEvent->isAutoRepeat() && keyEvent->modifiers()==Qt::NoModifier)
				emit Key(keyEvent->key());
			if(keyEvent->modifiers()==Qt::ControlModifier && keyEvent->key()==Qt::Key_C)
				emit Key(0);
			return true;
	  } else {
			// standard event processing
			return QObject::eventFilter(obj, event);
	  }
 }
Example #8
0
// Used to intercept the user hitting the up arrow in the input widget
bool MainWindow::eventFilter(QObject* obj, QEvent* event)
{
	// Only filter keypresses
	QKeyEvent* keyEvent = nullptr;
	if (event->type() == QEvent::KeyPress)
	{
		keyEvent = static_cast<QKeyEvent*>(event);
	}
	else
	{
		return QObject::eventFilter(obj, event);
	}

	// Catch up & down keys
	if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down)
	{
		if (keyEvent->key() == Qt::Key_Up)
		{
			if (m_historyIndex > 0)
				m_historyIndex--;
		}
		else if (keyEvent->key() == Qt::Key_Down)
		{
			if (m_historyIndex < m_inputHistory.size())
				m_historyIndex++;
		}

		// Populate the input edit or clear it if you're at the end
		if (m_historyIndex == m_inputHistory.size())
		{
			m_inputEdit->setText("");
		}
		else
		{
			m_inputEdit->setText(m_inputHistory[m_historyIndex]);
		}
	}
	else if (keyEvent->key() == Qt::Key_Enter)
	{
		executeCommand(false);
	}
	else
	{
		return QObject::eventFilter(obj, event);
	}

	return true;
}
Example #9
0
bool TextView::eventFilter(QObject *obj, QEvent *event)
{
#ifdef SCINTILLA
    QAbstractScrollArea * sa = scintEditor;
#else
    QAbstractScrollArea * sa = plainTextEdit;
#endif

    if (obj == sa) {
        sa->setAttribute(Qt::WA_NoMousePropagation, false);
        if (event->type() == QEvent::KeyPress) {
             QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
             switch (keyEvent->key())
             {
                 case Qt::Key_Z:
                     if (keyEvent->modifiers().testFlag(Qt::ShiftModifier) && keyEvent->modifiers().testFlag(Qt::ControlModifier)) {
                         byteSource->historyForward();
                         keyEvent->accept();
                         return true;
                     }
                     else if (keyEvent->modifiers().testFlag(Qt::ControlModifier)) {
                         byteSource->historyBackward();
                         keyEvent->accept();
                         return true;
                     }
                    break;
                 default:
                     return false;
             }

        } else if (event->type() == QEvent::Wheel) {
            if (sa->verticalScrollBar()->isVisible()) {
                sa->setAttribute(Qt::WA_NoMousePropagation);
            }

            return false;
        }
    }

    return QWidget::eventFilter(obj, event);

}
Example #10
0
bool Application::notify(QObject *receiver, QEvent *e)
{
    #ifdef BANG_EDITOR
    if (receiver == focusWidget())
    {
        if (e->type() == QEvent::MouseButtonPress)
        {
            DragDropManager::HandleGlobalMousePress(receiver, e);
        }
        else if (e->type() == QEvent::MouseButtonRelease)
        {
            DragDropManager::HandleGlobalMouseRelease(receiver, e);
        }

        if (e->type() == QEvent::KeyPress)
        {
            QKeyEvent *ev = dynamic_cast<QKeyEvent*>(e);
            m_lastKeyPressEvInfo.time = Time::GetNow();
            m_lastKeyPressEvInfo.key = ev->key();
            if (!ev->isAutoRepeat())
            {
                ShortcutManager::GetInstance()->OnKeyPressed( Input::Key(ev->key()) );
            }
        }
        else if (e->type() == QEvent::KeyRelease)
        {
            QKeyEvent *ev = dynamic_cast<QKeyEvent*>(e);
            if (!ev->isAutoRepeat())
            {
                ShortcutManager::GetInstance()->OnKeyReleased( Input::Key(ev->key()) );
            }
        }

        if (e->type() == QEvent::Shortcut)
        {
            ShortcutManager::GetInstance()->Clear();
        }
    }
    #endif

    return QApplication::notify(receiver, e);
}
bool QtKeyEventProvider::eventFilter(QObject * obj, QEvent * event)
{
    if (event->type() == QEvent::KeyPress ||
        event->type() == QEvent::KeyRelease)
    {
        QKeyEvent * qKeyEvent = dynamic_cast<QKeyEvent*>(event);
        if (qKeyEvent) {
            auto eventType = QtEventTransformer::keyboardTypeFromQtType(qKeyEvent->type());
            auto key = QtEventTransformer::fromQtKeyCode(qKeyEvent->key(), qKeyEvent->modifiers());
            KeyboardEvent * keyEvent = new KeyboardEvent(eventType
                , key, qKeyEvent->nativeScanCode(), qKeyEvent->modifiers());
            passEvent(keyEvent);
            return false;
        }
    }
    return QObject::eventFilter(obj, event);
}
Example #12
0
bool ChatbarTextEdit::event(QEvent *evt) {
	if (evt->type() == QEvent::ShortcutOverride) {
		return false;
	}

	if (evt->type() == QEvent::KeyPress) {
		QKeyEvent *kev = static_cast<QKeyEvent*>(evt);
		if ((kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return) && !(kev->modifiers() & Qt::ShiftModifier)) {
			g.mw->sendChatbarMessage();
			return true;
		}
		if (kev->key() == Qt::Key_Tab) {
			emit tabPressed();
			return true;
		} else if (kev->key() == Qt::Key_Space && kev->modifiers() == Qt::ControlModifier) {
			emit ctrlSpacePressed();
			return true;
		}
	}
	return QTextEdit::event(evt);
}
bool RKFunctionArgHinter::eventFilter (QObject *, QEvent *e) {
	if (e->type () == QEvent::KeyPress || e->type () == QEvent::AccelOverride) {
		RK_TRACE (COMMANDEDITOR);	// avoid loads of empty traces, putting this here
		QKeyEvent *k = static_cast<QKeyEvent *> (e);

		if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return || k->key () == Qt::Key_Up || k->key () == Qt::Key_Down || k->key () == Qt::Key_Left || k->key () == Qt::Key_Right || k->key () == Qt::Key_Home || k->key () == Qt::Key_Tab) {
			hideArgHint ();
		} else if (k->key () == Qt::Key_Backspace || k->key () == Qt::Key_Delete){
			tryArgHint ();
		} else {
			QString text = k->text ();
			if (text == "(") {
				tryArgHint ();
			} else if (text == ")") {
				tryArgHint ();
			}
		}
	}

	return false;
}
bool KLSHistoryCombo::eventFilter( QObject *o, QEvent *ev )
{
    // Handle Ctrl+Del/Backspace etc better than the Qt widget, which always
    // jumps to the next whitespace.
    QLineEdit *edit = lineEdit();
    if ( o == edit )
    {
        int type = ev->type();
        if ( type == QEvent::KeyPress )
        {
            QKeyEvent *e = static_cast<QKeyEvent *>( ev );

            if ( e->key() == Key_Return || e->key() == Key_Enter )
            {
                //m_modifier = e->state();
                return false;
            }

            int delete_word_back = KStdAccel::deleteWordBack().keyCodeQt();
            int delete_word_forward = KStdAccel::deleteWordForward().keyCodeQt();

            if ( KKey( e ) == KKey(delete_word_back) ||
                    KKey( e ) == KKey(delete_word_forward) ||
                    ((e->state() & ControlButton) &&
                     (e->key() == Key_Left || e->key() == Key_Right) ) )
            {
                selectWord(e);
                e->accept();
                return true;
            }
        }

        else if ( type == QEvent::MouseButtonDblClick )
        {
            edit->selectAll();
            return true;
        }
    }
    return KComboBox::eventFilter( o, ev );
}
Example #15
0
bool Question_widget::eventFilter(QObject *object, QEvent *event) {
  //if (object == ui->answer_editor) {
  if (buttons_widgets.contains(static_cast<QPushButton*>(object))) {
    if (event->type() == QEvent::KeyPress) {
      QKeyEvent* e = static_cast<QKeyEvent*>(event);
      if (e->key() == Qt::Key_Escape) {
        //ui->answer_frame->hide();
        main_window->get_active_pane()->setFocus();
        return true;
      } else if (e->key() == Qt::Key_Down) {
        main_window->switch_focus_question(this, 1);
        return true;
      } else if (e->key() == Qt::Key_Up) {
        main_window->switch_focus_question(this, -1);
        return true;
      } else if (e->key() == Qt::Key_Left && buttons_widgets.first() == object) {
        buttons_widgets.last()->setFocus();
        return true;
      } else if (e->key() == Qt::Key_Right && buttons_widgets.last() == object) {
        buttons_widgets.first()->setFocus();
        return true;
      }
      bool ok;
      int number = e->text().toInt(&ok);
      if (ok) {
        for(int i = 0; i < buttons.count(); i++) {
          if (buttons[i].number == number) {
            answered(buttons[i].data);
            main_window->get_active_pane()->setFocus();
            deleteLater();
            return true;
          }
        }
      }
    } else if (event->type() == QEvent::FocusOut) {
      //ui->answer_frame->hide();
    }
  }
  return false;
}
Example #16
0
bool TreeView::eventFilter(QObject *obj, QEvent *event)
{
	if (event->type() == QEvent::ShortcutOverride) {
		QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
		if (keyEvent->modifiers().testFlag(Qt::NoModifier)) {
			// If one has assigned a simple key like 'N' to 'Skip Forward' we don't actually want to skip the track
			if (65 <= keyEvent->key() && keyEvent->key() <= 90) {
				// We don't want this event to be propagated
				keyEvent->accept();
				return true;
			}
		} else {
			keyEvent->ignore();
			return false;
		}
	}
	return QTreeView::eventFilter(obj, event);
}
bool KGVSimplePrintPreviewWindow::event( QEvent * e )
{
  QEvent::Type t = e->type();
  if (t==QEvent::KeyPress)
  {
    QKeyEvent *ke = static_cast<QKeyEvent*>(e);
    const int k = ke->key();
    bool ok = true;
    if (k==Qt::Key_Equal || k==Qt::Key_Plus)
            slotZoomInClicked();
    else if (k==Qt::Key_Minus)
            slotZoomOutClicked();
    else if (k==Qt::Key_Home)
            slotFirstClicked();
    else if (k==Qt::Key_End)
            slotLastClicked();
    else
            ok = false;

    if (ok)
    {
      ke->accept();
      return true;
    }
  }
  else if (t==QEvent::ShortcutOverride)
  {
    QKeyEvent *ke = static_cast<QKeyEvent*>(e);
    const int k = ke->key();
    bool ok = true;
    if (k==Qt::Key_PageUp)
            slotPreviousClicked();
    else if (k==Qt::Key_PageDown)
            slotNextClicked();
    else
            ok = false;

    if (ok) {
            ke->accept();
            return true;
    }
  }
  return QWidget::event(e);
}
Example #18
0
//-----------------------------------------------------------------------------
bool ctkDoubleSpinBox::eventFilter(QObject* obj, QEvent* event)
{
  Q_D(ctkDoubleSpinBox);
  if (d->DOption & ctkDoubleSpinBox::DecimalsByShortcuts &&
    obj == d->SpinBox && event->type() == QEvent::KeyPress)
    {
    QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
    Q_ASSERT(keyEvent);
    int newDecimals = -1;
    if (keyEvent->modifiers() & Qt::ControlModifier)
      {
      if (keyEvent->key() == Qt::Key_Plus
        || keyEvent->key() == Qt::Key_Equal)
        {
        newDecimals = this->decimals() + 1;
        }
      else if (keyEvent->key() == Qt::Key_Minus)
        {
        newDecimals = this->decimals() - 1;
        }
      else if (keyEvent->key() == Qt::Key_0)
        {
        newDecimals = d->DefaultDecimals;
        }
      }
    if (newDecimals != -1)
      {
      double currentValue = this->value();
      if (d->Proxy)
        {
        currentValue = d->Proxy.data()->proxyValueFromValue(currentValue);
        }
      // increasing the number of decimals should restore lost precision
      d->setValue(currentValue, newDecimals);
      return true;
      }
    return QWidget::eventFilter(obj, event);
    }
  else
    {
    // pass the event on to the parent class
    return QWidget::eventFilter(obj, event);
    }
}
// The following keyboard shortcuts should work (although
// they may not work consistently depending on focus):
// / (slash), Ctrl-F - Focus and highlight the search box
// Ctrl-G, Ctrl-N, F3 - Find next
// Should we make it so that typing any text starts searching?
bool FollowStreamDialog::eventFilter(QObject *, QEvent *event)
{
    if (ui->teStreamContent->hasFocus() && event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
        if (keyEvent->matches(QKeySequence::SelectAll) || keyEvent->matches(QKeySequence::Copy)
                || keyEvent->text().isEmpty()) {
            return false;
        }
        ui->leFind->setFocus();
        if (keyEvent->matches(QKeySequence::Find)) {
            return true;
        } else if (keyEvent->matches(QKeySequence::FindNext)) {
            findText();
            return true;
        }
    }

    return false;
}
bool HelpBrowserFindBox::event( QEvent * event )
{
    switch(event->type()) {
    case QEvent::ShortcutOverride:
    {
        QKeyEvent *kevent = static_cast<QKeyEvent*>(event);
        if (kevent->key() == Qt::Key_Escape) {
            event->accept();
            return true;
        }
        if (kevent->key() == Qt::Key_W && (kevent->modifiers() & Qt::CTRL)) {
            MainWindow::instance()->helpBrowserDocklet()->close();
            event->accept();
            return true;
        }
    }
    case QEvent::KeyPress:
    {
        QKeyEvent *kevent = static_cast<QKeyEvent*>(event);
        switch (kevent->key()) {
        case Qt::Key_Return:
        case Qt::Key_Enter: {
            bool backwards = kevent->modifiers() & Qt::ShiftModifier;
            emit query( text(), backwards );
            return true;
        }
        case Qt::Key_Escape:
            clear();
        default:
            break;
        }
    }
    default:
        break;
    }

    return QLineEdit::event(event);
}
bool ossimQtImageControllerZoomEventFilter::eventFilter(QObject* /*obj*/,
                                                        QEvent* event)
{
   if(!theController) return false;
   
   if(!theController->getImageWidget()) return false;
   
   switch(event->type())
   {
      case QEvent::KeyPress:
      {
         QKeyEvent* keyEvent = (QKeyEvent*)event;
         if(keyEvent->stateAfter() & Qt::ShiftButton)
         {
	    theController->setZoomModeOut();
         }
         if(keyEvent->stateAfter() & Qt::ControlButton)
         {
            thePanToOverrideFlag = true;
         }
         break;
      }
      case QEvent::KeyRelease:
      {
         QKeyEvent* keyEvent = (QKeyEvent*)event;
         if(keyEvent->state() & Qt::ShiftButton)
         {
            theController->setZoomModeIn();
         }
         if(keyEvent->state() & Qt::ControlButton)
         {
            thePanToOverrideFlag = false;
         }
         break;
      }
      default:
      {
         break;
      }
   }
   
   return false;
}
Example #22
0
bool QFontDialog::eventFilter(QObject *o , QEvent *e)
{
    Q_D(QFontDialog);
    if (e->type() == QEvent::KeyPress) {
        QKeyEvent *k = (QKeyEvent *)e;
        if (o == d->sizeEdit &&
        (k->key() == Qt::Key_Up ||
             k->key() == Qt::Key_Down ||
         k->key() == Qt::Key_PageUp ||
         k->key() == Qt::Key_PageDown)) {

            int ci = d->sizeList->currentItem();
            (void)QApplication::sendEvent(d->sizeList, k);

            if (ci != d->sizeList->currentItem()
                    && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this))
                d->sizeEdit->selectAll();
            return true;
        } else if ((o == d->familyList || o == d->styleList) &&
                    (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) {
            k->accept();
        accept();
            return true;
        }
    } else if (e->type() == QEvent::FocusIn
               && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) {
        if (o == d->familyList)
            d->familyEdit->selectAll();
        else if (o == d->styleList)
            d->styleEdit->selectAll();
        else if (o == d->sizeList)
            d->sizeEdit->selectAll();
    } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) {
            d->sizeEdit->setFocus();
    }
    return QDialog::eventFilter(o, e);
}
Example #23
0
bool FApplication::eventFilter(QObject *obj, QEvent *event)
{
	// check whether the space bar is down.

	Q_UNUSED(obj);

	switch (event->type()) {
		case QEvent::MouseButtonPress:
			m_mousePressed = true;
			break;
		case QEvent::MouseButtonRelease:
			m_mousePressed = false;
			break;
		case QEvent::KeyPress:
			{
				if (!m_mousePressed) {
					QKeyEvent * kevent = static_cast<QKeyEvent *>(event);
					if (!kevent->isAutoRepeat() && (kevent->key() == Qt::Key_Space)) {
						m_spaceBarIsPressed = true;
						emit spaceBarIsPressedSignal(true);
					}
				}
			}
			break;
		case QEvent::KeyRelease:
			{
				if (m_spaceBarIsPressed) {
					QKeyEvent * kevent = static_cast<QKeyEvent *>(event);
					if (!kevent->isAutoRepeat() && (kevent->key() == Qt::Key_Space)) {
						m_spaceBarIsPressed = false;
						emit spaceBarIsPressedSignal(false);
					}
				}
			}
			break;
		default:
			break;
	}

	return false;
}
/*!
    \reimp
 */
bool QTabWidget::eventFilter( QObject *o, QEvent * e)
{
    if ( o == this ) {
	if ( e->type() == QEvent::LanguageChange || e->type() == QEvent::LayoutHint ) {
	    d->dirty = TRUE;
	    setUpLayout();
	    updateGeometry();
	} else if ( e->type() == QEvent::KeyPress ) {
	    QKeyEvent *ke = (QKeyEvent*) e;
	    if ( ( ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab ) &&
		 count() > 1 &&
		 ke->state() & Qt::ControlButton ) {
		int page = currentPageIndex();
		if ( ke->key() == Qt::Key_Backtab || ke->state() & Qt::ShiftButton ) {
		    page--;
		    if ( page < 0 )
			page = count() - 1;
		} else {
		    page++;
		    if ( page >= count() )
			page = 0;
		}
		setCurrentPage( page );
		if ( !qApp->focusWidget() )
		    d->tabs->setFocus();
		return TRUE;
	    }
	}

    } else if ( o == d->stack ) {
	if ( e->type() == QEvent::ChildRemoved
	     && ( (QChildEvent*)e )->child()->isWidgetType() ) {
	    removePage( (QWidget*)  ( (QChildEvent*)e )->child() );
	    return TRUE;
	} else if ( e->type() == QEvent::LayoutHint ) {
	    updateGeometry();
	}
    }
    return FALSE;
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
bool tApVrfCalibrationWizard::eventFilter(QObject* pObject, QEvent* pEvent)
{
    if ( m_CalibrationStep == eCS_ReadyForHoldToPort || m_CalibrationStep == eCS_HoldToPort )
    {
        if (pEvent->type() == QEvent::KeyPress) 
        {
            QKeyEvent* pKeyEvent = static_cast<QKeyEvent*>(pEvent);
            if ( pKeyEvent->key() == Key::Left || 
                 pKeyEvent->key() == Key::ZoomIn )
            {
                if ( pKeyEvent->isAutoRepeat() == false )
                {
                    OnTurnPortStart();
                }
                return true;
            }
        } 
    }

    if ( m_CalibrationStep == eCS_HoldToPort )
    {
        if (pEvent->type() == QEvent::KeyRelease) 
        {
            QKeyEvent* pKeyEvent = static_cast<QKeyEvent*>(pEvent);
            if ( pKeyEvent->key() == Key::Left || 
                 pKeyEvent->key() == Key::ZoomIn  )
            {
                if ( pKeyEvent->isAutoRepeat() == false )
                {
                    OnTurnPortStop();
                }
                return true;
            }
        } 
    }

    // pass the event 
    return QObject::eventFilter(pObject, pEvent);
}
Example #26
0
bool PlainTextEditor::event( QEvent* event )
{
    if ( event->type() == QEvent::KeyPress ) {
        QKeyEvent* ke = static_cast<QKeyEvent*>( event );
        const bool isBackTab =
                ( ke->key() == Qt::Key_Backtab && ( ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier ) ) ||
                ( ke->key() == Qt::Key_Tab && ke->modifiers() == Qt::ShiftModifier )
        ;
        const bool isTab = ke->key() == Qt::Key_Tab && ke->modifiers() == Qt::NoModifier;

        if ( isTab ) {
            onTabKey( ke );
            return true;
        }
        else if ( isBackTab ) {
            onShiftTabKey( ke );
            return true;
        }
    }

    return QPlainTextEdit::event( event );
}
Example #27
0
bool MainView::event( QEvent *event )
{
	switch (event->type())
	{
		case QEvent::KeyPress :
		{
			QKeyEvent *k = (QKeyEvent *)event;
			keyPressEvent(k);
			if (k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab ) event->accept();
			return true;
		}
		break;
		case QEvent::KeyRelease :
		{
			QKeyEvent *k = (QKeyEvent *)event;
			keyReleaseEvent(k);
			if (k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab ) event->accept();
			return true;
		}
		break;
		default: return View::event( event );
	}
}
Example #28
0
bool StatusFilter::eventFilter( QObject *dist, QEvent *event )
{
  if ( event->type() == QEvent::KeyPress )
  {
    QKeyEvent *keyEvent = static_cast<QKeyEvent*>( event );
    if ( keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return )
    {
      emit enterPressed();
      return true;
    }
    if ( keyEvent->key() == Qt::Key_Escape )
    {
      emit escPressed();
      return true;
    }
    if ( keyEvent->key() == Qt::Key_J && keyEvent->modifiers() == Qt::ControlModifier )
    {
      emit shortenUrlPressed();
      return true;
    }
  }
  return QObject::eventFilter(dist, event);
}
Example #29
0
bool PropertiesDock::event(QEvent *event)
{
    switch (event->type()) {
    case QEvent::ShortcutOverride: {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->matches(QKeySequence::Delete) || keyEvent->key() == Qt::Key_Backspace
                || keyEvent->matches(QKeySequence::Cut)
                || keyEvent->matches(QKeySequence::Copy)
                || keyEvent->matches(QKeySequence::Paste)) {
            event->accept();
            return true;
        }
        break;
    }
    case QEvent::LanguageChange:
        retranslateUi();
        break;
    default:
        break;
    }

    return QDockWidget::event(event);
}
Example #30
0
      bool notify(QObject* receiver, QEvent* event) {
         bool flag = QApplication::notify(receiver, event);
         if (event->type() == QEvent::KeyPress) {
#if QT_VERSION >= 0x050000
            const QMetaObject * mo = receiver->metaObject();
            bool forQWidgetWindow = false;
            if (mo){
               if (strcmp(mo->className(), "QWidgetWindow") == 0)
                  forQWidgetWindow = true;
            }
            if(forQWidgetWindow){
               return false;
            }
#endif
            QKeyEvent* ke = (QKeyEvent*)event;
            MusEGlobal::globalKeyState = ke->modifiers();
            bool accepted = ke->isAccepted();
            if (!accepted) {
               int key = ke->key();
               if (((QInputEvent*)ke)->modifiers() & Qt::ShiftModifier)
                  key += Qt::SHIFT;
               if (((QInputEvent*)ke)->modifiers() & Qt::AltModifier)
                  key += Qt::ALT;
               if (((QInputEvent*)ke)->modifiers() & Qt::ControlModifier)
                  key+= Qt::CTRL;
               muse->kbAccel(key);
               return true;
            }
         }
         if (event->type() == QEvent::KeyRelease) {
            QKeyEvent* ke = (QKeyEvent*)event;
            ///MusEGlobal::globalKeyState = ke->stateAfter();
            MusEGlobal::globalKeyState = ke->modifiers();
         }

         return flag;
      }