2
* mainwin.cpp - qGoClient's main window (cont. in tables.cpp)
4
#include "clientwindow_gui.h"
8
#include "playertable.h"
9
#include "gamestable.h"
10
#include "gamedialog.h"
11
#include "qgo_interface.h"
12
#include "komispinbox.h"
14
#include "igsconnection.h"
15
#include "mainwindow.h"
16
#include "qnewgamedlg.h"
17
#include "./pics/clientpics.h"
20
#include <qcombobox.h>
21
#include <qcheckbox.h>
22
#include <qtabwidget.h>
24
#include <qlineedit.h>
26
#include <qstatusbar.h>
27
#include <qmainwindow.h>
29
#include <qwhatsthis.h>
30
#include <qvaluelist.h>
31
#include <qpopupmenu.h>
32
#include <qtextstream.h>
33
#include <qeucjpcodec.h>
34
#include <qjiscodec.h>
35
#include <qsjiscodec.h>
36
#include <qgbkcodec.h>
37
#include <qeuckrcodec.h>
38
#include <qtsciicodec.h>
41
#include <qtoolbutton.h>
44
#include <qbuttongroup.h>
45
#include <qobjectlist.h>
48
#include <qplatinumstyle.h>
49
#include <qmotifstyle.h>
50
#include <qmotifplusstyle.h>
51
#include <qcdestyle.h>
52
#include <qsgistyle.h>
59
* Clientwindow = MainWidget
63
ClientWindow::ClientWindow(QMainWindow *parent, const char* name, WFlags fl)
64
: ClientWindowGui( parent, name, fl ), Misc<QString>()
68
prefsIcon= QPixmap::QPixmap(qembed_findImage("package_settings"));//QPixmap(ICON_PREFS);
69
// infoIcon= QPixmap(ICON_GAMEINFO);
70
exitIcon = QPixmap::QPixmap(qembed_findImage("exit"));//QPixmap(ICON_EXIT);
71
fileNewboardIcon = QPixmap::QPixmap(qembed_findImage("newboard"));//QPixmap(ICON_FILENEWBOARD);
72
fileNewIcon = QPixmap::QPixmap(qembed_findImage("filenew"));//QPixmap(ICON_FILENEW);
73
fileOpenIcon = QPixmap::QPixmap(qembed_findImage("fileopen"));//QPixmap(ICON_FILEOPEN);
74
// fileSaveIcon = QPixmap(ICON_FILESAVE);
75
// fileSaveAsIcon = QPixmap(ICON_FILESAVEAS);
76
// transformIcon = QPixmap(ICON_TRANSFORM);
77
// charIcon = QPixmap(ICON_CHARSET);
78
manualIcon = QPixmap::QPixmap(qembed_findImage("help"));//QPixmap(ICON_MANUAL);
79
// autoplayIcon = QPixmap(ICON_AUTOPLAY);
80
connectedIcon = QPixmap::QPixmap(qembed_findImage("connected"));//QPixmap(ICON_CONNECTED);
81
disconnectedIcon = QPixmap::QPixmap(qembed_findImage("connect_no"));//QPixmap(ICON_DISCONNECTED);
82
OpenIcon = QPixmap::QPixmap(qembed_findImage("open"));//QPixmap(ICON_OPEN);
83
LookingIcon = QPixmap::QPixmap(qembed_findImage("looking"));//QPixmap(ICON_LOOKING);
84
QuietIcon= QPixmap::QPixmap(qembed_findImage("quiet"));//QPixmap(ICON_QUIET);
85
NotOpenIcon = QPixmap::QPixmap(qembed_findImage("not_open"));//QPixmap(ICON_NOT_OPEN);
86
NotLookingIcon = QPixmap::QPixmap(qembed_findImage("not_looking"));//QPixmap(ICON_NOT_LOOKING);
87
NotQuietIcon= QPixmap::QPixmap(qembed_findImage("not_quiet"));//QPixmap(ICON_NOT_QUIET);
88
RefreshPlayersIcon = QPixmap::QPixmap(qembed_findImage("refresh_players"));//QPixmap(ICON_REFRESH_PLAYERS);
89
RefreshGamesIcon = QPixmap::QPixmap(qembed_findImage("refresh_games"));//QPixmap(ICON_REFRESH_GAMES);
90
ComputerPlayIcon = QPixmap::QPixmap(qembed_findImage("computerplay"));//QPixmap(ICON_COMPUTER_PLAY);
91
qgoIcon = QPixmap::QPixmap(qembed_findImage("Bowl"));//QPixmap(ICON_COMPUTER_PLAY);
102
setIcon(setting->image0);
103
myAccount = new Account(this);
105
defaultStyle = qApp->style().name() ;
106
// this is very dirty : we do this because there seem to be no clean way to backtrack from MainWindow to the defaultStyle :-(
107
setting->writeEntry("DEFAULT_STYLE",defaultStyle ) ;
109
hostlist.setAutoDelete(true);
112
sendBuffer.setAutoDelete(true);
113
currentCommand = new sendBuf("",0);
118
tn_wait_for_tn_ready = false;
119
// tn_active = false;
122
playerListEmpty = true;
123
gamesListSteadyUpdate = false;
124
playerListSteadyUpdate = false;
125
autoAwayMessage = false;
126
watch = ";" + setting->readEntry("WATCH") + ";";
127
exclude = ";" + setting->readEntry("EXCLUDE") + ";";
133
// set focus, clear entry field
134
cb_cmdLine->setFocus();
136
cb_cmdLine->insertItem("");
138
// create instance of telnetConnection
139
telnetConnection = new TelnetConnection(this);
141
// create parser and connect signals
142
parser = new Parser();
143
connect(parser, SIGNAL(signal_player(Player*, bool)), SLOT(slot_player(Player*, bool)));
144
connect(parser, SIGNAL(signal_statsPlayer(Player*)), SLOT(slot_statsPlayer(Player*)));
145
connect(parser, SIGNAL(signal_game(Game*)), SLOT(slot_game(Game*)));
146
connect(parser, SIGNAL(signal_message(QString)), SLOT(slot_message(QString)));
147
connect(parser, SIGNAL(signal_svname(GSName&)), SLOT(slot_svname(GSName&)));
148
connect(parser, SIGNAL(signal_accname(QString&)), SLOT(slot_accname(QString&)));
149
connect(parser, SIGNAL(signal_status(Status)), SLOT(slot_status(Status)));
150
connect(parser, SIGNAL(signal_connclosed()), SLOT(slot_connclosed()));
151
connect(parser, SIGNAL(signal_talk(const QString&, const QString&, bool)), SLOT(slot_talk(const QString&, const QString&, bool)));
152
connect(parser, SIGNAL(signal_checkbox(int, bool)), SLOT(slot_checkbox(int, bool)));
153
connect(parser, SIGNAL(signal_addToObservationList(int)), SLOT(slot_addToObservationList(int)));
154
connect(parser, SIGNAL(signal_channelinfo(int, const QString&)), SLOT(slot_channelinfo(int, const QString&)));
155
connect(parser, SIGNAL(signal_matchrequest(const QString&, bool)), this, SLOT(slot_matchrequest(const QString&, bool)));
156
connect(parser, SIGNAL(signal_matchCanceled(const QString&)), this, SLOT(slot_matchCanceled(const QString&)));
157
connect(parser, SIGNAL(signal_shout(const QString&, const QString&)), SLOT(slot_shout(const QString&, const QString&)));
159
// connect mouse to games table/player table
160
connect(ListView_games, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
161
SLOT(slot_menu_games(QListViewItem*, const QPoint&, int)));
164
connect(ListView_games, SIGNAL(doubleClicked(QListViewItem*)),
165
SLOT(slot_click_games(QListViewItem*)));
168
/* connect(ListView_games, SIGNAL(onViewport()),
169
SLOT(slot_moveOver_games()));
172
connect(ListView_players, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
173
SLOT(slot_menu_players(QListViewItem*, const QPoint&, int)));
176
connect(ListView_players, SIGNAL(doubleClicked(QListViewItem*)),
177
SLOT(slot_click_players(QListViewItem*)));
180
/* connect(ListView_players, SIGNAL(onViewport()),
181
SLOT(slot_moveOver_players()));
184
// restore last setting
187
setting = new Setting();
188
setting->loadSettings();
198
initToolBar(); //end add eb 5
203
// BEGIN find outdated keys:
206
if (setting->readIntEntry("VERSION") < SETTING_VERSION)
208
// version settings are not actual
209
int s_v = setting->readIntEntry("VERSION");
214
for (i = 1; i < 5; i++)
216
s = setting->readEntry("USER" + QString::number(i));
219
QString i_ = QString::number(i);
220
setting->writeEntry("USER" + i_ + "_1", element(s, 0, DELIMITER));
221
setting->writeEntry("USER" + i_ + "_2", element(s, 1, DELIMITER));
222
setting->writeEntry("USER" + i_ + "_3", element(s, 2, DELIMITER));
224
setting->writeEntry("USER" + i_, 0);
227
setting->writeEntry("HOSTWINDOW", 0);
230
while ((s = setting->readEntry("HOST" + QString::number(++i))) != NULL)
232
// check if 4 delimiters in s
233
if (s.contains(DELIMITER) == 4)
235
setting->writeEntry("HOST" + QString::number(i) + "a", element(s, 0, DELIMITER));
236
setting->writeEntry("HOST" + QString::number(i) + "b", element(s, 1, DELIMITER));
237
setting->writeIntEntry("HOST" + QString::number(i) + "c", element(s, 2, DELIMITER).toInt());
238
setting->writeEntry("HOST" + QString::number(i) + "d", element(s, 3, DELIMITER));
239
setting->writeEntry("HOST" + QString::number(i) + "e", element(s, 4, DELIMITER));
242
setting->writeEntry("HOST" + QString::number(i), QString());
256
while ((s = setting->readEntry("HOST" + QString::number(++i) + "a")) != NULL)
258
hostlist.inSort(new Host(setting->readEntry("HOST" + QString::number(i) + "a"),
259
setting->readEntry("HOST" + QString::number(i) + "b"),
260
setting->readIntEntry("HOST" + QString::number(i) + "c"),
261
setting->readEntry("HOST" + QString::number(i) + "d"),
262
setting->readEntry("HOST" + QString::number(i) + "e")));
265
// run slot command to initialize combobox and set host
266
QString w = setting->readEntry("ACTIVEHOST");
268
slot_cbconnect(QString());
270
// set host if available
273
//restore user buttons list
277
userButtonGroup = new QButtonGroup(this);
278
userButtonGroup->hide();
279
connect( userButtonGroup, SIGNAL(clicked(int)), SLOT(slotUserButtonClicked(int)) );
281
while ((s = setting->readEntry("USER" + QString::number(++i) + "_1")) != NULL)
283
b=new QToolButton(UserToolbar) ;
284
b->setText(setting->readEntry("USER" + QString::number(i) + "_1")); //label of the button : for display
285
b->setTextLabel(setting->readEntry("USER" + QString::number(i) + "_1")); //duplicated for storage
286
b->setCaption(setting->readEntry("USER" + QString::number(i) + "_2")); //dirty but handy
287
QToolTip::add(b,setting->readEntry("USER" + QString::number(i) + "_3"));
288
b->setIconText(setting->readEntry("USER" + QString::number(i) + "_4")); //dirty but handy
289
b->setMinimumWidth(25);
290
if (p.load(b->iconText()))
292
userButtonGroup->insert(b,-1);
295
//restore players list filters
296
whoBox1->setCurrentItem(setting->readIntEntry("WHO_1"));
297
whoBox2->setCurrentItem(setting->readIntEntry("WHO_2"));
298
whoOpenCheck->setChecked(setting->readIntEntry("WHO_CB"));
301
// restore size of client window
302
s = setting->readEntry("CLIENTWINDOW");
306
p.setX(element(s, 0, DELIMITER).toInt());
307
p.setY(element(s, 1, DELIMITER).toInt());
309
sz.setWidth(element(s, 2, DELIMITER).toInt());
310
sz.setHeight(element(s, 3, DELIMITER).toInt());
315
// restore splitter in client window
316
s = setting->readEntry("CLIENTSPLITTER");
319
QValueList<int> w1, h1, w2;
320
w1 << element(s, 0, DELIMITER).toInt() << element(s, 1, DELIMITER).toInt();
321
h1 << element(s, 2, DELIMITER).toInt() << element(s, 3, DELIMITER).toInt();
322
w2 << element(s, 4, DELIMITER).toInt() << element(s, 5, DELIMITER).toInt();
323
//mainTable->s1->setSizes(w1);
329
// restore size of debug window
330
s = setting->readEntry("DEBUGWINDOW");
333
view_p.setX(element(s, 0, DELIMITER).toInt());
334
view_p.setY(element(s, 1, DELIMITER).toInt());
335
view_s.setWidth(element(s, 2, DELIMITER).toInt());
336
view_s.setHeight(element(s, 3, DELIMITER).toInt());
344
// restore size of menu window
345
s = setting->readEntry("MENUWINDOW");
348
menu_p.setX(element(s, 0, DELIMITER).toInt());
349
menu_p.setY(element(s, 1, DELIMITER).toInt());
350
menu_s.setWidth(element(s, 2, DELIMITER).toInt());
351
menu_s.setHeight(element(s, 3, DELIMITER).toInt());
359
// restore size of preferences window
360
s = setting->readEntry("PREFWINDOW");
363
pref_p.setX(element(s, 0, DELIMITER).toInt());
364
pref_p.setY(element(s, 1, DELIMITER).toInt());
365
pref_s.setWidth(element(s, 2, DELIMITER).toInt());
366
pref_s.setHeight(element(s, 3, DELIMITER).toInt());
374
// 'user' cmd instead of 'who'?
375
setColumnsForExtUserInfo();
377
// create qGo Interface for board handling
378
qgoif = new qGoIF(this);
380
connect(parser, SIGNAL(signal_move(GameInfo*)), qgoif, SLOT(slot_move(GameInfo*)));
381
connect(parser, SIGNAL(signal_move(Game*)), qgoif, SLOT(slot_move(Game*)));
382
connect(parser, SIGNAL(signal_kibitz(int, const QString&, const QString&)), qgoif, SLOT(slot_kibitz(int, const QString&, const QString&)));
383
connect(parser, SIGNAL(signal_title(const QString&)), qgoif, SLOT(slot_title(const QString&)));
384
connect(parser, SIGNAL(signal_komi(const QString&, const QString&, bool)), qgoif, SLOT(slot_komi(const QString&, const QString&, bool)));
385
connect(parser, SIGNAL(signal_freegame(bool)), qgoif, SLOT(slot_freegame(bool)));
386
connect(parser, SIGNAL(signal_matchcreate(const QString&, const QString&)), qgoif, SLOT(slot_matchcreate(const QString&, const QString&)));
387
connect(parser, SIGNAL(signal_removestones(const QString&, const QString&)), qgoif, SLOT(slot_removestones(const QString&, const QString&)));
388
connect(parser, SIGNAL(signal_undo(const QString&, const QString&)), qgoif, SLOT(slot_undo(const QString&, const QString&)));
389
connect(parser, SIGNAL(signal_result(const QString&, const QString&, bool, const QString&)), qgoif, SLOT(slot_result(const QString&, const QString&, bool, const QString&)));
390
connect(parser, SIGNAL(signal_requestDialog(const QString&, const QString&, const QString&, const QString&)), qgoif, SLOT(slot_requestDialog(const QString&, const QString&, const QString&, const QString&)));
391
connect(this, SIGNAL(signal_move(Game*)), qgoif, SLOT(slot_move(Game*)));
392
connect(this, SIGNAL(signal_computer_game(QNewGameDlg*)), qgoif, SLOT(slot_computer_game(QNewGameDlg*)));//SL added eb 12
393
connect(qgoif, SIGNAL(signal_sendcommand(const QString&, bool)), this, SLOT(slot_sendcommand(const QString&, bool)));
394
connect(qgoif, SIGNAL(signal_addToObservationList(int)), this, SLOT(slot_addToObservationList(int)));
395
connect(qgoif->get_qgo(), SIGNAL(signal_updateFont()), this, SLOT(slot_updateFont()));
396
connect(parser, SIGNAL(signal_timeAdded(int, bool)), qgoif, SLOT(slot_timeAdded(int, bool)));
399
// connect(ListView_players, SIGNAL(contentsMoving(int, int)), this, SLOT(slot_playerContentsMoving(int, int)));
400
connect(ListView_games, SIGNAL(contentsMoving(int, int)), this, SLOT(slot_gamesContentsMoving(int, int)));
402
// add menu bar and status bar
403
// MainAppWidgetLayout->addWidget(menuBar, 0, 0);
408
// set style - same as set up a board with qgoif
409
int style = setting->readEntry("STYLE").toInt();
410
if (style < 0 || style > 6)
412
setting->writeEntry("STYLE", "0");
421
//qApp->setStyle(NULL);
425
qApp->setStyle(new QWindowsStyle);
429
qApp->setStyle(new QPlatinumStyle);
433
qApp->setStyle(new QMotifStyle);
437
qApp->setStyle(new QMotifPlusStyle);
441
// there seems to be a problem within X11...
443
qApp->setStyle(new QCDEStyle);
447
qApp->setStyle(new QSGIStyle);
452
#if (QT_VERSION > 0x030102)
453
qApp->setStyle(new QWindowsXPStyle);
455
qApp->setStyle(new QWindowsStyle);
461
qWarning("Unrecognized style!");
467
QToolTip::setGloballyEnabled(true);
469
// install an event filter
470
qApp->installEventFilter(this);
473
ClientWindow::~ClientWindow()
477
delete telnetConnection;
484
void ClientWindow::initStatusBar(QWidget* /*parent*/)
486
// statusBar = new QStatusBar(parent);
487
// statusBar->resize(-1, 20);
489
statusBar()->setSizeGripEnabled(false);
490
statusBar()->message(tr("Ready.")); // Normal indicator
492
// Standard Text instead of "message" cause WhatsThisButten overlaps
493
statusMessage = new QLabel(statusBar());
494
statusMessage->setAlignment(AlignCenter | SingleLine);
495
statusMessage->setText("");
496
statusBar()->addWidget(statusMessage, 0, true); // Permanent indicator
499
statusWhatsThis = new QLabel(statusBar);
500
statusWhatsThis->setAlignment(AlignCenter | SingleLine);
501
statusWhatsThis->setText("WHATSTHIS");
502
statusBar->addWidget(statusWhatsThis, 0, true); // Permanent indicator
503
QWhatsThis::whatsThisButton(statusWhatsThis);
506
statusUsers = new QLabel(statusBar());
507
statusUsers->setAlignment(AlignCenter | SingleLine);
508
statusUsers->setText(" P: 0 / 0 ");
509
statusBar()->addWidget(statusUsers, 0, true); // Permanent indicator
510
QToolTip::add(statusUsers, tr("Current online players / watched players"));
511
QWhatsThis::add(statusUsers, tr("Displays the number of current online players\nand the number of online players you are watching.\nA player you are watching has an entry in the 'watch player:' field."));
514
statusGames = new QLabel(statusBar());
515
statusGames->setAlignment(AlignCenter | SingleLine);
516
statusGames->setText(" G: 0 / 0 ");
517
statusBar()->addWidget(statusGames, 0, true); // Permanent indicator
518
QToolTip::add(statusGames, tr("Current online games / observed games + matches"));
519
QWhatsThis::add(statusGames, tr("Displays the number of games currently played on this server and the number of games you are observing or playing"));
522
statusServer = new QLabel(statusBar());
523
statusServer->setAlignment(AlignCenter | SingleLine);
524
statusServer->setText(" OFFLINE ");
525
statusBar()->addWidget(statusServer, 0, true); // Permanent indicator
526
QToolTip::add(statusServer, tr("Current server"));
527
QWhatsThis::add(statusServer, tr("Displays the current server's name or OFFLINE if you are not connected to the internet."));
529
// The channel widget
530
statusChannel = new QLabel(statusBar());
531
statusChannel->setAlignment(AlignCenter | SingleLine);
532
statusChannel->setText("");
533
statusBar()->addWidget(statusChannel, 0, true); // Permanent indicator
534
QToolTip::add(statusChannel, tr("Current channels and users"));
535
QWhatsThis::add(statusChannel, tr("Displays the current channels you are in and the number of users inthere.\nThe tooltip text contains the channels' title and users' names"));
538
statusOnlineTime = new QLabel(statusBar());
539
statusOnlineTime->setAlignment(AlignCenter | SingleLine);
540
statusOnlineTime->setText(" 00:00 ");
541
statusBar()->addWidget(statusOnlineTime, 0, true); // Permanent indicator
542
QToolTip::add(statusOnlineTime, tr("Online Time"));
543
QWhatsThis::add(statusOnlineTime, tr("Displays the current online time.\n(A) -> auto answer\n(Hold) -> hold the line"));
546
void ClientWindow::timerEvent(QTimerEvent*)
548
// some variables for forcing send buffer and keep line established
549
// static int counter = 3599;
550
static int holdTheLine = true;
551
static int tnwait = 0;
552
static int statusCnt = 0;
553
static QString statusTxt = QString();
557
// case: ready to send
562
//qDebug(QString("%1: HoldTheLine SET: something has been sent").arg(statusOnlineTime->text()));
563
// case: not ready to send, but maybe waiting for READY message
565
// something was sent, so reset counter
568
autoAwayMessage = false;
570
/* else if (!tn_active)
572
qDebug("---> sending forced!!!");
573
// case: not ready to send, waiting too long -> force sending
578
qDebug("---> not forced because of tn_active");
580
// show status bar text for 5 seconds
581
/* if (statusTxt != statusMessage->text())
583
statusTxt = statusMessage->text();
586
if (statusCnt-- == 0)
587
statusMessage->setText("");
589
if (counter % 300 == 0)
591
// 5 mins away -> set auto answering
592
autoAwayMessage = true;
595
// send "ayt" every half hour anyway
596
// new: reset timer after one hour of idle state
597
// -> if not observing a game!
598
//qDebug(QString("%1 -> HoldTheLine: status = %2").arg(statusOnlineTime->text()).arg(holdTheLine));
600
sendcommand("ayt", false);
605
if (myAccount->num_observedgames == 0)
609
//qDebug(QString("%1: HoldTheLine END!").arg(statusOnlineTime->text()));
613
//qDebug(QString("%1: HoldTheLine LENGTHENED: observing game...").arg(statusOnlineTime->text()));
616
else if (myAccount->get_gsname() == IGS && holdTheLine)
618
sendcommand("ayt", false);
619
qDebug(QString("%1 -> ayt").arg(statusOnlineTime->text()));
625
// display online time
627
int hr = onlineCount/3600;
628
int min = (onlineCount % 3600)/60;
629
int sec = onlineCount % 60;
635
min_ = "0" + QString::number(min);
637
min_ = QString::number(min);
640
sec_ = "0" + QString::number(sec);
642
sec_ = QString::number(sec);
645
pre += QString::number(hr) + "h ";
647
statusOnlineTime->setText(pre + min_ + ":" + sec_ + " ");
650
QToolTip::remove(statusServer);
651
QToolTip::add(statusServer, tr("Current server") + "\n" +
652
tr("Bytes in:") + " " + QString::number(bytesIn) + "\n" +
653
tr("Bytes out:") + " " + QString::number(bytesOut));
654
// LineEdit_bytesIn->setText(QString::number(bytesIn));
655
// LineEdit_bytesOut->setText(QString::number(bytesOut));
657
// DEBUG ONLY BEGIN ****
658
// DEBUG display remaining time
660
min = (counter % 3600)/60;
668
min_ = "0" + QString::number(min);
670
min_ = QString::number(min);
673
sec_ = "0" + QString::number(sec);
675
sec_ = QString::number(sec);
678
pre += QString::number(hr) + "h ";
680
statusMessage->setText(pre + min_ + ":" + sec_ + (holdTheLine ? " Hold" :
682
// DEBUG ONLY END ****
685
// slot_connect: emitted when connect button has toggled
686
void ClientWindow::slot_connect(bool b)
691
// create instance of telnetConnection
692
if (!telnetConnection)
693
qFatal("No telnetConnection!");
695
// connect to selected host
696
telnetConnection->slotHostConnect();
701
telnetConnection->slotHostQuit();
706
void ClientWindow::slot_connclosed()
708
// no Timers in offline mode!
712
myAccount->set_offline();
713
//pb_connect->setOn(FALSE);
714
toolConnect->setOn(FALSE); //SL added eb 5
717
prepare_tables(CHANNELS);
722
qDebug("slot_connclosed()");
723
qDebug(QString("%1 -> slot_connclosed()").arg(statusOnlineTime->text()));
725
qgoif->get_qgo()->playConnectSound();
727
// show current Server name in status bar
728
statusServer->setText(" OFFLINE ");
731
Connect->setEnabled(true);
732
Disconnect->setEnabled(false);
733
toolConnect->setOn(false);
734
toolConnect->setPixmap(disconnectedIcon);
735
QToolTip::remove(toolConnect);
736
QToolTip::add(toolConnect, tr("Connect with") + " " + cb_connect->currentText());
740
void ClientWindow::saveSettings()
744
for (Host *h = hostlist.first(); h != 0; h = hostlist.next())
747
setting->writeEntry("HOST" + QString::number(i) + "a", h->title());
748
setting->writeEntry("HOST" + QString::number(i) + "b", h->host());
749
setting->writeIntEntry("HOST" + QString::number(i) + "c", h->port());
750
setting->writeEntry("HOST" + QString::number(i) + "d", h->loginName());
751
setting->writeEntry("HOST" + QString::number(i) + "e", h->password());
753
while (setting->readEntry("HOST" + QString::number(++i) + "a"))
755
// delete unused entries
756
setting->writeEntry("HOST" + QString::number(i) + "a", QString());
757
setting->writeEntry("HOST" + QString::number(i) + "b", QString());
758
setting->writeEntry("HOST" + QString::number(i) + "c", QString());
759
setting->writeEntry("HOST" + QString::number(i) + "d", QString());
760
setting->writeEntry("HOST" + QString::number(i) + "e", QString());
763
// set the user toolbar list
765
QObjectList *bl = UserToolbar->queryList( "QToolButton" ,NULL,true,false);
768
for ( b0 = (QToolButton*)bl->first(); b0 != 0; b0 = (QToolButton*)bl->next())
771
setting->writeEntry("USER" + QString::number(i) + "_1",b0->textLabel());
772
setting->writeEntry("USER" + QString::number(i) + "_2",b0->caption());
773
setting->writeEntry("USER" + QString::number(i) + "_3",QToolTip::textFor (b0) );
774
setting->writeEntry("USER" + QString::number(i) + "_4",b0->iconText());
777
while (setting->readEntry("USER" + QString::number(++i) + "_1"))
779
setting->writeEntry("USER" + QString::number(i) + "_1",QString());
780
setting->writeEntry("USER" + QString::number(i) + "_2",QString());
781
setting->writeEntry("USER" + QString::number(i) + "_3",QString());
782
setting->writeEntry("USER" + QString::number(i) + "_4",QString());
786
// save current connection if at least one host exists
787
if (!hostlist.isEmpty())
788
setting->writeEntry("ACTIVEHOST",cb_connect->currentText());
790
setting->writeEntry("CLIENTWINDOW",
791
QString::number(pos().x()) + DELIMITER +
792
QString::number(pos().y()) + DELIMITER +
793
QString::number(size().width()) + DELIMITER +
794
QString::number(size().height()));
796
setting->writeEntry("CLIENTSPLITTER",
797
QString::number(s1->sizes().first()) + DELIMITER +
798
QString::number(s1->sizes().last()) + DELIMITER +
799
QString::number(s2->sizes().first()) + DELIMITER +
800
QString::number(s2->sizes().last()) + DELIMITER +
801
QString::number(s3->sizes().first()) + DELIMITER +
802
QString::number(s3->sizes().last()));
805
setting->writeEntry("DEBUGWINDOW",
806
QString::number(DD->pos().x()) + DELIMITER +
807
QString::number(DD->pos().y()) + DELIMITER +
808
QString::number(DD->size().width()) + DELIMITER +
809
QString::number(DD->size().height()));
812
if (menu_s.width() > 0)
813
setting->writeEntry("MENUWINDOW",
814
QString::number(menu_p.x()) + DELIMITER +
815
QString::number(menu_p.y()) + DELIMITER +
816
QString::number(menu_s.width()) + DELIMITER +
817
QString::number(menu_s.height()));
819
if (pref_s.width() > 0)
820
setting->writeEntry("PREFWINDOW",
821
QString::number(pref_p.x()) + DELIMITER +
822
QString::number(pref_p.y()) + DELIMITER +
823
QString::number(pref_s.width()) + DELIMITER +
824
QString::number(pref_s.height()));
826
setting->writeBoolEntry("EXTUSERINFO", extUserInfo);
828
setting->writeIntEntry("WHO_1", whoBox1->currentItem());
829
setting->writeIntEntry("WHO_2", whoBox2->currentItem());
830
setting->writeBoolEntry("WHO_CB", whoOpenCheck->isChecked());
832
// write settings to file
833
setting->saveSettings();
837
void ClientWindow::quit()
843
// distribute text from telnet session and local commands to tables
844
void ClientWindow::sendTextToApp(const QString &txt)
846
#if (QT_VERSION > 0x030006)
847
static int store_sort_col = -1;
848
static int store_games_sort_col = -1;
850
static bool player7active = false;
856
QTextStream t(&buf, IO_WriteOnly);
858
t.setCodec(textCodec);
859
QString tx = textFromHost;
867
qDebug("##buffer empty");
871
// put text to parser
872
InfoType it_ = parser->put_line(QString::fromLocal8Bit(txt));
875
setBytesIn(txt.length()+2);
878
// a input is being parsed -> wait until tn_active == false before sending new cmd
881
// GAME7_END emulation:
882
if (player7active && it_ != GAME7)
884
player7active = false;
885
if (store_games_sort_col != -1)
886
ListView_games->setSorting(store_games_sort_col);
887
store_games_sort_col = -1;
889
ListView_games->sort();
895
// ok, telnet is ready to receive commands
896
// tn_active = false;
897
currentCommand->txt="";
898
if (!tn_wait_for_tn_ready && !tn_ready)
900
QTimer::singleShot(200, this, SLOT(set_tn_ready()));
901
tn_wait_for_tn_ready = true;
903
sendTextFromApp(NULL);
905
// ready or white space -> return
906
// currentCommand->txt="";
910
// echo entered command
911
// echo server enter line
918
set_sessionparameter("client", true);
922
// normally no connection -> wait until logged in
933
} while (sendTextFromApp(NULL) != 0);
935
// check if tables are sorted
936
#if (QT_VERSION > 0x030006)
937
if (ListView_players->sortColumn() == -1)
938
ListView_players->setSorting(2);
939
if (ListView_games->sortColumn() == -1)
940
ListView_games->setSorting(2);
943
switch(myAccount->get_gsname())
947
// IGS - check if client mode
949
/*int cmd_nr =*/ element(txt, 0, " ").toInt(&ok);
951
set_sessionparameter("client", true);
953
// set quiet false; refresh players, games
954
//if (myAccount->get_status() == GUEST)
955
set_sessionparameter("quiet", false);
957
// set id - only available if registerd; who knows why...
958
sendcommand("id qGo " + QString(VERSION), true);
966
set_sessionparameter("client", true);
967
// set quiet false; refresh players, games
968
//if (myAccount->get_status() == GUEST)
969
set_sessionparameter("quiet", false);
971
if (myAccount->get_gsname() != CWS)
977
Connect->setEnabled(false);
978
Disconnect->setEnabled(true);
979
toolConnect->setOn(true);
980
toolConnect->setPixmap(connectedIcon);
981
QToolTip::remove(toolConnect);
982
QToolTip::add(toolConnect, tr("Disconnect from") + " " + cb_connect->currentText());
984
// quiet mode? if yes do clear table before refresh
985
gamesListSteadyUpdate = ! setQuietMode->isOn();
986
playerListSteadyUpdate = ! setQuietMode->isOn();
987
//!CheckBox_quiet->isChecked();
989
// enable extended user info features
990
setColumnsForExtUserInfo();
992
// check for messages
994
sendcommand("message", false);
996
// let qgo know which server
997
qgoif->set_gsName(myAccount->get_gsname());
998
// show current Server name in status bar
999
statusServer->setText(" " + myAccount->svname + " ");
1001
// start timer: event every second
1005
slot_talk("Shouts*", 0, true);
1006
qgoif->get_qgo()->playConnectSound();
1009
// end of 'who'/'user' cmd
1012
// anyway, end of fast filling
1013
if (store_sort_col != -1)
1014
ListView_players->setSorting(store_sort_col);
1016
store_sort_col = -1;
1017
ListView_players->sort();
1018
playerListEmpty = false;
1021
// skip table if initial table is to be loaded
1022
case PLAYER27_START:
1023
case PLAYER42_START:
1024
// disable sorting for fast operation; store sort column index
1025
store_sort_col = ListView_players->sortColumn();
1026
ListView_players->setSorting(-1);
1028
if (playerListEmpty)
1029
prepare_tables(WHO);
1033
// "emulate" GAME7_END
1034
player7active = true;
1035
// disable sorting for fast operation; store sort column index
1036
// unfortunately there is not GAME7_END cmd, thus, it's emulated
1037
if (playerListEmpty)
1039
// only if playerListEmpty, else PLAYERXX_END would not arise
1040
store_games_sort_col = ListView_games->sortColumn();
1041
ListView_games->setSorting(-1);
1046
// let qgo and parser know which account in case of setting something for own games
1047
qgoif->set_myName(myAccount->acc_name);
1048
parser->set_myname(myAccount->acc_name);
1053
// we just received a players name as first line of stats -> create the dialog tab
1054
currentCommand->txt="stats";
1056
if (!talklist.current())
1057
slot_talk( parser->get_statsPlayer()->name,0,true);
1059
else if (parser->get_statsPlayer()->name != talklist.current()->get_name())
1060
slot_talk( parser->get_statsPlayer()->name,0,true);
1065
// QApplication::beep();
1072
// skip player list and game list
1077
if (!extUserInfo || myAccount->get_gsname() != IGS)
1096
// show all in messages window, but players and games
1097
// Scroll at bottom of text, set cursor to end of line
1098
MultiLineEdit_messages->insertLine(txt);
1104
// used for singleShot actions
1105
void ClientWindow::set_tn_ready()
1108
tn_wait_for_tn_ready = false;
1112
// send text via telnet session; skipping empty string!
1113
int ClientWindow::sendTextFromApp(const QString &txt, bool localecho)
1115
// implements a simple buffer
1116
int valid = txt.length();
1120
setBytesOut(valid+2);
1122
if (myAccount->get_status() == OFFLINE)
1124
// skip all commands while not telnet connection
1125
sendTextToApp("Command skipped - no telnet connection: " + txt);
1131
// check if telnet ready
1134
sendBuf *s = sendBuffer.getFirst();
1138
// send buffer cmd first; then put current cmd to buffer
1139
telnetConnection->sendTextFromApp(s->get_txt());
1140
//qDebug("SENDBUFFER send: " + s->get_txt());
1142
// hold the line if cmd is sent; 'ayt' is autosend cmd
1143
if (s->get_txt().find("ayt") != -1)
1145
if (s->get_localecho())
1146
sendTextToApp(CONSOLECMDPREFIX + QString(" ") + s->get_txt());
1149
// delete sent command from buffer
1150
//currentCommand->txt = s->get_txt();
1151
sendBuffer.removeFirst();
1156
// append current command to send as soon as possible
1157
sendBuffer.append(new sendBuf(txt, localecho));
1158
//qDebug("SENDBUFFER added: " + txt);
1163
// buffer empty -> send direct
1164
telnetConnection->sendTextFromApp(txt);
1165
//currentCommand->txt = txt;
1167
if (!txt.contains("ayt"))
1170
sendTextToApp(CONSOLECMDPREFIX + QString(" ") + txt);
1173
//qDebug("SENDBUFFER send direct: " + txt);
1178
//qDebug("SENDBUFFER added: " + txt);
1179
sendBuffer.append(new sendBuf(txt, localecho));
1182
return sendBuffer.count();
1185
// show command, send it, and tell parser
1186
void ClientWindow::sendcommand(const QString &cmd, bool localecho)
1188
QString testcmd = cmd;
1191
if (cmd.find("#") == 0)
1193
qDebug("detected TEST (#) command");
1194
testcmd = testcmd.remove(0, 1).stripWhiteSpace();
1197
if (testcmd.length() <= 1)
1199
sendTextToApp("local cmds available:\n"
1200
"#+dbgwin\t#+dbg\t\t#-dbg\n");
1204
// detect internal commands
1205
if (testcmd.contains("+dbgwin"))
1207
// show debug window
1209
this->setActiveWindow();
1211
else if (testcmd.contains("+dbg"))
1213
// show debug window and activate debug mode
1214
qDebug("*** set Debug on ***");
1217
this->setActiveWindow();
1219
else if (testcmd.contains("-dbg"))
1221
// hide debug window and deactivate debug mode
1222
qDebug("*** set Debug off ***");
1227
sendTextToApp(testcmd);
1234
// add to Messages, anyway
1235
// Scroll at bottom of text, set cursor to end of line
1238
slot_message(cmd,Qt::blue);
1242
sendTextFromApp(cmd, localecho);
1245
// howver, sendcommand is no slot...
1246
void ClientWindow::slot_sendcommand(const QString &cmd, bool localecho)
1248
sendcommand(cmd, localecho);
1251
void ClientWindow::slot_toolbaractivated(const QString &cmd)
1253
// do some cmd lind checks for toolbar too
1254
bool valid_marker = cmd_valid;
1256
slot_cmdactivated(cmd);
1257
cmd_valid = valid_marker;
1260
// return pressed in edit line -> command to send
1261
void ClientWindow::slot_cmdactivated(const QString &cmd)
1266
qDebug("cmd_valid: ", cmd_valid);
1267
// check if valid cmd -> cmd number risen
1270
// clear field, and restore the blank line at top
1271
cb_cmdLine->removeItem(1);
1272
cb_cmdLine->insertItem("",0);
1273
cb_cmdLine->clearEdit();
1276
QString cmdLine = cmd;
1277
sendcommand(cmdLine.stripWhiteSpace(),true);
1280
// check for known commands
1281
if (cmdLine.mid(0,2).contains("ob"))
1285
qDebug("found cmd: observe");
1286
testcmd = element(cmdLine, 1, " ");
1289
qgoif->set_observe(testcmd);
1290
sendcommand("games " + testcmd);
1293
if (cmdLine.mid(0,3).contains("who"))
1295
// clear table if manually entered
1296
prepare_tables(WHO);
1297
playerListSteadyUpdate = false;
1299
if (cmdLine.mid(0,5).contains("; \\-1") && myAccount->get_gsname() == IGS)
1301
// exit all channels
1302
prepare_tables(CHANNELS);
1307
// number of activated cmd
1308
void ClientWindow::slot_cmdactivated_int(int i)
1310
if (cb_cmdLine->count() > cmd_count)
1312
cmd_count = cb_cmdLine->count();
1319
// set session parameter
1320
void ClientWindow::set_sessionparameter(QString par, bool val)
1328
switch(myAccount->get_gsname())
1332
sendcommand("toggle " + par + value);
1336
sendcommand("set " + par + value);
1341
// select connection or create new one - combobox connection
1342
void ClientWindow::slot_cbconnect(const QString &txt)
1350
// txt empty: update combobox - server table has been edited...
1351
// keep current host
1352
text = cb_connect->currentText();
1355
cb_connect->clear();
1356
for (Host *h_ = hostlist.first(); h_ != NULL; h_ = hostlist.next())
1358
cb_connect->insertItem(h_->title());
1359
if (h_->title() == text)
1361
i = cb_connect->count();
1368
// view active host in cb_connect
1369
h = hostlist.first();
1370
while (h != NULL && h->title() != text)
1372
h = hostlist.next();
1377
// view selected host
1378
cb_connect->setCurrentItem(i-1);
1380
// check if host exists
1381
if (!h && !(h = hostlist.getFirst()))
1384
// inform telnet about selected host
1385
QString lg = h->loginName();
1386
QString pw = h->password();
1387
telnetConnection->setHost(h->host(), lg, pw, h->port());
1390
QToolTip::remove(toolConnect);
1391
QToolTip::add(toolConnect, tr("Connect with") + " " + cb_connect->currentText());
1395
qDebug("setting up codec...");
1396
// QTextCodec *tc = textCodec;
1397
textCodec = new QGbkCodec();
1398
textStream->setEncoding(QTextStream::Locale);
1399
textStream->setCodec(textCodec);
1403
// set checkbox status because of server info or because menu / checkbok toggled
1404
void ClientWindow::slot_checkbox(int nr, bool val)
1406
// set checkbox (nr) to val
1411
//toolOpen->setOn(val);
1412
setOpenMode->setOn(val);
1417
//toolLooking->setOn(val);
1418
setLookingMode->setOn(val);
1423
//toolQuiet->setOn(val);
1424
setQuietMode->setOn(val);
1428
qWarning("checkbox doesn't exist");
1433
// checkbox looking cklicked
1434
void ClientWindow::slot_cblooking()
1436
bool val = setLookingMode->isOn();
1437
// setLookingMode->setOn(val);
1438
set_sessionparameter("looking", val);
1440
// if looking then set open
1441
set_sessionparameter("open", true);
1445
// checkbox open clicked
1446
void ClientWindow::slot_cbopen()
1448
bool val = setOpenMode->isOn();
1449
// setOpenMode->setOn(val);
1450
set_sessionparameter("open", val);
1452
// if not open then set close
1453
set_sessionparameter("looking", false);
1456
// checkbox quiet clicked
1457
void ClientWindow::slot_cbquiet()
1459
bool val = setQuietMode->isOn();
1460
//setQuietMode->setOn(val);
1461
//qDebug("bouton %b",toolQuiet->isOn());
1462
set_sessionparameter("quiet", val);
1466
// if 'quiet' button is once set to true the list is not reliable any longer
1467
gamesListSteadyUpdate = false;
1468
playerListSteadyUpdate = false;
1473
// switch between 'who' and 'user' cmds
1474
void ClientWindow::setColumnsForExtUserInfo()
1476
if (!extUserInfo || (myAccount->get_gsname() != IGS))
1478
// set player table's columns to 'who' mode
1479
ListView_players->removeColumn(11);
1480
ListView_players->removeColumn(10);
1481
ListView_players->removeColumn(9);
1482
ListView_players->removeColumn(8);
1483
ListView_players->removeColumn(7);
1487
// set player table's columns to 'user' mode
1488
// first: remove invisible column
1489
ListView_players->removeColumn(7);
1490
// second: add new columns
1491
ListView_players->addColumn(tr("Info"));
1492
ListView_players->addColumn(tr("Won"));
1493
ListView_players->addColumn(tr("Lost"));
1494
ListView_players->addColumn(tr("Country"));
1495
ListView_players->addColumn(tr("Lang"));
1496
ListView_players->setColumnAlignment(7, AlignRight);
1497
ListView_players->setColumnAlignment(8, AlignRight);
1498
ListView_players->setColumnAlignment(9, AlignRight);
1502
// switch between 'who' and 'user' cmds
1503
void ClientWindow::slot_cbExtUserInfo()
1505
extUserInfo = setting->readBoolEntry("EXTUSERINFO");
1506
setColumnsForExtUserInfo();
1509
void ClientWindow::slot_updateFont()
1512
ListView_players->setFont(setting->fontLists);
1513
ListView_games->setFont(setting->fontLists);
1514
cb_connect->setFont(setting->fontLists);
1517
MultiLineEdit2->selectAll(true);
1518
MultiLineEdit2->setCurrentFont(setting->fontConsole);
1519
MultiLineEdit2->selectAll(false);
1520
MultiLineEdit3->setCurrentFont(setting->fontComments);
1521
cb_cmdLine->setFont(setting->fontComments);
1524
setFont(setting->fontStandard);
1527
QPalette pal = MultiLineEdit2->palette();
1528
pal.setColor(QColorGroup::Base, setting->colorBackground);
1529
MultiLineEdit2->setPalette(pal);
1530
MultiLineEdit3->setPalette(pal);
1533
for (dlg = talklist.first(); dlg != 0; dlg = talklist.next())
1534
dlg->setTalkWindowColor(pal);
1535
pal = cb_cmdLine->palette();
1536
pal.setColor(QColorGroup::Base, setting->colorBackground);
1537
cb_cmdLine->setPalette(pal);
1538
pal = ListView_players->palette();
1539
pal.setColor(QColorGroup::Base, setting->colorBackground);
1540
ListView_players->setPalette(pal);
1541
ListView_games->setPalette(pal);
1542
pal = cb_connect->palette();
1543
pal.setColor(QColorGroup::Base, setting->colorBackground);
1544
cb_connect->setPalette(pal);
1547
viewToolBar->setOn(setting->readBoolEntry("MAINTOOLBAR"));
1548
viewUserToolBar->setOn(setting->readBoolEntry("USERTOOLBAR"));
1549
if (setting->readBoolEntry("MAINMENUBAR"))
1551
viewMenuBar->setOn(false);
1552
viewMenuBar->setOn(true);
1554
viewStatusBar->setOn(setting->readBoolEntry("MAINSTATUSBAR"));
1556
// slot_userDefinedKeysTextChanged();
1559
// refresh button clicked
1560
void ClientWindow::slot_refresh(int i)
1563
QString wparam = "" ;
1564
// refresh depends on selected page
1568
prepare_tables(WHO);
1570
// send "WHO" command
1571
//set the params of "who command"
1572
if ((whoBox1->currentItem() >1) || (whoBox2->currentItem() >1))
1574
wparam.append(whoBox1->currentItem()==1 ? "9p" : whoBox1->currentText());
1575
if ((whoBox1->currentItem()) && (whoBox2->currentItem()))
1577
wparam.append(whoBox2->currentItem()==1 ? "9p" : whoBox2->currentText());
1579
else if ((whoBox1->currentItem()) || (whoBox2->currentItem()))
1580
wparam.append("1p-9p");
1583
if (whoOpenCheck->isChecked())
1584
wparam.append(" o");
1587
if (myAccount->get_gsname() == IGS && extUserInfo)
1588
sendcommand(wparam.prepend("user "));
1590
sendcommand(wparam.prepend("who "));
1592
prepare_tables(WHO);
1596
prepare_tables(GAMES);
1598
// send "GAMES" command
1599
sendcommand("games");
1600
// prepare_tables(GAMES);
1601
// which games are watched right now
1602
// don't work correct at IGS !!!!
1603
// sendcommand("watching");
1613
void ClientWindow::slot_pbrefreshgames()
1615
if (gamesListSteadyUpdate)
1619
// clear table in case of quiet mode
1621
gamesListSteadyUpdate = !setQuietMode->isOn(); //!CheckBox_quiet->isChecked();
1626
void ClientWindow::slot_pbrefreshplayers()
1628
if (playerListSteadyUpdate)
1632
// clear table in case of quiet mode
1634
playerListSteadyUpdate = !setQuietMode->isOn(); //!CheckBox_quiet->isChecked();
1638
void ClientWindow::slot_gamesPopup(int i)
1646
// set up game for observing
1647
if (qgoif->set_observe(lv_popupGames->text(0)))
1649
QString gameID = lv_popupGames->text(0);
1650
// if game is set up new -> get moves
1651
// set game to observe
1652
sendcommand("observe " + gameID);
1654
// check if enough data here
1655
if (lv_popupGames->text(7).length() == 0)
1657
// LGS sends the needed information, anyway
1658
if (myAccount->get_gsname() != LGS)
1659
sendcommand("games " + gameID);
1663
// complete game info
1665
g.nr = lv_popupGames->text(0);
1666
g.wname = lv_popupGames->text(1);
1667
g.wrank = lv_popupGames->text(2);
1668
g.bname = lv_popupGames->text(3);
1669
g.brank = lv_popupGames->text(4);
1670
g.mv = lv_popupGames->text(5);
1671
g.Sz = lv_popupGames->text(6);
1672
g.H = lv_popupGames->text(7);
1673
g.K = lv_popupGames->text(8);
1674
g.By = lv_popupGames->text(9);
1675
g.FR = lv_popupGames->text(10);
1676
g.ob = lv_popupGames->text(11);
1678
g.oneColorGo = false;
1681
emit signal_move(&g);
1689
slot_sendcommand("stats " + lv_popupGames->text(1), false);
1694
slot_sendcommand("stats " + lv_popupGames->text(3), false);
1702
// doubleclick actions...
1703
void ClientWindow::slot_click_games(QListViewItem *lv)
1705
// do actions if button clicked on item
1706
slot_mouse_games(3, lv, QPoint(), 0);
1707
qDebug("games list double clicked");
1709
// move over ListView
1711
void ClientWindow::slot_moveOver_games()
1713
qDebug("move over games list...");
1715
// doubleclick actions...
1716
void ClientWindow::slot_menu_games(QListViewItem *lv, const QPoint &pt, int
1719
// emulate right button
1720
slot_mouse_games(2, lv, pt, 0);
1721
qDebug("games list double clicked");
1723
// mouse click on ListView_games
1724
void ClientWindow::slot_mouse_games(int button, QListViewItem *lv, const QPoint &pt, int /*column*/)
1726
static QPopupMenu *puw = 0;
1728
// create popup window
1731
puw = new QPopupMenu(0, 0);
1732
puw->insertItem(tr("observe"), this, SLOT(slot_gamesPopup(int)), 0, 1);
1733
puw->insertItem(tr("stats W"), this, SLOT(slot_gamesPopup(int)), 0, 2);
1734
puw->insertItem(tr("stats B"), this, SLOT(slot_gamesPopup(int)), 0, 3);
1738
// do actions if button clicked on item
1751
puw->popup( QCursor::pos() );
1752
// store selected lv
1753
lv_popupGames = static_cast<GamesTableItem*>(lv);
1757
// first menue item if doubleclick
1761
// store selected lv
1762
lv_popupGames = static_cast<GamesTableItem*>(lv);
1774
void ClientWindow::slot_matchCanceled(const QString &opponent)
1776
// set up match dialog
1778
GameDialog *dlg = NULL;
1782
// look for same opponent
1783
dlg = matchlist.first();
1784
while (dlg && dlg->playerWhiteEdit->text() != opponent && dlg->playerBlackEdit->text() != opponent)
1785
dlg = matchlist.next();
1796
void ClientWindow::slot_matchrequest(const QString &line, bool myrequest)
1798
// set up match dialog
1800
GameDialog *dlg = NULL;
1806
// match xxxx B 19 1 10
1807
opponent = element(line, 1, " ");
1810
qgoif->get_qgo()->playMatchSound();
1815
opponent = element(line, 0, " ");
1818
// look for same opponent
1819
dlg = matchlist.first();
1820
while (dlg && dlg->playerWhiteEdit->text() != opponent && dlg->playerBlackEdit->text() != opponent)
1821
dlg = matchlist.next();
1825
matchlist.insert(0, new GameDialog(0, tr("New Game"), false));
1826
dlg = matchlist.current();
1828
if (myAccount->get_gsname() == NNGS ||
1829
myAccount->get_gsname() == LGS)
1831
// now connect suggest signal
1833
SIGNAL(signal_suggest(const QString&, const QString&, const QString&, const QString&, int)),
1835
SLOT(slot_suggest(const QString&, const QString&, const QString&, const QString&, int)));
1839
SIGNAL(signal_sendcommand(const QString&, bool)),
1841
SLOT(slot_sendcommand(const QString&, bool)));
1843
SIGNAL(signal_matchcreate(const QString&, const QString&)),
1845
SLOT(slot_matchcreate(const QString&, const QString&)));
1847
SIGNAL(signal_notopen(const QString&)),
1849
SLOT(slot_notopen(const QString&)));
1851
SIGNAL(signal_komirequest(const QString&, int, int, bool)),
1853
SLOT(slot_komirequest(const QString&, int, int, bool)));
1855
SIGNAL(signal_opponentopen(const QString&)),
1857
SLOT(slot_opponentopen(const QString&)));
1859
SIGNAL(signal_matchsettings(const QString&, const QString&, const QString&, assessType)),
1861
SLOT(slot_matchsettings(const QString&, const QString&, const QString&, assessType)));
1866
QString rk = element(line, 1, " ");
1869
dlg->playerWhiteEdit->setText(myAccount->acc_name);
1870
dlg->playerWhiteEdit->setReadOnly(true);
1871
dlg->playerBlackEdit->setText(opponent);
1872
dlg->playerBlackEdit->setReadOnly(false);
1874
// set my and opponent's rank for suggestion
1876
dlg->playerBlackRkEdit->setText(rk);
1877
rk = myAccount->get_rank();
1879
dlg->playerWhiteRkEdit->setText(rk);
1880
dlg->set_gsName(myAccount->get_gsname());
1882
dlg->buttonDecline->setDisabled(true);
1884
// my request: free/rated game is also requested
1885
//dlg->cb_free->setChecked(true);
1888
if (dlg->playerWhiteEdit->text() == dlg->playerBlackEdit->text())
1889
dlg->buttonOffer->setText(tr("Teaching"));
1892
dlg->boardSizeSpin->setValue(setting->readIntEntry("DEFAULT_SIZE"));
1893
dlg->timeSpin->setValue(setting->readIntEntry("DEFAULT_TIME"));
1894
dlg->byoTimeSpin->setValue(setting->readIntEntry("DEFAULT_BY"));
1895
dlg->komiSpin->setValue(setting->readIntEntry("DEFAULT_KOMI")*10+5);
1899
// match xxxx B 19 1 10 - using this line means: I am black!
1900
bool opp_plays_white = (element(line, 2, " ") == "B");//QString(tr("B")));
1901
QString size = element(line, 3, " ");
1902
QString time = element(line, 4, " ");
1903
QString byotime = element(line, 5, " ");
1905
QString rk = getPlayerRk(opponent);
1907
QString myrk = myAccount->get_rank();
1908
dlg->set_myRk(myrk);
1910
if (opp_plays_white)
1912
dlg->playerBlackEdit->setText(myAccount->acc_name);
1913
dlg->playerBlackEdit->setReadOnly(true);
1914
dlg->playerBlackRkEdit->setText(myAccount->get_rank());
1915
dlg->playerWhiteEdit->setText(opponent);
1916
dlg->playerWhiteEdit->setReadOnly(false);
1917
dlg->playerWhiteRkEdit->setText(rk);
1921
dlg->playerWhiteEdit->setText(myAccount->acc_name);
1922
dlg->playerWhiteEdit->setReadOnly(true);
1923
dlg->playerWhiteRkEdit->setText(myAccount->get_rank());
1924
dlg->playerBlackEdit->setText(opponent);
1925
dlg->playerBlackEdit->setReadOnly(false);
1926
dlg->playerBlackRkEdit->setText(rk);
1929
dlg->buttonDecline->setEnabled(true);
1930
dlg->buttonOffer->setText(tr("Accept"));
1931
dlg->buttonCancel->setDisabled(true);
1932
dlg->boardSizeSpin->setValue(size.toInt());
1933
dlg->timeSpin->setValue(time.toInt());
1934
dlg->byoTimeSpin->setValue(byotime.toInt());
1937
dlg->slot_changed();
1939
dlg->setActiveWindow();
1943
// result of player popup
1944
void ClientWindow::slot_playerPopup(int i)
1946
if (!lv_popupPlayer)
1948
qWarning("*** programming error - no item selected");
1952
// some invited players on IGS get a * after their name
1953
QString player_name = (lv_popupPlayer->text(1).right(1) == "*" ? lv_popupPlayer->text(1).left( lv_popupPlayer->text(1).length() -1 ):lv_popupPlayer->text(1));
1960
slot_matchrequest(player_name + " " + lv_popupPlayer->text(2), true);
1965
// talk and stats at the same time
1966
slot_talk(player_name, 0, true);
1967
//slot_sendcommand("stats " + lv_popupPlayer->text(1), false);
1972
//slot_sendcommand("stats " + lv_popupPlayer->text(1), false);
1977
slot_sendcommand("stored " + player_name, false);
1982
slot_sendcommand("result " + player_name, false);
1987
// toggle watch list
1988
QString cpy = ";" + setting->readEntry("WATCH").simplifyWhiteSpace() + ";";
1992
int cnt = cpy.contains(';') + 1;
1993
for (int i = 0; i < cnt; i++)
1995
name = element(cpy, i, ";");
1998
if (name == lv_popupPlayer->text(1))
1999
// skip player if found
2008
// not found -> add to list
2009
line += lv_popupPlayer->text(1);
2010
// update player list
2011
if (lv_popupPlayer->text(6) != "M")
2013
myAccount->num_watchedplayers++;
2014
lv_popupPlayer->setText(6, "W");
2017
else if (line.length() > 0)
2020
line.truncate(line.length() - 1);
2025
if (lv_popupPlayer->text(6) != "M")
2027
myAccount->num_watchedplayers--;
2028
lv_popupPlayer->setText(6, "");
2032
setting->writeEntry("WATCH", line);
2034
lv_popupPlayer->ownRepaint();
2035
ListView_players->sort();
2036
statusUsers->setText(" P: " + QString::number(myAccount->num_players) + " / " + QString::number(myAccount->num_watchedplayers) + " ");
2041
// toggle exclude list
2043
// toggle watch list
2044
QString cpy = ";" + setting->readEntry("EXCLUDE").simplifyWhiteSpace() + ";";
2048
int cnt = cpy.contains(';') + 1;
2049
for (int i = 0; i < cnt; i++)
2051
name = element(cpy, i, ";");
2054
if (name == lv_popupPlayer->text(1))
2055
// skip player if found
2064
// not found -> add to list
2065
line += lv_popupPlayer->text(1);
2066
if (lv_popupPlayer->text(6) != "M")
2067
lv_popupPlayer->setText(6, "X");
2069
else if (line.length() > 0)
2072
line.truncate(line.length() - 1);
2077
if (lv_popupPlayer->text(6) != "M")
2078
lv_popupPlayer->setText(6, "");
2081
setting->writeEntry("EXCLUDE", line);
2083
lv_popupPlayer->ownRepaint();
2084
ListView_players->sort();
2090
if (myAccount->get_gsname() == IGS)
2091
slot_sendcommand("prob " + player_name, false);
2093
slot_sendcommand("rating " + player_name,false);
2102
// emulate mouse click
2103
QListViewItemIterator lv(ListView_games);
2104
for (QListViewItem *lvi; lvi = lv.current();)
2107
if (lv_popupPlayer->text(3) == lvi->text(0))
2109
// emulate mouse button - doubleclick on games
2110
slot_mouse_games(3, lvi, QPoint(), 0);
2119
// if not found -> load new data
2121
g.nr = lv_popupPlayer->text(3);
2122
// g.running = true;
2126
if (qgoif->set_observe(g.nr))
2127
sendcommand("observe " + g.nr, false);
2128
// sendcommand("games " + g.nr, false);
2140
void ClientWindow::slot_click_players(QListViewItem *lv)
2142
// emulate right button
2143
slot_mouse_players(3, lv, QPoint(), 0);
2145
// move over ListView
2146
/*void ClientWindow::slot_moveOver_players()
2148
qDebug("move over player list...");
2151
void ClientWindow::slot_menu_players(QListViewItem *lv, const QPoint& pt, int)
2153
// emulate right button
2154
slot_mouse_players(2, lv, pt, 0);
2156
// mouse click on ListView_players
2157
void ClientWindow::slot_mouse_players(int button, QListViewItem *lv, const QPoint& pt, int /*column*/)
2159
static QPopupMenu *puw = 0;
2161
// create popup window
2164
puw = new QPopupMenu(0, 0);
2165
puw->insertItem(tr("match"), this, SLOT(slot_playerPopup(int)), 0, 1);
2166
puw->insertItem(tr("talk"), this, SLOT(slot_playerPopup(int)), 0, 2);
2167
puw->insertSeparator();
2168
puw->insertItem(tr("stats"), this, SLOT(slot_playerPopup(int)), 0, 3);
2169
puw->insertItem(tr("stored games"), this, SLOT(slot_playerPopup(int)), 0, 4);
2170
puw->insertItem(tr("results"), this, SLOT(slot_playerPopup(int)), 0, 5);
2171
puw->insertItem(tr("rating"), this, SLOT(slot_playerPopup(int)), 0, 8);
2172
puw->insertItem(tr("observe game"), this, SLOT(slot_playerPopup(int)), 0, 9);
2173
puw->insertSeparator();
2174
puw->insertItem(tr("toggle watch list"), this, SLOT(slot_playerPopup(int)), 0, 6);
2175
puw->insertItem(tr("toggle exclude list"), this, SLOT(slot_playerPopup(int)), 0, 7);
2180
// do actions if button clicked on item
2194
/*QRect r = ListView_players->geometry();
2195
QPoint p = r.topLeft() + pt;
2198
puw->popup( QCursor::pos() );
2199
// store selected lv
2200
lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
2204
// first menu item if doubleclick
2208
// store selected lv
2209
lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
2211
slot_playerPopup(1);
2220
// release Talk Tabs
2221
void ClientWindow::slot_pbRelTabs()
2224
Talk *dlg = talklist.first();
2227
if (dlg->get_name().find('*') == -1)
2229
TabWidget_mini_2->removePage(dlg->get_tabWidget());
2230
dlg->pageActive = false;
2232
dlg = talklist.next();
2236
// release Talk Tabs
2237
void ClientWindow::slot_pbRelOneTab(QWidget *w)
2240
Talk *dlg = talklist.first();
2243
if (dlg->get_tabWidget() == w)
2245
TabWidget_mini_2->removePage(w);
2246
dlg->pageActive = false;
2249
dlg = talklist.next();
2253
// handle chat boxes in a list
2254
void ClientWindow::slot_talk(const QString &name, const QString &text, bool isplayer)
2259
bool autoAnswer = true;
2261
if (text && text != "@@@")
2262
// text given or player logged in
2264
else if (text == "@@@" && isplayer)
2266
// player logged out -> iplayer == false
2267
txt = tr("USER NOT LOGGED IN.");
2276
// dialog recently used?
2277
if (dlg && dlg->get_name() == name)
2279
else if (!name.isEmpty() && name != tr("msg*"))
2282
dlg = talklist.first();
2283
while (dlg != NULL && dlg->get_name() != name)
2284
dlg = talklist.next();
2286
// not found -> create new dialog
2289
talklist.insert(0, new Talk(name, 0, isplayer));
2290
dlg = talklist.current();
2291
connect(dlg, SIGNAL(signal_talkto(QString&, QString&)), this, SLOT(slot_talkto(QString&, QString&)));
2292
connect(dlg, SIGNAL(signal_matchrequest(const QString&,bool)), this, SLOT(slot_matchrequest(const QString&,bool)));
2294
// make new multiline field
2295
//mainTable->TabWidget_mini_2->addTab(dlg->get_tabWidget(), dlg->get_name());
2296
TabWidget_mini_2->addTab(dlg->get_tabWidget(), dlg->get_name());
2297
TabWidget_mini_2->showPage(dlg->get_tabWidget());
2298
dlg->pageActive = true;
2299
connect(dlg->get_le(), SIGNAL(returnPressed()), dlg, SLOT(slot_returnPressed()));
2300
connect(dlg, SIGNAL(signal_pbRelOneTab(QWidget*)), this, SLOT(slot_pbRelOneTab(QWidget*)));
2302
QPalette pal = dlg->get_mle()->palette();
2303
pal.setColor(QColorGroup::Base, setting->colorBackground);
2304
dlg->get_mle()->setPalette(pal);
2305
dlg->get_le()->setPalette(pal);
2307
if (!name.isEmpty() && name != tr("Shouts*") && currentCommand->get_txt() !="stats")
2308
slot_sendcommand("stats " + name, false); // automatically request stats
2315
// play sound on new created dialog
2319
// check if it was a channel message
2320
if (autoAnswer &= (isplayer && autoAwayMessage && !name.contains('*') && text[0] == '>'))
2322
// send when qGo is NOT the active application - TO DO
2323
sendcommand("tell " + name + " [I'm away right now]");
2326
if (!dlg->pageActive)
2328
TabWidget_mini_2->addTab(dlg->get_tabWidget(), dlg->get_name());
2329
dlg->pageActive = true;
2332
// play a sound - not for shouts
2333
if ((text[0] == '>' && bonus || !dlg->get_le()->hasFocus()) && !name.contains('*'))
2335
qgoif->get_qgo()->playTalkSound();
2337
// set cursor to last line
2338
//dlg->get_mle()->setCursorPosition(dlg->get_mle()->lines(), 999); //eb16
2339
dlg->get_mle()->append(""); //eb16
2340
//dlg->get_mle()->removeParagraph(dlg->get_mle()->paragraphs()-2); //eb16
2343
MultiLineEdit3->append(statusOnlineTime->text() + " " + name + (autoAnswer ? " (A)" : ""));
2345
else if (name == tr("msg*"))
2347
qgoif->get_qgo()->playTalkSound();
2349
// set cursor to last line
2350
// dlg->get_mle()->setCursorPosition(dlg->get_mle()->numLines(), 999); //eb16
2351
dlg->get_mle()->append(""); //eb16
2352
// dlg->get_mle()->removeParagraph(dlg->get_mle()->paragraphs()-2); //eb16
2355
MultiLineEdit3->append(tr("Message") + ": " + text);
2359
// talk dialog -> return pressed
2360
void ClientWindow::slot_talkto(QString &receiver, QString &txt)
2365
switch (myAccount->get_gsname())
2370
// test if it's a number -> channel
2371
/*int nr =*/ receiver.toInt(&ok);
2373
// yes, channel talk
2374
sendcommand("yell " + txt, false);
2375
else if (receiver.contains('*'))
2376
sendcommand("shout " + txt, false);
2378
sendcommand("tell " + receiver + " " + txt, false);
2383
// send tell command w/o echo
2384
if (receiver.contains('*'))
2385
sendcommand("shout " + txt, false);
2387
sendcommand("tell " + receiver + " " + txt, false);
2391
// lokal echo in talk window
2392
slot_talk(receiver, "-> " + txt, true);
2396
// set players to be watched
2397
void ClientWindow::slot_watchplayer(const QString &txt)
2399
if (txt.length() > 0)
2401
watch = ";" + txt + ";";
2407
// set players to be excluded
2408
void ClientWindow::slot_excludeplayer(const QString &txt)
2410
if (txt.length() > 0)
2412
exclude = ";" + txt + ";";
2415
exclude = QString();
2418
// open a local board ??? Do we need this ?
2419
void ClientWindow::slot_localBoard()
2424
// open a local board, size 19x19, skip questions
2425
void ClientWindow::slot_local19()
2427
openLocalBoard("/19/");
2430
// open a local board
2431
void ClientWindow::slot_preferences()
2433
qgoif->openPreferences();
2436
void ClientWindow::reStoreWindowSize(QString strKey, bool store)
2441
setting->writeEntry("CLIENTWINDOW_" + strKey,
2442
QString::number(pos().x()) + DELIMITER +
2443
QString::number(pos().y()) + DELIMITER +
2444
QString::number(size().width()) + DELIMITER +
2445
QString::number(size().height()));
2447
setting->writeEntry("CLIENTSPLITTER_" + strKey,
2448
QString::number(s1->sizes().first()) + DELIMITER +
2449
QString::number(s1->sizes().last()) + DELIMITER +
2450
QString::number(s2->sizes().first()) + DELIMITER +
2451
QString::number(s2->sizes().last()) + DELIMITER +
2452
QString::number(s3->sizes().first()) + DELIMITER +
2453
QString::number(s3->sizes().last()));
2454
//QString::number(mainTable->s3->sizes().last()));
2456
statusBar()->message(tr("Window size saved.") + " (" + strKey + ")");
2460
// restore size of client window
2461
QString s = setting->readEntry("CLIENTWINDOW_" + strKey);
2465
p.setX(element(s, 0, DELIMITER).toInt());
2466
p.setY(element(s, 1, DELIMITER).toInt());
2468
sz.setWidth(element(s, 2, DELIMITER).toInt());
2469
sz.setHeight(element(s, 3, DELIMITER).toInt());
2474
// restore splitter in client window
2475
s = setting->readEntry("CLIENTSPLITTER_" + strKey);
2478
QValueList<int> w1, h1, w2;
2479
w1 << element(s, 0, DELIMITER).toInt() << element(s, 1, DELIMITER).toInt();
2480
h1 << element(s, 2, DELIMITER).toInt() << element(s, 3, DELIMITER).toInt();
2481
w2 << element(s, 4, DELIMITER).toInt() << element(s, 5, DELIMITER).toInt();
2487
statusBar()->message(tr("Window size restored.") + " (" + strKey + ")");
2491
// set Cursor to last position
2492
void ClientWindow::slot_tabWidgetMainChanged(QWidget *w)
2494
if (w->child("MultiLineEdit_messages"))
2496
MultiLineEdit_messages->setCursorPosition(MultiLineEdit_messages->numLines(), 999);
2497
MultiLineEdit_messages->insertLine("");
2498
MultiLineEdit_messages->removeLine(MultiLineEdit_messages->numLines()-2);
2501
if (w->child("MultiLineEdit2"))
2503
MultiLineEdit2->setCursorPosition(MultiLineEdit2->numLines(), 999);
2504
MultiLineEdit2->insertLine("");
2505
MultiLineEdit2->removeLine(MultiLineEdit2->numLines()-2);
2509
bool ClientWindow::eventFilter(QObject *obj, QEvent *ev)
2511
if (ev->type() == QEvent::KeyPress)
2513
//qDebug(QString("eventFilter: %1").arg(ev->type()));
2514
//qDebug(QString("eventFilter: obj = %1, class = %2, parent = %3").arg(obj->name()).arg(obj->className()).arg(obj->parent() ? obj->parent()->name() : "0"));
2515
QKeyEvent *keyEvent = (QKeyEvent *) ev;
2516
int key = keyEvent->key();
2518
//qDebug(QString("eventFilter: keyPress %1").arg(key));
2520
if (key >= Key_0 && key <= Key_9)
2522
//qDebug("eventFilter: keyPress -> 0..9");
2523
QString strKey = QString::number(key - Key_0);
2525
if (obj == cb_cmdLine || obj->parent() && obj->parent() == cb_cmdLine || obj == this)
2527
if (keyEvent->state() & AltButton)
2529
qDebug("eventFilter: keyPress -> Alt + 0..9");
2531
reStoreWindowSize(strKey, true);
2534
else if (keyEvent->state() & ControlButton)
2536
qDebug("eventFilter: keyPress -> Control + 0..9");
2538
reStoreWindowSize(strKey, false);
2543
else if (key == Key_F1)
2546
qgoif->get_qgo()->openManual();
2554
void ClientWindow::keyReleaseEvent(QKeyEvent *e)
2556
if (!(e->state() & AltButton || e->state() & ControlButton))
2565
void ClientWindow::keyPressEvent(QKeyEvent *e)
2568
if (e->state() & AltButton && e->state() & ControlButton)
2571
// releaseKeyboard();
2573
else if (e->state() & AltButton || e->state() & ControlButton)
2575
// get all keystrokes until both alt and control button release
2579
// check for window resize command = number button
2580
if (e->key() >= Key_0 && e->key() <= Key_9)
2582
QString strKey = QString::number(e->key() - Key_0);
2584
if (e->state() & AltButton)
2587
reStoreWindowSize(strKey, true);
2589
else if (e->state() & ControlButton)
2592
reStoreWindowSize(strKey, false);
2595
// cut last digit from cb_cmdLine
2596
if (e->state() & ControlButton || e->state() & AltButton)
2598
QString tmpTxt = cb_cmdLine->currentText();
2599
tmpTxt.truncate(tmpTxt.length() - 1);
2600
cb_cmdLine->changeItem(tmpTxt, cb_cmdLine->currentItem());
2609
case Key_Up: // Scroll up in history
2611
/* if (historyCounter > 0)
2613
if (historyCounter > historyList->count())
2614
historyCounter = historyList->count();
2615
LineEdit1->setText(historyList->operator[](historyCounter));
2618
case Key_Down: // Scroll down in history
2620
/* historyCounter ++;
2621
if (historyCounter > historyList->count())
2622
historyCounter = historyList->count();
2623
LineEdit1->setText(historyList->operator[](historyCounter));
2628
// TODO: pageUp/pageDown are protected. :(
2629
// MultiLineEdit1->pageUp();
2633
qDebug("PAGE DOWN");
2634
// MultiLineEdit1->pageDown();
2639
qgoif->get_qgo()->openManual();
2643
cb_cmdLine->setFocus();
2644
cb_cmdLine->setCurrentItem(0);
2655
void ClientWindow::initmenus(QWidget *parent)
2659
void ClientWindow::initActions()
2662
// signals and slots connections
2663
connect( cb_cmdLine, SIGNAL( activated(int) ), this, SLOT( slot_cmdactivated_int(int) ) );
2664
connect( cb_cmdLine, SIGNAL( activated(const QString&) ), this, SLOT( slot_cmdactivated(const QString&) ) );
2666
QWhatsThis::add(ListView_games, tr("Table of games\n\n"
2667
"right click to observe\n\n"
2668
"Symbol explanation: (click on tab to sort by)\n"
2670
"White/WR\twhite player's name and rank\n"
2671
"Black/BR\tblack player's name and rank\n"
2672
"Mv\tnumber of moves at last refresh\n"
2676
"By\tbyoyomi time\n"
2677
"FR\tfree (FI), rated (I) or teach (TI) game\n"
2678
"(Ob)\tnumber of observers at last refresh\n\n"
2679
"This table can be updated by 'Refresh games'"));
2681
QWhatsThis::add(ListView_players, tr("Table of players\n\n"
2682
"right click for menu\n\n"
2683
"Symbol explanation: (click on tab to sort by)\n"
2684
"Stat\tplayer's stats:\n"
2686
"\t!...looking = wants to play a game\n"
2687
"\tQ...quiet = doesn't receive system messages\n"
2688
"\tS...shout = can't receive shouts\n"
2689
"\t??...unknown - player entered after last table update\n"
2690
"name\tplayer's name\n"
2691
"Rk\tplayer's rank\n"
2692
"pl\tplaying game (only one game visible)\n"
2693
"ob\tobserving game (only one game visible)\n"
2695
"X\tprivate info:\n"
2697
"\tX..excluded from shout\n"
2698
"\tW..watched (sort: X entries, then Rk)\n"
2699
"and, if extended player info (Toolbox) is active (IGS only):\n"
2700
"Info\tplayer's info string\n"
2701
"Won\tnumber of games won by player\n"
2702
"Lost\tnumber of games lost by player\n"
2703
"Country\torigin of player (from e-mail address)\n"
2704
"Lang\tpreferred language\n\n"
2705
"This table can be updated by 'Refresh players'\n\n"
2706
"Menu entries (right click):\n"
2707
"match\trequest for match (dialog arises)\n"
2708
"talk\ttalk to player (tab arises)\n"
2710
"stats\t\tshow player's stats\n"
2711
"stored games\tshow stored games\n"
2712
"results\t\tshow results\n"
2713
"rating\t\tshow rating (NNGS/IGS only)\n"
2714
"observe game\tshow game currently played by player\n"
2716
"toggle watch list\t\tput/remove player to/from watch list - make 'W' entry at 'X' column; entry/leave sounds are activated\n"
2717
"toggle exclude list\tsimilar to watch - make 'X' entry; player's shouts are no longer shown"));
2723
connect(fileNewBoard, SIGNAL(activated()), this, SLOT(slotFileNewBoard()));
2724
connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNewGame()));
2725
connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
2726
connect(computerPlay, SIGNAL(activated()), this, SLOT(slotComputerPlay()));
2727
connect(fileQuit, SIGNAL(activated()), this, SLOT(quit()));
2732
connect(Connect, SIGNAL(activated()), this, SLOT(slotMenuConnect()));
2733
connect(Disconnect, SIGNAL(activated()), this, SLOT(slotMenuDisconnect()));
2734
Disconnect->setEnabled(false);
2735
connect(editServers, SIGNAL(activated()), this, SLOT(slotMenuEditServers()));
2740
connect(setPreferences, SIGNAL(activated()), this, SLOT(slot_preferences()));
2745
connect(viewToolBar, SIGNAL(toggled(bool)), this, SLOT(slotViewToolBar(bool)));
2746
connect(viewUserToolBar, SIGNAL(toggled(bool)), this, SLOT(slotViewUserToolBar(bool)));
2747
connect(viewMenuBar, SIGNAL(toggled(bool)), this, SLOT(slotViewMenuBar(bool)));
2748
viewStatusBar->setWhatsThis(tr("Statusbar\n\nEnables/disables the statusbar."));
2749
connect(viewStatusBar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
2754
connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
2755
connect(helpSoundInfo, SIGNAL(activated()), this, SLOT(slotHelpSoundInfo()));
2756
connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
2757
connect(helpAboutQt, SIGNAL(activated()), this, SLOT(slotHelpAboutQt()));
2760
void ClientWindow::initToolBar()
2766
connect( cb_connect, SIGNAL( activated(const QString&) ), this, SLOT( slot_cbconnect(const QString&) ) );
2768
// toolConnect->setText(tr("Connect with") + " " + cb_connect->currentText());
2769
connect( toolConnect, SIGNAL( toggled(bool) ), this, SLOT( slot_connect(bool) ) ); //end add eb 5
2772
QIconSet OIC,OIC2 ;//= new QIconSet;
2775
OIC.setPixmap ( NotOpenIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
2776
OIC.setPixmap ( OpenIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
2778
setOpenMode->setIconSet(OIC);
2781
OIC2.setPixmap (NotLookingIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
2782
OIC2.setPixmap (LookingIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
2783
setLookingMode->setIconSet(OIC2);
2786
OIC.setPixmap ( NotQuietIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
2787
OIC.setPixmap ( QuietIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::On);
2788
setQuietMode->setIconSet(OIC);
2790
tb = QWhatsThis::whatsThisButton(Toolbar);
2791
//tb->setProperty( "geometry", QRect(0, 0, 20, 20));
2794
refreshPlayers->setIconSet(QIconSet::QIconSet(RefreshPlayersIcon));
2795
refreshGames->setIconSet(QIconSet::QIconSet(RefreshGamesIcon));
2796
fileNew->setIconSet(QIconSet::QIconSet(fileNewIcon));
2797
fileNewBoard->setIconSet(QIconSet::QIconSet(fileNewboardIcon));
2798
fileOpen->setIconSet(QIconSet::QIconSet(fileOpenIcon));
2799
fileQuit->setIconSet(QIconSet::QIconSet(exitIcon));
2800
computerPlay->setIconSet(QIconSet::QIconSet(ComputerPlayIcon));
2801
Connect->setIconSet(QIconSet::QIconSet(connectedIcon));
2802
Disconnect->setIconSet(QIconSet::QIconSet(disconnectedIcon));
2803
helpManual->setIconSet(QIconSet::QIconSet(manualIcon));
2804
setPreferences->setIconSet(QIconSet::QIconSet(prefsIcon));
2807
UserToolbar->show();
2813
void ClientWindow::slotHelpManual()
2815
setting->qgo->openManual();
2818
void ClientWindow::slotHelpSoundInfo()
2821
setting->qgo->testSound(true);
2824
void ClientWindow::slotHelpAbout()
2826
setting->qgo->slotHelpAbout();
2829
void ClientWindow::slotHelpAboutQt()
2831
QMessageBox::aboutQt(this);
2834
void ClientWindow::slotFileNewBoard()
2836
setting->qgo->addBoardWindow();
2839
void ClientWindow::slotFileNewGame()
2841
MainWindow *w = setting->qgo->addBoardWindow() ;
2842
w->slotFileNewGame();
2845
void ClientWindow::slotFileOpen()
2847
//if (!checkModified())
2849
QString fileName(QFileDialog::getOpenFileName(setting->readEntry("LAST_DIR"),
2850
tr("SGF Files (*.sgf);;MGT Files (*.mgt);;XML Files (*.xml);;All Files (*)"), this));
2851
if (fileName.isEmpty())
2854
MainWindow *w = setting->qgo->addBoardWindow() ;
2855
w->doOpen(fileName, w->getFileExtension(fileName));
2858
void ClientWindow::slotComputerPlay()
2860
QString s = setting->readEntry("COMPUTER_PATH");
2862
if (setting->readEntry("COMPUTER_PATH").isNull() ||
2863
setting->readEntry("COMPUTER_PATH").isEmpty())
2865
QMessageBox::warning(this, PACKAGE, tr("You did not set the Computer program path !"));
2866
qgoif->openPreferences(3);
2870
QNewGameDlg * dlg = new QNewGameDlg(this);
2871
if(!(dlg->exec()== QDialog::Accepted))
2874
emit signal_computer_game(dlg);
2878
void ClientWindow::slotMenuConnect()
2881
toolConnect->toggle(); //SL added eb 5
2884
void ClientWindow::slotMenuDisconnect()
2887
toolConnect->toggle(); //SL added eb 5
2890
void ClientWindow::slotMenuEditServers()
2892
qgoif->openPreferences(4);
2895
void ClientWindow::slotViewStatusBar(bool toggle)
2898
statusBar()->hide();
2900
statusBar()->show();
2902
setting->writeBoolEntry("MAINSTATUSBAR", toggle);
2904
statusBar()->message(tr("Ready."));
2907
void ClientWindow::slotViewMenuBar(bool toggle)
2914
setting->writeBoolEntry("MAINMENUBAR", toggle);
2916
statusBar()->message(tr("Ready."));
2919
void ClientWindow::slotViewToolBar(bool toggle)
2926
setting->writeBoolEntry("MAINTOOLBAR", toggle);
2928
statusBar()->message(tr("Ready."));
2931
void ClientWindow::slotViewUserToolBar(bool toggle)
2934
UserToolbar->hide();
2936
UserToolbar->show();
2938
setting->writeBoolEntry("USERTOOLBAR", toggle);
2940
statusBar()->message(tr("Ready."));
2945
void ClientWindow::slotUserButtonClicked(int i)
2947
slot_toolbaractivated(userButtonGroup->find(i)->caption());
2950
void ClientWindow::slot_statsPlayer(Player *p)
2954
if (!p->name.isEmpty())
2957
dlg = talklist.first();
2958
while (dlg != NULL && dlg->get_name() != p->name)
2959
dlg = talklist.next();
2964
dlg->stats_rating->setText(p->rank);
2965
dlg->stats_info->setText(p->info);
2966
dlg->stats_default->setText(p->extInfo);
2967
dlg->stats_wins->setText(p->won);
2968
dlg->stats_loss->setText(p->lost );
2969
dlg->stats_country->setText(p->country);
2970
dlg->stats_playing->setText(p->play_str);
2971
dlg->stats_rated->setText(p->rated);
2972
dlg->stats_address->setText(p->address);
2974
// stored either idle time or last access
2975
dlg->stats_idle->setText(p->idle);
2976
dlg->Label_Idle->setText(p->idle.at(0).isDigit() ? "Idle :": "Last log :");