Ejemplo n.º 1
0
bool KviWindow::eventFilter(QObject * pObject, QEvent * pEvent)
{
	switch(pEvent->type())
	{
		case QEvent::FocusIn:
			// a child got focused
			m_pLastFocusedChild = (QWidget *)pObject;
			if(g_pActiveWindow != this)
				g_pMainWindow->windowActivated(this);
			break;
		case QEvent::Enter:
			// this is a handler moved here from KviMdiChild::eventFilter
			if(QApplication::overrideCursor())
				QApplication::restoreOverrideCursor();
			break;
		case QEvent::ChildAdded:
			if(((QChildEvent *)pEvent)->child()->isWidgetType())
				childInserted((QWidget *)((QChildEvent *)pEvent)->child());
			break;
		case QEvent::ChildRemoved:
			if(((QChildEvent *)pEvent)->child()->isWidgetType())
				childRemoved((QWidget *)((QChildEvent *)pEvent)->child());
			break;
		default: /* make gcc happy */
			break;
	}
	return false;
}
Ejemplo n.º 2
0
void KviWindow::childInserted(QWidget * pObject)
{
	pObject->removeEventFilter(this);  // ensure that we don't filter twice
	pObject->installEventFilter(this); // we filter its events

	connect(pObject, SIGNAL(destroyed()), this, SLOT(childDestroyed()));

	// attempt to grab a decent focus handler

	if(pObject->inherits("KviInput"))
	{
		// KviInput is our preferential focus handler
		m_pFocusHandler = pObject;
	}
	else
	{
		// not a KviInput
		if(!m_pFocusHandler && (pObject->focusPolicy() == Qt::StrongFocus))
		{
			// still without a focus handler: take this widget (possibly only temporarily)
			m_pFocusHandler = pObject;
		}
	}

	for(auto & it : pObject->children())
	{
		QObject * pObj = it;
		if(pObj->isWidgetType())
			childInserted((QWidget *)pObj);
	}
}
Ejemplo n.º 3
0
void KviWindow::childEvent(QChildEvent * pEvent)
{
	if(pEvent->child()->isWidgetType())
	{
		if(pEvent->removed())
			childRemoved((QWidget *)(pEvent->child()));
		else
			childInserted((QWidget *)(pEvent->child()));
	}
	QWidget::childEvent(pEvent);
}
Ejemplo n.º 4
0
bool KviWindow::eventFilter(QObject * pObject, QEvent * pEvent)
{
    switch(pEvent->type())
    {
    case QEvent::FocusIn:
        // a child got focused
        m_pLastFocusedChild = (QWidget *)pObject;
        if(g_pActiveWindow != this)
            g_pMainWindow->childWindowActivated(this);
        break;
    case QEvent::Enter:
        // this is a handler moved here from KviMdiChild::eventFilter
        if(QApplication::overrideCursor())
            QApplication::restoreOverrideCursor();
        break;
#if 0
    case QEvent::MouseButtonPress:
        if((((QWidget *)pObject)->focusPolicy() == Qt::NoFocus) ||
                (((QWidget *)pObject)->focusPolicy() == Qt::TabFocus))
        {
            // this will not focus our window
            // set the focus to the focus handler
            if(m_pLastFocusedChild)
            {
                if(m_pLastFocusedChild->hasFocus() && m_pLastFocusedChild->isVisible())
                    return false;
            }

            if(m_pFocusHandler)
                m_pFocusHandler->setFocus();
            else
                setFocus(); // we grab the focus (someone must do it, damn :D)
        }
        break;
#endif
    case QEvent::ChildAdded:
        if(((QChildEvent *)pEvent)->child()->isWidgetType())
            childInserted((QWidget *)((QChildEvent *)pEvent)->child());
        break;
    case QEvent::ChildRemoved:
        if(((QChildEvent *)pEvent)->child()->isWidgetType())
            childRemoved((QWidget *)((QChildEvent *)pEvent)->child());
        break;
    default: /* make gcc happy */
        break;
    }
    return false;
}