summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2016-09-30 21:31:52 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2016-09-30 21:31:52 +0900
commitfebf3bbebfc048a068894f90d3a43d7fc6043aa3 (patch)
tree10db9fdafcdf4f1563aa6ec6259a259cba0e02cc
parent26ccf10eaceb1c3326ae2207bcd1cb6ecf6fd894 (diff)
downloadknights-febf3bbebfc048a068894f90d3a43d7fc6043aa3.tar.gz
knights-febf3bbebfc048a068894f90d3a43d7fc6043aa3.zip
Added user option to delete chess engine log files (game.### and log.###) from user home folder on exit.
This resolves bug 2665. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--doc/help_en.docbook3
-rw-r--r--knights/knights.cpp20
-rw-r--r--knights/knights.h1
-rw-r--r--knights/main.cpp1
-rw-r--r--knights/resource.cpp2
-rw-r--r--knights/resource.h1
-rw-r--r--knights/setpagegeneral.cpp20
-rw-r--r--knights/setpagegeneral.h2
8 files changed, 50 insertions, 0 deletions
diff --git a/doc/help_en.docbook b/doc/help_en.docbook
index 1be9fd8..6bc3be7 100644
--- a/doc/help_en.docbook
+++ b/doc/help_en.docbook
@@ -352,6 +352,9 @@
<para>
<menuchoice><guimenu>Call Flag Automatically</guimenu></menuchoice> This option will automatically declare you the winner of the match if your opponent's clock runs out of time.
</para>
+ <para>
+ <menuchoice><guimenu>Delete Log Files on Exit</guimenu></menuchoice> If set, chess engine log files will be deleted on exit. Only files named "game.###" and "log.###" placed in the user home folder will be removed
+ </para>
</sect1>
<sect1 id="configure-display">
<title>Display</title>
diff --git a/knights/knights.cpp b/knights/knights.cpp
index 89f994f..f9d3867 100644
--- a/knights/knights.cpp
+++ b/knights/knights.cpp
@@ -49,6 +49,7 @@ Knights::Knights(TDECmdLineArgs *Args, TQWidget *parent, const char *name) : TDE
SplashScreen = NULL;
setFocusPolicy( TQ_ClickFocus );
}
+
Knights::~Knights()
{
if( !InitAll )
@@ -101,6 +102,7 @@ void Knights::menuClose(void)
{
if( !queryClose() )
return;
+
tqApp->quit();
}
///////////////////////////////////////
@@ -114,6 +116,24 @@ bool Knights::queryClose(void)
}
///////////////////////////////////////
//
+// Knights::aboutToQuit
+//
+///////////////////////////////////////
+void Knights::aboutToQuit(void)
+{
+ if (Resource->OPTION_Delete_Logs)
+ {
+ // Delete log files on exit. Only files named "game.###" and "log.###"
+ // placed in the user home folder will be removed
+ TQDir userdir( TQDir::homeDirPath(), "game.[0-9][0-9]*;log.[0-9][0-9]*" );
+ for ( int i = 0; i < userdir.count(); i++ )
+ {
+ userdir.remove( userdir.absFilePath(userdir[i]), TRUE );
+ }
+ }
+}
+///////////////////////////////////////
+//
// Knights::KillAll
//
///////////////////////////////////////
diff --git a/knights/knights.h b/knights/knights.h
index 4eb9989..56a6b1e 100644
--- a/knights/knights.h
+++ b/knights/knights.h
@@ -72,6 +72,7 @@ class Knights : public TDEMainWindow
public slots:
void KillAll( void );
void menuClose( void );
+ void aboutToQuit( void );
/** Yeah, they're sloppy, but I need my own geometry managment routines
because I don't like the "default" look my statusbar was getting
( double-height ). Plus, I want the console to appear only when needed. */
diff --git a/knights/main.cpp b/knights/main.cpp
index 0b60729..cc76045 100644
--- a/knights/main.cpp
+++ b/knights/main.cpp
@@ -81,5 +81,6 @@ int main(int argc, char *argv[])
/* Without this connection, the destructors are not called, and some
housecleaning ( like destroying child processes ) isn't done */
a.connect( &a, TQT_SIGNAL( shutDown () ), knights, TQT_SLOT( KillAll() ) );
+ a.connect( &a, SIGNAL( aboutToQuit() ), knights, SLOT( aboutToQuit() ) );
return a.exec();
}
diff --git a/knights/resource.cpp b/knights/resource.cpp
index f3d8ed6..c191c11 100644
--- a/knights/resource.cpp
+++ b/knights/resource.cpp
@@ -159,6 +159,7 @@ void resource::ConfigRead( void )
OPTION_Book_White = CFG->readBoolEntry( "BookWhite", FALSE );
OPTION_Book_Black = CFG->readBoolEntry( "BookBlack", FALSE );
OPTION_Pause_On_Minimize = CFG->readBoolEntry( "PauseOnMinimize", TRUE );
+ OPTION_Delete_Logs = CFG->readBoolEntry( "DeleteLogOnExit", FALSE );
OPTION_Reuse_PGN = CFG->readBoolEntry( "ReusePGN", FALSE );
PGN_Filename = CFG->readEntry( "PGNFilename", TQString() );
SCID_Image_Path = CFG->readEntry( "SCIDImages", TQString() );
@@ -235,6 +236,7 @@ void resource::ConfigWrite( void )
CFG->writeEntry( "BookBlack", OPTION_Book_Black );
CFG->writeEntry( "BoardOrientation", OPTION_Board_Orientation );
CFG->writeEntry( "PauseOnMinimize", OPTION_Pause_On_Minimize );
+ CFG->writeEntry( "DeleteLogOnExit", OPTION_Delete_Logs );
CFG->writeEntry( "ReusePGN", OPTION_Reuse_PGN );
CFG->writeEntry( "PGNFilename", PGN_Filename );
CFG->writeEntry( "AutoCloseLastICS", OPTION_Auto_Close_Last_ICS );
diff --git a/knights/resource.h b/knights/resource.h
index 1303b0a..9812632 100644
--- a/knights/resource.h
+++ b/knights/resource.h
@@ -109,6 +109,7 @@ class resource
bool OPTION_Book_White;
bool OPTION_Book_Black;
bool OPTION_Board_Orientation;
+ bool OPTION_Delete_Logs;
bool OPTION_Ponder;
bool OPTION_Show_Coord;
bool OPTION_Show_Last_Move;
diff --git a/knights/setpagegeneral.cpp b/knights/setpagegeneral.cpp
index 7dcf58e..d3731b9 100644
--- a/knights/setpagegeneral.cpp
+++ b/knights/setpagegeneral.cpp
@@ -18,6 +18,7 @@
#include <tdefiledialog.h>
#include <kicontheme.h>
#include "setpagegeneral.moc"
+#include <tqwhatsthis.h>
setPageGeneral::setPageGeneral(TQWidget *parent, resource *Rsrc ) : TQVBoxLayout(parent)
{
@@ -95,6 +96,15 @@ setPageGeneral::setPageGeneral(TQWidget *parent, resource *Rsrc ) : TQVBoxLayout
connect( BUTTON_Auto_Flag, TQT_SIGNAL( toggled(bool) ),
this, TQT_SLOT( slot_Auto_Flag(bool) ) );
addWidget( BUTTON_Auto_Flag );
+
+ BUTTON_Delete_Logs = new TQCheckBox( i18n( "Delete Log Files on Exit" ), parent );
+ TQWhatsThis::add( BUTTON_Delete_Logs, i18n("If set, chess engine log files will be deleted on exit. "
+ "Only files named \"game.###\" and \"log.###\" placed in the user home folder will be removed"));
+ BUTTON_Delete_Logs->setChecked( Resource->OPTION_Delete_Logs );
+ connect( BUTTON_Delete_Logs, TQT_SIGNAL( toggled(bool) ),
+ this, TQT_SLOT( slot_Delete_Logs(bool) ) );
+ addWidget( BUTTON_Delete_Logs );
+
}
setPageGeneral::~setPageGeneral()
{
@@ -173,6 +183,16 @@ void setPageGeneral::slot_Auto_Flag( bool state )
}
///////////////////////////////////////
//
+// setPageGeneral::slot_Delete_Logs
+//
+///////////////////////////////////////
+void setPageGeneral::slot_Delete_Logs( bool state )
+{
+ Resource->OPTION_Delete_Logs = state;
+ emit enableApply();
+}
+///////////////////////////////////////
+//
// setPageGeneral::slot_UserName
//
///////////////////////////////////////
diff --git a/knights/setpagegeneral.h b/knights/setpagegeneral.h
index d62d52e..bdf6e6e 100644
--- a/knights/setpagegeneral.h
+++ b/knights/setpagegeneral.h
@@ -50,6 +50,7 @@ class setPageGeneral : public TQVBoxLayout
void slot_Pause_On_Minimize( bool state );
void slot_Auto_Queen( bool state );
void slot_Auto_Flag( bool state );
+ void slot_Delete_Logs( bool state );
void slot_Reuse_PGN( bool );
void slot_PGN_Filename( const TQString& );
void slot_PGN_Filename_Button( void );
@@ -76,6 +77,7 @@ class setPageGeneral : public TQVBoxLayout
TQCheckBox *BUTTON_Pause_On_Minimize;
TQCheckBox *BUTTON_Auto_Queen;
TQCheckBox *BUTTON_Auto_Flag;
+ TQCheckBox *BUTTON_Delete_Logs;
};
#endif