You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
piklab/src/common/common/synchronous.cpp

44 lines
1.4 KiB

/***************************************************************************
* Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
* *
* 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 <tqwidget.h>
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();
}