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>
pull/1/head
Michele Calgaro 8 years ago
parent 26ccf10eac
commit febf3bbebf

@ -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>

@ -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
//
///////////////////////////////////////

@ -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. */

@ -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();
}

@ -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 );

@ -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;

@ -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
//
///////////////////////////////////////

@ -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

Loading…
Cancel
Save