diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp new file mode 100644 index 00000000..dc1c403f --- /dev/null +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp @@ -0,0 +1,57 @@ +// +// C++ Implementation: opengametimeoutmsgboximpl +// +// Description: +// +// +// Author: Felix Hammer , (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "timeoutmsgboximpl.h" +#include "session.h" + +timeoutMsgBoxImpl::timeoutMsgBoxImpl(QDialog *parent, Session *s, int id) + : QMessageBox(parent), mySession(s), msgId(id) +{ + okButton = this->addButton(QMessageBox::Ok); + + this->setWindowTitle(tr("Timeout Warning")); + this->setIcon(QMessageBox::Warning); + this->setInformativeText(tr("Please click \"OK\" to stop timeout!")); + + timeOutTimer = new QTimer; + + connect(timeOutTimer, SIGNAL(timeout()), this, SLOT(timerRefresh())); +// connect(okButton, SIGNAL(clicked()), mySession, SLOT(spechialSessionSlot(msgId))); + +} + +timeoutMsgBoxImpl::~timeoutMsgBoxImpl() +{ +} + +void timeoutMsgBoxImpl::startTimeout() { + //start the real timer + realTimer.reset(); + realTimer.start(); + timerRefresh(); + timeOutTimer->start(1000); +} + +void timeoutMsgBoxImpl::timerRefresh() { + + int sec = 60; + unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); + sec -= realTimerValue/1000; + if (sec < 0) sec = 0; + switch (msgId) { + case 0: { this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); } + break; + case 1: { this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10)); } + break; + } + +} + diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h new file mode 100644 index 00000000..4db0baf4 --- /dev/null +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h @@ -0,0 +1,47 @@ +// +// C++ Interface: opengametimeoutmsgboximpl +// +// Description: +// +// +// Author: Felix Hammer , (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef TIMEOUTMSGBOXIMPL_H +#define TIMEOUTMSGBOXIMPL_H + +#include +#include +#include +#include + +/** + @author Felix Hammer +*/ +class Session; + +class timeoutMsgBoxImpl : public QMessageBox +{ +Q_OBJECT +public: + timeoutMsgBoxImpl(QDialog*, Session*, int); + + ~timeoutMsgBoxImpl(); + +public slots: + + void startTimeout(); + void timerRefresh(); + +private: + + QTimer *timeOutTimer; + QPushButton *okButton; + Session *mySession; + int msgId; + boost::timers::portable::microsec_timer realTimer; +}; + +#endif