Skip to content

Commit

Permalink
GNUChess.
Browse files Browse the repository at this point in the history
  • Loading branch information
textbrowser committed Jan 4, 2025
1 parent 1400058 commit 71c11a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
31 changes: 21 additions & 10 deletions Source/qtchess_gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ qtchess_gui::~qtchess_gui()
m_gnuchess.waitForFinished();
}

bool qtchess_gui::is_ready(void) const
{
if(comm && comm->is_ready())
return true;
else if(m_gnuchess.state() == QProcess::Running)
return true;
else
return false;
}

qtchess_promotion *qtchess_gui::get_promote_dialog(void) const
{
return m_promotion;
Expand Down Expand Up @@ -480,7 +490,7 @@ void qtchess_gui::initialize_board(void)

chess->set_turn(MY_TURN);

if(comm->is_ready() || m_gnuchess.state() == QProcess::Running)
if((comm && comm->is_ready()) || m_gnuchess.state() == QProcess::Running)
{
if(chess->get_my_color() == WHITE)
m_ui.side->setText(tr("You Play As Left"));
Expand Down Expand Up @@ -538,11 +548,13 @@ void qtchess_gui::slot_new_game(void)
}

initialize_board();
m_gnuchess.kill();
}

void qtchess_gui::slot_new_gnuchess_game(void)
{
QApplication::setOverrideCursor(Qt::WaitCursor);
comm ? comm->disconnect_remotely(), comm->stop_listening() : (void) 0;
m_gnuchess.kill();
m_gnuchess.waitForFinished();
m_gnuchess.start(QTCHESS_GNUCHESS_PATH, QStringList() << "--easy");
Expand Down Expand Up @@ -946,16 +958,15 @@ void qtchess_setup::slot_listen(void)
{
auto state = false;

if(sender() == m_ui.listen)
if(comm)
{
if(comm->is_listening())
comm->stop_listening();
else
comm->set_listen();
if(comm && m_ui.listen == sender())
{
if(comm->is_listening())
comm->stop_listening();
else
comm->set_listen();

state = comm->is_listening();
}
state = comm->is_listening();
}

m_ui.local_host->setReadOnly(state);
m_ui.local_ipv4->setEnabled(!state);
Expand Down
1 change: 1 addition & 0 deletions Source/qtchess_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class qtchess_gui: public QMainWindow
QPointer<qtchess_setup> m_setup;
QProcess m_gnuchess;
Ui_qtchess_mainwindow m_ui;
bool is_ready(void) const;

void closeEvent(QCloseEvent *event)
{
Expand Down

0 comments on commit 71c11a0

Please sign in to comment.