📄 preferences.cpp
字号:
slot_cbtitle(QString()); for (h = parent_cw->hostlist.first(); h != 0; h = parent_cw->hostlist.next()) new QListViewItem(ListView_hosts, h->title(), h->host(), QString::number(h->port()), h->loginName(), (h->password().length() ? "***" : "")); insertStandardHosts();}void PreferencesDialog::slot_new(){ slot_cbtitle(QString());}void PreferencesDialog::slot_clickedListView(QListViewItem *lvi, const QPoint&, int){ if (!lvi) return; slot_cbtitle(lvi->text(0));}void PreferencesDialog::slot_cbtitle(const QString &txt){ LineEdit_pass->clear(); if (txt.isEmpty() || txt.isNull()) { LineEdit_title->clear(); LineEdit_host->clear(); LineEdit_port->clear(); LineEdit_login->clear(); ComboBox_codec->setCurrentText(""); } // fix coding: standard servers else if (txt == QString("-- Aurora --")) { LineEdit_title->clear(); LineEdit_host->setText("aurora.go.art.pl"); LineEdit_port->setText("9696"); LineEdit_login->setText("guest"); // What codec does this use? ComboBox_codec->setCurrentText(""); } else if (txt == QString("-- CTN --")) { LineEdit_title->clear(); LineEdit_host->setText("weiqi.online.sh.cn"); LineEdit_port->setText("8888"); LineEdit_login->setText("guest"); // What codec does this use? ComboBox_codec->setCurrentText(""); } else if (txt == QString("-- CWS --")) { LineEdit_title->clear(); LineEdit_host->setText("cws.weiqi.net"); LineEdit_port->setText("9696"); LineEdit_login->setText("qGo" + QString::number(rand() % 10000)); // What codec does this use? ComboBox_codec->setCurrentText(""); } else if (txt == QString("-- LGS --")) { LineEdit_title->clear(); LineEdit_host->setText("lgs.taiwango.net"); LineEdit_port->setText("9696"); LineEdit_login->setText("guest"); // What codec does this use? ComboBox_codec->setCurrentText(""); } else if (txt == QString("-- WING --")) { LineEdit_title->clear(); LineEdit_host->setText("wing.gr.jp"); LineEdit_port->setText("1515"); LineEdit_login->setText("guest"); // What codec does this use? ComboBox_codec->setCurrentText(""); } else if (txt == QString("-- IGS --")) { LineEdit_title->clear(); LineEdit_host->setText("igs.joyjoy.net"); LineEdit_port->setText("7777"); LineEdit_login->setText("guest"); ComboBox_codec->setCurrentText("SJIS"); } else if (txt == QString("-- NNGS --")) { LineEdit_title->clear(); LineEdit_host->setText("nngs.cosmic.org"); LineEdit_port->setText("9696"); LineEdit_login->setText("qGo" + QString::number(rand() % 10000)); // A guess ComboBox_codec->setCurrentText("iso-8859-1"); } else if (txt == QString("-- EGF --")) { LineEdit_title->clear(); LineEdit_host->setText("server.european-go.org"); LineEdit_port->setText("6969"); LineEdit_login->setText("qGo" + QString::number(rand() % 10000)); // A guess ComboBox_codec->setCurrentText("iso-8859-15"); } else if (!txt.isEmpty()) { // fill host info of selected title Host *h = parent_cw->hostlist.first(); bool found = false; while (h != 0) { if (h->title() == txt) { LineEdit_title->setText(h->title()); LineEdit_host->setText(h->host()); LineEdit_port->setText(QString::number(h->port())); LineEdit_login->setText(h->loginName()); LineEdit_pass->setText(h->password()); ComboBox_codec->setCurrentText(h->codec()); found = true; } h = parent_cw->hostlist.next(); } }}void PreferencesDialog::slot_textChanged(const QString &title){ bool found = false; Host *h; for (h = parent_cw->hostlist.first(); !found && h != 0; h = parent_cw->hostlist.next()) { if (h->title() == title) found = true; } if (found) pb_add->setText(tr("Change")); else pb_add->setText(tr("Add"));}// play the sound if check box has been clickedvoid PreferencesDialog::slot_clickedSoundCheckBox(int boxID){ qDebug("boxID = " + QString::number(boxID)); QButton *cb = soundButtonGroups->find(boxID); qDebug("button text = " + cb->text()); if (cb->text() == tr("Stones")) setting->qgo->playClick(); else if (cb->text() == tr("Pass")) setting->qgo->playPassSound(); else if (cb->text() == tr("Autoplay")) setting->qgo->playAutoPlayClick(); else if (cb->text().startsWith(tr("Time"),false)) setting->qgo->playTimeSound(); else if (cb->text() == tr("Talk")) setting->qgo->playTalkSound(); else if (cb->text() == tr("Say")) setting->qgo->playSaySound(); else if (cb->text() == tr("Match")) setting->qgo->playMatchSound(); else if (cb->text() == tr("Enter")) setting->qgo->playEnterSound(); else if (cb->text() == tr("Game end")) setting->qgo->playGameEndSound(); else if (cb->text() == tr("Leave")) setting->qgo->playLeaveSound(); else if (cb->text() == tr("Disconnect")) setting->qgo->playDisConnectSound(); else if (cb->text() == tr("Connect")) setting->qgo->playConnectSound();}void PreferencesDialog::slot_getComputerPath(){ QString fileName(QFileDialog::getOpenFileName(setting->readEntry("LAST_DIR"), tr("All Files (*)"), this)); if (fileName.isEmpty()) return; LineEdit_computer->setText(fileName);}void PreferencesDialog::slot_getGobanPicturePath(){#ifdef Q_OS_MACX // On the Mac, we want to default this dialog to the directory in the bundle // that contains the wood images we ship with the app //get the bundle path and find our resources CFURLRef bundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFStringRef bundlePath = CFURLCopyFileSystemPath(bundleRef, kCFURLPOSIXPathStyle); QString path = (QString)CFStringGetCStringPtr(bundlePath, CFStringGetSystemEncoding()) + "/Contents/Resources/Backgrounds";#else QString path = setting->readEntry("LAST_DIR");#endif QString fileName(QFileDialog::getOpenFileName(path, tr("Images (*.png *.xpm *.jpg)"), this)); if (fileName.isEmpty()) return; LineEdit_goban->setText(fileName);}void PreferencesDialog::slot_getTablePicturePath(){#ifdef Q_OS_MACX // On the Mac, we want to default this dialog to the directory in the bundle // that contains the wood images we ship with the app //get the bundle path and find our resources CFURLRef bundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFStringRef bundlePath = CFURLCopyFileSystemPath(bundleRef, kCFURLPOSIXPathStyle); QString path = (QString)CFStringGetCStringPtr(bundlePath, CFStringGetSystemEncoding()) + "/Contents/Resources/Backgrounds";#else QString path = setting->readEntry("LAST_DIR");#endif QString fileName(QFileDialog::getOpenFileName(path, tr("Images (*.png *.xpm *.jpg)"), this)); if (fileName.isEmpty()) return; LineEdit_Table->setText(fileName);}void PreferencesDialog::slot_getPixmapPath(){ QString fileName(QFileDialog::getOpenFileName("",tr("Images (*.png *.jpg *.xpm *.ico)"), this)); if (fileName.isEmpty()) return; LineEdit_pixfile->setText(fileName); QPixmap p; p.load(fileName); pixmapLabel->setPixmap(p);}void PreferencesDialog::slot_text_buttonChanged(const QString &title){ if (ListView_buttons->findItem(title,1)) pb_add_2->setText(tr("Change")); else pb_add_2->setText(tr("Add"));}void PreferencesDialog::slot_new_button(){ LineEdit_label->clear(); LineEdit_help->clear(); LineEdit_pixfile->clear(); LineEdit_command->clear(); pixmapLabel->setPixmap(NULL);}// button "add" clicked or "ok" pressedvoid PreferencesDialog::slot_add_button(){ QToolButton *b,*b0; QObjectList *bl = parent_cw->UserToolbar->queryList( "QToolButton" ,NULL,true,false); bool found = false; // check if at least title and host inserted if (!LineEdit_label->text().isEmpty() && !LineEdit_command->text().isEmpty()) { // check if label already exists for ( b0 = (QToolButton*)bl->first(); (b0 != 0) && !found; b0 = (QToolButton*)bl->next()) { if (b0->textLabel() == LineEdit_label->text()) { found = true; // if found, remove old item parent_cw->userButtonGroup->remove(b0); delete b0; } } QPixmap p; b=new QToolButton(parent_cw->UserToolbar) ; b->setTextLabel(LineEdit_label->text()); //label of the button b->setText(LineEdit_label->text()); b->setCaption(LineEdit_command->text()); //dirty but handy b->setIconText(LineEdit_pixfile->text()); //dirty also but handy QToolTip::add(b,LineEdit_help->text()); b->setMinimumWidth(25); if ( p.load(LineEdit_pixfile->text())) b->setPixmap(p); parent_cw->userButtonGroup->insert(b,-1); if (!found) { QListViewItem *buttonItem = new QListViewItem(ListView_buttons, "", LineEdit_label->text(), LineEdit_command->text(), LineEdit_help->text(), LineEdit_pixfile->text()); buttonItem->setPixmap(0,p); } else { ListView_buttons->currentItem()->setText(1, LineEdit_label->text()); ListView_buttons->currentItem()->setText(2, LineEdit_command->text()); ListView_buttons->currentItem()->setText(3, LineEdit_help->text()); ListView_buttons->currentItem()->setText(4, LineEdit_pixfile->text()); ListView_buttons->currentItem()->setPixmap(0,p); } } slot_new_button(); }void PreferencesDialog::slot_clicked_buttonListView(QListViewItem *lvi, const QPoint&, int){ if (!lvi) return; LineEdit_label->setText(lvi->text(1)); LineEdit_command->setText(lvi->text(2)); LineEdit_help->setText(lvi->text(3)); LineEdit_pixfile->setText(lvi->text(4)); QPixmap p; p.load(LineEdit_pixfile->text()); pixmapLabel->setPixmap(p);}void PreferencesDialog::slot_delete_button(){ QObjectList *bl = parent_cw->UserToolbar->queryList( "QToolButton" ,NULL,true,false); bool found=false; QToolButton *b0; // check if at least title and host inserted if (!LineEdit_label->text().isEmpty() )//&& !LineEdit_command->text().isEmpty()) { // check if label already exists QListViewItem *lvi = ListView_buttons->findItem(LineEdit_label->text(),1); // if found, remove old item and clear fields if(lvi) { for ( b0 = (QToolButton*)bl->first(); (b0 != 0) && !found; b0 = (QToolButton*)bl->next()) { //QString sb= b0->text(); //QString sl = LineEdit_label->text(); if (b0->textLabel() == LineEdit_label->text()) { found = true; // if found, remove old item parent_cw->userButtonGroup->remove(b0); delete b0; } } ListView_buttons->takeItem(lvi); slot_new_button(); } } }void PreferencesDialog::slot_main_time_changed(int n){ timeSpin_Nmatch->setMinValue(n);}void PreferencesDialog::slot_BY_time_changed(int n){ BYSpin_Nmatch->setMinValue(n);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -