log file handling as standalone dialog finished

This commit is contained in:
doitux
2012-09-17 23:44:33 +02:00
parent d322a1b080
commit 09e8cc9004
9 changed files with 357 additions and 280 deletions
+161 -23
View File
@@ -1,39 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>LogFileDialog</class> <class>LogFileDialog</class>
<widget class="QDialog" name="LogFileDialog"> <widget class="QDialog" name="LogFileDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>618</width>
<height>300</height> <height>392</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<widget class="QDialogButtonBox" name="buttonBox"> <layout class="QGridLayout" name="gridLayout">
<property name="geometry"> <item row="0" column="0">
<rect> <layout class="QVBoxLayout" name="verticalLayout">
<x>30</x> <item>
<y>240</y> <layout class="QHBoxLayout" name="horizontalLayout">
<width>341</width> <item>
<height>32</height> <widget class="QLabel" name="label">
</rect> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<property name="orientation"> <horstretch>0</horstretch>
<enum>Qt::Horizontal</enum> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="standardButtons"> </property>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <property name="text">
</property> <string>Game:</string>
</widget> </property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="treeWidget_logFiles">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="indentation">
<number>5</number>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Log File</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_37">
<property name="text">
<string>Preview:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser_logPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="pushButton_exportLogHtml">
<property name="text">
<string>Export as HTML</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/text-html.png</normaloff>:/gfx/text-html.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_exportLogTxt">
<property name="text">
<string>Export as txt</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/text-plain.png</normaloff>:/gfx/text-plain.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_saveLogAs">
<property name="text">
<string>Save as ...</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/filesave.png</normaloff>:/gfx/filesave.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_deleteLog">
<property name="text">
<string>Delete</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/editdelete.png</normaloff>:/gfx/editdelete.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
<pixmapfunction/> <resources>
<resources/> <include location="resources/pokerth.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
+139 -2
View File
@@ -18,15 +18,152 @@
#include "logfiledialog.h" #include "logfiledialog.h"
#include "ui_logfiledialog.h" #include "ui_logfiledialog.h"
#include <QtCore>
#include "guilog.h"
#include "configfile.h"
#include "mymessagebox.h"
LogFileDialog::LogFileDialog(QWidget *parent) : LogFileDialog::LogFileDialog(QWidget *parent, ConfigFile *c) :
QDialog(parent), QDialog(parent), myConfig(c),
ui(new Ui::LogFileDialog) ui(new Ui::LogFileDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
connect( ui->pushButton_deleteLog, SIGNAL(clicked()), this, SLOT (deleteLogFile()));
connect( ui->pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml()));
connect( ui->pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt()));
connect( ui->pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs()));
connect( ui->treeWidget_logFiles, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showLogFilePreview()));
} }
LogFileDialog::~LogFileDialog() LogFileDialog::~LogFileDialog()
{ {
delete ui; delete ui;
} }
void LogFileDialog::exec()
{
refreshLogFileList();
QDialog::exec();
}
void LogFileDialog::refreshLogFileList()
{
QDir logFileDir;
logFileDir.setPath(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
QStringList filters;
filters << "*.pdb";
QFileInfoList dbFilesList = logFileDir.entryInfoList(filters, QDir::Files, QDir::Time);
QFileInfo currentSqliteLogFile(QString::fromStdString(myGuiLog->getMySqliteLogFileName()));
ui->treeWidget_logFiles->clear();
int i;
for (i=0; i < dbFilesList.size(); i++) {
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, dbFilesList.at(i).fileName());
item->setData(0, Qt::UserRole, dbFilesList.at(i).absoluteFilePath());
if(currentSqliteLogFile.fileName() == dbFilesList.at(i).fileName()) {
item->setData(0, Qt::BackgroundColorRole, QColor(Qt::red));
item->setData(0, Qt::TextColorRole, QColor(Qt::white));
item->setData(0, Qt::UserRole+1, "current");
}
ui->treeWidget_logFiles->addTopLevelItem(item);
}
ui->treeWidget_logFiles->sortItems(0, Qt::DescendingOrder);
}
void LogFileDialog::deleteLogFile()
{
QList<QTreeWidgetItem*> selectedItemsList = ui->treeWidget_logFiles->selectedItems();
if(!selectedItemsList.isEmpty() && !( selectedItemsList.size() == 1 && selectedItemsList.front()->data(0, Qt::UserRole+1).toString() == "current" )) {
int ret = MyMessageBox::warning(this, tr("PokerTH - Delete log files"),
tr("Do you really want to delete the selected log files?"),
QMessageBox::Yes | QMessageBox::No);
if(ret == QMessageBox::Yes) {
for (int i = 0; i < selectedItemsList.size(); ++i) {
if(selectedItemsList.at(i)->data(0, Qt::UserRole+1).toString() != "current") {
if(!QFile::remove(selectedItemsList.at(i)->data(0, Qt::UserRole).toString())) {
MyMessageBox::warning(this, "Remove log file", "PokerTH cannot remove this log file, please verify that you have write access to this file!", QMessageBox::Close );
}
}
}
refreshLogFileList();
}
}
}
void LogFileDialog::exportLogToHtml()
{
QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem();
if(selectedItem) {
QFileInfo fi(selectedItem->text(0));
QString fileName = QFileDialog::getSaveFileName(this, tr("Export PokerTH log file to HTML"),
QDir::homePath()+"/"+fi.baseName()+".html",
tr("PokerTH HTML log (*.html)"));
if(!fileName.isEmpty()) {
myGuiLog->exportLogPdbToHtml(selectedItem->data(0, Qt::UserRole).toString(),fileName);
}
}
}
void LogFileDialog::exportLogToTxt()
{
QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem();
if(selectedItem) {
QFileInfo fi(selectedItem->text(0));
QString fileName = QFileDialog::getSaveFileName(this, tr("Export PokerTH log file to plain text"),
QDir::homePath()+"/"+fi.baseName()+".txt",
tr("PokerTH plain text log (*.txt)"));
if(!fileName.isEmpty()) {
myGuiLog->exportLogPdbToTxt(selectedItem->data(0, Qt::UserRole).toString(),fileName);
}
}
}
void LogFileDialog::saveLogFileAs()
{
QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem();
if(selectedItem) {
QFileInfo fi(selectedItem->text(0));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save PokerTH log file"),
QDir::homePath()+"/"+fi.baseName()+".pdb",
tr("PokerTH SQL log (*.pdb)"));
if(!fileName.isEmpty()) {
QFile::copy(selectedItem->data(0, Qt::UserRole).toString(), fileName);
}
}
}
void LogFileDialog::showLogFilePreview()
{
QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem();
if(selectedItem) {
myGuiLog->showLog(selectedItem->data(0, Qt::UserRole).toString(), ui->textBrowser_logPreview);
}
QTextCursor cursor(ui->textBrowser_logPreview->textCursor());
cursor.movePosition(QTextCursor::Start);
ui->textBrowser_logPreview->setTextCursor(cursor);
}
void LogFileDialog::keyPressEvent ( QKeyEvent * event )
{
if (event->key() == Qt::Key_Delete ) { /*Delete*/
if(ui->treeWidget_logFiles->hasFocus()) {
ui->pushButton_deleteLog->click();
}
}
}
+20 -1
View File
@@ -21,19 +21,38 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui {
class LogFileDialog; class LogFileDialog;
} }
class guiLog;
class ConfigFile;
class LogFileDialog : public QDialog class LogFileDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit LogFileDialog(QWidget *parent = 0); explicit LogFileDialog(QWidget *parent = 0, ConfigFile *c = 0);
~LogFileDialog(); ~LogFileDialog();
void setGuiLog(guiLog *g) { myGuiLog = g; }
void exec();
public slots:
void refreshLogFileList();
void deleteLogFile();
void exportLogToHtml();
void exportLogToTxt();
void saveLogFileAs();
void showLogFilePreview();
void keyPressEvent ( QKeyEvent * event );
private: private:
ConfigFile *myConfig;
guiLog *myGuiLog;
Ui::LogFileDialog *ui; Ui::LogFileDialog *ui;
}; };
+11 -105
View File
@@ -3534,107 +3534,17 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_11"> <spacer name="verticalSpacer_7">
<item> <property name="orientation">
<widget class="QTreeWidget" name="treeWidget_logFiles"> <enum>Qt::Vertical</enum>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <property name="sizeHint" stdset="0">
<horstretch>0</horstretch> <size>
<verstretch>0</verstretch> <width>20</width>
</sizepolicy> <height>40</height>
</property> </size>
<property name="alternatingRowColors"> </property>
<bool>true</bool> </spacer>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="indentation">
<number>5</number>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Log File</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_37">
<property name="text">
<string>Preview:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser_logPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="pushButton_exportLogHtml">
<property name="text">
<string>Export as HTML</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/text-html.png</normaloff>:/gfx/text-html.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_exportLogTxt">
<property name="text">
<string>Export as txt</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/text-plain.png</normaloff>:/gfx/text-plain.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_saveLogAs">
<property name="text">
<string>Save as ...</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/filesave.png</normaloff>:/gfx/filesave.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_deleteLog">
<property name="text">
<string>Delete</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/editdelete.png</normaloff>:/gfx/editdelete.png</iconset>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@@ -3887,10 +3797,6 @@ p, li { white-space: pre-wrap; }
<tabstop>comboBox_logInterval</tabstop> <tabstop>comboBox_logInterval</tabstop>
<tabstop>lineEdit_logDir</tabstop> <tabstop>lineEdit_logDir</tabstop>
<tabstop>pushButton_openLogDir</tabstop> <tabstop>pushButton_openLogDir</tabstop>
<tabstop>pushButton_exportLogHtml</tabstop>
<tabstop>pushButton_exportLogTxt</tabstop>
<tabstop>pushButton_saveLogAs</tabstop>
<tabstop>pushButton_deleteLog</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>
@@ -22,7 +22,6 @@
#include "carddeckstylereader.h" #include "carddeckstylereader.h"
#include "configfile.h" #include "configfile.h"
#include "guilog.h"
#include <net/socket_startup.h> #include <net/socket_startup.h>
#include <QSet> #include <QSet>
@@ -46,14 +45,6 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, ConfigFile *c, selectAva
listWidget->takeItem(1); listWidget->takeItem(1);
#endif #endif
if(!SQLITE_LOG) {//temporarely remove sql log features
pushButton_deleteLog->hide();
pushButton_saveLogAs->hide();
pushButton_exportLogTxt->hide();
pushButton_exportLogHtml->hide();
treeWidget_logFiles->hide();
}
myManualBlindsOrderDialog = new manualBlindsOrderDialogImpl; myManualBlindsOrderDialog = new manualBlindsOrderDialogImpl;
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
@@ -141,12 +132,6 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, ConfigFile *c, selectAva
connect( pushButton_removeCardDeckStyle, SIGNAL( clicked() ), this, SLOT( removeCardDeckStyle()) ); connect( pushButton_removeCardDeckStyle, SIGNAL( clicked() ), this, SLOT( removeCardDeckStyle()) );
connect( pushButton_internetGameRemoveIgnoredPlayer, SIGNAL( clicked()), this, SLOT( removePlayerFromIgnoredPlayersList())); connect( pushButton_internetGameRemoveIgnoredPlayer, SIGNAL( clicked()), this, SLOT( removePlayerFromIgnoredPlayersList()));
connect( pushButton_deleteLog, SIGNAL(clicked()), this, SLOT (deleteLogFile()));
connect( pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml()));
connect( pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt()));
connect( pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs()));
connect( treeWidget_logFiles, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showLogFilePreview()));
#ifdef GUI_800x480 #ifdef GUI_800x480
//make the scrollbar touchable for mobile guis //make the scrollbar touchable for mobile guis
comboBox_switchLanguage->setStyleSheet("QObject {font: 30px} QScrollBar:vertical { border: 1px solid grey; background: white; width: 60px; margin: 0px -1px 0px 0px; } QScrollBar::handle:vertical { border-radius: 3px; border: 2px solid grey; background: LightGrey ; min-height: 60px; } QScrollBar::add-line:vertical { background: none; } QScrollBar::sub-line:vertical { background: none; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { background: none; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }"); comboBox_switchLanguage->setStyleSheet("QObject {font: 30px} QScrollBar:vertical { border: 1px solid grey; background: white; width: 60px; margin: 0px -1px 0px 0px; } QScrollBar::handle:vertical { border-radius: 3px; border: 2px solid grey; background: LightGrey ; min-height: 60px; } QScrollBar::add-line:vertical { background: none; } QScrollBar::sub-line:vertical { background: none; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { background: none; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }");
@@ -517,8 +502,6 @@ void settingsDialogImpl::prepareDialog()
spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration")); spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration"));
comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval")); comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval"));
refreshLogFileList();
bool tmpHasIpv6 = socket_has_ipv6(); bool tmpHasIpv6 = socket_has_ipv6();
bool tmpHasSctp = socket_has_sctp(); bool tmpHasSctp = socket_has_sctp();
checkBox_useIpv6->setEnabled(tmpHasIpv6); checkBox_useIpv6->setEnabled(tmpHasIpv6);
@@ -955,7 +938,6 @@ void settingsDialogImpl::setLogDir()
QDir logDir(dir); QDir logDir(dir);
if(logDir.exists()) { if(logDir.exists()) {
lineEdit_logDir->setText(dir); lineEdit_logDir->setText(dir);
refreshLogFileList();
MyMessageBox::information(this, tr("Settings Information"), MyMessageBox::information(this, tr("Settings Information"),
tr("You have changed the log file directory.\n" tr("You have changed the log file directory.\n"
"Please restart PokerTH to use the new directory for the log files!"), "Please restart PokerTH to use the new directory for the log files!"),
@@ -1371,118 +1353,6 @@ void settingsDialogImpl::removePlayerFromIgnoredPlayersList()
} }
} }
void settingsDialogImpl::refreshLogFileList()
{
QDir logFileDir;
logFileDir.setPath(lineEdit_logDir->text());
QStringList filters;
filters << "*.pdb";
QFileInfoList dbFilesList = logFileDir.entryInfoList(filters, QDir::Files, QDir::Time);
QFileInfo currentSqliteLogFile(QString::fromStdString(myGuiLog->getMySqliteLogFileName()));
treeWidget_logFiles->clear();
int i;
for (i=0; i < dbFilesList.size(); i++) {
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, dbFilesList.at(i).fileName());
item->setData(0, Qt::UserRole, dbFilesList.at(i).absoluteFilePath());
if(currentSqliteLogFile.fileName() == dbFilesList.at(i).fileName()) {
item->setData(0, Qt::BackgroundColorRole, QColor(Qt::red));
item->setData(0, Qt::TextColorRole, QColor(Qt::white));
item->setData(0, Qt::UserRole+1, "current");
}
treeWidget_logFiles->addTopLevelItem(item);
}
treeWidget_logFiles->sortItems(0, Qt::DescendingOrder);
}
void settingsDialogImpl::deleteLogFile()
{
QList<QTreeWidgetItem*> selectedItemsList = treeWidget_logFiles->selectedItems();
if(!selectedItemsList.isEmpty() && !( selectedItemsList.size() == 1 && selectedItemsList.front()->data(0, Qt::UserRole+1).toString() == "current" )) {
int ret = MyMessageBox::warning(this, tr("PokerTH - Delete log files"),
tr("Do you really want to delete the selected log files?"),
QMessageBox::Yes | QMessageBox::No);
if(ret == QMessageBox::Yes) {
for (int i = 0; i < selectedItemsList.size(); ++i) {
if(selectedItemsList.at(i)->data(0, Qt::UserRole+1).toString() != "current") {
if(!QFile::remove(selectedItemsList.at(i)->data(0, Qt::UserRole).toString())) {
MyMessageBox::warning(this, "Remove log file", "PokerTH cannot remove this log file, please verify that you have write access to this file!", QMessageBox::Close );
}
}
}
refreshLogFileList();
}
}
}
void settingsDialogImpl::exportLogToHtml()
{
QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem();
if(selectedItem) {
QFileInfo fi(selectedItem->text(0));
QString fileName = QFileDialog::getSaveFileName(this, tr("Export PokerTH log file to HTML"),
QDir::homePath()+"/"+fi.baseName()+".html",
tr("PokerTH HTML log (*.html)"));
if(!fileName.isEmpty()) {
myGuiLog->exportLogPdbToHtml(selectedItem->data(0, Qt::UserRole).toString(),fileName);
}
}
}
void settingsDialogImpl::exportLogToTxt()
{
QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem();
if(selectedItem) {
QFileInfo fi(selectedItem->text(0));
QString fileName = QFileDialog::getSaveFileName(this, tr("Export PokerTH log file to plain text"),
QDir::homePath()+"/"+fi.baseName()+".txt",
tr("PokerTH plain text log (*.txt)"));
if(!fileName.isEmpty()) {
myGuiLog->exportLogPdbToTxt(selectedItem->data(0, Qt::UserRole).toString(),fileName);
}
}
}
void settingsDialogImpl::saveLogFileAs()
{
QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem();
if(selectedItem) {
QFileInfo fi(selectedItem->text(0));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save PokerTH log file"),
QDir::homePath()+"/"+fi.baseName()+".pdb",
tr("PokerTH SQL log (*.pdb)"));
if(!fileName.isEmpty()) {
QFile::copy(selectedItem->data(0, Qt::UserRole).toString(), fileName);
}
}
}
void settingsDialogImpl::showLogFilePreview()
{
QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem();
if(selectedItem) {
myGuiLog->showLog(selectedItem->data(0, Qt::UserRole).toString(), textBrowser_logPreview);
}
QTextCursor cursor(textBrowser_logPreview->textCursor());
cursor.movePosition(QTextCursor::Start);
textBrowser_logPreview->setTextCursor(cursor);
}
void settingsDialogImpl::resetSettings() void settingsDialogImpl::resetSettings()
{ {
int ret = MyMessageBox::warning(this, tr("PokerTH - Settings"), int ret = MyMessageBox::warning(this, tr("PokerTH - Settings"),
@@ -1496,11 +1366,3 @@ void settingsDialogImpl::resetSettings()
} }
void settingsDialogImpl::keyPressEvent ( QKeyEvent * event )
{
if (event->key() == Qt::Key_Delete ) { /*Delete*/
if(treeWidget_logFiles->hasFocus()) {
pushButton_deleteLog->click();
}
}
}
@@ -112,14 +112,7 @@ public slots:
void addCardDeckStyle(); void addCardDeckStyle();
void removeCardDeckStyle(); void removeCardDeckStyle();
void removePlayerFromIgnoredPlayersList(); void removePlayerFromIgnoredPlayersList();
void refreshLogFileList();
void deleteLogFile();
void exportLogToHtml();
void exportLogToTxt();
void saveLogFileAs();
void showLogFilePreview();
void resetSettings(); void resetSettings();
void keyPressEvent ( QKeyEvent * event );
private: private:
@@ -140,7 +133,6 @@ private:
std::list<std::string> myCardDeckStylesList; std::list<std::string> myCardDeckStylesList;
ConfigFile* myConfig; ConfigFile* myConfig;
guiLog* myGuiLog;
selectAvatarDialogImpl *mySelectAvatarDialogImpl; selectAvatarDialogImpl *mySelectAvatarDialogImpl;
manualBlindsOrderDialogImpl *myManualBlindsOrderDialog; manualBlindsOrderDialogImpl *myManualBlindsOrderDialog;
@@ -149,6 +141,7 @@ private:
bool languageIsChanged; bool languageIsChanged;
bool calledIngame; bool calledIngame;
int changedLanguageIndex; int changedLanguageIndex;
guiLog *myGuiLog;
}; };
#endif #endif
+11 -1
View File
@@ -198,7 +198,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>450</width> <width>450</width>
<height>26</height> <height>24</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuPokerTH"> <widget class="QMenu" name="menuPokerTH">
@@ -215,6 +215,7 @@
<addaction name="actionStart_Local_Game"/> <addaction name="actionStart_Local_Game"/>
<addaction name="actionInternet_Game"/> <addaction name="actionInternet_Game"/>
<addaction name="menuNetwork_Game"/> <addaction name="menuNetwork_Game"/>
<addaction name="actionLogs"/>
<addaction name="actionAbout_PokerTH"/> <addaction name="actionAbout_PokerTH"/>
<addaction name="actionQuit"/> <addaction name="actionQuit"/>
</widget> </widget>
@@ -296,6 +297,15 @@
<string>Join Network Game ...</string> <string>Join Network Game ...</string>
</property> </property>
</action> </action>
<action name="actionLogs">
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset>
</property>
<property name="text">
<string>Logs ...</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="resources/pokerth.qrc"/> <include location="resources/pokerth.qrc"/>
+10 -1
View File
@@ -43,6 +43,7 @@
#include "chattools.h" #include "chattools.h"
#include "serverlistdialogimpl.h" #include "serverlistdialogimpl.h"
#include "internetgamelogindialogimpl.h" #include "internetgamelogindialogimpl.h"
#include "logfiledialog.h"
#include "guilog.h" #include "guilog.h"
using namespace std; using namespace std;
@@ -119,10 +120,12 @@ startWindowImpl::startWindowImpl(ConfigFile *c, Log *l)
myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig);
myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig);
myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig);
myLogFileDialog = new LogFileDialog(this, myConfig);
myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW()); myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW());
myGameLobbyDialog->setMyW(myGuiInterface->getMyW()); myGameLobbyDialog->setMyW(myGuiInterface->getMyW());
mySettingsDialog->setGuiLog(myGuiLog); mySettingsDialog->setGuiLog(myGuiLog);
myLogFileDialog->setGuiLog(myGuiLog);
myTimeoutDialog = new timeoutMsgBoxImpl(this); myTimeoutDialog = new timeoutMsgBoxImpl(this);
myServerListDialog = new serverListDialogImpl(this, this, myConfig); myServerListDialog = new serverListDialogImpl(this, this, myConfig);
@@ -135,7 +138,8 @@ startWindowImpl::startWindowImpl(ConfigFile *c, Log *l)
connect( actionCreate_Network_Game, SIGNAL( triggered() ), this, SLOT( callCreateNetworkGameDialog() ) ); connect( actionCreate_Network_Game, SIGNAL( triggered() ), this, SLOT( callCreateNetworkGameDialog() ) );
connect( pushButton_Create_Network_Game, SIGNAL( clicked() ), this, SLOT( callCreateNetworkGameDialog() ) ); connect( pushButton_Create_Network_Game, SIGNAL( clicked() ), this, SLOT( callCreateNetworkGameDialog() ) );
connect( actionJoin_Network_Game, SIGNAL( triggered() ), this, SLOT( callJoinNetworkGameDialog() ) ); connect( actionJoin_Network_Game, SIGNAL( triggered() ), this, SLOT( callJoinNetworkGameDialog() ) );
connect( pushButton_Join_Network_Game, SIGNAL( clicked() ), this, SLOT( callJoinNetworkGameDialog() ) ); connect( pushButton_Join_Network_Game, SIGNAL( clicked() ), this, SLOT( callJoinNetworkGameDialog() ) );
connect( actionLogs, SIGNAL( triggered() ), this, SLOT( callLogFileDialog() ) );
connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog()));
@@ -625,6 +629,11 @@ void startWindowImpl::callSettingsDialog(bool ingame)
} }
} }
void startWindowImpl::callLogFileDialog()
{
myLogFileDialog->exec();
}
void startWindowImpl::showTimeoutDialog(int msgID, unsigned duration) void startWindowImpl::showTimeoutDialog(int msgID, unsigned duration)
{ {
if(myTimeoutDialog->isHidden()) { if(myTimeoutDialog->isHidden()) {
+4 -1
View File
@@ -53,6 +53,7 @@ class serverListDialogImpl;
class internetGameLoginDialogImpl; class internetGameLoginDialogImpl;
class guiLog; class guiLog;
class Log; class Log;
class LogFileDialog;
class startWindowImpl: public QMainWindow, public Ui::startWindow class startWindowImpl: public QMainWindow, public Ui::startWindow
{ {
@@ -139,6 +140,7 @@ public slots:
void joinGameLobby(); void joinGameLobby();
void showClientDialog(); void showClientDialog();
void showNetworkStartDialog(); void showNetworkStartDialog();
void callLogFileDialog();
void startNewLocalGame(newGameDialogImpl* =0); void startNewLocalGame(newGameDialogImpl* =0);
@@ -178,8 +180,9 @@ private:
startWindowImpl *myStartWindow; startWindowImpl *myStartWindow;
serverListDialogImpl *myServerListDialog; serverListDialogImpl *myServerListDialog;
internetGameLoginDialogImpl *myInternetGameLoginDialog; internetGameLoginDialogImpl *myInternetGameLoginDialog;
LogFileDialog *myLogFileDialog;
MyMessageBox msgBoxOutdatedVersion; MyMessageBox msgBoxOutdatedVersion;
bool msgBoxOutdatedVersionActive; bool msgBoxOutdatedVersionActive;
friend class GuiWrapper; friend class GuiWrapper;