📄 mainwin.cpp
字号:
cb_connect->setCurrentItem(i-1); // check if host exists if (!h && !(h = hostlist.getFirst())) return; // inform telnet about selected host QString lg = h->loginName(); QString pw = h->password(); telnetConnection->setHost(h->host(), lg, pw, h->port(), h->codec()); if (toolConnect) { QToolTip::remove(toolConnect); QToolTip::add(toolConnect, tr("Connect with") + " " + cb_connect->currentText()); }}// set checkbox status because of server info or because menu / checkbok toggledvoid ClientWindow::slot_checkbox(int nr, bool val){ // set checkbox (nr) to val switch (nr) { // open case 0: //toolOpen->setOn(val); setOpenMode->setOn(val); break; // looking case 1: //toolLooking->setOn(val); setLookingMode->setOn(val); break; // quiet case 2: //toolQuiet->setOn(val); setQuietMode->setOn(val); break; default: qWarning("checkbox doesn't exist"); break; }}// checkbox looking cklickedvoid ClientWindow::slot_cblooking(){ bool val = setLookingMode->isOn(); // setLookingMode->setOn(val); set_sessionparameter("looking", val); if (val) // if looking then set open set_sessionparameter("open", true);}// checkbox open clickedvoid ClientWindow::slot_cbopen(){ bool val = setOpenMode->isOn(); // setOpenMode->setOn(val); set_sessionparameter("open", val); if (!val) // if not open then set close set_sessionparameter("looking", false);}// checkbox quiet clickedvoid ClientWindow::slot_cbquiet(){ bool val = setQuietMode->isOn(); //setQuietMode->setOn(val); //qDebug("bouton %b",toolQuiet->isOn()); set_sessionparameter("quiet", val); if (val) { // if 'quiet' button is once set to true the list is not reliable any longer gamesListSteadyUpdate = false; playerListSteadyUpdate = false; }}// switch between 'who' and 'user' cmdsvoid ClientWindow::setColumnsForExtUserInfo(){ if (!extUserInfo || (myAccount->get_gsname() != IGS) ) { // set player table's columns to 'who' mode ListView_players->removeColumn(11); ListView_players->removeColumn(10); ListView_players->removeColumn(9); ListView_players->removeColumn(8); ListView_players->removeColumn(7); } else if ( ListView_players->columns() < 9 ) { // set player table's columns to 'user' mode // first: remove invisible column ListView_players->removeColumn(7); // second: add new columns ListView_players->addColumn(tr("Info")); ListView_players->addColumn(tr("Won")); ListView_players->addColumn(tr("Lost")); ListView_players->addColumn(tr("Country")); ListView_players->addColumn(tr("Match prefs")); ListView_players->setColumnAlignment(7, AlignRight); ListView_players->setColumnAlignment(8, AlignRight); ListView_players->setColumnAlignment(9, AlignRight); }}// switch between 'who' and 'user' cmdsvoid ClientWindow::slot_cbExtUserInfo(){ extUserInfo = setting->readBoolEntry("EXTUSERINFO"); setColumnsForExtUserInfo();}void ClientWindow::slot_updateFont(){ // lists ListView_players->setFont(setting->fontLists); ListView_games->setFont(setting->fontLists); cb_connect->setFont(setting->fontLists); // comment fields MultiLineEdit2->selectAll(true); MultiLineEdit2->setCurrentFont(setting->fontConsole); MultiLineEdit2->selectAll(false); MultiLineEdit3->setCurrentFont(setting->fontComments); cb_cmdLine->setFont(setting->fontComments); // standard setFont(setting->fontStandard); // set some colors QPalette pal = MultiLineEdit2->palette(); pal.setColor(QColorGroup::Base, setting->colorBackground); MultiLineEdit2->setPalette(pal); MultiLineEdit3->setPalette(pal); // talklist Talk *dlg; for (dlg = talklist.first(); dlg != 0; dlg = talklist.next()) dlg->setTalkWindowColor(pal); pal = cb_cmdLine->palette(); pal.setColor(QColorGroup::Base, setting->colorBackground); cb_cmdLine->setPalette(pal); pal = ListView_players->palette(); pal.setColor(QColorGroup::Base, setting->colorBackground); ListView_players->setPalette(pal); ListView_games->setPalette(pal); pal = cb_connect->palette(); pal.setColor(QColorGroup::Base, setting->colorBackground); cb_connect->setPalette(pal); RoomList->setPalette(pal); // init menu viewToolBar->setOn(setting->readBoolEntry("MAINTOOLBAR")); viewUserToolBar->setOn(setting->readBoolEntry("USERTOOLBAR")); if (setting->readBoolEntry("MAINMENUBAR")) { viewMenuBar->setOn(false); viewMenuBar->setOn(true); } viewStatusBar->setOn(setting->readBoolEntry("MAINSTATUSBAR")); extUserInfo = setting->readBoolEntry("EXTUSERINFO"); setColumnsForExtUserInfo();// slot_userDefinedKeysTextChanged();}// refresh button clickedvoid ClientWindow::slot_refresh(int i){ QString wparam = "" ; // refresh depends on selected page switch (i) { case 10: prepare_tables(WHO); case 0: // send "WHO" command //set the params of "who command" if ((whoBox1->currentItem() >1) || (whoBox2->currentItem() >1)) { wparam.append(whoBox1->currentItem()==1 ? "9p" : whoBox1->currentText()); if ((whoBox1->currentItem()) && (whoBox2->currentItem())) wparam.append("-"); wparam.append(whoBox2->currentItem()==1 ? "9p" : whoBox2->currentText()); } else if ((whoBox1->currentItem()) || (whoBox2->currentItem())) wparam.append("1p-9p"); else wparam.append(((myAccount->get_gsname() == IGS) ? "9p-BC" : " ")); if (whoOpenCheck->isChecked()) wparam.append(((myAccount->get_gsname() == WING) ? "O" : "o"));//wparam.append(" o"); if (myAccount->get_gsname() == IGS )//&& extUserInfo) sendcommand(wparam.prepend("userlist ")); else sendcommand(wparam.prepend("who ")); prepare_tables(WHO); break; case 11: prepare_tables(GAMES); case 1: // send "GAMES" command sendcommand("games");// prepare_tables(GAMES); // which games are watched right now // don't work correct at IGS !!!!// sendcommand("watching"); break; default: break; }}// refresh gamesvoid ClientWindow::slot_pbrefreshgames(){ if (gamesListSteadyUpdate) slot_refresh(1); else { // clear table in case of quiet mode slot_refresh(11); gamesListSteadyUpdate = !setQuietMode->isOn(); //!CheckBox_quiet->isChecked(); }}// refresh playersvoid ClientWindow::slot_pbrefreshplayers(){ if (playerListSteadyUpdate) slot_refresh(0); else { // clear table in case of quiet mode slot_refresh(10); playerListSteadyUpdate = !setQuietMode->isOn(); //!CheckBox_quiet->isChecked(); }}void ClientWindow::slot_gamesPopup(int i){ QString player_nameW = (lv_popupGames->text(1).right(1) == "*" ? lv_popupGames->text(1).left( lv_popupGames->text(1).length() -1 ):lv_popupGames->text(1)); QString player_nameB = (lv_popupGames->text(3).right(1) == "*" ? lv_popupGames->text(3).left( lv_popupGames->text(3).length() -1 ):lv_popupGames->text(3)); switch (i) { case 1: // observe if (lv_popupGames) { // set up game for observing //if (qgoif->set_observe(lv_popupGames->text(0))) { QString gameID = lv_popupGames->text(0); // if game is set up new -> get moves // set game to observe sendcommand("observe " + gameID); // check if enough data here if (lv_popupGames->text(7).length() == 0) { // LGS sends the needed information, anyway if (myAccount->get_gsname() != LGS) sendcommand("games " + gameID); } else { // complete game info Game g; g.nr = lv_popupGames->text(0); g.wname = lv_popupGames->text(1); g.wrank = lv_popupGames->text(2); g.bname = lv_popupGames->text(3); g.brank = lv_popupGames->text(4); g.mv = lv_popupGames->text(5); g.Sz = lv_popupGames->text(6); g.H = lv_popupGames->text(7); g.K = lv_popupGames->text(8); g.By = lv_popupGames->text(9); g.FR = lv_popupGames->text(10); g.ob = lv_popupGames->text(11); g.running = true; g.oneColorGo = false; emit signal_move(&g); } } } break; case 2: // stats slot_sendcommand("stats " + player_nameW, false); break; case 3: // stats slot_sendcommand("stats " + player_nameB, false); break; default: break; }}// doubleclick actions...void ClientWindow::slot_click_games(QListViewItem *lv){ // do actions if button clicked on item slot_mouse_games(3, lv, QPoint(), 0);qDebug("games list double clicked");}// move over ListView/*void ClientWindow::slot_moveOver_games(){ qDebug("move over games list...");} */// doubleclick actions...void ClientWindow::slot_menu_games(QListViewItem *lv, const QPoint &pt, int /*column*/){ // emulate right button slot_mouse_games(2, lv, pt, 0);qDebug("games list double clicked");}// mouse click on ListView_gamesvoid ClientWindow::slot_mouse_games(int button, QListViewItem *lv, const QPoint& /*pt*/, int /*column*/){ static QPopupMenu *puw = 0; // create popup window if (!puw) { puw = new QPopupMenu(0, 0); puw->insertItem(tr("observe"), this, SLOT(slot_gamesPopup(int)), 0, 1); puw->insertItem(tr("stats W"), this, SLOT(slot_gamesPopup(int)), 0, 2); puw->insertItem(tr("stats B"), this, SLOT(slot_gamesPopup(int)), 0, 3); } //puw->hide(); // do actions if button clicked on item switch (button) { // left case 1: break; // right case 2: if (lv) { //puw->move(pt); //puw->show(); puw->popup( QCursor::pos() ); // store selected lv lv_popupGames = static_cast<GamesTableItem*>(lv); } break; // first menue item if doubleclick case 3: if (lv) { // store selected lv lv_popupGames = static_cast<GamesTableItem*>(lv); slot_gamesPopup(1); } break; default: break; }}void ClientWindow::slot_removeMatchDialog(const QString &opponent){ // set up match dialog // match_dialog() GameDialog *dlg = NULL; // seek dialog // look for same opponent dlg = matchlist.first(); while (dlg && dlg->playerOpponentEdit->text() != opponent ) //&& dlg->playerBlackEdit->text() != opponent) dlg = matchlist.next(); if (dlg) { matchlist.remove(); delete dlg; }} void ClientWindow::slot_matchrequest(const QString &line, bool myrequest){ // set up match dialog // match_dialog() GameDialog *dlg = NULL; QString opponent; // seek dialog if (!myrequest) { // match xxxx B 19 1 10 opponent = element(line, 1, " "); // play sound qgoif->get_qgo()->playMatchSound(); } else { // xxxxx 4k* opponent = element(line, 0, " "); } // look for same opponent dlg = matchlist.first(); while (dlg && dlg->playerOpponentEdit->text() != opponent)// && dlg->playerBlackEdit->text() != opponent) dlg = matchlist.next(); if (!dlg) { matchlist.insert(0, new GameDialog(0, tr("New Game"), false)); dlg = matchlist.current(); if (myAccount->get_gsname() == NNGS || myAccount->get_gsname() == LGS) { // now connect suggest signal connect(parser, SIGNAL(signal_suggest(const QString&, const QString&, const QString&, const QString&, int)), dlg, SLOT(slot_suggest(const QString&, const QString&, const QString&, const QString&, int))); } connect(dlg,SIGNAL(signal_removeDialog(dlg)), this, SLOT(slot_removeDialog(dlg))); connect(dlg, SIGNAL(signal_sendcommand(const QString&, bool)), this, SLOT(slot_sendcommand(const QString&, bool)));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -