bool QLuaApplication::event(QEvent *e) { if (e->type() == QEvent::FileOpen) { QString f = static_cast<QFileOpenEvent*>(e)->file(); d->filesToOpen.append(f); emit fileOpenEvent(); return true; } else if (e->type() == QEvent::Close) { // carefully close all windows bool okay = true; QSet<QWidget*> closed; QWidgetList wl = topLevelWidgets(); while (okay && wl.size()) { QWidget *w = wl.takeFirst(); if (w == 0 || !w->isVisible() || w->windowType() == Qt::Desktop || closed.contains(w) ) continue; closed += w; okay = w->close(); wl = topLevelWidgets(); } // accept event on success e->setAccepted(okay); return true; } return QApplication::event(e); }
bool Launcher::eventFilter(QObject* object, QEvent* event) { bool retval = false; // Not interested in other objects' events if (object != QApplication::instance()) return false; if (event->type() == QEvent::FileOpen) { QFileOpenEvent* fileOpenEvent(static_cast<QFileOpenEvent*>(event)); QString path(fileOpenEvent->url().path()); if (path.isEmpty() == true) { path = fileOpenEvent->file(); if (path.isEmpty() == true) { // Nothing to open event->ignore(); return false; } } if (path.endsWith(KExtWorkspace, Qt::CaseInsensitive) == true) { launchQLC(QApplication::arguments() << "--open" << path); retval = true; } else if (path.endsWith(KExtFixture, Qt::CaseInsensitive) == true) { launchFXED(QApplication::arguments() << "--open" << path); retval = true; } } if (retval == true) event->accept(); else event->ignore(); return retval; }