| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009 by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | |
| 23 | #include <QtWidgets> |
| 24 | #include "undoprompt.h"cxx . . $ `<file>/src/game_interfaces/undoprompt.h`/ |
| 25 | |
| 26 | UndoPromptcxx . . $ UndoPrompt#::UndoPromptcxx . . $ UndoPrompt#UndoPrompt(cdf5cc4a64da14c4).(const QStringcxx . . $ QString# * _name, bool multiple, int _moves) : namecxx . . $ UndoPrompt#name.(_name), movescxx . . $ UndoPrompt#moves.(_moves) |
| 27 | { |
| 28 | movesSpincxx . . $ UndoPrompt#movesSpin. = 0; |
| 29 | |
| 30 | if(namecxx . . $ UndoPrompt#name.) |
| 31 | { |
| 32 | if(!multiple) |
| 33 | mainlabelcxx . . $ UndoPrompt#mainlabel. = new QLabelcxx . . $ QLabel#(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("%1 wants to undo the last move").argcxx . . $ QString#arg(bc823072288cbbb5).(*namecxx . . $ UndoPrompt#name.)); |
| 34 | else |
| 35 | mainlabelcxx . . $ UndoPrompt#mainlabel. = new QLabelcxx . . $ QLabel#(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("%1 wants to undo to move %2").argcxx . . $ QString#arg(bc823072288cbbb5).(*namecxx . . $ UndoPrompt#name.).argcxx . . $ QString#arg(64ab2ed17cc11715).(movescxx . . $ UndoPrompt#moves.)); |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | if(!multiple) |
| 40 | mainlabelcxx . . $ UndoPrompt#mainlabel. = new QLabelcxx . . $ QLabel#(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("Undo the last move?").argcxx . . $ QString#arg(bc823072288cbbb5).(*namecxx . . $ UndoPrompt#name.)); |
| 41 | else |
| 42 | { |
| 43 | mainlabelcxx . . $ UndoPrompt#mainlabel. = new QLabelcxx . . $ QLabel#(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("Undo to what move?")); |
| 44 | movesSpincxx . . $ UndoPrompt#movesSpin. = new QSpinBoxcxx . . $ QSpinBox#(); |
| 45 | movesSpincxx . . $ UndoPrompt#movesSpin.->setValuecxx . . $ QSpinBox#setValue(d4f767463ce0a6b3).(movescxx . . $ UndoPrompt#moves.); // really shouldn't this be moves -1? |
| 46 | movesSpincxx . . $ UndoPrompt#movesSpin.->setRangecxx . . $ QSpinBox#setRange(3e454b8ccf442868).(0, movescxx . . $ UndoPrompt#moves.); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | if(!movesSpincxx . . $ UndoPrompt#movesSpin.) |
| 51 | { |
| 52 | acceptButtoncxx . . $ UndoPrompt#acceptButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("&Accept")); |
| 53 | acceptButtoncxx . . $ UndoPrompt#acceptButton.->setDefaultcxx . . $ QPushButton#setDefault(b45ddcbc8423892c).(true); |
| 54 | |
| 55 | declineButtoncxx . . $ UndoPrompt#declineButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("&Decline")); |
| 56 | } |
| 57 | else |
| 58 | { |
| 59 | acceptButtoncxx . . $ UndoPrompt#acceptButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("&Request")); |
| 60 | acceptButtoncxx . . $ UndoPrompt#acceptButton.->setDefaultcxx . . $ QPushButton#setDefault(b45ddcbc8423892c).(true); |
| 61 | |
| 62 | declineButtoncxx . . $ UndoPrompt#declineButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("&Cancel")); |
| 63 | } |
| 64 | buttonBoxcxx . . $ UndoPrompt#buttonBox. = new QDialogButtonBoxcxx . . $ QDialogButtonBox#(Qtcxx . . $ Qt/::Horizontalcxx . . $ Qt/Horizontal.); |
| 65 | buttonBoxcxx . . $ UndoPrompt#buttonBox.->addButtoncxx . . $ QDialogButtonBox#addButton(7ed195453ac96140).(acceptButtoncxx . . $ UndoPrompt#acceptButton., QDialogButtonBoxcxx . . $ QDialogButtonBox#::ActionRolecxx . . $ QDialogButtonBox#ActionRole.); |
| 66 | buttonBoxcxx . . $ UndoPrompt#buttonBox.->addButtoncxx . . $ QDialogButtonBox#addButton(7ed195453ac96140).(declineButtoncxx . . $ UndoPrompt#declineButton., QDialogButtonBoxcxx . . $ QDialogButtonBox#::ActionRolecxx . . $ QDialogButtonBox#ActionRole.); |
| 67 | |
| 68 | connectcxx . . $ QObject#connect(835f87066c895669).(acceptButtoncxx . . $ UndoPrompt#acceptButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &UndoPromptcxx . . $ UndoPrompt#::slot_acceptcxx . . $ UndoPrompt#slot_accept(49f6e7a06ebc5aa8).); |
| 69 | connectcxx . . $ QObject#connect(835f87066c895669).(declineButtoncxx . . $ UndoPrompt#declineButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &UndoPromptcxx . . $ UndoPrompt#::slot_declinecxx . . $ UndoPrompt#slot_decline(49f6e7a06ebc5aa8).); |
| 70 | |
| 71 | QGridLayoutcxx . . $ QGridLayout# * mainLayout = new QGridLayoutcxx . . $ QGridLayout#; |
| 72 | mainLayout->setSizeConstraintcxx . . $ QLayout#setSizeConstraint(2d278d641bf12a66).(QLayoutcxx . . $ QLayout#::SetFixedSizecxx . . $ QLayout#SetFixedSize.); |
| 73 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(mainlabelcxx . . $ UndoPrompt#mainlabel., 0, 0); |
| 74 | if(movesSpincxx . . $ UndoPrompt#movesSpin.) |
| 75 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(movesSpincxx . . $ UndoPrompt#movesSpin., 1, 0); |
| 76 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(buttonBoxcxx . . $ UndoPrompt#buttonBox., (movesSpincxx . . $ UndoPrompt#movesSpin. ? 2 : 1), 0); |
| 77 | setLayoutcxx . . $ QWidget#setLayout(23396b1058755fec).(mainLayout); |
| 78 | |
| 79 | if(namecxx . . $ UndoPrompt#name.) |
| 80 | setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("Undo requested")); |
| 81 | else |
| 82 | setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(trcxx . . $ UndoPrompt#tr(75d9f1c324b4579d).("Request undo?")); |
| 83 | |
| 84 | |
| 85 | // we might want to set modality here |
| 86 | //startTimer(1000); |
| 87 | } |
| 88 | |
| 89 | void UndoPromptcxx . . $ UndoPrompt#::timerEventcxx . . $ UndoPrompt#timerEvent(b9e57d1150f23bf5).(QTimerEventcxx . . $ QTimerEvent#*) |
| 90 | { |
| 91 | // in case we need this? |
| 92 | } |
| 93 | |
| 94 | UndoPromptcxx . . $ UndoPrompt#::~cxx . . $ UndoPrompt#`~UndoPrompt`(ced63f7c635d850d).UndoPromptcxx . . $ UndoPrompt#() |
| 95 | { |
| 96 | delete acceptButtoncxx . . $ UndoPrompt#acceptButton.; |
| 97 | delete declineButtoncxx . . $ UndoPrompt#declineButton.; |
| 98 | delete mainlabelcxx . . $ UndoPrompt#mainlabel.; |
| 99 | delete movesSpincxx . . $ UndoPrompt#movesSpin.; |
| 100 | delete buttonBoxcxx . . $ UndoPrompt#buttonBox.; |
| 101 | } |
| 102 | |
| 103 | /* I'm assuming here that a close by time returns 0 */ |
| 104 | void UndoPromptcxx . . $ UndoPrompt#::slot_acceptcxx . . $ UndoPrompt#slot_accept(49f6e7a06ebc5aa8).(void) |
| 105 | { |
| 106 | if(!movesSpincxx . . $ UndoPrompt#movesSpin.) |
| 107 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(movescxx . . $ UndoPrompt#moves.); |
| 108 | else |
| 109 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(movesSpincxx . . $ UndoPrompt#movesSpin.->valuecxx . . $ QSpinBox#value(455f465bc33b4cdf).()); |
| 110 | } |
| 111 | |
| 112 | void UndoPromptcxx . . $ UndoPrompt#::slot_declinecxx . . $ UndoPrompt#slot_decline(49f6e7a06ebc5aa8).(void) |
| 113 | { |
| 114 | donecxx . . $ QDialog#done(d4f767463ce0a6b3).(-1); |
| 115 | } |