⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.cpp

📁 qgo-1.5.4-r3.tar.gz linux下一个很好玩的游戏
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	navBackward->addTo(toolBar);	navForward->addTo(toolBar);	navLast->addTo(toolBar);		toolBar->addSeparator();		navMainBranch->addTo(toolBar);	navStartVar->addTo(toolBar);	navPrevVar->addTo(toolBar);	navNextVar->addTo(toolBar);	navNextBranch->addTo(toolBar);		toolBar->addSeparator();	navPrevComment->addTo(toolBar);        // added eb 2	navNextComment->addTo(toolBar);	navIntersection->addTo(toolBar);       //SL added eb 11	toolBar->addSeparator();               //end add eb 2		navAutoplay->addTo(toolBar);		toolBar->addSeparator();	soundToggle->addTo(toolBar);	viewCoords->addTo(toolBar);	toolBar->addSeparator();		QWhatsThis::whatsThisButton(toolBar);		toolBar->addSeparator();//	setPreferences->addTo(toolBar);	setGameInfo->addTo(toolBar);		// Edit toolbar	editBar = new QToolBar(this, "editbar");		editCut->addTo(editBar);	editPaste->addTo(editBar);	editDelete->addTo(editBar);}void MainWindow::initStatusBar(){	// The coords widget	statusTip = new StatusTip(statusBar());	statusBar()->addWidget(statusTip);	//statusBar()->show();	statusBar()->setSizeGripEnabled(true);	statusBar()->message(tr("Ready."));  // Normal indicator	connect(statusTip, SIGNAL(clearStatusBar()), statusBar(), SLOT(clear()));		// The turn widget	statusTurn = new QLabel(statusBar());	statusTurn->setAlignment(AlignCenter | SingleLine);	statusTurn->setText(" 0 ");	statusBar()->addWidget(statusTurn, 0, true);  // Permanent indicator	QToolTip::add(statusTurn, tr("Current move"));	QWhatsThis::add(statusTurn, tr("Move\nDisplays the number of the current turn and the last move played."));		// The nav widget	statusNav = new QLabel(statusBar());	statusNav->setAlignment(AlignCenter | SingleLine);	statusNav->setText(" 0/0 ");	statusBar()->addWidget(statusNav, 0, true);  // Permanent indicator	QToolTip::add(statusNav, tr("Brothers / sons"));	QWhatsThis::add(statusNav, tr("Navigation\nShows the brothers and sons of the current move."));		// The mode widget	statusMode = new QLabel(statusBar());	statusMode->setAlignment(AlignCenter | SingleLine);	statusMode->setText(" " + QObject::tr("N", "Board status line: normal mode") + " ");	statusBar()->addWidget(statusMode, 0, true);  // Permanent indicator	QToolTip::add(statusMode, tr("Current mode"));	QWhatsThis::add(statusMode,		tr("Mode\nShows the current mode. 'N' for normal mode, 'E' for edit mode."));		// The mark widget	statusMark = new QLabel(statusBar());	statusMark->setAlignment(AlignCenter | SingleLine);	statusMark->setText(" - ");	statusBar()->addWidget(statusMark, 0, true);  // Permanent indicator	QToolTip::add(statusMark, tr("Current edit mark"));	QWhatsThis::add(statusMark, tr("Mark\nShows the current edit mark. '-' in normal mode."));}void MainWindow::slotFileNewBoard(){	setting->qgo->addBoardWindow();}void MainWindow::slotFileNewGame(){	if (!checkModified())		return;		if (board->getGameMode() == modeNormal)	{		NewLocalGameDialog dlg(this, tr("newgame"), true);				if (dlg.exec() == QDialog::Accepted)		{			GameData *d = new GameData;			d->size = dlg.boardSizeSpin->value();			d->komi = (float)dlg.komiSpin->value() / 10.0;			d->handicap = dlg.handicapSpin->value();			d->playerBlack = dlg.playerBlackEdit->text();			d->rankBlack = dlg.playerBlackRkEdit->text();			d->playerWhite = dlg.playerWhiteEdit->text();			d->rankWhite = dlg.playerWhiteRkEdit->text();			d->gameName = "";			d->gameNumber = 0;			d->fileName = "";			d->byoTime = dlg.byoTimeSpin->value();			d->style = 1;			board->initGame(d);		}	}	else	{		NewGameDialog dlg(this, tr("newgame"), true);				if (dlg.exec() == QDialog::Accepted)		{			GameData *d = new GameData;			d->size = dlg.boardSizeSpin->value();			d->komi = (float)dlg.komiSpin->value() / 10.0;			d->handicap = dlg.handicapSpin->value();//			d->playerBlack = dlg.playerBlackEdit->text();//			d->playerWhite = dlg.playerWhiteEdit->text();			d->gameName = "";			d->gameNumber = 0;			d->fileName = "";			d->byoTime = dlg.byoTimeSpin->value();			d->style = 1;			board->initGame(d);		}	}	interfaceHandler->normalTools->komi->setText(QString::number(board->getGameData()->komi));	interfaceHandler->normalTools->handicap->setText(QString::number(board->getGameData()->handicap));		statusBar()->message(tr("New board prepared."));}void MainWindow::slotFileOpen(){	if (!checkModified())		return;	QString fileName(QFileDialog::getOpenFileName(setting->readEntry("LAST_DIR"),		tr("SGF Files (*.sgf *.SGF);;MGT Files (*.mgt);;XML Files (*.xml);;All Files (*)"), this));	if (fileName.isEmpty())		return;	doOpen(fileName, getFileExtension(fileName));}QString MainWindow::getFileExtension(const QString &fileName, bool defaultExt){	QString filter;	if (defaultExt)		filter = tr("SGF");	else		filter = "";		int pos=0, oldpos=-1, len = fileName.length();		while ((pos = fileName.find('.', ++pos)) != -1 && pos < len)		oldpos = pos;		if (oldpos != -1)		filter = fileName.mid(oldpos+1, fileName.length()-pos).upper();		return filter;}void MainWindow::doOpen(const QString &fileName, const QString &filter, bool storedir){	// qDebug("doOpen - fileName: %s - filter: %s", fileName.latin1(), filter.latin1());		if (setting->readBoolEntry("REM_DIR") && storedir)		rememberLastDir(fileName);		if (board->openSGF(fileName, filter))		statusBar()->message(fileName + " " + tr("loaded."));}bool MainWindow::startComputerPlay(QNewGameDlg * dlg, const QString &fileName, const QString &filter, const QString &computer_path){	GameData *d = new GameData;	d->size = dlg->getSize();	d->komi = dlg->getKomi();	d->handicap = dlg->getHandicap();	d->playerBlack = dlg->getPlayerBlackName();	//d->rankBlack = dlg.playerBlackRkEdit->text();	d->playerWhite = dlg->getPlayerWhiteName();	//d->rankWhite = dlg.playerWhiteRkEdit->text();	d->gameName = "";	d->gameNumber = 0;	d->fileName = "";	d->byoTime = dlg->getTime();	d->style = 1;	d->oneColorGo = dlg->getOneColorGo();	blackPlayerType = dlg->getPlayerBlackType();	whitePlayerType = dlg->getPlayerWhiteType();		//if (fileName.isNull() || fileName.isEmpty())	//	board->initGame(d);	if (!board->startComputerPlay(dlg,fileName, filter, computer_path))		return false;	return true;}bool MainWindow::slotFileSave(){	QString fileName;	if ((fileName = board->getGameData()->fileName).isEmpty())	{		if (setting->readBoolEntry("REM_DIR"))			fileName = setting->readEntry("LAST_DIR");		else			fileName = QString::null;		return doSave(fileName, false);	}	else		return doSave(board->getGameData()->fileName, true);}bool MainWindow::slotFileSaveAs(){//	if (setting->readBoolEntry("REM_DIR"))//		return doSave(setting->readEntry("LAST_DIR"), false);	return doSave(0, false);}bool MainWindow::doSave(QString fileName, bool force){	if (!force)  	{     		if  (fileName == NULL ||			fileName.isNull() ||          		fileName.isEmpty() ||          		QDir(fileName).exists())            	{              		QString base = board->getCandidateFileName();              		if (fileName == NULL || fileName.isNull() || fileName.isEmpty())                		fileName = base;              		else                		fileName.append(base);		}		fileName = QFileDialog::getSaveFileName(fileName, tr("SGF Files (*.sgf);;All Files (*)"), this);	}		if (fileName.isEmpty())		return false;		if (getFileExtension(fileName, false).isEmpty())		fileName.append(".sgf");		// Confirm overwriting file.	if (!force && QFile(fileName).exists())		if (QMessageBox::information(this, PACKAGE,			tr("This file already exists. Do you want to overwrite it?"),			tr("Yes"), tr("No"), 0, 0, 1) == 1)			return false;			board->getGameData()->fileName = fileName;			if (setting->readBoolEntry("REM_DIR"))		rememberLastDir(fileName);				if (!board->saveBoard(fileName))		{			QMessageBox::warning(this, PACKAGE, tr("Cannot save SGF file."));			return false;		}			statusBar()->message(fileName + " " + tr("saved."));	board->setModified(false);	return true;}void MainWindow::slotFileClose(){	if (checkModified() == 1)	{		board->setModified(false);  // Prevent to ask a second time in qGo::quit()		close();	}}void MainWindow::slotFileImportSgfClipB(){	// check wheter it's an edit board during online game	if (getInterfaceHandler()->refreshButton->text() != tr("Update") && !checkModified())		return;		if (!board->importSGFClipboard())		QMessageBox::warning(this, PACKAGE, tr("Cannot load from clipboard. Is it empty?"));	else		statusBar()->message(tr("SGF imported."));}void MainWindow::slotFileExportSgfClipB(){	if (!board->exportSGFtoClipB())		QMessageBox::warning(this, PACKAGE, tr("Failed to export SGF to clipboard."));	else		statusBar()->message(tr("SGF exported."));}void MainWindow::slotFileImportASCII(){	QString fileName(QFileDialog::getOpenFileName(QString::null,		tr("Text Files (*.txt);;All Files (*)"),		this));	if (fileName.isEmpty())		return;		board->importASCII(fileName);	statusBar()->message(tr("ASCII imported."));}void MainWindow::slotFileImportASCIIClipB(){	if (!board->importASCII(NULL, true))		QMessageBox::warning(this, PACKAGE, tr("Importing ASCII failed. Clipboard empty?"));	else		statusBar()->message(tr("ASCII imported."));}void MainWindow::slotFileExportASCII(){	board->exportASCII();	statusBar()->message(tr("Ready."));}void MainWindow::slotFileExportPic(){   QString *filter = new QString("");   QString fileName = QFileDialog::getSaveFileName(    "",		"PNG (*.png);;BMP (*.bmp);;XPM (*.xpm);;XBM (*.xbm);;PNM (*.pnm);;GIF (*.gif);;JPEG (*.jpeg);;MNG (*.mng)",		this,    "qGo",    tr("Export image as"),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -