bool QDesigner::event(QEvent *ev) { bool eaten; switch (ev->type()) { case QEvent::FileOpen: // Set it true first since, if it's a Qt 3 form, the messagebox from convert will fire the timer. m_suppressNewFormShow = true; if (!m_workbench->readInForm(static_cast<QFileOpenEvent *>(ev)->file())) m_suppressNewFormShow = false; eaten = true; break; case QEvent::Close: { QCloseEvent *closeEvent = static_cast<QCloseEvent *>(ev); closeEvent->setAccepted(m_workbench->handleClose()); if (closeEvent->isAccepted()) { // We're going down, make sure that we don't get our settings saved twice. if (m_mainWindow) m_mainWindow->setCloseEventPolicy(MainWindowBase::AcceptCloseEvents); eaten = QApplication::event(ev); } eaten = true; break; } default: eaten = QApplication::event(ev); break; } return eaten; }
void MainWindow::quit() { // NCore::globalCore()->disconnectFromServer(false); QCloseEvent e; closeEvent( &e ); if( e.isAccepted() ) qApp->exit(0); }
bool QLuaApplication::close() { if (! d->closingDown) { d->closingDown = true; QCloseEvent ev; sendEvent(this, &ev); d->closingDown = ev.isAccepted(); if (d->closingDown) { sendPostedEvents(); QTimer::singleShot(0, this, SLOT(quit())); } } return d->closingDown; }
bool pTabbedWorkspace::eventFilter( QObject* o, QEvent* e ) { // get event type QEvent::Type t = e->type(); // get document QWidget* td = qobject_cast<QWidget*>( o ); // child modified state if ( t == QEvent::ModifiedChange ) mTabBar->setTabText( indexOf( td ), td->windowTitle().append( td->isWindowModified() ? QString( "*" ) : QString::null ) ); // if mode is toplevel and event is activate, activate correct window if needed else if ( mTabMode == tmTopLevel && t == QEvent::WindowActivate ) { if ( td && td != currentDocument() ) setCurrentDocument( td ); } // remove document from workspace else if ( t == QEvent::Close && td ) { // get closeevent QCloseEvent* ce = static_cast<QCloseEvent*>( e ); // emit that document will be close, giving event so user can cancel it emit aboutToCloseTab( indexOf( td ), ce ); emit aboutToCloseDocument( td, ce ); // close document if accepted if ( !ce->isAccepted() && td->property( "ForceClose" ).toBool() && !td->testAttribute( Qt::WA_DeleteOnClose ) ) td->deleteLater(); else if ( ce->isAccepted() && !td->testAttribute( Qt::WA_DeleteOnClose ) ) removeDocument( td ); else return true; } // return default event filter return QWidget::eventFilter( o, e ); }