📄 mainwin.cpp
字号:
connect(dlg, SIGNAL(signal_removeDialog(const QString&)), this, SLOT(slot_removeMatchDialog(const QString&))); connect(parser, SIGNAL(signal_matchcreate(const QString&, const QString&)), dlg, SLOT(slot_matchcreate(const QString&, const QString&))); connect(parser, SIGNAL(signal_notopen(const QString&)), dlg, SLOT(slot_notopen(const QString&))); connect(parser, SIGNAL(signal_komirequest(const QString&, int, int, bool)), dlg, SLOT(slot_komirequest(const QString&, int, int, bool))); connect(parser, SIGNAL(signal_opponentopen(const QString&)), dlg, SLOT(slot_opponentopen(const QString&))); connect(parser, SIGNAL(signal_dispute(const QString&, const QString&)), dlg, SLOT(slot_dispute(const QString&, const QString&))); connect(dlg, SIGNAL(signal_matchsettings(const QString&, const QString&, const QString&, assessType)), qgoif, SLOT(slot_matchsettings(const QString&, const QString&, const QString&, assessType))); } if (myrequest) { QString rk = element(line, 1, " "); // set values /*dlg->playerWhiteEdit->setText(myAccount->acc_name); dlg->playerWhiteEdit->setReadOnly(true); dlg->playerBlackEdit->setText(opponent); dlg->playerBlackEdit->setReadOnly(false); */ dlg->playerOpponentEdit->setText(opponent); dlg->playerOpponentEdit->setReadOnly(true); dlg->set_myName( myAccount->acc_name); // set my and opponent's rank for suggestion dlg->set_oppRk(rk); dlg->playerOpponentRkEdit->setText(rk); rk = myAccount->get_rank(); dlg->set_myRk(rk); //dlg->playerWhiteRkEdit->setText(rk); dlg->set_gsName(myAccount->get_gsname()); dlg->handicapSpin->setEnabled(false); dlg->buttonDecline->setDisabled(true); // my request: free/rated game is also requested //dlg->cb_free->setChecked(true); // teaching game: if (dlg->playerOpponentEdit->text() == myAccount->acc_name) dlg->buttonOffer->setText(tr("Teaching")); //nmatch settings from opponent bool is_nmatch = false; // we want to make sure the player is selected, because the match request may come from an other command (match button on the tab dialog) QString lv_popup_name ; if (lv_popupPlayer ) { lv_popup_name = (lv_popupPlayer->text(1).right(1) == "*" ? lv_popupPlayer->text(1).left( lv_popupPlayer->text(1).length() -1 ):lv_popupPlayer->text(1)); is_nmatch = ((lv_popupPlayer->nmatch ) && (lv_popup_name == opponent));// && setting->readBoolEntry("USE_NMATCH"); } dlg->set_is_nmatch(is_nmatch); if ( (is_nmatch) && (lv_popupPlayer->nmatch_settings )) { dlg->timeSpin->setRange((int)(lv_popupPlayer->nmatch_timeMin/60), (int)(lv_popupPlayer->nmatch_timeMax/60)); dlg->byoTimeSpin->setRange((int)(lv_popupPlayer->nmatch_BYMin/60), (int)(lv_popupPlayer->nmatch_BYMax/60)); dlg->handicapSpin->setRange(lv_popupPlayer->nmatch_handicapMin,lv_popupPlayer->nmatch_handicapMax); } else { dlg->timeSpin->setRange(0,60); dlg->byoTimeSpin->setRange(0,60); dlg->handicapSpin->setRange(0,9); } //no handicap with usual game requests dlg->handicapSpin->setEnabled(is_nmatch); dlg->play_nigiri_button->setEnabled(is_nmatch); //default settings dlg->boardSizeSpin->setValue(setting->readIntEntry("DEFAULT_SIZE")); dlg->timeSpin->setValue(setting->readIntEntry("DEFAULT_TIME")); dlg->byoTimeSpin->setValue(setting->readIntEntry("DEFAULT_BY")); dlg->komiSpin->setValue(setting->readIntEntry("DEFAULT_KOMI")*10+5); dlg->slot_pbsuggest(); } else { // match xxxx B 19 1 10 - using this line means: I am black! bool opp_plays_white = (element(line, 2, " ") == "B");//QString(tr("B"))); bool opp_plays_nigiri = (element(line, 2, " ") == "N"); QString handicap, size, time,byotime, byostones ; if (line.contains("nmatch")) { //specific behavior here : IGS nmatch not totally supported // disputes are hardly supported dlg->set_is_nmatch(true); handicap = element(line,3 , " "); size = element(line, 4, " "); time = element(line, 5, " "); byotime = element(line, 6, " "); byostones = element(line, 7, " "); dlg->timeSpin->setRange(0,100); dlg->timeSpin->setValue(time.toInt()/60); dlg->byoTimeSpin->setRange(0,100); dlg->byoTimeSpin->setValue(byotime.toInt()/60); dlg->BY_label->setText(tr(" Byoyomi Time : (")+byostones+ tr(" stones)")); dlg->handicapSpin->setRange(0,9); dlg->handicapSpin->setValue(handicap.toInt()); dlg->boardSizeSpin->setRange(1,19); dlg->boardSizeSpin->setValue(size.toInt()); } else { dlg->set_is_nmatch(false); size = element(line, 3, " "); time = element(line, 4, " "); byotime = element(line, 5, " "); dlg->timeSpin->setRange(0,1000); dlg->timeSpin->setValue(time.toInt()); dlg->byoTimeSpin->setRange(0,100); dlg->byoTimeSpin->setValue(byotime.toInt()); dlg->handicapSpin->setEnabled(false); dlg->play_nigiri_button->setEnabled(false); dlg->boardSizeSpin->setRange(1,19); dlg->boardSizeSpin->setValue(size.toInt()); } QString rk = getPlayerRk(opponent); dlg->set_oppRk(rk); QString myrk = myAccount->get_rank(); dlg->set_myRk(myrk); dlg->playerOpponentEdit->setText(opponent); dlg->playerOpponentEdit->setReadOnly(true); dlg->playerOpponentRkEdit->setText(rk); dlg->set_myName( myAccount->acc_name); if (opp_plays_white) {/* dlg->playerBlackEdit->setText(myAccount->acc_name); dlg->playerBlackEdit->setReadOnly(true); dlg->playerBlackRkEdit->setText(myAccount->get_rank()); dlg->playerWhiteEdit->setText(opponent); dlg->playerWhiteEdit->setReadOnly(false); dlg->playerWhiteRkEdit->setText(rk);*/ dlg->play_black_button->setChecked(true); } else if (opp_plays_nigiri) {/* dlg->playerWhiteEdit->setText(myAccount->acc_name); dlg->playerWhiteEdit->setReadOnly(true); dlg->playerWhiteRkEdit->setText(myAccount->get_rank()); dlg->playerBlackEdit->setText(opponent); dlg->playerBlackEdit->setReadOnly(false); dlg->playerBlackRkEdit->setText(rk);*/ dlg->play_nigiri_button->setChecked(true); } else dlg->play_white_button->setChecked(true); dlg->buttonDecline->setEnabled(true); dlg->buttonOffer->setText(tr("Accept")); dlg->buttonCancel->setDisabled(true); } dlg->slot_changed(); dlg->show(); dlg->setActiveWindow(); dlg->raise();}// result of player popupvoid ClientWindow::slot_playerPopup(int i){ if (!lv_popupPlayer) { qWarning("*** programming error - no item selected"); return; } // some invited players on IGS get a * after their name QString player_name = (lv_popupPlayer->text(1).right(1) == "*" ? lv_popupPlayer->text(1).left( lv_popupPlayer->text(1).length() -1 ):lv_popupPlayer->text(1)); switch (i) { case 1 : case 11 : // match slot_matchrequest(player_name + " " + lv_popupPlayer->text(2), true); break; case 2: case 3: // talk and stats at the same time slot_talk(player_name, 0, true); //slot_sendcommand("stats " + lv_popupPlayer->text(1), false); break; //case 3: // stats //slot_sendcommand("stats " + lv_popupPlayer->text(1), false); //break; case 4: // stored games slot_sendcommand("stored " + player_name, false); break; case 5: // results slot_sendcommand("result " + player_name, false); break; case 12: // trail slot_sendcommand("trail " + player_name, false); break; case 6: { // toggle watch list QString cpy = ";" + setting->readEntry("WATCH").simplifyWhiteSpace() + ";"; QString line; QString name; bool found = false; int cnt = cpy.contains(';') + 1; for (int i = 0; i < cnt; i++) { name = element(cpy, i, ";"); if (name) { if (name == lv_popupPlayer->text(1)) // skip player if found found = true; else line += name + ";"; } } if (!found) { // not found -> add to list line += lv_popupPlayer->text(1); // update player list if (lv_popupPlayer->text(6) != "M") { myAccount->num_watchedplayers++; lv_popupPlayer->setText(6, "W"); } } else if (line.length() > 0) { // skip one ";" line.truncate(line.length() - 1); } if (found) { if (lv_popupPlayer->text(6) != "M") { myAccount->num_watchedplayers--; lv_popupPlayer->setText(6, ""); } } setting->writeEntry("WATCH", line); lv_popupPlayer->ownRepaint(); ListView_players->sort(); statusUsers->setText(" P: " + QString::number(myAccount->num_players) + " / " + QString::number(myAccount->num_watchedplayers) + " "); } break; case 7: // toggle exclude list { // toggle watch list QString cpy = ";" + setting->readEntry("EXCLUDE").simplifyWhiteSpace() + ";"; QString line; QString name; bool found = false; int cnt = cpy.contains(';') + 1; for (int i = 0; i < cnt; i++) { name = element(cpy, i, ";"); if (name) { if (name == lv_popupPlayer->text(1)) // skip player if found found = true; else line += name + ";"; } } if (!found) { // not found -> add to list line += lv_popupPlayer->text(1); if (lv_popupPlayer->text(6) != "M") lv_popupPlayer->setText(6, "X"); } else if (line.length() > 0) { // skip one ";" line.truncate(line.length() - 1); } if (found) { if (lv_popupPlayer->text(6) != "M") lv_popupPlayer->setText(6, ""); } setting->writeEntry("EXCLUDE", line); lv_popupPlayer->ownRepaint(); ListView_players->sort(); } break; case 8: // rating if (myAccount->get_gsname() == IGS) slot_sendcommand("prob " + player_name, false); else slot_sendcommand("rating " + player_name,false); break; case 9: { // observe game bool found = false; // emulate mouse click QListViewItemIterator lv(ListView_games); for (QListViewItem *lvi; (lvi = lv.current());) { // compare game ids if (lv_popupPlayer->text(3) == lvi->text(0)) { // emulate mouse button - doubleclick on games slot_mouse_games(3, lvi, QPoint(), 0); found = true; break; } lv++; } if (!found) { // if not found -> load new data Game g; g.nr = lv_popupPlayer->text(3);// g.running = true;// slot_game(&g); // observe// if (qgoif->set_observe(g.nr)) sendcommand("observe " + g.nr, false);// sendcommand("games " + g.nr, false); } break; } default: break; }}// doubleclick...void ClientWindow::slot_click_players(QListViewItem *lv){ // emulate right button slot_mouse_players(3, lv, QPoint(), 0);}// move over ListView/*void ClientWindow::slot_moveOver_players(){ qDebug("move over player list...");} */// mouse menusvoid ClientWindow::slot_menu_players(QListViewItem *lv, const QPoint& pt, int){ // emulate right button if (lv) slot_mouse_players(2, lv, pt, 0);}// mouse click on ListView_playersvoid ClientWindow::slot_mouse_players(int button, QListViewItem *lv, const QPoint& /*pt */, int /*column*/){ static QPopupMenu *puw = 0; lv_popupPlayer = static_cast<PlayerTableItem*>(lv); // create popup window if (!puw) { puw = new QPopupMenu(0, 0); puw->insertItem(tr("match"), this, SLOT(slot_playerPopup(int)), 0, 1); puw->insertItem(tr("match within his prefs"), this, SLOT(slot_playerPopup(int)), 0, 11); puw->insertItem(tr("talk"), this, SLOT(slot_playerPopup(int)), 0, 2); puw->insertSeparator(); puw->insertItem(tr("stats"), this, SLOT(slot_playerPopup(int)), 0, 3); puw->insertItem(tr("stored games"), this, SLOT(slot_playerPopup(int)), 0, 4); puw->insertItem(tr("results"), this, SLOT(slot_playerPopup(int)), 0, 5); puw->insertItem(tr("rating"), this, SLOT(slot_playerPopup(int)), 0, 8); puw->insertItem(tr("observe game"), this, SLOT(slot_playerPopup(int)), 0, 9); puw->insertItem(tr("trail"), this, SLOT(slot_playerPopup(int)), 0, 12); puw->insertSeparator(); puw->insertItem(tr("toggle watch list"), this, SLOT(slot_playerPopup(int)), 0, 6); puw->insertItem(tr("toggle exclude list"), this, SLOT(slot_playerPopup(int)), 0, 7); } puw->setItemEnabled(11,lv_popupPlayer->nmatch);//puw->hide(); // do actions if button clicked on item switch (button) { // left button case 1: if (lv) { } break; // right button case 2: if (lv) { /*QRect r = ListView_players->geometry(); QPoint p =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -