/*************************************************************************** * Copyright (C) 2006 Nicolas Hadacek * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "synchronous.h" #include "common/global/global.h" # include Synchronous::Synchronous(uint timeout) { connect(&_timer, TQT_SIGNAL(timeout()), TQT_SLOT(done())); if (timeout) _timer.start(timeout, true); } // uplifted from tdelibs... void qt_enter_modal(TQWidget *widget); void qt_leave_modal(TQWidget *widget); bool Synchronous::enterLoop() { TQWidget *dummy = 0; if ( tqApp->type()!=TQApplication::Tty ) { dummy = new TQWidget(0, 0, WType_Dialog | WShowModal); dummy->setFocusPolicy(TQ_NoFocus); qt_enter_modal(dummy); } TQApplication::eventLoop()->enterLoop(); if ( tqApp->type()!=TQApplication::Tty ) { qt_leave_modal(dummy); delete dummy; } return _timer.isActive(); } void Synchronous::done() { TQApplication::eventLoop()->exitLoop(); }