📄 mainwindow.cpp
字号:
delete helpManual; delete helpSoundInfo; delete helpAboutApp; delete helpAboutQt;}void MainWindow::initActions(){ // Load the pixmaps QPixmap exitIcon, fileNewboardIcon, fileNewIcon, fileOpenIcon, fileSaveIcon, fileSaveAsIcon, transformIcon, charIcon, cutIcon, pasteIcon, deleteIcon, nextCommentIcon, previousCommentIcon, navIntersectionIcon, rightArrowIcon, leftArrowIcon,two_rightArrowIcon, two_leftArrowIcon, prevVarIcon, nextVarIcon, startVarIcon, mainBranchIcon, nextBranchIcon, autoplayIcon, prefsIcon, infoIcon, increaseIcon, decreaseIcon, fullscreenIcon, manualIcon, coordsIcon, sound_onIcon, sound_offIcon;//#ifdef USE_XPM prefsIcon = QPixmap(const_cast<const char**>(package_settings_xpm)); infoIcon = QPixmap(const_cast<const char**>(idea_xpm)); exitIcon = QPixmap(const_cast<const char**>(exit_xpm)); fileNewboardIcon = QPixmap(const_cast<const char**>(newboard_xpm)); fileNewIcon = QPixmap(const_cast<const char**>(filenew_xpm)); fileOpenIcon = QPixmap(const_cast<const char**>(fileopen_xpm)); fileSaveIcon = QPixmap(const_cast<const char**>(filesave_xpm)); fileSaveAsIcon = QPixmap(const_cast<const char**>(filesaveas_xpm)); transformIcon = QPixmap(const_cast<const char**>(transform_xpm)); charIcon = QPixmap(const_cast<const char**>(charset_xpm)); cutIcon = QPixmap(const_cast<const char**>(editcut_xpm)); pasteIcon = QPixmap(const_cast<const char**>(editpaste_xpm)); deleteIcon = QPixmap(const_cast<const char**>(editdelete_xpm)); rightArrowIcon = QPixmap(const_cast<const char**>(rightarrow_xpm)); leftArrowIcon = QPixmap(const_cast<const char**>(leftarrow_xpm)); nextCommentIcon = QPixmap(const_cast<const char**>(rightcomment_xpm)); previousCommentIcon = QPixmap(const_cast<const char**>(leftcomment_xpm)); two_rightArrowIcon = QPixmap(const_cast<const char**>(two_rightarrow_xpm)); two_leftArrowIcon = QPixmap(const_cast<const char**>(two_leftarrow_xpm)); nextVarIcon = QPixmap(const_cast<const char**>(down_xpm)); prevVarIcon = QPixmap(const_cast<const char**>(up_xpm)); mainBranchIcon = QPixmap(const_cast<const char**>(start_xpm)); startVarIcon = QPixmap(const_cast<const char**>(top_xpm)); nextBranchIcon = QPixmap(const_cast<const char**>(bottom_xpm)); increaseIcon = QPixmap(const_cast<const char**>(viewmagplus_xpm)); decreaseIcon = QPixmap(const_cast<const char**>(viewmagminus_xpm)); fullscreenIcon = QPixmap(const_cast<const char**>(window_fullscreen_xpm)); manualIcon = QPixmap(const_cast<const char**>(help_xpm)); autoplayIcon = QPixmap(const_cast<const char**>(player_pause_xpm)); navIntersectionIcon = QPixmap(const_cast<const char**>(navIntersection_xpm)); //SL added eb 11 coordsIcon= QPixmap(const_cast<const char**>(coords_xpm)); sound_onIcon= QPixmap(const_cast<const char**>(sound_on_xpm)); sound_offIcon= QPixmap(const_cast<const char**>(sound_off_xpm)); /*#else prefsIcon = QPixmap(ICON_PREFS); infoIcon = QPixmap(ICON_GAMEINFO); exitIcon = QPixmap(ICON_EXIT); fileNewboardIcon = QPixmap(ICON_FILENEWBOARD); fileNewIcon = QPixmap(ICON_FILENEW); fileOpenIcon = QPixmap(ICON_FILEOPEN); fileSaveIcon = QPixmap(ICON_FILESAVE); fileSaveAsIcon = QPixmap(ICON_FILESAVEAS); transformIcon = QPixmap(ICON_TRANSFORM); charIcon = QPixmap(ICON_CHARSET); cutIcon = QPixmap(ICON_CUT); pasteIcon = QPixmap(ICON_PASTE); deleteIcon = QPixmap(ICON_DELETE); rightArrowIcon = QPixmap(ICON_RIGHTARROW); leftArrowIcon = QPixmap(ICON_LEFTARROW); nextCommentIcon = QPixmap(ICON_RIGHTCOMMENT); //added eb previousCommentIcon = QPixmap(ICON_LEFTCOMMENT); //added eb two_rightArrowIcon = QPixmap(ICON_TWO_RIGHTARROW); two_leftArrowIcon = QPixmap(ICON_TWO_LEFTARROW); nextVarIcon = QPixmap(ICON_NEXT_VAR); prevVarIcon = QPixmap(ICON_PREV_VAR); startVarIcon = QPixmap(ICON_START_VAR); mainBranchIcon = QPixmap(ICON_MAIN_BRANCH); nextBranchIcon = QPixmap(ICON_NEXT_BRANCH); increaseIcon = QPixmap(ICON_INCREASE_SIZE); decreaseIcon = QPixmap(ICON_DECREASE_SIZE); fullscreenIcon = QPixmap(ICON_FULLSCREEN); manualIcon = QPixmap(ICON_MANUAL); autoplayIcon = QPixmap(ICON_AUTOPLAY); navIntersectionIcon = QPixmap(ICON_NAV_INTERSECTION); coordsIcon = QPixmap(ICON_COORDS); sound_onIcon = QPixmap(ICON_SOUND_ON); sound_offIcon = QPixmap(ICON_SOUND_Off);#endif*/ /* * Global actions */ // Escape focus: Escape key to get the focus from comment field to main window. escapeFocus = new QAction(this); escapeFocus->setAccel(Key_Escape); connect(escapeFocus, SIGNAL(activated()), this, SLOT(setFocus())); // Toggle game mode: Normal / Edit - Ctrl-E toggleEdit = new QAction(this); toggleEdit->setAccel(QAccel::stringToKey(tr("Ctrl+E"))); // connect in constructor, as we need the mainwidget instance first. // Toggle through the marks - Ctrl-T toggleMarks = new QAction(this); toggleMarks->setAccel(QAccel::stringToKey(tr("Ctrl+T"))); connect(toggleMarks, SIGNAL(activated()), this, SLOT(slotToggleMarks())); /* * Menu File */ // File New Board fileNewBoard = new QAction(tr("New"), fileNewboardIcon, tr("New &Board"), QAccel::stringToKey(tr("Ctrl+B")), this); fileNewBoard->setStatusTip(tr("Creates a new board")); fileNewBoard->setWhatsThis(tr("New\n\nCreates a new board.")); connect(fileNewBoard, SIGNAL(activated()), this, SLOT(slotFileNewBoard())); // File New Game fileNew = new QAction(tr("New game"), fileNewIcon, tr("&New game"), QAccel::stringToKey(tr("Ctrl+N")), this); fileNew->setStatusTip(tr("Creates a new game on this board")); fileNew->setWhatsThis(tr("New\n\nCreates a new game on this board.")); connect(fileNew, SIGNAL(activated()), this, SLOT(slotFileNewGame())); // File Open fileOpen = new QAction(tr("Open"), fileOpenIcon, tr("&Open"), QAccel::stringToKey(tr("Ctrl+O")), this); fileOpen->setStatusTip(tr("Open a sgf file")); fileOpen->setWhatsThis(tr("Open\n\nOpen a sgf file.")); connect(fileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen())); // File Save fileSave = new QAction(tr("Save"), fileSaveIcon, tr("&Save"), QAccel::stringToKey(tr("Ctrl+S")), this); fileSave->setStatusTip(tr("Save a sgf file")); fileSave->setWhatsThis(tr("Save\n\nSave a sgf file.")); connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); // File SaveAs fileSaveAs = new QAction(tr("Save As"), fileSaveAsIcon, tr("Save &As"), 0, this); fileSaveAs->setStatusTip(tr("Save a sgf file under a new name")); fileSaveAs->setWhatsThis(tr("Save As\n\nSave a sgf file under a new name.")); connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); // File Close fileClose = new QAction(tr("Close"), tr("&Close"), QAccel::stringToKey(tr("Ctrl+W")), this); fileClose->setStatusTip(tr("Close this board")); fileClose->setWhatsThis(tr("Exit\n\nClose this board.")); connect(fileClose, SIGNAL(activated()), this, SLOT(slotFileClose())); // File ImportASCII fileImportASCII = new QAction(tr("Import ASCII"), charIcon, tr("Import &ASCII"), 0, this); fileImportASCII->setStatusTip(tr("Import an ASCII file as new variation")); fileImportASCII->setWhatsThis(tr("Import ASCII\n\nImport an ASCII file as new variation.")); connect(fileImportASCII, SIGNAL(activated()), this, SLOT(slotFileImportASCII())); // File ImportASCIIClipB fileImportASCIIClipB = new QAction(tr("Import ASCII from clipboard"), charIcon, tr("Import ASCII from &clipboard"), 0, this); fileImportASCIIClipB->setStatusTip(tr("Import an ASCII board as new variation from the clipboard")); fileImportASCIIClipB->setWhatsThis(tr("Import ASCII from clipboard\n\nImport an ASCII file as new variation from the clipboard.")); connect(fileImportASCIIClipB, SIGNAL(activated()), this, SLOT(slotFileImportASCIIClipB())); // File ExportASCII fileExportASCII = new QAction(tr("Export ASCII"), charIcon, tr("&Export ASCII"), 0, this); fileExportASCII->setStatusTip(tr("Export current board to ASCII")); fileExportASCII->setWhatsThis(tr("Export ASCII\n\nExport current board to ASCII.")); connect(fileExportASCII, SIGNAL(activated()), this, SLOT(slotFileExportASCII())); // File ImportSgfClipB fileImportSgfClipB = new QAction(tr("Import SGF from clipboard"), fileOpenIcon, tr("Import SGF &from clipboard"), 0, this); fileImportSgfClipB->setStatusTip(tr("Import a complete game in SGF format from clipboard")); fileImportSgfClipB->setWhatsThis(tr("Import SGF from clipboard\n\n" "Import a complete game in SGF format from clipboard.")); connect(fileImportSgfClipB, SIGNAL(activated()), this, SLOT(slotFileImportSgfClipB())); // File ExportSgfClipB fileExportSgfClipB = new QAction(tr("Export SGF to clipboard"), fileSaveIcon, tr("Export SGF &to clipboard"), 0, this); fileExportSgfClipB->setStatusTip(tr("Export a complete game in SGF format to clipboard")); fileExportSgfClipB->setWhatsThis(tr("Export SGF to clipboard\n\n" "Export a complete game in SGF format to clipboard.")); connect(fileExportSgfClipB, SIGNAL(activated()), this, SLOT(slotFileExportSgfClipB())); // File ExportPic fileExportPic = new QAction(tr("Export Image"), transformIcon, tr("Export &Image"), 0, this); fileExportPic->setStatusTip(tr("Export current board to an image")); fileExportPic->setWhatsThis(tr("Export Image\n\nExport current board to an image.")); connect(fileExportPic, SIGNAL(activated()), this, SLOT(slotFileExportPic())); // File ExportPic fileExportPicClipB = new QAction(tr("Export Image to clipboard"), transformIcon, tr("E&xport Image to clipboard"), 0, this); fileExportPicClipB->setStatusTip(tr("Export current board to the clipboard as image")); fileExportPicClipB->setWhatsThis(tr("Export Image to clipboard\n\nExport current board to the clipboard as image.")); connect(fileExportPicClipB, SIGNAL(activated()), this, SLOT(slotFileExportPicClipB())); // File Quit fileQuit = new QAction(tr("Exit"), exitIcon, tr("E&xit"), QAccel::stringToKey(tr("Ctrl+Q")), this); fileQuit->setStatusTip(tr("Quits the application")); fileQuit->setWhatsThis(tr("Exit\n\nQuits the application.")); connect(fileQuit, SIGNAL(activated()), this, SLOT(slotFileClose()));//(qGo*)qApp, SLOT(quit())); /* * Menu Edit */ // Edit cut editCut = new QAction(tr("Cut"), cutIcon, tr("&Cut"), QAccel::stringToKey(tr("Ctrl+X")), this); editCut->setStatusTip(tr("Cut this and all following positions")); editCut->setWhatsThis(tr("Cut\n\nCut this and all following positions.")); connect(editCut, SIGNAL(activated()), this, SLOT(slotEditCut())); // Edit paste editPaste = new QAction(tr("Paste"), pasteIcon, tr("&Paste"), QAccel::stringToKey(tr("Ctrl+P")), this); editPaste->setStatusTip(tr("Paste as son of the current move")); editPaste->setWhatsThis(tr("Paste\n\nPaste as son of the current move.")); connect(editPaste, SIGNAL(activated()), this, SLOT(slotEditPaste())); // Edit paste as brother editPasteBrother = new QAction(tr("Paste as brother"), tr("Paste as &brother"), 0, this); editPasteBrother->setStatusTip(tr("Paste as brother of the current move")); editPasteBrother->setWhatsThis(tr("Paste\n\nPaste as brother of the current move.")); connect(editPasteBrother, SIGNAL(activated()), this, SLOT(slotEditPasteBrother())); // Edit delete editDelete = new QAction(tr("Delete"), deleteIcon, tr("&Delete"), QAccel::stringToKey(tr("Ctrl+D")), this); editDelete->setStatusTip(tr("Delete this and all following positions")); editDelete->setWhatsThis(tr("Delete\n\nDelete this and all following positions.")); connect(editDelete, SIGNAL(activated()), this, SLOT(slotEditDelete())); // QQQ Toggle Hide Stones editHideStones = new QAction(tr("Toggle Hiding"), tr("Toggle &Hiding"), QAccel::stringToKey(tr("Alt+F2")), this); editHideStones->setStatusTip(tr("Toggle to Hide all Stones in the board.")); editHideStones->setWhatsThis(tr("Toggle to Hide Stones\n\nToggle to Hide all Stones in the board.")); connect(editHideStones, SIGNAL(activated()), this, SLOT(slotEditHideStones())); // Edit number moves editNumberMoves = new QAction(tr("Number Moves"), tr("&Number Moves"), QAccel::stringToKey(tr("Shift+F2")), this); editNumberMoves->setStatusTip(tr("Mark all moves with the number of their turn")); editNumberMoves->setWhatsThis(tr("Number moves\n\nMark all moves with the number of their turn.")); connect(editNumberMoves, SIGNAL(activated()), this, SLOT(slotEditNumberMoves())); // Edit mark brothers editMarkBrothers = new QAction(tr("Mark brothers"), tr("Mark &brothers"), QAccel::stringToKey(tr("Shift+F3")), this); editMarkBrothers->setStatusTip(tr("Mark all brothers of the current move")); editMarkBrothers->setWhatsThis(tr("Mark brothers\n\nMark all brothers of the current move.")); connect(editMarkBrothers, SIGNAL(activated()), this, SLOT(slotEditMarkBrothers())); // Edit mark sons editMarkSons = new QAction(tr("Mark sons"), tr("Mark &sons"), QAccel::stringToKey(tr("Shift+F4")), this); editMarkSons->setStatusTip(tr("Mark all sons of the current move")); editMarkSons->setWhatsThis(tr("Mark sons\n\nMark all sons of the current move.")); connect(editMarkSons, SIGNAL(activated()), this, SLOT(slotEditMarkSons())); /* * Menu Navigation */ // Navigation Backward navBackward = new QAction(tr("Previous move (Left)"), leftArrowIcon, tr("&Previous move") + "\t" + tr("Left"), 0, this); navBackward->setStatusTip(tr("To previous move")); navBackward->setWhatsThis(tr("Previous move\n\nMove one move backward.")); connect(navBackward, SIGNAL(activated()), this, SLOT(slotNavBackward())); // Navigation Forward navForward = new QAction(tr("Next move (Right)"), rightArrowIcon, tr("&Next move") + "\t" + tr("Right"), 0, this); navForward->setStatusTip(tr("To next move")); navForward->setWhatsThis(tr("Next move\n\nMove one move forward.")); connect(navForward, SIGNAL(activated()), this, SLOT(slotNavForward())); // Navigation First navFirst = new QAction(tr("First move (Home)"), two_leftArrowIcon, tr("&First move") + "\t" + tr("Home"), 0, this); navFirst->setStatusTip(tr("To first move")); navFirst->setWhatsThis(tr("First move\n\nMove to first move.")); connect(navFirst, SIGNAL(activated()), this, SLOT(slotNavFirst())); // Navigation Last navLast = new QAction(tr("Last move (End)"), two_rightArrowIcon, tr("&Last move") + "\t" + tr("End"), 0, this); navLast->setStatusTip(tr("To last move")); navLast->setWhatsThis(tr("Last move\n\nMove to last move.")); connect(navLast, SIGNAL(activated()), this, SLOT(slotNavLast())); // Navigation previous variation navPrevVar = new QAction(tr("Previous variation (Up)"), prevVarIcon, tr("P&revious variation") + "\t" + tr("Up"), 0, this); navPrevVar->setStatusTip(tr("To previous variation")); navPrevVar->setWhatsThis(tr("Previous variation\n\nMove to the previous variation of this move.")); connect(navPrevVar, SIGNAL(activated()), this, SLOT(slotNavPrevVar())); // Navigation next variation navNextVar = new QAction(tr("Next variation (Down)"), nextVarIcon, tr("N&ext variation") + "\t" + tr("Down"), 0, this); navNextVar->setStatusTip(tr("To next variation")); navNextVar->setWhatsThis(tr("Next variation\n\nMove to the next variation of this move.")); connect(navNextVar, SIGNAL(activated()), this, SLOT(slotNavNextVar())); // Navigation main branch navMainBranch = new QAction(tr("Main Branch"), mainBranchIcon, tr("&Main branch"), Key_Insert, this); navMainBranch->setStatusTip(tr("To main branch")); navMainBranch->setWhatsThis(tr("Main Branch\n\nMove to the main branch where variation started.")); connect(navMainBranch, SIGNAL(activated()), this, SLOT(slotNavMainBranch())); // Navigation variation start navStartVar = new QAction(tr("Variation start"), startVarIcon, tr("Variation &start"), Key_PageUp, this); navStartVar->setStatusTip(tr("To top of variation")); navStartVar->setWhatsThis(tr("Variation start\n\nMove to the top variation of this branch.")); connect(navStartVar, SIGNAL(activated()), this, SLOT(slotNavStartVar())); // Navigation next branch navNextBranch = new QAction(tr("Next branch"), nextBranchIcon, tr("Next &branch"), Key_PageDown, this); navNextBranch->setStatusTip(tr("To next branch starting a variation")); navNextBranch->setWhatsThis(tr("Next branch\n\nMove to the next branch starting a variation.")); connect(navNextBranch, SIGNAL(activated()), this, SLOT(slotNavNextBranch())); // Navigation goto Nth move navNthMove = new QAction(tr("Goto move"), tr("&Goto Move"), QAccel::stringToKey(tr("Ctrl+G")) , this); navNthMove->setStatusTip(tr("Goto a move of main branch by number")); navNthMove->setWhatsThis(tr("Goto move\n\nGoto a move of main branch by number.")); connect(navNthMove, SIGNAL(activated()), this, SLOT(slotNavNthMove())); // Navigation Autoplay navAutoplay = new QAction(tr("Autoplay"), autoplayIcon, tr("&Autoplay"), QAccel::stringToKey(tr("Ctrl+A")), this, 0, true); navAutoplay->setOn(false); navAutoplay->setStatusTip(tr("Start/Stop autoplaying current game")); navAutoplay->setWhatsThis(tr("Autoplay\n\nStart/Stop autoplaying current game.")); connect(navAutoplay, SIGNAL(toggled(bool)), this, SLOT(slotNavAutoplay(bool))); // Navigation empty branch navEmptyBranch = new QAction(tr("Empty branch"), tr("Empt&y branch"), 0, this); navEmptyBranch->setStatusTip(tr("Create an empty branch")); navEmptyBranch->setWhatsThis(tr("Empty branch\n\nCreate an empty branch.")); connect(navEmptyBranch, SIGNAL(activated()), this, SLOT(slotNavEmptyBranch())); // Navigation duplicate move navCloneNode = new QAction(tr("Duplicate move"), tr("D&uplicate move"), 0, this); navCloneNode->setStatusTip(tr("Copies and duplicates this move")); navCloneNode->setWhatsThis(tr("Duplicate move\n\nCopies and duplicates this move.")); connect(navCloneNode, SIGNAL(activated()), this, SLOT(slotNavCloneNode())); // Navigation swap variations navSwapVariations = new QAction(tr("Swap variations"), tr("S&wap variations"), 0, this); navSwapVariations->setStatusTip(tr("Swap current move with previous variation")); navSwapVariations->setWhatsThis(tr("Swap variations\n\nSwap current move with previous variation.")); connect(navSwapVariations, SIGNAL(activated()), this, SLOT(slotNavSwapVariations()));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -