Files
pokerth/src/gui/qt/log.cpp
T

90 lines
2.9 KiB
C++
Raw Normal View History

2007-01-13 02:40:33 +00:00
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
2007-01-31 22:48:44 +00:00
#include "log.h"
2007-01-13 02:40:33 +00:00
#include "mainwindowimpl.h"
using namespace std;
2007-01-31 22:48:44 +00:00
Log::Log(mainWindowImpl* w) : myW(w)
2007-01-13 02:40:33 +00:00
{
2007-01-31 22:48:44 +00:00
myW->setLog(this);
2007-02-03 22:47:16 +00:00
myConfig = new ConfigFile;
if(myConfig->readConfigString("LogDir") != "" && QDir::QDir(QString::fromStdString(myConfig->readConfigString("LogDir"))).exists()) {
myLogDir = new QDir(QString::fromStdString(myConfig->readConfigString("LogDir")));
2007-02-04 00:34:44 +00:00
myLogFile = new QFile(myLogDir->absolutePath()+"/pokerth-log-"+QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss")+".html");
//Logo-Pixmap extrahieren
QPixmap::QPixmap(":graphics/graphics/logo-140-100.png").save(myLogDir->absolutePath()+"/logo.png");
2007-02-03 22:47:16 +00:00
myLogFile->open( QIODevice::WriteOnly );
QTextStream stream( myLogFile );
2007-02-04 00:34:44 +00:00
stream << "<html>";
stream << "<body>";
stream << "<img src='logo.png'>";
stream << "<h3><b>Log-File for PokerTH Session started on "+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"</b></h3>";
stream << "</body>";
stream << "</html>";
2007-02-03 22:47:16 +00:00
myLogFile->close();
}
;
2007-01-13 02:40:33 +00:00
}
2007-01-31 22:48:44 +00:00
Log::~Log()
2007-01-13 02:40:33 +00:00
{
}
2007-02-04 00:34:44 +00:00
void Log::logPlayerActionMsg(string playerName, int action, int setValue) const {
2007-01-13 02:40:33 +00:00
QString msg;
msg = QString::fromStdString(playerName);
switch (action) {
case 1: msg += " folds.";
break;
case 2: msg += " checks.";
break;
case 3: msg += " calls ";
break;
case 4: msg += " bets ";
break;
case 5: msg += " sets ";
break;
case 6: msg += " is all in with ";
break;
default: msg += "ERROR";
}
if (action >= 3) { msg += QString::number(setValue,10)+"$."; }
myW->textBrowser_Log->append(msg);
}