bool DMainWindow::eventFilter(QObject *obj, QEvent *ev)
{
    QWidget *w = (QWidget*)obj;
    if (!m_widgets.contains(w))
        return KParts::MainWindow::eventFilter(obj, ev);
    
    if ((m_currentWidget != w) && (ev->type() == QEvent::FocusIn))
    {
        m_currentWidget = w;
        emit widgetChanged(w);
    }
    else if (ev->type() == QEvent::IconChange)
    {
        if (m_widgetTabs.contains(w))
        {
            DTabWidget *tab = m_widgetTabs[w];
            tab->setTabIconSet(w, w->icon() ? (*(w->icon())) : QPixmap());
        }
    }
    else if (ev->type() == QEvent::CaptionChange)
    {
        kdDebug() << "caption change" << endl;
    }

    return KParts::MainWindow::eventFilter(obj, ev);
}
Example #2
0
bool AQEventFilter::eventFilter(QObject *obj, QEvent *ev)
#endif
{
  if (AQWEBAPP->ignoreEvents_ || ev->aq_ignore || !obj->isWidgetType())
#ifdef AQ_USE_NOTIFY
    return QApplication::notify(obj, ev);
#else
    return false;
#endif

  switch (ev->type()) {
    case QEvent::Show: {
      ev->aq_ignore = true;
      QApplication::sendEvent(obj, ev);
      ev->aq_ignore = false;
      AQWEBAPP->postAQEvent(new AQEvent(obj, new QEvent(QEvent::Show)));
      return true;
    }

    case QEvent::Hide: {
      ev->aq_ignore = true;
      QApplication::sendEvent(obj, ev);
      ev->aq_ignore = false;
      QWidget *w = AQ_WIDGET(obj);
      if (w->isTopLevel()) {
        //printf("hide %p %s\n", w, w->QObject::name());
        //if (AQWEBAPP->lastDeactivate_)
        //  printf("hide lastDeactivate_ %p %s\n", AQWEBAPP->lastDeactivate_, AQWEBAPP->lastDeactivate_->QObject::name());
        if (AQWEBAPP->lastDeactivate_ == w)
          AQWEBAPP->lastDeactivate_ = 0;
        AQWidgetInfo *wInfo = AQWEBAPP->createdWidgets_.find(w);
        if (wInfo && wInfo->backActive_) {
          //printf("hide backActive_ %p %s\n", wInfo->backActive_, wInfo->backActive_->QObject::name());
          if (AQWEBAPP->createdWidgets_.find(wInfo->backActive_))
            wInfo->backActive_->setActiveWindow();
          wInfo->backActive_ = 0;
        }
      }
      AQWEBAPP->postAQEvent(new AQEvent(obj, new QEvent(QEvent::Hide)));
      //break;
      return true;
    }

    case QEvent::Move: {
      QMoveEvent *mv = static_cast<QMoveEvent *>(ev);
      if (mv->pos() != mv->oldPos())
        AQWEBAPP->postAQEvent(new AQEvent(obj, new QMoveEvent(mv->pos(), mv->oldPos())));
      break;
    }

    case QEvent::Resize: {
      QResizeEvent *rs = static_cast<QResizeEvent *>(ev);
      if (rs->size() != rs->oldSize())
        AQWEBAPP->postAQEvent(new AQEvent(obj, new QResizeEvent(rs->size(), rs->oldSize())));
      break;
    }

    case QEvent::Reparent: {
      AQWEBAPP->postAQEvent(new AQEvent(obj, new QEvent(QEvent::Reparent)));
      break;
    }

    case QEvent::WindowActivate: {
      QWidget *w = AQ_WIDGET(obj);
      if (w->isTopLevel()) {
        //printf("activate %p %s\n", w, w->QObject::name());
        if (AQWEBAPP->lastDeactivate_ && AQWEBAPP->lastDeactivate_ != w) {
          AQWidgetInfo *wInfo = AQWEBAPP->createdWidgets_.find(w);
          if (wInfo) {
            wInfo->backActive_ = AQWEBAPP->lastDeactivate_;
            //printf("activate backActive_ %p %s\n", wInfo->backActive_, wInfo->backActive_->QObject::name());
          }
        }
        AQWEBAPP->postAQEvent(new AQEvent(obj, new QEvent(QEvent::WindowActivate)));
      }
      break;
    }

    case QEvent::WindowDeactivate: {
      QWidget *w = AQ_WIDGET(obj);
      if (w->isTopLevel()) {
        //printf("deactivate %p %s\n", w, w->QObject::name());
        AQWEBAPP->lastDeactivate_ = w;
        AQWEBAPP->postAQEvent(new AQEvent(obj, new QEvent(QEvent::WindowDeactivate)));
      }
      break;
    }

    case QEvent::CaptionChange: {
      QWidget *w = AQ_WIDGET(obj);
      if (w->isTopLevel() && !w->isPopup())
        aq_notify_gui_args_event(w, "xgen",
                                 QString::fromLatin1("caption:") +
                                 w->caption());
      break;
    }

    case QEvent::IconChange: {
      QWidget *w = AQ_WIDGET(obj);
      if (w->isTopLevel() && !w->isPopup())
        aq_notify_gui_args_event(w, "xgen",
                                 QString::fromLatin1("icon:") +
                                 QString::number(aq_store_pixmap(w, w->icon()), 36));
      break;
    }
  }

#ifdef AQ_USE_NOTIFY
  return QApplication::notify(obj, ev);
#else
  return false;
#endif
}