|
2 | 2 | import sys |
3 | 3 | import time |
4 | 4 |
|
| 5 | +from PyQt4.QtCore import Qt |
| 6 | + |
5 | 7 | from Code import ControlPosicion |
6 | 8 | from Code import Gestor |
7 | 9 | from Code import PGN |
@@ -676,34 +678,7 @@ def configurarGS(self): |
676 | 678 | self.reiniciar() |
677 | 679 |
|
678 | 680 | elif resp == "posicion": |
679 | | - resp = XVoyager.xVoyagerFEN(self.pantalla, self.configuracion, self.fen) |
680 | | - if resp is not None: |
681 | | - self.fen = resp |
682 | | - self.bloqueApertura = None |
683 | | - self.posicApertura = None |
684 | | - |
685 | | - if self.xpgn: |
686 | | - siInicio = self.fen == ControlPosicion.FEN_INICIAL |
687 | | - li = self.xpgn.split("\n") |
688 | | - lin = [] |
689 | | - siFen = False |
690 | | - for linea in li: |
691 | | - if linea.startswith("["): |
692 | | - if "FEN " in linea: |
693 | | - siFen = True |
694 | | - if siInicio: |
695 | | - continue |
696 | | - linea = '[FEN "%s"]' % self.fen |
697 | | - lin.append(linea) |
698 | | - else: |
699 | | - break |
700 | | - if not siFen: |
701 | | - linea = '[FEN "%s"]' % self.fen |
702 | | - lin.append(linea) |
703 | | - self.liPGN = lin |
704 | | - self.xpgn = "\n".join(lin) + "\n\n*" |
705 | | - |
706 | | - self.reiniciar() |
| 681 | + self.startPosition() |
707 | 682 |
|
708 | 683 | elif resp == "pasteposicion": |
709 | 684 | texto = QTUtil.traePortapapeles() |
@@ -771,11 +746,50 @@ def configurarGS(self): |
771 | 746 | self.reiniciar(dic) |
772 | 747 |
|
773 | 748 | def controlTeclado(self, nkey): |
774 | | - if nkey == 86: # V |
| 749 | + if nkey == Qt.Key_V: |
775 | 750 | self.paste(QTUtil.traePortapapeles()) |
776 | | - elif nkey == 80: # P |
| 751 | + elif nkey == Qt.Key_T: |
777 | 752 | li = [self.fen if self.fen else ControlPosicion.FEN_INICIAL,"",self.partida.pgnBaseRAW()] |
778 | 753 | self.saveSelectedPosition("|".join(li)) |
| 754 | + elif nkey == Qt.Key_S: |
| 755 | + self.startPosition() |
| 756 | + |
| 757 | + def listHelpTeclado(self): |
| 758 | + return [ |
| 759 | + ("V", _("Paste position")), |
| 760 | + ("T", _("Save position in 'Selected positions' file")), |
| 761 | + ("S", _("Set start position")) |
| 762 | + ] |
| 763 | + |
| 764 | + def startPosition(self): |
| 765 | + resp = XVoyager.xVoyagerFEN(self.pantalla, self.configuracion, self.fen) |
| 766 | + if resp is not None: |
| 767 | + self.fen = resp |
| 768 | + self.bloqueApertura = None |
| 769 | + self.posicApertura = None |
| 770 | + |
| 771 | + if self.xpgn: |
| 772 | + siInicio = self.fen == ControlPosicion.FEN_INICIAL |
| 773 | + li = self.xpgn.split("\n") |
| 774 | + lin = [] |
| 775 | + siFen = False |
| 776 | + for linea in li: |
| 777 | + if linea.startswith("["): |
| 778 | + if "FEN " in linea: |
| 779 | + siFen = True |
| 780 | + if siInicio: |
| 781 | + continue |
| 782 | + linea = '[FEN "%s"]' % self.fen |
| 783 | + lin.append(linea) |
| 784 | + else: |
| 785 | + break |
| 786 | + if not siFen: |
| 787 | + linea = '[FEN "%s"]' % self.fen |
| 788 | + lin.append(linea) |
| 789 | + self.liPGN = lin |
| 790 | + self.xpgn = "\n".join(lin) + "\n\n*" |
| 791 | + |
| 792 | + self.reiniciar() |
779 | 793 |
|
780 | 794 | def paste(self, texto): |
781 | 795 | cp = ControlPosicion.ControlPosicion() |
|
0 commit comments