Files
pokerth/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp
T

63 lines
1.5 KiB
C++
Raw Normal View History

2008-03-03 10:27:36 +00:00
//
// C++ Implementation: opengametimeoutmsgboximpl
//
// Description:
//
//
// Author: Felix Hammer <f.hammer@web.de>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "timeoutmsgboximpl.h"
#include "session.h"
2008-03-03 23:31:20 +00:00
timeoutMsgBoxImpl::timeoutMsgBoxImpl(QMainWindow *parent)
: QMessageBox(parent), msgID(NETWORK_TIMEOUT_GENERIC)
2008-03-03 10:27:36 +00:00
{
okButton = this->addButton(QMessageBox::Ok);
this->setWindowTitle(tr("Timeout Warning"));
this->setIcon(QMessageBox::Warning);
this->setInformativeText(tr("Please click \"OK\" to stop the countdown!"));
2008-03-03 10:27:36 +00:00
timeOutTimer = new QTimer;
connect(timeOutTimer, SIGNAL(timeout()), this, SLOT(timerRefresh()));
2008-03-03 23:31:20 +00:00
connect(okButton, SIGNAL(clicked()), this, SLOT(stopTimeout()));
2008-03-03 10:27:36 +00:00
}
timeoutMsgBoxImpl::~timeoutMsgBoxImpl()
{
}
void timeoutMsgBoxImpl::startTimeout() {
//start the real timer
realTimer.reset();
realTimer.start();
timerRefresh();
timeOutTimer->start(1000);
}
void timeoutMsgBoxImpl::timerRefresh() {
2008-03-03 23:43:51 +00:00
int sec = timeoutDuration;
2008-03-03 10:27:36 +00:00
unsigned int realTimerValue = realTimer.elapsed().total_milliseconds();
sec -= realTimerValue/1000;
if (sec < 0) sec = 0;
2008-03-03 23:31:20 +00:00
switch (msgID) {
case NETWORK_TIMEOUT_GAME_ADMIN_IDLE:
2008-03-08 21:55:18 +00:00
this->setText(tr("You are game-admin of an open game which will time out in %1 seconds.").arg(sec,0,10));
break;
default:
this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10));
break;
2008-03-03 10:27:36 +00:00
}
}
2008-03-03 23:31:20 +00:00
void timeoutMsgBoxImpl::stopTimeout() {
mySession->resetNetworkTimeout();
2008-03-03 23:31:20 +00:00
}