~ubuntu-branches/ubuntu/quantal/qgo/quantal

« back to all changes in this revision

Viewing changes to src/mainwin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Chaboisseau
  • Date: 2006-10-03 23:46:07 UTC
  • mfrom: (1.2.1 upstream) (2.1.9 edgy)
  • Revision ID: james.westby@ubuntu.com-20061003234607-jtuoreigx712b4lw
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include <qpixmap.h>
44
44
#include <qbuttongroup.h> 
45
45
#include <qobjectlist.h> 
 
46
#include <qlistbox.h> 
 
47
#include <qmovie.h> 
 
48
#include <qradiobutton.h>
46
49
 
47
50
#ifndef QGO_NOSTYLES
48
51
#include <qplatinumstyle.h>
89
92
        RefreshGamesIcon = QPixmap::QPixmap(qembed_findImage("refresh_games"));//QPixmap(ICON_REFRESH_GAMES);        
90
93
        ComputerPlayIcon = QPixmap::QPixmap(qembed_findImage("computerplay"));//QPixmap(ICON_COMPUTER_PLAY);
91
94
        qgoIcon = QPixmap::QPixmap(qembed_findImage("Bowl"));//QPixmap(ICON_COMPUTER_PLAY);  
92
 
 
93
 
 
94
 
 
 
95
        NotSeekingIcon = QPixmap::QPixmap(qembed_findImage("not_seeking"));
 
96
        seekingIcon[0] = QPixmap::QPixmap(qembed_findImage("seeking1"));
 
97
        seekingIcon[1] = QPixmap::QPixmap(qembed_findImage("seeking2"));
 
98
        seekingIcon[2] = QPixmap::QPixmap(qembed_findImage("seeking3"));
 
99
        seekingIcon[3] = QPixmap::QPixmap(qembed_findImage("seeking4"));
95
100
 
96
101
        // init
97
102
 
101
106
        setting->cw = this;
102
107
        setIcon(setting->image0);
103
108
        myAccount = new Account(this);
104
 
 
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
        
 
110
        defaultStyle = qApp->style().name() ;
 
111
        // this is very dirty : we do this because there seem to be no clean way to backtrack from MainWindow to the defaultStyle :-(
 
112
        setting->writeEntry("DEFAULT_STYLE",defaultStyle ) ;
108
113
  
109
114
        hostlist.setAutoDelete(true);
110
115
        cmd_count = 0;
111
116
 
112
117
        sendBuffer.setAutoDelete(true);
113
 
  currentCommand = new sendBuf("",0);
 
118
        currentCommand = new sendBuf("",0);
114
119
  
115
120
        resetCounter();
116
121
        cmd_valid = false;
128
133
        // statistics
129
134
        bytesIn = 0;
130
135
        bytesOut = 0;
 
136
        seekButtonTimer = 0;
131
137
//      toolConnect = 0;
132
138
 
133
139
        // set focus, clear entry field
153
159
        connect(parser, SIGNAL(signal_addToObservationList(int)), SLOT(slot_addToObservationList(int)));
154
160
        connect(parser, SIGNAL(signal_channelinfo(int, const QString&)), SLOT(slot_channelinfo(int, const QString&)));
155
161
        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&)));
 
162
        connect(parser, SIGNAL(signal_matchCanceled(const QString&)), this, SLOT(slot_removeMatchDialog(const QString&)));
157
163
        connect(parser, SIGNAL(signal_shout(const QString&, const QString&)), SLOT(slot_shout(const QString&, const QString&)));
 
164
        connect(parser, SIGNAL(signal_room(const QString&, bool)),SLOT(slot_room(const QString&, bool)));
 
165
        connect(parser, SIGNAL(signal_addSeekCondition(const QString&,const QString&, const QString&, const QString&, const QString&)),this,
 
166
                        SLOT(slot_addSeekCondition(const QString&, const QString&, const QString&, const QString&, const QString&)));
 
167
        connect(parser, SIGNAL(signal_clearSeekCondition()),this,SLOT(slot_clearSeekCondition()));
 
168
        connect(parser, SIGNAL(signal_cancelSeek()),this,SLOT(slot_cancelSeek()));
 
169
        connect(parser, SIGNAL(signal_SeekList(const QString&, const QString&)),this,SLOT(slot_SeekList(const QString&, const QString&)));
 
170
        connect(parser, SIGNAL(signal_refresh(int)),this, SLOT(slot_refresh(int)));
158
171
 
159
172
        // connect mouse to games table/player table
160
173
        connect(ListView_games, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)),
193
206
        // Sets actions
194
207
        initActions();
195
208
        // Set menus
196
 
        initmenus(this);
 
209
        //initmenus(this);
197
210
        // Sets toolbar
198
211
        initToolBar();                              //end add eb 5
199
212
 
259
272
                                             setting->readEntry("HOST" + QString::number(i) + "b"),
260
273
                                             setting->readIntEntry("HOST" + QString::number(i) + "c"),
261
274
                                             setting->readEntry("HOST" + QString::number(i) + "d"),
262
 
                                             setting->readEntry("HOST" + QString::number(i) + "e")));
 
275
                                             setting->readEntry("HOST" + QString::number(i) + "e"),
 
276
                                             setting->readEntry("HOST" + QString::number(i) + "f")));
263
277
        }
264
278
 
265
279
        // run slot command to initialize combobox and set host
278
292
  userButtonGroup->hide();
279
293
  connect( userButtonGroup, SIGNAL(clicked(int)), SLOT(slotUserButtonClicked(int)) );
280
294
  
281
 
        while ((s = setting->readEntry("USER" + QString::number(++i) + "_1")) != NULL)
282
 
        {
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()))
291
 
      b->setPixmap(p);
292
 
    userButtonGroup->insert(b,-1);
293
 
        }
 
295
  while ((s = setting->readEntry("USER" + QString::number(++i) + "_1")) != NULL)
 
296
  {
 
297
        b=new QToolButton(UserToolbar) ;
 
298
        b->setText(setting->readEntry("USER" + QString::number(i) + "_1"));   //label of the button : for display
 
299
        b->setTextLabel(setting->readEntry("USER" + QString::number(i) + "_1"));   //duplicated  for storage
 
300
        b->setCaption(setting->readEntry("USER" + QString::number(i) + "_2")); //dirty but handy
 
301
        QToolTip::add(b,setting->readEntry("USER" + QString::number(i) + "_3"));
 
302
         b->setIconText(setting->readEntry("USER" + QString::number(i) + "_4"));  //dirty but handy    
 
303
        b->setMinimumWidth(25);
 
304
        if (p.load(b->iconText()))
 
305
                b->setPixmap(p);
 
306
        userButtonGroup->insert(b,-1);
 
307
  }
294
308
 
295
309
  //restore players list filters
296
310
  whoBox1->setCurrentItem(setting->readIntEntry("WHO_1"));
321
335
                h1 << element(s, 2, DELIMITER).toInt() << element(s, 3, DELIMITER).toInt();
322
336
                w2 << element(s, 4, DELIMITER).toInt() << element(s, 5, DELIMITER).toInt();
323
337
                //mainTable->s1->setSizes(w1);
324
 
    s1->setSizes(w1);
 
338
                s1->setSizes(w1);
325
339
                s2->setSizes(h1);
326
340
                s3->setSizes(w2);
327
341
        }
377
391
        // create qGo Interface for board handling
378
392
        qgoif = new qGoIF(this);
379
393
        // qGo Interface
 
394
        
 
395
        connect(parser, SIGNAL(signal_set_observe( const QString&)), qgoif, SLOT(set_observe(const QString&)));
380
396
        connect(parser, SIGNAL(signal_move(GameInfo*)), qgoif, SLOT(slot_move(GameInfo*)));
381
397
        connect(parser, SIGNAL(signal_move(Game*)), qgoif, SLOT(slot_move(Game*)));
382
398
        connect(parser, SIGNAL(signal_kibitz(int, const QString&, const QString&)), qgoif, SLOT(slot_kibitz(int, const QString&, const QString&)));
394
410
        connect(qgoif, SIGNAL(signal_addToObservationList(int)), this, SLOT(slot_addToObservationList(int)));
395
411
        connect(qgoif->get_qgo(), SIGNAL(signal_updateFont()), this, SLOT(slot_updateFont()));
396
412
        connect(parser, SIGNAL(signal_timeAdded(int, bool)), qgoif, SLOT(slot_timeAdded(int, bool)));
 
413
        //connect(parser, SIGNAL(signal_undoRequest(const QString&)), qgoif, SLOT(slot_undoRequest(const QString&)));
397
414
 
398
415
        //gamestable
399
416
//      connect(ListView_players, SIGNAL(contentsMoving(int, int)), this, SLOT(slot_playerContentsMoving(int, int)));
404
421
 
405
422
 
406
423
 
 
424
/*
407
425
#ifndef QGO_NOSTYLES
408
426
        // set style - same as set up a board with qgoif
409
427
        int style = setting->readEntry("STYLE").toInt();
414
432
        }
415
433
 
416
434
 
417
 
  
 
435
        
418
436
        switch (style)
419
437
        {
420
438
    case 0:
447
465
                        qApp->setStyle(new QSGIStyle);
448
466
                        break;
449
467
#endif
450
 
/*
 
468
 
451
469
                case 6:
452
470
#if (QT_VERSION > 0x030102)
453
471
                        qApp->setStyle(new QWindowsXPStyle);
455
473
                        qApp->setStyle(new QWindowsStyle);
456
474
#endif
457
475
                        break;
458
 
*/
 
476
 
459
477
 
460
478
                default:
461
479
                        qWarning("Unrecognized style!");
462
480
        }
463
481
#endif
464
 
 
 
482
*/
465
483
        slot_updateFont();
466
484
 
467
485
        QToolTip::setGloballyEnabled(true);
543
561
        QWhatsThis::add(statusOnlineTime, tr("Displays the current online time.\n(A) -> auto answer\n(Hold) -> hold the line"));
544
562
}
545
563
 
546
 
void ClientWindow::timerEvent(QTimerEvent*)
 
564
void ClientWindow::timerEvent(QTimerEvent* e)
547
565
{
548
566
        // some variables for forcing send buffer and keep line established
549
567
//      static int counter = 3599;
550
568
        static int holdTheLine = true;
551
569
        static int tnwait = 0;
552
 
        static int statusCnt = 0;
 
570
//      static int statusCnt = 0;
553
571
        static QString statusTxt = QString();
 
572
        static int imagecounter = 0;
 
573
        
 
574
        //qDebug( "timer event, id %d", e->timerId() );
 
575
 
 
576
        if (e->timerId() == seekButtonTimer)
 
577
        {       
 
578
                imagecounter = (imagecounter+1) % 4;
 
579
                toolSeek->setIconSet(QIconSet::QIconSet(seekingIcon[imagecounter]));
 
580
                return;
 
581
        }
554
582
 
555
583
        if (tn_ready)
556
584
        {
559
587
        }
560
588
        else if (tnwait < 2)
561
589
        {
562
 
//qDebug(QString("%1: HoldTheLine SET: something has been sent").arg(statusOnlineTime->text()));
 
590
                //qDebug(QString("%1: HoldTheLine SET: something has been sent").arg(statusOnlineTime->text()));
563
591
                // case: not ready to send, but maybe waiting for READY message
564
592
                tnwait++;
565
593
                // something was sent, so reset counter
595
623
                        // send "ayt" every half hour anyway
596
624
                        // new: reset timer after one hour of idle state
597
625
                        //      -> if not observing a game!
598
 
      //qDebug(QString("%1 -> HoldTheLine: status = %2").arg(statusOnlineTime->text()).arg(holdTheLine));
 
626
                        //qDebug(QString("%1 -> HoldTheLine: status = %2").arg(statusOnlineTime->text()).arg(holdTheLine));
599
627
                        if (holdTheLine)
600
628
                                sendcommand("ayt", false);
601
629
 
677
705
        if (hr)
678
706
                pre += QString::number(hr) + "h ";
679
707
 
680
 
        statusMessage->setText(pre + min_ + ":" + sec_ + (holdTheLine ? " Hold" : 
681
 
" "));
 
708
        statusMessage->setText(pre + min_ + ":" + sec_ + (holdTheLine ? " Hold" : " "));
682
709
// DEBUG ONLY END ****
683
710
}
684
711
 
685
712
// slot_connect: emitted when connect button has toggled
686
713
void ClientWindow::slot_connect(bool b)
687
714
{
688
 
qDebug("connect",b);
 
715
qDebug("connect %i", (int)b);
689
716
        if (b)
690
717
        {
691
718
                // create instance of telnetConnection
711
738
        // set to offline:
712
739
        myAccount->set_offline();
713
740
        //pb_connect->setOn(FALSE);
714
 
        toolConnect->setOn(FALSE);       //SL added eb 5
 
741
        toolConnect->setOn(FALSE);
 
742
        seekMenu->clear();
 
743
        slot_cancelSeek();      
715
744
 
716
745
        // clear channel
717
746
        prepare_tables(CHANNELS);
749
778
                setting->writeIntEntry("HOST" + QString::number(i) + "c", h->port());
750
779
                setting->writeEntry("HOST" + QString::number(i) + "d", h->loginName());
751
780
                setting->writeEntry("HOST" + QString::number(i) + "e", h->password());
 
781
                setting->writeEntry("HOST" + QString::number(i) + "f", h->codec());
752
782
        }
753
783
        while (setting->readEntry("HOST" + QString::number(++i) + "a"))
754
784
        {
758
788
                setting->writeEntry("HOST" + QString::number(i) + "c", QString());
759
789
                setting->writeEntry("HOST" + QString::number(i) + "d", QString());
760
790
                setting->writeEntry("HOST" + QString::number(i) + "e", QString());
 
791
                setting->writeEntry("HOST" + QString::number(i) + "f", QString());
761
792
        }
762
793
 
763
794
   // set the user toolbar list
848
879
        static int store_games_sort_col = -1;
849
880
#endif
850
881
        static bool player7active = false;
851
 
/*
852
 
 
853
 
 
854
 
        // set codec
855
 
        QString buf;
856
 
        QTextStream t(&buf, IO_WriteOnly);
857
 
        if (textCodec)
858
 
                t.setCodec(textCodec);
859
 
        QString tx = textFromHost;
860
 
        t << tx;
861
 
        QString txt;
862
 
        if (!t.eof())
863
 
                txt = t.read();
864
 
qDebug("#" + buf);
865
 
        if (txt == 0)
866
 
        {
867
 
                qDebug("##buffer empty");
868
 
                return;
869
 
        }
870
 
//*/
 
882
 
871
883
        // put text to parser
872
 
        InfoType it_ = parser->put_line(QString::fromLocal8Bit(txt));
 
884
        InfoType it_ = parser->put_line(txt);
873
885
 
874
886
        // some statistics
875
887
        setBytesIn(txt.length()+2);
920
932
 
921
933
                case YOUHAVEMSG:
922
934
                        // normally no connection -> wait until logged in
923
 
                youhavemsg = true;
 
935
                        youhavemsg = true;
924
936
                        break;
925
937
 
926
938
                case SERVERNAME:
950
962
                                        if (!ok)
951
963
                                                set_sessionparameter("client", true);
952
964
 
953
 
                                        // set quiet false; refresh players, games
 
965
                                        // set quiet true; refresh players, games
954
966
                                        //if (myAccount->get_status() == GUEST)
955
 
                                                set_sessionparameter("quiet", false);
 
967
                                        set_sessionparameter("quiet", true);
956
968
                                        //else
957
 
                                                // set id - only available if registerd; who knows why...
958
 
                                                sendcommand("id qGo " + QString(VERSION), true);
 
969
                                        // set id - only available if registerd; who knows why...
 
970
                                        sendcommand("id qGo " + QString(VERSION), true);
 
971
                                        sendcommand("toggle newrating");
 
972
//                                      if (setting->readBoolEntry("USE_NMATCH"))
 
973
//                                      {
 
974
// we wanted to allow user to disable 'nmatch', but IGS disables 'seek' with nmatch
 
975
                                                sendcommand("toggle nmatch");
959
976
 
 
977
                                                //temporaary settings to prevent use of Koryo BY on IGS (as opposed to canadian)
 
978
                                                sendcommand("nmatchrange BWN 0-9 19-19 60-60 60-3600 25-25 0 0 0-0",false);
 
979
//                                      }
 
980
                                        sendcommand("toggle newundo");
 
981
                                        sendcommand("toggle seek");
 
982
                                        sendcommand("seek config_list ");
 
983
                                        sendcommand("room");
 
984
                                                
960
985
                                        slot_refresh(11);
961
986
                                        slot_refresh(10);
962
987
                                        break;
966
991
                                        set_sessionparameter("client", true);
967
992
                                        // set quiet false; refresh players, games
968
993
                                        //if (myAccount->get_status() == GUEST)
969
 
                                                set_sessionparameter("quiet", false);
 
994
                                        set_sessionparameter("quiet", false);
970
995
                                        slot_refresh(11);
971
996
                                        if (myAccount->get_gsname() != CWS)
972
997
                                                slot_refresh(10);
984
1009
                        // quiet mode? if yes do clear table before refresh
985
1010
                        gamesListSteadyUpdate = ! setQuietMode->isOn(); 
986
1011
                        playerListSteadyUpdate = ! setQuietMode->isOn(); 
987
 
//!CheckBox_quiet->isChecked();
 
1012
 
988
1013
 
989
1014
                        // enable extended user info features
990
1015
                        setColumnsForExtUserInfo();
1003
1028
                        startTimer(1000);
1004
1029
                        // init shouts
1005
1030
                        slot_talk("Shouts*", 0, true);
 
1031
                        
1006
1032
                        qgoif->get_qgo()->playConnectSound();
1007
1033
                        break;
1008
1034
 
1014
1040
                                ListView_players->setSorting(store_sort_col);
1015
1041
 
1016
1042
                        store_sort_col = -1;
 
1043
 
 
1044
                        if (myAccount->get_gsname()==IGS)
 
1045
                                ListView_players->showOpen(whoOpenCheck->isChecked());
1017
1046
                        ListView_players->sort();
1018
1047
                        playerListEmpty = false;
1019
1048
                        break;
1053
1082
        // we just received a players name as first line of stats -> create the dialog tab
1054
1083
        currentCommand->txt="stats";
1055
1084
 
1056
 
        if (!talklist.current())
 
1085
       // if (!talklist.current())
1057
1086
            slot_talk( parser->get_statsPlayer()->name,0,true);
1058
1087
        
1059
 
        else if (parser->get_statsPlayer()->name != talklist.current()->get_name())
1060
 
            slot_talk( parser->get_statsPlayer()->name,0,true);
 
1088
        //else if (parser->get_statsPlayer()->name != talklist.current()->get_name())
 
1089
        //    slot_talk( parser->get_statsPlayer()->name,0,true);
1061
1090
 
1062
1091
      break;
1063
1092
      
1263
1292
        if (!cmd)
1264
1293
                return;
1265
1294
 
1266
 
qDebug("cmd_valid: ", cmd_valid);
 
1295
qDebug("cmd_valid: %i", (int)cmd_valid);
1267
1296
        // check if valid cmd -> cmd number risen
1268
1297
        if (cmd_valid)
1269
1298
        {
1286
1315
                        testcmd = element(cmdLine, 1, " ");
1287
1316
                        if (testcmd)
1288
1317
                        {
1289
 
                                qgoif->set_observe(testcmd);
 
1318
//                              qgoif->set_observe(testcmd);
1290
1319
                                sendcommand("games " + testcmd);
1291
1320
                        }
1292
1321
                }
1305
1334
}
1306
1335
 
1307
1336
// number of activated cmd
1308
 
void ClientWindow::slot_cmdactivated_int(int i)
 
1337
void ClientWindow::slot_cmdactivated_int(int)
1309
1338
{
1310
1339
        if (cb_cmdLine->count() > cmd_count)
1311
1340
        {
1384
1413
        // inform telnet about selected host
1385
1414
        QString lg = h->loginName();
1386
1415
        QString pw = h->password();
1387
 
        telnetConnection->setHost(h->host(), lg, pw, h->port());
 
1416
        telnetConnection->setHost(h->host(), lg, pw, h->port(), h->codec());
1388
1417
        if (toolConnect)
1389
1418
        {
1390
1419
                QToolTip::remove(toolConnect);
1391
1420
                QToolTip::add(toolConnect, tr("Connect with") + " " + cb_connect->currentText());
1392
1421
        }
1393
 
/*
1394
 
                // set up codec
1395
 
                qDebug("setting up codec...");
1396
 
//                      QTextCodec *tc = textCodec;
1397
 
                textCodec = new QGbkCodec();
1398
 
                textStream->setEncoding(QTextStream::Locale);
1399
 
                textStream->setCodec(textCodec);
1400
 
//*/
1401
1422
}
1402
1423
 
1403
1424
// set checkbox status because of server info or because menu / checkbok toggled
1473
1494
// switch between 'who' and 'user' cmds
1474
1495
void ClientWindow::setColumnsForExtUserInfo()
1475
1496
{
1476
 
        if (!extUserInfo || (myAccount->get_gsname() != IGS))
 
1497
        
 
1498
        if (!extUserInfo || (myAccount->get_gsname() != IGS) )
1477
1499
        {
1478
1500
                // set player table's columns to 'who' mode
1479
1501
                ListView_players->removeColumn(11);
1482
1504
                ListView_players->removeColumn(8);
1483
1505
                ListView_players->removeColumn(7);
1484
1506
        }
1485
 
        else
 
1507
        else if ( ListView_players->columns()  < 9 )  
1486
1508
        {
1487
1509
                // set player table's columns to 'user' mode
1488
1510
                // first: remove invisible column
1492
1514
                ListView_players->addColumn(tr("Won"));
1493
1515
                ListView_players->addColumn(tr("Lost"));
1494
1516
                ListView_players->addColumn(tr("Country"));
1495
 
                ListView_players->addColumn(tr("Lang"));
 
1517
                ListView_players->addColumn(tr("Match prefs"));
1496
1518
                ListView_players->setColumnAlignment(7, AlignRight);
1497
1519
                ListView_players->setColumnAlignment(8, AlignRight);
1498
1520
                ListView_players->setColumnAlignment(9, AlignRight);
1514
1536
        cb_connect->setFont(setting->fontLists);
1515
1537
 
1516
1538
        // comment fields
1517
 
  MultiLineEdit2->selectAll(true);
 
1539
        MultiLineEdit2->selectAll(true);
1518
1540
        MultiLineEdit2->setCurrentFont(setting->fontConsole);
1519
 
  MultiLineEdit2->selectAll(false);
1520
 
  MultiLineEdit3->setCurrentFont(setting->fontComments); 
 
1541
        MultiLineEdit2->selectAll(false);
 
1542
        MultiLineEdit3->setCurrentFont(setting->fontComments); 
1521
1543
        cb_cmdLine->setFont(setting->fontComments);
1522
1544
 
1523
1545
        // standard
1532
1554
        Talk *dlg;
1533
1555
        for (dlg = talklist.first(); dlg != 0; dlg = talklist.next())
1534
1556
                dlg->setTalkWindowColor(pal);
 
1557
                
1535
1558
        pal = cb_cmdLine->palette();
1536
1559
        pal.setColor(QColorGroup::Base, setting->colorBackground);
1537
1560
        cb_cmdLine->setPalette(pal);
1542
1565
        pal = cb_connect->palette();
1543
1566
        pal.setColor(QColorGroup::Base, setting->colorBackground);
1544
1567
        cb_connect->setPalette(pal);
1545
 
 
 
1568
        RoomList->setPalette(pal);
 
1569
        
1546
1570
        // init menu
1547
1571
        viewToolBar->setOn(setting->readBoolEntry("MAINTOOLBAR"));
1548
 
  viewUserToolBar->setOn(setting->readBoolEntry("USERTOOLBAR"));
 
1572
        viewUserToolBar->setOn(setting->readBoolEntry("USERTOOLBAR"));
1549
1573
        if (setting->readBoolEntry("MAINMENUBAR"))
1550
1574
        {
1551
1575
                viewMenuBar->setOn(false);
1553
1577
        }
1554
1578
        viewStatusBar->setOn(setting->readBoolEntry("MAINSTATUSBAR"));
1555
1579
 
 
1580
        extUserInfo = setting->readBoolEntry("EXTUSERINFO");
 
1581
        setColumnsForExtUserInfo();
1556
1582
//      slot_userDefinedKeysTextChanged();
1557
1583
}
1558
1584
 
1568
1594
                        prepare_tables(WHO);
1569
1595
                case 0:
1570
1596
                        // send "WHO" command
1571
 
      //set the params of "who command"
1572
 
      if ((whoBox1->currentItem() >1)  || (whoBox2->currentItem() >1))
1573
 
        {
1574
 
             wparam.append(whoBox1->currentItem()==1 ? "9p" : whoBox1->currentText());
1575
 
             if ((whoBox1->currentItem())  && (whoBox2->currentItem()))
1576
 
                wparam.append("-");
1577
 
             wparam.append(whoBox2->currentItem()==1 ? "9p" : whoBox2->currentText());
1578
 
         }
1579
 
      else if ((whoBox1->currentItem())  || (whoBox2->currentItem()))
1580
 
           wparam.append("1p-9p");
1581
 
 
1582
 
      
1583
 
      if (whoOpenCheck->isChecked())
1584
 
          wparam.append(" o");
1585
 
 
1586
 
                  
1587
 
                        if (myAccount->get_gsname() == IGS && extUserInfo)
1588
 
                                sendcommand(wparam.prepend("user "));
 
1597
                        //set the params of "who command"
 
1598
                        if ((whoBox1->currentItem() >1)  || (whoBox2->currentItem() >1))
 
1599
                        {
 
1600
                                wparam.append(whoBox1->currentItem()==1 ? "9p" : whoBox1->currentText());
 
1601
                                if ((whoBox1->currentItem())  && (whoBox2->currentItem()))
 
1602
                                        wparam.append("-");
 
1603
 
 
1604
                                wparam.append(whoBox2->currentItem()==1 ? "9p" : whoBox2->currentText());
 
1605
                        } 
 
1606
                        else if ((whoBox1->currentItem())  || (whoBox2->currentItem()))
 
1607
                                wparam.append("1p-9p");
 
1608
                        else
 
1609
                                wparam.append(((myAccount->get_gsname() == IGS) ? "9p-BC" : " "));
 
1610
                                
 
1611
 
 
1612
                        if (whoOpenCheck->isChecked())
 
1613
                                wparam.append(((myAccount->get_gsname() == WING) ? "O" : "o"));//wparam.append(" o");
 
1614
 
 
1615
                        if (myAccount->get_gsname() == IGS )//&& extUserInfo)
 
1616
                                sendcommand(wparam.prepend("userlist "));
1589
1617
                        else
1590
1618
                                sendcommand(wparam.prepend("who "));
1591
1619
 
1592
 
      prepare_tables(WHO);
 
1620
                        prepare_tables(WHO);
1593
1621
                        break;
1594
1622
 
1595
1623
                case 11:
1637
1665
 
1638
1666
void ClientWindow::slot_gamesPopup(int i)
1639
1667
{
 
1668
 
 
1669
        QString player_nameW = (lv_popupGames->text(1).right(1) == "*" ? lv_popupGames->text(1).left( lv_popupGames->text(1).length() -1 ):lv_popupGames->text(1));
 
1670
 
 
1671
        QString player_nameB = (lv_popupGames->text(3).right(1) == "*" ? lv_popupGames->text(3).left( lv_popupGames->text(3).length() -1 ):lv_popupGames->text(3));
 
1672
 
1640
1673
        switch (i)
1641
1674
        {
1642
1675
                case 1:
1644
1677
                        if (lv_popupGames)
1645
1678
                        {
1646
1679
                                // set up game for observing
1647
 
                                if (qgoif->set_observe(lv_popupGames->text(0)))
 
1680
                                //if (qgoif->set_observe(lv_popupGames->text(0)))
1648
1681
                                {
1649
1682
                                        QString gameID = lv_popupGames->text(0);
1650
1683
                                        // if game is set up new -> get moves
1675
1708
                                                g.FR = lv_popupGames->text(10);
1676
1709
                                                g.ob = lv_popupGames->text(11);
1677
1710
                                                g.running = true;
1678
 
            g.oneColorGo = false;
 
1711
                                                g.oneColorGo = false;
1679
1712
            
1680
1713
 
1681
1714
                                                emit signal_move(&g);
1686
1719
 
1687
1720
                case 2:
1688
1721
                        // stats
1689
 
                        slot_sendcommand("stats " + lv_popupGames->text(1), false);
 
1722
                        slot_sendcommand("stats " + player_nameW, false);
1690
1723
                        break;
1691
1724
 
1692
1725
                case 3:
1693
1726
                        // stats
1694
 
                        slot_sendcommand("stats " + lv_popupGames->text(3), false);
 
1727
                        slot_sendcommand("stats " + player_nameB, false);
1695
1728
                        break;
1696
1729
 
1697
1730
                default:
1721
1754
qDebug("games list double clicked");
1722
1755
}
1723
1756
// mouse click on ListView_games
1724
 
void ClientWindow::slot_mouse_games(int button, QListViewItem *lv, const QPoint &pt, int /*column*/)
 
1757
void ClientWindow::slot_mouse_games(int button, QListViewItem *lv, const QPoint& /*pt*/, int /*column*/)
1725
1758
{
1726
1759
        static QPopupMenu *puw = 0;
1727
1760
        
1748
1781
                        {
1749
1782
                                //puw->move(pt);
1750
1783
                                //puw->show();
1751
 
        puw->popup( QCursor::pos() );
 
1784
                                puw->popup( QCursor::pos() );
1752
1785
                                // store selected lv
1753
1786
                                lv_popupGames = static_cast<GamesTableItem*>(lv);
1754
1787
                        }
1771
1804
}
1772
1805
 
1773
1806
 
1774
 
void ClientWindow::slot_matchCanceled(const QString &opponent)
 
1807
void ClientWindow::slot_removeMatchDialog(const QString &opponent)
1775
1808
{
1776
1809
        // set up match dialog
1777
1810
        // match_dialog()
1781
1814
        // seek dialog
1782
1815
                // look for same opponent
1783
1816
        dlg = matchlist.first();
1784
 
        while (dlg && dlg->playerWhiteEdit->text() != opponent && dlg->playerBlackEdit->text() != opponent)
 
1817
        while (dlg && dlg->playerOpponentEdit->text() != opponent ) //&& dlg->playerBlackEdit->text() != opponent)
1785
1818
                dlg = matchlist.next();
1786
1819
 
1787
1820
        if (dlg)
1788
 
    {
1789
 
    matchlist.remove();
1790
 
    delete dlg;
1791
 
    }
 
1821
        {
 
1822
                matchlist.remove();
 
1823
                delete dlg;
 
1824
        }
1792
1825
}   
1793
1826
 
1794
1827
 
1795
 
  
1796
1828
void ClientWindow::slot_matchrequest(const QString &line, bool myrequest)
1797
1829
{
1798
1830
        // set up match dialog
1817
1849
 
1818
1850
        // look for same opponent
1819
1851
        dlg = matchlist.first();
1820
 
        while (dlg && dlg->playerWhiteEdit->text() != opponent && dlg->playerBlackEdit->text() != opponent)
 
1852
        while (dlg && dlg->playerOpponentEdit->text() != opponent)// && dlg->playerBlackEdit->text() != opponent)
1821
1853
                dlg = matchlist.next();
1822
1854
 
1823
1855
        if (!dlg)
1835
1867
                                SLOT(slot_suggest(const QString&, const QString&, const QString&, const QString&, int)));
1836
1868
                }
1837
1869
                
 
1870
                connect(dlg,SIGNAL(signal_removeDialog(dlg)), this, SLOT(slot_removeDialog(dlg)));
 
1871
 
1838
1872
                connect(dlg,
1839
1873
                        SIGNAL(signal_sendcommand(const QString&, bool)),
1840
1874
                        this,
1841
1875
                        SLOT(slot_sendcommand(const QString&, bool)));
 
1876
 
 
1877
                connect(dlg,
 
1878
                        SIGNAL(signal_removeDialog(const QString&)),
 
1879
                        this,
 
1880
                        SLOT(slot_removeMatchDialog(const QString&)));
 
1881
 
 
1882
 
1842
1883
                connect(parser,
1843
1884
                        SIGNAL(signal_matchcreate(const QString&, const QString&)),
1844
1885
                        dlg,
1855
1896
                        SIGNAL(signal_opponentopen(const QString&)),
1856
1897
                        dlg,
1857
1898
                        SLOT(slot_opponentopen(const QString&)));
 
1899
                connect(parser,
 
1900
                        SIGNAL(signal_dispute(const QString&, const QString&)),
 
1901
                        dlg,
 
1902
                        SLOT(slot_dispute(const QString&, const QString&)));
 
1903
 
1858
1904
                connect(dlg,
1859
1905
                        SIGNAL(signal_matchsettings(const QString&, const QString&, const QString&, assessType)),
1860
1906
                        qgoif,
1866
1912
                QString rk = element(line, 1, " ");
1867
1913
 
1868
1914
                // set values
1869
 
                dlg->playerWhiteEdit->setText(myAccount->acc_name);
 
1915
                /*dlg->playerWhiteEdit->setText(myAccount->acc_name);
1870
1916
                dlg->playerWhiteEdit->setReadOnly(true);
1871
1917
                dlg->playerBlackEdit->setText(opponent);
1872
1918
                dlg->playerBlackEdit->setReadOnly(false);
 
1919
                */
 
1920
                dlg->playerOpponentEdit->setText(opponent);             
 
1921
                dlg->playerOpponentEdit->setReadOnly(true);
 
1922
                dlg->set_myName( myAccount->acc_name);
1873
1923
 
1874
1924
                // set my and opponent's rank for suggestion
1875
1925
                dlg->set_oppRk(rk);
1876
 
                dlg->playerBlackRkEdit->setText(rk);
 
1926
                dlg->playerOpponentRkEdit->setText(rk);
1877
1927
                rk = myAccount->get_rank();
1878
1928
                dlg->set_myRk(rk);
1879
 
                dlg->playerWhiteRkEdit->setText(rk);
 
1929
                //dlg->playerWhiteRkEdit->setText(rk);
1880
1930
                dlg->set_gsName(myAccount->get_gsname());
1881
 
                
 
1931
                dlg->handicapSpin->setEnabled(false);
 
1932
 
1882
1933
                dlg->buttonDecline->setDisabled(true);
1883
 
 
 
1934
                
1884
1935
                // my request: free/rated game is also requested
1885
1936
                //dlg->cb_free->setChecked(true);
1886
1937
 
1887
1938
                // teaching game:
1888
 
                if (dlg->playerWhiteEdit->text() == dlg->playerBlackEdit->text())
 
1939
                if (dlg->playerOpponentEdit->text() == myAccount->acc_name)
1889
1940
                        dlg->buttonOffer->setText(tr("Teaching"));
1890
1941
 
 
1942
                //nmatch settings from opponent 
 
1943
                bool is_nmatch = (lv_popupPlayer->nmatch)&&setting->readBoolEntry("USE_NMATCH");
 
1944
                dlg->set_is_nmatch(is_nmatch);
 
1945
 
 
1946
                if ( (is_nmatch) && (lv_popupPlayer->nmatch_settings ))
 
1947
                {
 
1948
                        dlg->timeSpin->setRange((int)(lv_popupPlayer->nmatch_timeMin/60), (int)(lv_popupPlayer->nmatch_timeMax/60));
 
1949
                        dlg->byoTimeSpin->setRange((int)(lv_popupPlayer->nmatch_BYMin/60), (int)(lv_popupPlayer->nmatch_BYMax/60));
 
1950
                        dlg->handicapSpin->setRange(lv_popupPlayer->nmatch_handicapMin,lv_popupPlayer->nmatch_handicapMax);
 
1951
                }
 
1952
                else
 
1953
                {
 
1954
                        dlg->timeSpin->setRange(0,60);
 
1955
                        dlg->byoTimeSpin->setRange(0,60);
 
1956
                        dlg->handicapSpin->setRange(0,9);
 
1957
                }
 
1958
                //no handicap with usual game requests
 
1959
                dlg->handicapSpin->setEnabled(lv_popupPlayer->nmatch);
 
1960
                dlg->play_nigiri_button->setEnabled(lv_popupPlayer->nmatch);
 
1961
 
1891
1962
                //default settings
1892
1963
                dlg->boardSizeSpin->setValue(setting->readIntEntry("DEFAULT_SIZE"));
1893
1964
                dlg->timeSpin->setValue(setting->readIntEntry("DEFAULT_TIME"));
1894
1965
                dlg->byoTimeSpin->setValue(setting->readIntEntry("DEFAULT_BY"));
1895
1966
                dlg->komiSpin->setValue(setting->readIntEntry("DEFAULT_KOMI")*10+5);
 
1967
 
 
1968
                dlg->slot_pbsuggest();
1896
1969
        }
1897
1970
        else
1898
1971
        {
1899
1972
                // match xxxx B 19 1 10 - using this line means: I am black!
1900
1973
                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, " ");
 
1974
                bool opp_plays_nigiri = (element(line, 2, " ") == "N");
 
1975
 
 
1976
                QString handicap, size, time,byotime, byostones ;
 
1977
 
 
1978
                if (line.contains("nmatch"))
 
1979
                {
 
1980
                        //specific behavior here : IGS nmatch not totally supported
 
1981
                        // disputes are hardly supported
 
1982
                        dlg->set_is_nmatch(true);
 
1983
                        handicap = element(line,3 , " ");
 
1984
                        size = element(line, 4, " ");
 
1985
                        time = element(line, 5, " ");
 
1986
                        byotime = element(line, 6, " ");
 
1987
                        byostones = element(line, 7, " ");
 
1988
                        dlg->timeSpin->setRange(0,100);
 
1989
                        dlg->timeSpin->setValue(time.toInt()/60);
 
1990
                        dlg->byoTimeSpin->setRange(0,100);
 
1991
                        dlg->byoTimeSpin->setValue(byotime.toInt()/60);
 
1992
                        dlg->BY_label->setText(tr(" Byoyomi Time : (")+byostones+ tr(" stones)"));
 
1993
                        dlg->handicapSpin->setRange(0,9);
 
1994
                        dlg->handicapSpin->setValue(handicap.toInt());
 
1995
                        dlg->boardSizeSpin->setRange(1,19);
 
1996
                        dlg->boardSizeSpin->setValue(size.toInt());
 
1997
                }
 
1998
                else
 
1999
                {
 
2000
                        dlg->set_is_nmatch(false);
 
2001
                        size = element(line, 3, " ");
 
2002
                        time = element(line, 4, " ");
 
2003
                        byotime = element(line, 5, " ");
 
2004
                        dlg->timeSpin->setRange(0,1000);
 
2005
                        dlg->timeSpin->setValue(time.toInt());
 
2006
                        dlg->byoTimeSpin->setRange(0,100);
 
2007
                        dlg->byoTimeSpin->setValue(byotime.toInt());
 
2008
                        dlg->handicapSpin->setEnabled(false);
 
2009
                        dlg->play_nigiri_button->setEnabled(false);
 
2010
                        dlg->boardSizeSpin->setRange(1,19);
 
2011
                        dlg->boardSizeSpin->setValue(size.toInt());
 
2012
                }
 
2013
                
1904
2014
 
1905
2015
                QString rk = getPlayerRk(opponent);
1906
2016
                dlg->set_oppRk(rk);
1907
2017
                QString myrk = myAccount->get_rank();
1908
2018
                dlg->set_myRk(myrk);
1909
2019
 
 
2020
                dlg->playerOpponentEdit->setText(opponent);             
 
2021
                dlg->playerOpponentEdit->setReadOnly(true);             
 
2022
                dlg->playerOpponentRkEdit->setText(rk);
 
2023
                dlg->set_myName( myAccount->acc_name);
 
2024
 
1910
2025
                if (opp_plays_white)
1911
2026
                {
1912
 
                        dlg->playerBlackEdit->setText(myAccount->acc_name);
 
2027
/*                      dlg->playerBlackEdit->setText(myAccount->acc_name);
1913
2028
                        dlg->playerBlackEdit->setReadOnly(true);
1914
2029
                        dlg->playerBlackRkEdit->setText(myAccount->get_rank());
1915
2030
                        dlg->playerWhiteEdit->setText(opponent);
1916
2031
                        dlg->playerWhiteEdit->setReadOnly(false);
1917
2032
                        dlg->playerWhiteRkEdit->setText(rk);
 
2033
*/
 
2034
                        dlg->play_black_button->setChecked(true);
 
2035
 
 
2036
 
1918
2037
                }
1919
 
                else
 
2038
                else if (opp_plays_nigiri)
1920
2039
                {
1921
 
                        dlg->playerWhiteEdit->setText(myAccount->acc_name);
 
2040
/*                      dlg->playerWhiteEdit->setText(myAccount->acc_name);
1922
2041
                        dlg->playerWhiteEdit->setReadOnly(true);
1923
2042
                        dlg->playerWhiteRkEdit->setText(myAccount->get_rank());
1924
2043
                        dlg->playerBlackEdit->setText(opponent);
1925
2044
                        dlg->playerBlackEdit->setReadOnly(false);
1926
2045
                        dlg->playerBlackRkEdit->setText(rk);
 
2046
*/
 
2047
                        dlg->play_nigiri_button->setChecked(true);
1927
2048
                }
 
2049
                else
 
2050
                        dlg->play_white_button->setChecked(true);               
1928
2051
 
1929
2052
                dlg->buttonDecline->setEnabled(true);
1930
2053
                dlg->buttonOffer->setText(tr("Accept"));
1931
2054
                dlg->buttonCancel->setDisabled(true);
1932
 
                dlg->boardSizeSpin->setValue(size.toInt());
1933
 
                dlg->timeSpin->setValue(time.toInt());
1934
 
                dlg->byoTimeSpin->setValue(byotime.toInt());
 
2055
 
1935
2056
        }
1936
2057
 
1937
2058
        dlg->slot_changed();
1955
2076
  
1956
2077
        switch (i)
1957
2078
        {
1958
 
                case 1:
 
2079
                case 1 :
 
2080
                case 11 :
1959
2081
                        // match
1960
2082
                        slot_matchrequest(player_name + " " + lv_popupPlayer->text(2), true);
1961
 
                        break;
 
2083
                        break;                  
 
2084
 
1962
2085
 
1963
2086
                case 2:
1964
2087
                case 3:
1982
2105
                        slot_sendcommand("result " + player_name, false);
1983
2106
                        break;
1984
2107
 
 
2108
                case 12:
 
2109
                        // trail
 
2110
                        slot_sendcommand("trail " + player_name, false);
 
2111
                        break;
 
2112
 
1985
2113
                case 6:
1986
2114
                {
1987
2115
                        // toggle watch list
2101
2229
 
2102
2230
                        // emulate mouse click
2103
2231
                        QListViewItemIterator lv(ListView_games);
2104
 
                        for (QListViewItem *lvi; lvi = lv.current();)
 
2232
                        for (QListViewItem *lvi; (lvi = lv.current());)
2105
2233
                        {
2106
2234
                                // compare game ids
2107
2235
                                if (lv_popupPlayer->text(3) == lvi->text(0))
2123
2251
//                              slot_game(&g);
2124
2252
 
2125
2253
                                // observe
2126
 
                                if (qgoif->set_observe(g.nr))
 
2254
//                              if (qgoif->set_observe(g.nr))
2127
2255
                                        sendcommand("observe " + g.nr, false);
2128
2256
//                              sendcommand("games " + g.nr, false);
2129
2257
                        }
2151
2279
void ClientWindow::slot_menu_players(QListViewItem *lv, const QPoint& pt, int)
2152
2280
{
2153
2281
        // emulate right button
2154
 
        slot_mouse_players(2, lv, pt, 0);
 
2282
        if (lv)
 
2283
                slot_mouse_players(2, lv, pt, 0);
2155
2284
}
2156
2285
// mouse click on ListView_players
2157
 
void ClientWindow::slot_mouse_players(int button, QListViewItem *lv, const QPoint& pt, int /*column*/)
 
2286
void ClientWindow::slot_mouse_players(int button, QListViewItem *lv, const QPoint& /*pt */, int /*column*/)
2158
2287
{
2159
2288
        static QPopupMenu *puw = 0;
2160
 
        
 
2289
        lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
2161
2290
        // create popup window
2162
2291
        if (!puw)
2163
2292
        {
2164
2293
                puw = new QPopupMenu(0, 0);
2165
2294
                puw->insertItem(tr("match"), this, SLOT(slot_playerPopup(int)), 0, 1);
 
2295
                puw->insertItem(tr("match within his prefs"), this, SLOT(slot_playerPopup(int)), 0, 11);
2166
2296
                puw->insertItem(tr("talk"), this, SLOT(slot_playerPopup(int)), 0, 2);
2167
2297
                puw->insertSeparator();
2168
2298
                puw->insertItem(tr("stats"), this, SLOT(slot_playerPopup(int)), 0, 3);
2170
2300
                puw->insertItem(tr("results"), this, SLOT(slot_playerPopup(int)), 0, 5);
2171
2301
                puw->insertItem(tr("rating"), this, SLOT(slot_playerPopup(int)), 0, 8);
2172
2302
                puw->insertItem(tr("observe game"), this, SLOT(slot_playerPopup(int)), 0, 9);
 
2303
                puw->insertItem(tr("trail"), this, SLOT(slot_playerPopup(int)), 0, 12);
2173
2304
                puw->insertSeparator();
2174
2305
                puw->insertItem(tr("toggle watch list"), this, SLOT(slot_playerPopup(int)), 0, 6);
2175
2306
                puw->insertItem(tr("toggle exclude list"), this, SLOT(slot_playerPopup(int)), 0, 7);
2176
2307
 
2177
 
  }
2178
 
        //puw->hide();
2179
 
 
 
2308
        }
 
2309
        
 
2310
        puw->setItemEnabled(11,lv_popupPlayer->nmatch);
 
2311
//puw->hide();
 
2312
        
2180
2313
        // do actions if button clicked on item
2181
2314
        switch (button)
2182
2315
        {
2197
2330
                                puw->show();*/
2198
2331
                                puw->popup( QCursor::pos() );
2199
2332
                                // store selected lv
2200
 
                                lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
 
2333
                                //lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
2201
2334
                        }
2202
2335
                        break;
2203
2336
 
2206
2339
                        if (lv)
2207
2340
                        {
2208
2341
                                // store selected lv
2209
 
                                lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
 
2342
                                //lv_popupPlayer = static_cast<PlayerTableItem*>(lv);
2210
2343
 
2211
2344
                                slot_playerPopup(1);
2212
2345
                        }
2248
2381
                }
2249
2382
                dlg = talklist.next();
2250
2383
        }
 
2384
 
2251
2385
}
2252
2386
 
2253
2387
 // handle chat boxes in a list
2289
2423
                        talklist.insert(0, new Talk(name, 0, isplayer));     
2290
2424
                        dlg = talklist.current();
2291
2425
                        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)));
 
2426
                        connect(dlg, SIGNAL(signal_matchrequest(const QString&,bool)), this, SLOT(slot_matchrequest(const QString&,bool)));
2293
2427
      
2294
2428
                        // 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());
 
2429
                        TabWidget_mini_2->addTab(dlg->get_tabWidget(), dlg->get_name());
 
2430
                        
 
2431
                        if (name != tr("Shouts*"))
 
2432
                                TabWidget_mini_2->showPage(dlg->get_tabWidget());
 
2433
                                
2298
2434
                        dlg->pageActive = true;
2299
2435
                        connect(dlg->get_le(), SIGNAL(returnPressed()), dlg, SLOT(slot_returnPressed()));
2300
2436
                        connect(dlg, SIGNAL(signal_pbRelOneTab(QWidget*)), this, SLOT(slot_pbRelOneTab(QWidget*)));
2303
2439
                        pal.setColor(QColorGroup::Base, setting->colorBackground);
2304
2440
                        dlg->get_mle()->setPalette(pal);
2305
2441
                        dlg->get_le()->setPalette(pal);
2306
 
 
2307
 
      if (!name.isEmpty() && name != tr("Shouts*") && currentCommand->get_txt() !="stats")
2308
 
        slot_sendcommand("stats " + name, false);    // automatically request stats
 
2442
                        
 
2443
                        //if (!name.isEmpty() && name != tr("Shouts*") && currentCommand->get_txt() !="stats")
 
2444
                        if (!name.isEmpty() && isplayer)
 
2445
                                slot_sendcommand("stats " + name, false);    // automatically request stats
2309
2446
      
2310
2447
                }
2311
2448
 
2325
2462
 
2326
2463
        if (!dlg->pageActive)
2327
2464
        {
2328
 
          TabWidget_mini_2->addTab(dlg->get_tabWidget(), dlg->get_name());
 
2465
                TabWidget_mini_2->addTab(dlg->get_tabWidget(), dlg->get_name());
2329
2466
                dlg->pageActive = true;
 
2467
                TabWidget_mini_2->showPage(dlg->get_tabWidget());
 
2468
                
2330
2469
        }
2331
2470
 
2332
2471
        // play a sound - not for shouts
2591
2730
                        // restore sizes
2592
2731
                        reStoreWindowSize(strKey, false);
2593
2732
                }
2594
 
/*
 
2733
 
2595
2734
                // cut last digit from cb_cmdLine
2596
2735
                if (e->state() & ControlButton || e->state() & AltButton)
2597
2736
                {
2651
2790
        e->accept();
2652
2791
2653
2792
 
2654
 
 
 
2793
/*
2655
2794
void ClientWindow::initmenus(QWidget *parent)                              
2656
2795
2657
2796
}
 
2797
*/
2658
2798
 
2659
2799
void ClientWindow::initActions()
2660
2800
{
2743
2883
        * Menu View
2744
2884
        */
2745
2885
        connect(viewToolBar, SIGNAL(toggled(bool)), this, SLOT(slotViewToolBar(bool)));
2746
 
  connect(viewUserToolBar, SIGNAL(toggled(bool)), this, SLOT(slotViewUserToolBar(bool)));
 
2886
        connect(viewUserToolBar, SIGNAL(toggled(bool)), this, SLOT(slotViewUserToolBar(bool)));
2747
2887
        connect(viewMenuBar, SIGNAL(toggled(bool)), this, SLOT(slotViewMenuBar(bool)));
2748
2888
        viewStatusBar->setWhatsThis(tr("Statusbar\n\nEnables/disables the statusbar."));
2749
2889
        connect(viewStatusBar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
2755
2895
        connect(helpSoundInfo, SIGNAL(activated()), this, SLOT(slotHelpSoundInfo()));
2756
2896
        connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
2757
2897
        connect(helpAboutQt, SIGNAL(activated()), this, SLOT(slotHelpAboutQt()));
 
2898
        connect(helpNewVersion, SIGNAL(activated()), this, SLOT(slotNewVersion()));
2758
2899
}
2759
2900
  
2760
2901
void ClientWindow::initToolBar()
2763
2904
        QToolButton *tb;
2764
2905
 
2765
2906
 
2766
 
        connect( cb_connect, SIGNAL( activated(const QString&) ), this, SLOT( slot_cbconnect(const QString&) ) );
 
2907
        //connect( cb_connect, SIGNAL( activated(const QString&) ), this, SLOT( slot_cbconnect(const QString&) ) );
2767
2908
 
2768
 
//  toolConnect->setText(tr("Connect with") + " " + cb_connect->currentText()); 
2769
 
        connect( toolConnect, SIGNAL( toggled(bool) ), this, SLOT( slot_connect(bool) ) );  //end add eb 5
 
2909
        //  toolConnect->setText(tr("Connect with") + " " + cb_connect->currentText()); 
 
2910
        //connect( toolConnect, SIGNAL( toggled(bool) ), this, SLOT( slot_connect(bool) ) );  //end add eb 5
2770
2911
  
2771
2912
    
2772
 
        QIconSet  OIC,OIC2 ;//= new QIconSet;
 
2913
        QIconSet  OIC,OIC2, OIC3 ;//= new QIconSet;
2773
2914
 
2774
 
  
2775
2915
        OIC.setPixmap ( NotOpenIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
2776
2916
        OIC.setPixmap ( OpenIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
2777
2917
 
2778
2918
        setOpenMode->setIconSet(OIC);
2779
2919
 
2780
 
 
2781
2920
        OIC2.setPixmap (NotLookingIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
2782
2921
        OIC2.setPixmap (LookingIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
2783
2922
        setLookingMode->setIconSet(OIC2);
2784
 
  
2785
2923
 
2786
2924
        OIC.setPixmap ( NotQuietIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
2787
2925
        OIC.setPixmap ( QuietIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::On);
2788
2926
        setQuietMode->setIconSet(OIC);
2789
2927
  
 
2928
        OIC3.setPixmap ( NotSeekingIcon, QIconSet::Automatic, QIconSet::Normal, QIconSet::Off);
 
2929
        OIC3.setPixmap ( seekingIcon[0], QIconSet::Automatic, QIconSet::Normal, QIconSet::On);
 
2930
 
 
2931
        toolSeek->setIconSet(OIC3);
 
2932
        seekMenu = new QPopupMenu();
 
2933
        toolSeek->setPopup(seekMenu);
 
2934
        toolSeek->setPopupDelay(1);
 
2935
 
2790
2936
        tb = QWhatsThis::whatsThisButton(Toolbar);
2791
2937
        //tb->setProperty( "geometry", QRect(0, 0, 20, 20));
2792
2938
 
2831
2977
        QMessageBox::aboutQt(this);
2832
2978
}
2833
2979
 
 
2980
void ClientWindow::slotNewVersion()
 
2981
{
 
2982
        QMessageBox::warning(this ,PACKAGE,NEWVERSIONWARNING);
 
2983
}
 
2984
 
 
2985
 
2834
2986
void ClientWindow::slotFileNewBoard()
2835
2987
{
2836
2988
        setting->qgo->addBoardWindow();
2857
3009
 
2858
3010
void ClientWindow::slotComputerPlay()
2859
3011
{
 
3012
#ifndef Q_OS_MACX
2860
3013
        QString s =  setting->readEntry("COMPUTER_PATH");
2861
3014
 
2862
3015
        if (setting->readEntry("COMPUTER_PATH").isNull() ||
2866
3019
                qgoif->openPreferences(3);
2867
3020
                return;
2868
3021
        }
2869
 
 
 
3022
#endif
2870
3023
        QNewGameDlg * dlg = new QNewGameDlg(this);
2871
3024
        if(!(dlg->exec()== QDialog::Accepted))
2872
3025
                return;
2973
3126
         
2974
3127
         // stored either idle time or last access       
2975
3128
         dlg->stats_idle->setText(p->idle);
2976
 
        dlg->Label_Idle->setText(p->idle.at(0).isDigit() ? "Idle :": "Last log :");
 
3129
         dlg->Label_Idle->setText(p->idle.at(0).isDigit() ? "Idle :": "Last log :");
2977
3130
 
2978
3131
         
2979
3132
        }   
2983
3136
  
2984
3137
}  
2985
3138
 
 
3139
void ClientWindow::slot_room(const QString& room, bool b)
 
3140
{
 
3141
        //do we already have the same room number in list ?
 
3142
        if (RoomList->findItem(room.left(3), Qt::BeginsWith ))
 
3143
                return;
 
3144
        //so far, we just create the room if it is open
 
3145
        if (!b)
 
3146
                RoomList->insertItem (room,  -1 );
 
3147
        
 
3148
        //RoomList->item(RoomList->count()-1)->setSelectable(!b);               
 
3149
}       
 
3150
 
 
3151
void ClientWindow::slot_enterRoom(const QString& room)
 
3152
{
 
3153
        
 
3154
        sendcommand("join " + room);    
 
3155
        
 
3156
        if (room == "0")
 
3157
                statusBar()->message(tr("rooms left"));
 
3158
        else
 
3159
                statusBar()->message(tr("Room ")+ room);
 
3160
        
 
3161
        //refresh the players table
 
3162
        slot_refresh(0);                
 
3163
}       
 
3164
 
 
3165
void ClientWindow::slot_leaveRoom()
 
3166
{
 
3167
        slot_enterRoom("0");
 
3168
}       
 
3169
 
 
3170
 
 
3171
void ClientWindow::slot_RoomListClicked(QListBoxItem *qli)
 
3172
{
 
3173
        slot_enterRoom(qli->text().section(":",0,0));
 
3174
}       
 
3175
 
 
3176
void ClientWindow::slot_addSeekCondition(const QString& a, const QString& b, const QString& c, const QString& d, const QString& )
 
3177
{
 
3178
        QString time_condition ;
 
3179
        
 
3180
        time_condition = QString::number(int(b.toInt() / 60)) + " min + " + QString::number(int(c.toInt() / 60)) + " min / " + d + " stones";
 
3181
 
 
3182
        seekMenu->insertItem(time_condition, this, SLOT(slot_seek(int)), 0, a.toInt());
 
3183
}
 
3184
 
 
3185
 
 
3186
void ClientWindow::slot_clearSeekCondition()
 
3187
{
 
3188
        seekMenu->clear();
 
3189
}
 
3190
 
 
3191
void ClientWindow::slot_seek(bool b)
 
3192
{
 
3193
//qDebug("seek button pressed : status %i", (int)b);
 
3194
 
 
3195
        //if the button was just pressed on, we have already used the popup menu : nothing to do
 
3196
        if (b)
 
3197
                return;
 
3198
 
 
3199
        sendcommand("seek entry_cancel",false);
 
3200
}
 
3201
 
 
3202
void ClientWindow::slot_cancelSeek()
 
3203
{
 
3204
 
 
3205
        toolSeek->setOn(false);
 
3206
        toolSeek->setPopup(seekMenu);
 
3207
        toolSeek->setPopupDelay(1);
 
3208
        toolSeek->setIconSet(QIconSet::QIconSet(NotSeekingIcon));
 
3209
        killTimer(seekButtonTimer);
 
3210
        seekButtonTimer = 0;
 
3211
}
 
3212
 
 
3213
void ClientWindow::slot_seek(int i)
 
3214
{
 
3215
 
 
3216
        toolSeek->setOn(true);
 
3217
        toolSeek->setPopup(NULL);
 
3218
 
 
3219
        //seek entry 1 19 5 3 0
 
3220
        QString send_seek =     "seek entry " + 
 
3221
                                QString::number(i) + 
 
3222
                                " 19 " ;
 
3223
 
 
3224
        //childish, but we want to have an animated icon there
 
3225
        seekButtonTimer = startTimer(200);
 
3226
 
 
3227
        switch (cb_seek_handicap->currentItem())
 
3228
        {
 
3229
                case 0 :
 
3230
                        send_seek.append("1 1 0");
 
3231
                        break ;
 
3232
 
 
3233
                case 1 :
 
3234
                        send_seek.append("2 2 0");
 
3235
                        break ;
 
3236
                
 
3237
                case 2 :
 
3238
                        send_seek.append("5 5 0");
 
3239
                        break ;
 
3240
 
 
3241
                case 3 :
 
3242
                        send_seek.append("9 9 0");
 
3243
                        break ;
 
3244
 
 
3245
                case 4 :
 
3246
                        send_seek.append("0 9 0");
 
3247
                        break ; 
 
3248
 
 
3249
                case 5 :
 
3250
                        send_seek.append("9 0 0");
 
3251
                        break ;
 
3252
        }
 
3253
        
 
3254
        sendcommand(send_seek,false);
 
3255
 
 
3256
}
 
3257
 
 
3258
void ClientWindow::slot_SeekList(const QString& player, const QString& condition)
 
3259
{
 
3260
        QString Rk = getPlayerRk(player);
 
3261
        QString hop = Rk.right(1);
 
3262
        if ((Rk.right(1) != "?") && (Rk.right(1) != "+"))
 
3263
                Rk.append(" ");
 
3264
 
 
3265
        slot_message(player.leftJustify(15,' ',true) + Rk.rightJustify(5) +  " : " + condition);
 
3266
}