- Compilation fix for Windows

- Display the Eliot icon
 - Improved printing
 - Allow changing the level of computer players
 - Generate automatically a default name for players
 - Translate Qt's own strings (only works on Linux at the moment)
This commit is contained in:
Olivier Teulière 2008-09-03 17:28:27 +00:00
parent 75a67b28a5
commit f5bde7fb4e
16 changed files with 678 additions and 158 deletions

View file

@ -26,6 +26,8 @@ package-win32-zip:
mkdir -p $(WIN32_PACKAGE_DIR)/locale/$${lang}/LC_MESSAGES; \
cp $(top_srcdir)/po/$${lang}.gmo $(WIN32_PACKAGE_DIR)/locale/$${lang}/LC_MESSAGES/eliot.mo; \
done
mkdir -p $(WIN32_PACKAGE_DIR)/locale/qt4
cp $(QT4LOCALEDIR)/*.qm $(WIN32_PACKAGE_DIR)/locale/qt4/ || true
# Copy relevant text files
for i in AUTHORS COPYING NEWS; do \

View file

@ -147,11 +147,14 @@ dnl check for Qt
AC_ARG_ENABLE([qt],AC_HELP_STRING([--enable-qt],
[Qt interface support (default disabled)]))
qt_ok=0
AS_IF([test "${enable_qt}" = "yes"],
AS_IF([test "${enable_qt}" != "no"],
[PKG_CHECK_MODULES(QT, [QtCore QtGui >= 4.2.0],
[qt_ok=1
AC_PATH_PROG(MOC, moc, moc,`$PKG_CONFIG --variable=exec_prefix QtCore`/bin)
AC_PATH_PROG(UIC, uic, uic,`$PKG_CONFIG --variable=exec_prefix QtCore`/bin)
AC_PATH_PROG(RCC, rcc, rcc,`$PKG_CONFIG --variable=exec_prefix QtCore`/bin)
QT4LOCALEDIR="$($PKG_CONFIG --variable=prefix QtCore)/share/qt4/translations/"
AC_SUBST(QT4LOCALEDIR)
],
[AC_MSG_ERROR([Could not find Qt on your system (using pkg-config)])]
)

View file

@ -190,7 +190,7 @@ void evaluate(const Header &iHeader, iter_t const& i, stack<Node*> &evalStack,
for (iter = i->children.begin(); iter != i->children.end(); ++iter)
evaluate(iHeader, iter, evalStack, iList);
// "Concatenate" the created child nodes with AND nodes
for (uint j = 0; j < i->children.size() - 1; ++j)
for (unsigned int j = 0; j < i->children.size() - 1; ++j)
{
Node *old2 = evalStack.top();
evalStack.pop();

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-08-31 12:51+0200\n"
"POT-Creation-Date: 2008-09-02 23:17+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -270,8 +270,8 @@ msgstr ""
msgid "Invalid regular expression: "
msgstr ""
#: game/training.cpp:49 qt/new_game.cpp:86 qt/new_game.cpp:94
#: qt/new_game.cpp:126 qt/ui/new_game.ui:46
#: game/training.cpp:49 qt/new_game.cpp:96 qt/new_game.cpp:104
#: qt/new_game.cpp:139 qt/ui/new_game.ui:46
msgid "Training"
msgstr ""
@ -309,7 +309,7 @@ msgstr ""
msgid " N | RACK | SOLUTION | REF | PTS | P | BONUS"
msgstr ""
#: utils/ncurses.cpp:411 qt/history_widget.cpp:143 qt/main_window.cpp:435
#: utils/ncurses.cpp:411 qt/history_widget.cpp:143 qt/main_window.cpp:442
msgid "(PASS)"
msgstr ""
@ -415,7 +415,7 @@ msgstr ""
msgid " Ctrl-l Refresh the screen"
msgstr ""
#: utils/ncurses.cpp:483 wxwin/auxframes.cc:147 qt/main_window.cpp:518
#: utils/ncurses.cpp:483 wxwin/auxframes.cc:147 qt/main_window.cpp:525
#: qt/ui/main_window.ui:188
msgid "Bag"
msgstr ""
@ -817,7 +817,7 @@ msgstr ""
msgid "&Save as...\tCtrl+S"
msgstr ""
#: wxwin/mainframe.cc:276 qt/ui/main_window.ui:229
#: wxwin/mainframe.cc:276 qt/ui/main_window.ui:232
msgid "Save the current game"
msgstr ""
@ -857,7 +857,7 @@ msgstr ""
msgid "&Dictionary...\tCtrl+D"
msgstr ""
#: wxwin/mainframe.cc:287 wxwin/mainframe.cc:604 qt/main_window.cpp:485
#: wxwin/mainframe.cc:287 wxwin/mainframe.cc:604 qt/main_window.cpp:492
msgid "Choose a dictionary"
msgstr ""
@ -1065,7 +1065,7 @@ msgstr ""
msgid "&About..."
msgstr ""
#: wxwin/mainframe.cc:331 wxwin/mainframe.cc:733 qt/main_window.cpp:596
#: wxwin/mainframe.cc:331 wxwin/mainframe.cc:733 qt/main_window.cpp:603
#: qt/ui/main_window.ui:161
msgid "About Eliot"
msgstr ""
@ -1256,12 +1256,11 @@ msgstr ""
msgid "Ref"
msgstr ""
#: qt/history_widget.cpp:87 qt/new_game.cpp:49 qt/score_widget.cpp:46
#: qt/ui/new_game.ui:102
#: qt/history_widget.cpp:87 qt/score_widget.cpp:46
msgid "Player"
msgstr ""
#: qt/main_window.cpp:91 qt/main_window.cpp:536 qt/ui/main_window.ui:40
#: qt/main_window.cpp:91 qt/main_window.cpp:543 qt/ui/main_window.ui:40
msgid "Board"
msgstr ""
@ -1277,7 +1276,7 @@ msgstr ""
msgid "Duplicate game"
msgstr ""
#: qt/main_window.cpp:201 qt/new_game.cpp:88 qt/new_game.cpp:145
#: qt/main_window.cpp:201 qt/new_game.cpp:98 qt/new_game.cpp:164
#: qt/ui/new_game.ui:41
msgid "Free game"
msgstr ""
@ -1298,44 +1297,44 @@ msgstr ""
msgid "Game saved"
msgstr ""
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "N."
msgstr ""
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "RACK"
msgstr ""
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "SOLUTION"
msgstr ""
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "REF"
msgstr ""
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "PTS"
msgstr ""
#: qt/main_window.cpp:476
#: qt/main_window.cpp:483
msgid "Stop current game?"
msgstr ""
#: qt/main_window.cpp:477
#: qt/main_window.cpp:484
msgid ""
"Loading a dictionary will stop the current game. Do you want to continue?"
msgstr ""
#: qt/main_window.cpp:554 qt/ui/main_window.ui:53 qt/ui/main_window.ui:251
#: qt/main_window.cpp:561 qt/ui/main_window.ui:53 qt/ui/main_window.ui:257
msgid "History"
msgstr ""
#: qt/main_window.cpp:571 qt/ui/main_window.ui:276
#: qt/main_window.cpp:578 qt/ui/main_window.ui:282
msgid "Dictionary tools"
msgstr ""
#: qt/main_window.cpp:588
#: qt/main_window.cpp:595
msgid ""
"Copyright (C) 1999-2008 - Antoine Fraboulet & Olivier Teuliere\n"
"\n"
@ -1345,31 +1344,36 @@ msgid ""
"any later version."
msgstr ""
#: qt/new_game.cpp:36 qt/ui/new_game.ui:117
#: qt/new_game.cpp:38 qt/ui/new_game.ui:117
msgid "Human"
msgstr ""
#: qt/new_game.cpp:37 qt/ui/new_game.ui:122
#: qt/new_game.cpp:39 qt/ui/new_game.ui:122
msgid "Computer"
msgstr ""
#: qt/new_game.cpp:47
msgid "Name"
msgstr ""
#: qt/new_game.cpp:48
msgid "Type"
msgstr ""
#: qt/new_game.cpp:51
msgid "Eliot"
msgstr ""
#: qt/new_game.cpp:101
#: qt/new_game.cpp:46 qt/new_game.cpp:53 qt/new_game.cpp:111
#: qt/new_game.cpp:200 qt/new_game.cpp:203
msgid "Player %1"
msgstr ""
#: qt/new_game.cpp:144 qt/ui/new_game.ui:36
#: qt/new_game.cpp:50
msgid "Name"
msgstr ""
#: qt/new_game.cpp:51
msgid "Type"
msgstr ""
#: qt/new_game.cpp:52
msgid "Level"
msgstr ""
#: qt/new_game.cpp:55
msgid "Eliot"
msgstr ""
#: qt/new_game.cpp:163 qt/ui/new_game.ui:36
msgid "Duplicate"
msgstr ""
@ -1453,43 +1457,43 @@ msgstr ""
msgid "Edit the preferences"
msgstr ""
#: qt/ui/main_window.ui:207
#: qt/ui/main_window.ui:210
msgid "Save"
msgstr ""
#: qt/ui/main_window.ui:215
#: qt/ui/main_window.ui:218
msgid "Load..."
msgstr ""
#: qt/ui/main_window.ui:218
#: qt/ui/main_window.ui:221
msgid "Load an existing game"
msgstr ""
#: qt/ui/main_window.ui:226
#: qt/ui/main_window.ui:229
msgid "Save as..."
msgstr ""
#: qt/ui/main_window.ui:240
#: qt/ui/main_window.ui:243
msgid "External board"
msgstr ""
#: qt/ui/main_window.ui:243
#: qt/ui/main_window.ui:246
msgid "Show/hide the external board"
msgstr ""
#: qt/ui/main_window.ui:254
#: qt/ui/main_window.ui:260
msgid "Show/hide the game history"
msgstr ""
#: qt/ui/main_window.ui:262
#: qt/ui/main_window.ui:268
msgid "Print..."
msgstr ""
#: qt/ui/main_window.ui:265
#: qt/ui/main_window.ui:271
msgid "Print the current game"
msgstr ""
#: qt/ui/main_window.ui:279
#: qt/ui/main_window.ui:285
msgid "Show/hide the dictionary tools"
msgstr ""
@ -1513,11 +1517,15 @@ msgstr ""
msgid "Type:"
msgstr ""
#: qt/ui/new_game.ui:134
#: qt/ui/new_game.ui:130
msgid "Level:"
msgstr ""
#: qt/ui/new_game.ui:154
msgid "Add player"
msgstr ""
#: qt/ui/new_game.ui:157
#: qt/ui/new_game.ui:177
msgid "Remove player"
msgstr ""

110
po/fr.po
View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: eliot 1.7\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-08-31 12:51+0200\n"
"POT-Creation-Date: 2008-09-02 23:17+0200\n"
"PO-Revision-Date: 2008-08-31 10:43+0100\n"
"Last-Translator: Olivier Teuliere <ipkiss@via.ecp.fr>\n"
"Language-Team: French <traduc@traduc.org>\n"
@ -288,8 +288,8 @@ msgstr "résultat :"
msgid "Invalid regular expression: "
msgstr "Expression régulière invalide : "
#: game/training.cpp:49 qt/new_game.cpp:86 qt/new_game.cpp:94
#: qt/new_game.cpp:126 qt/ui/new_game.ui:46
#: game/training.cpp:49 qt/new_game.cpp:96 qt/new_game.cpp:104
#: qt/new_game.cpp:139 qt/ui/new_game.ui:46
msgid "Training"
msgstr "Entraînement"
@ -327,7 +327,7 @@ msgstr "Historique de la partie"
msgid " N | RACK | SOLUTION | REF | PTS | P | BONUS"
msgstr " N | TIRAGE | SOLUTION | REF | PTS | J | BONUS"
#: utils/ncurses.cpp:411 qt/history_widget.cpp:143 qt/main_window.cpp:435
#: utils/ncurses.cpp:411 qt/history_widget.cpp:143 qt/main_window.cpp:442
msgid "(PASS)"
msgstr "(PASSE)"
@ -438,7 +438,7 @@ msgstr " <pgup>, <pgdown> Naviguer dans une boîte page par page"
msgid " Ctrl-l Refresh the screen"
msgstr " Ctrl-l Rafraîchir l'écran"
#: utils/ncurses.cpp:483 wxwin/auxframes.cc:147 qt/main_window.cpp:518
#: utils/ncurses.cpp:483 wxwin/auxframes.cc:147 qt/main_window.cpp:525
#: qt/ui/main_window.ui:188
msgid "Bag"
msgstr "Sac"
@ -840,7 +840,7 @@ msgstr "&Charger...\tCtrl+O"
msgid "&Save as...\tCtrl+S"
msgstr "&Enregistrer sous...\tCtrl+S"
#: wxwin/mainframe.cc:276 qt/ui/main_window.ui:229
#: wxwin/mainframe.cc:276 qt/ui/main_window.ui:232
msgid "Save the current game"
msgstr "Sauvegarder la partie en cours"
@ -880,7 +880,7 @@ msgstr "Quitter Eliot"
msgid "&Dictionary...\tCtrl+D"
msgstr "&Dictionnaire...\tCtrl+D"
#: wxwin/mainframe.cc:287 wxwin/mainframe.cc:604 qt/main_window.cpp:485
#: wxwin/mainframe.cc:287 wxwin/mainframe.cc:604 qt/main_window.cpp:492
msgid "Choose a dictionary"
msgstr "Choisir un dictionnaire"
@ -1088,7 +1088,7 @@ msgstr "Ré&sultats"
msgid "&About..."
msgstr "À &propos..."
#: wxwin/mainframe.cc:331 wxwin/mainframe.cc:733 qt/main_window.cpp:596
#: wxwin/mainframe.cc:331 wxwin/mainframe.cc:733 qt/main_window.cpp:603
#: qt/ui/main_window.ui:161
msgid "About Eliot"
msgstr "À propos d'Eliot"
@ -1286,12 +1286,11 @@ msgstr "Coup"
msgid "Ref"
msgstr "Ref"
#: qt/history_widget.cpp:87 qt/new_game.cpp:49 qt/score_widget.cpp:46
#: qt/ui/new_game.ui:102
#: qt/history_widget.cpp:87 qt/score_widget.cpp:46
msgid "Player"
msgstr "Joueur"
#: qt/main_window.cpp:91 qt/main_window.cpp:536 qt/ui/main_window.ui:40
#: qt/main_window.cpp:91 qt/main_window.cpp:543 qt/ui/main_window.ui:40
msgid "Board"
msgstr "Grille"
@ -1308,7 +1307,7 @@ msgstr "Pas de partie en cours"
msgid "Duplicate game"
msgstr "Partie duplicate"
#: qt/main_window.cpp:201 qt/new_game.cpp:88 qt/new_game.cpp:145
#: qt/main_window.cpp:201 qt/new_game.cpp:98 qt/new_game.cpp:164
#: qt/ui/new_game.ui:41
msgid "Free game"
msgstr "Partie libre"
@ -1329,45 +1328,45 @@ msgstr "Sauvegarder la partie"
msgid "Game saved"
msgstr "Partie enregistrée"
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "N."
msgstr "N."
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "RACK"
msgstr "TIRAGE"
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "SOLUTION"
msgstr "SOLUTION"
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "REF"
msgstr "REF"
#: qt/main_window.cpp:343
#: qt/main_window.cpp:350
msgid "PTS"
msgstr "PTS"
#: qt/main_window.cpp:476
#: qt/main_window.cpp:483
msgid "Stop current game?"
msgstr "Arrêter la partie en cours ?"
#: qt/main_window.cpp:477
#: qt/main_window.cpp:484
msgid ""
"Loading a dictionary will stop the current game. Do you want to continue?"
msgstr ""
"Charger un dictionnaire arrêtera la partie en cours. Voulez-vous continuer ?"
#: qt/main_window.cpp:554 qt/ui/main_window.ui:53 qt/ui/main_window.ui:251
#: qt/main_window.cpp:561 qt/ui/main_window.ui:53 qt/ui/main_window.ui:257
msgid "History"
msgstr "Historique"
#: qt/main_window.cpp:571 qt/ui/main_window.ui:276
#: qt/main_window.cpp:578 qt/ui/main_window.ui:282
msgid "Dictionary tools"
msgstr "Dictionnaire"
msgstr "Outils du dictionnaire"
#: qt/main_window.cpp:588
#: qt/main_window.cpp:595
msgid ""
"Copyright (C) 1999-2008 - Antoine Fraboulet & Olivier Teuliere\n"
"\n"
@ -1383,31 +1382,36 @@ msgstr ""
"publiée par la Free Software Fundation ; soit la version 2 de la Licence, "
"soit (comme vous le préférez), n'importe quelle version ultérieure."
#: qt/new_game.cpp:36 qt/ui/new_game.ui:117
#: qt/new_game.cpp:38 qt/ui/new_game.ui:117
msgid "Human"
msgstr "Humain"
#: qt/new_game.cpp:37 qt/ui/new_game.ui:122
#: qt/new_game.cpp:39 qt/ui/new_game.ui:122
msgid "Computer"
msgstr "Ordinateur"
#: qt/new_game.cpp:47
msgid "Name"
msgstr "Nom"
#: qt/new_game.cpp:48
msgid "Type"
msgstr "Type"
#: qt/new_game.cpp:51
msgid "Eliot"
msgstr "Eliot"
#: qt/new_game.cpp:101
#: qt/new_game.cpp:46 qt/new_game.cpp:53 qt/new_game.cpp:111
#: qt/new_game.cpp:200 qt/new_game.cpp:203
msgid "Player %1"
msgstr "Joueur %1"
#: qt/new_game.cpp:144 qt/ui/new_game.ui:36
#: qt/new_game.cpp:50
msgid "Name"
msgstr "Nom"
#: qt/new_game.cpp:51
msgid "Type"
msgstr "Type"
#: qt/new_game.cpp:52
msgid "Level"
msgstr "Niveau"
#: qt/new_game.cpp:55
msgid "Eliot"
msgstr "Eliot"
#: qt/new_game.cpp:163 qt/ui/new_game.ui:36
msgid "Duplicate"
msgstr "Duplicate"
@ -1491,43 +1495,43 @@ msgstr "&Préférences..."
msgid "Edit the preferences"
msgstr "Modifier les préférences"
#: qt/ui/main_window.ui:207
#: qt/ui/main_window.ui:210
msgid "Save"
msgstr "Sauver"
#: qt/ui/main_window.ui:215
#: qt/ui/main_window.ui:218
msgid "Load..."
msgstr "&Charger..."
#: qt/ui/main_window.ui:218
#: qt/ui/main_window.ui:221
msgid "Load an existing game"
msgstr "Charger une partie existante"
#: qt/ui/main_window.ui:226
#: qt/ui/main_window.ui:229
msgid "Save as..."
msgstr "&Enregistrer sous..."
#: qt/ui/main_window.ui:240
#: qt/ui/main_window.ui:243
msgid "External board"
msgstr "&Plateau de jeu externe"
#: qt/ui/main_window.ui:243
#: qt/ui/main_window.ui:246
msgid "Show/hide the external board"
msgstr "Afficher/cacher le plateau de jeu externe"
#: qt/ui/main_window.ui:254
#: qt/ui/main_window.ui:260
msgid "Show/hide the game history"
msgstr "Afficher/cacher l'historique de la partie"
#: qt/ui/main_window.ui:262
#: qt/ui/main_window.ui:268
msgid "Print..."
msgstr "&Impression..."
#: qt/ui/main_window.ui:265
#: qt/ui/main_window.ui:271
msgid "Print the current game"
msgstr "Imprimer la partie en cours"
#: qt/ui/main_window.ui:279
#: qt/ui/main_window.ui:285
msgid "Show/hide the dictionary tools"
msgstr "Afficher/cacher les outils de recherche dans le dictionnaire"
@ -1551,11 +1555,15 @@ msgstr "Nom :"
msgid "Type:"
msgstr "Type :"
#: qt/ui/new_game.ui:134
#: qt/ui/new_game.ui:130
msgid "Level:"
msgstr "Niveau :"
#: qt/ui/new_game.ui:154
msgid "Add player"
msgstr "Ajouter un joueur"
#: qt/ui/new_game.ui:157
#: qt/ui/new_game.ui:177
msgid "Remove player"
msgstr "Supprimer un joueur"

View file

@ -20,19 +20,24 @@ localedir = $(datadir)/locale
if BUILD_QT
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" @QT_CFLAGS@ -I$(top_srcdir) -I../intl -I$(top_srcdir)/dic -I$(top_srcdir)/game
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" @QT_CFLAGS@ -DQT4LOCALEDIR=\"@QT4LOCALEDIR@\" -I$(top_srcdir) -I../intl -I$(top_srcdir)/dic -I$(top_srcdir)/game
SUFFIXES=.ui.h .moc.cpp
bin_PROGRAMS = qeliot
RESOURCES = \
images/eliot.xpm
EXTRA_DIST = \
ui/dic_tools_widget.ui \
ui/main_window.ui \
ui/new_game.ui \
ui/training_widget.ui \
ui/prefs_dialog.ui \
ui/player_widget.ui \
ui/dic_tools_widget.ui
ui/prefs_dialog.ui \
ui/training_widget.ui \
eliot.qrc \
$(RESOURCES)
BUILT_SOURCES = \
ui/main_window.ui.h \
@ -51,7 +56,8 @@ BUILT_SOURCES = \
training_widget.moc.cpp \
prefs_dialog.moc.cpp \
aux_window.moc.cpp \
main_window.moc.cpp
main_window.moc.cpp \
resources.cpp
qeliot_SOURCES = \
qtcommon.h \
@ -71,6 +77,10 @@ qeliot_SOURCES += $(BUILT_SOURCES)
qeliot_LDADD = @QT_LIBS@ ../game/libgame.a ../dic/libdic.a @LIBINTL@
# Generate a cpp file from the resources
resources.cpp: eliot.qrc $(RESOURCES)
$(RCC) -o $@ $<
# Generate the implementation file from the header
%.moc.cpp: %.h
$(MOC) -o $@ $<

View file

@ -20,6 +20,7 @@
#include "config.h"
#include <QtGui/QApplication>
#include <QtGui/QAction>
#include <QtGui/QWidget>
#include <QtGui/QVBoxLayout>
@ -35,6 +36,7 @@ AuxWindow::AuxWindow(QWidget &iWidget, QString iWindowTitle,
: m_widget(iWidget), m_windowName(iWindowName), m_action(iAction)
{
setWindowTitle(iWindowTitle);
setWindowIcon(qApp->windowIcon());
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(&iWidget);
setLayout(layout);

5
qt/eliot.qrc Normal file
View file

@ -0,0 +1,5 @@
<RCC>
<qresource>
<file>images/eliot.xpm</file>
</qresource>
</RCC>

315
qt/images/eliot.xpm Normal file
View file

@ -0,0 +1,315 @@
/* XPM */
static char * eliot_xpm[] = {
"48 48 264 2",
" c None",
". c #E2E2E2",
"+ c #EFEFEF",
"@ c #EEEFEE",
"# c #EEEEEE",
"$ c #DBDBDB",
"% c #EDEEED",
"& c #D9DAD9",
"* c #FFFFFF",
"= c #CACACA",
"- c #F0F0F0",
"; c #BEBEBE",
"> c #E1E1E1",
", c #C7C7C7",
"' c #BCBCBC",
") c #D3D3D3",
"! c #A3A3A3",
"~ c #F9F9F9",
"{ c #A0A0A0",
"] c #C1C1C1",
"^ c #E0E0E0",
"/ c #B5B5B5",
"( c #D2D2D2",
"_ c #CDCDCD",
": c #B4B4B4",
"< c #B9B9B9",
"[ c #FDFDFD",
"} c #C3C3C3",
"| c #D4D4D4",
"1 c #F5F5F5",
"2 c #969696",
"3 c #EDEDED",
"4 c #A9A9A9",
"5 c #A6A6A6",
"6 c #BFBFBF",
"7 c #A8A8A8",
"8 c #E5E6E5",
"9 c #FBFBFB",
"0 c #E5E2E2",
"a c #E2DFDF",
"b c #E4E3E2",
"c c #E3E3E3",
"d c #DCDCDC",
"e c #E4E5E4",
"f c #E2E3E2",
"g c #E2E4E4",
"h c #CED1D2",
"i c #DEE1E2",
"j c #DEDEDE",
"k c #E5E5E5",
"l c #DFE0DF",
"m c #E4E4E4",
"n c #DFDCDC",
"o c #E4E4E3",
"p c #E0E1E0",
"q c #E0E4E5",
"r c #D5D9D9",
"s c #DFE1E1",
"t c #E4E3E3",
"u c #DEDBDA",
"v c #F6505A",
"w c #DF787D",
"x c #64C0E0",
"y c #1DAEE2",
"z c #20BEF6",
"A c #C3DCE4",
"B c #FAFAFA",
"C c #EAEBEA",
"D c #E3BBBD",
"E c #E19EA2",
"F c #E7E8E7",
"G c #21BDF4",
"H c #51BADF",
"I c #E0868B",
"J c #E3C5C6",
"K c #CC878C",
"L c #E5CFD9",
"M c #CFC6CA",
"N c #7EB9CC",
"O c #52ADCD",
"P c #59BDDF",
"Q c #BACACE",
"R c #AABAD2",
"S c #B5C6E3",
"T c #AAB8CE",
"U c #CEB6B6",
"V c #CDA4A5",
"W c #B2BDCE",
"X c #CECFCF",
"Y c #D1D2D1",
"Z c #59BCDE",
"` c #73B5CC",
" . c #CFC8CB",
".. c #CC8E93",
"+. c #DFCCCD",
"@. c #FF91C5",
"#. c #E5B5CB",
"$. c #EAEAEA",
"%. c #2268E3",
"&. c #1869F6",
"*. c #3171DE",
"=. c #5789DF",
"-. c #DDE0E5",
";. c #E5BED0",
">. c #E5C6D4",
",. c #9A9A9A",
"'. c #CFAABB",
"). c #E5BACE",
"!. c #CFC5CA",
"~. c #D2D3D2",
"{. c #CFD0CF",
"]. c #7B9BD0",
"^. c #7FA3E1",
"/. c #7B9BCC",
"(. c #8DCCE1",
"_. c #9BC1CD",
":. c #AAC5CE",
"<. c #7DA2CC",
"[. c #CCCECF",
"}. c #E3E4E3",
"|. c #CFC9CB",
"1. c #CFC2C8",
"2. c #C9C9C9",
"3. c #E5C9D6",
"4. c #D9E2E5",
"5. c #61BFE0",
"6. c #86CAE1",
"7. c #B4D7E3",
"8. c #E5D3DB",
"9. c #E5B1C9",
"0. c #CFCFCF",
"a. c #CFA4B8",
"b. c #D298B3",
"c. c #E5A6C3",
"d. c #CFC7CA",
"e. c #D4D5D4",
"f. c #CCCFCF",
"g. c #ACD5E3",
"h. c #8EBDCD",
"i. c #82BACC",
"j. c #C3CDCF",
"k. c #E3A5C2",
"l. c #CFA1B7",
"m. c #CFC3C8",
"n. c #89BCCC",
"o. c #C8DADF",
"p. c #ACACAC",
"q. c #D8DBDC",
"r. c #EA85B5",
"s. c #E5D5DC",
"t. c #AFD6E3",
"u. c #8ACBE1",
"v. c #FD90C4",
"w. c #E59DBF",
"x. c #6CC2E0",
"y. c #BBD9E3",
"z. c #D6E1E4",
"A. c #C6CDCF",
"B. c #CFCCCD",
"C. c #D2CCCE",
"D. c #E5DEE1",
"E. c #CF96B0",
"F. c #E591B9",
"G. c #E090B6",
"H. c #C9CECF",
"I. c #CF8DAC",
"J. c #D18BAB",
"K. c #E3DCDF",
"L. c #CFCBCD",
"M. c #C7CECF",
"N. c #DDE0E0",
"O. c #9F9F9F",
"P. c #E59ABD",
"Q. c #FA8FC2",
"R. c #E58EB7",
"S. c #E78AB6",
"T. c #D6D6D6",
"U. c #D9D9D9",
"V. c #D694B3",
"W. c #ED8CB9",
"X. c #E88BB6",
"Y. c #DADBDA",
"Z. c #D689AD",
"`. c #D886AC",
" + c #EBEBEB",
".+ c #F7F8F7",
"++ c #B1C2DD",
"@+ c #1C69EF",
"#+ c #7EA0DB",
"$+ c #DFDFDF",
"%+ c #F2F3F2",
"&+ c #2568DC",
"*+ c #3370D8",
"=+ c #5888D9",
"-+ c #D7DADE",
";+ c #F5F6F5",
">+ c #90ACDC",
",+ c #9FB6DC",
"'+ c #C2C2C2",
")+ c #92B0E2",
"!+ c #A2BAE2",
"~+ c #AEBBCE",
"{+ c #447DDF",
"]+ c #7C9FCC",
"^+ c #C6DDE4",
"/+ c #487ACE",
"(+ c #507ECA",
"_+ c #BDCBCF",
":+ c #C2CCCF",
"<+ c #668ECB",
"[+ c #CACDCF",
"}+ c #CACFCF",
"|+ c #87A7CC",
"1+ c #A1B2CE",
"2+ c #E1E2E1",
"3+ c #BFDAE3",
"4+ c #7BC7E1",
"5+ c #ADADAD",
"6+ c #E2ADB0",
"7+ c #CDADAE",
"8+ c #A3C3CE",
"9+ c #73C4E0",
"0+ c #88BCCC",
"a+ c #90BFCF",
"b+ c #9DD0E2",
"c+ c #C4CDCF",
"d+ c #8CB4C8",
"e+ c #E5C2D2",
"f+ c #9FB4C6",
"g+ c #B6C9CE",
"h+ c #9CCFE0",
"i+ c #8CBDCD",
"j+ c #99C0CD",
"k+ c #CEB1B2",
"l+ c #E0D6D6",
"m+ c #E5CBD7",
"n+ c #E582B1",
"o+ c #E5B9CD",
"p+ c #E7E7E7",
"q+ c #E6E7E6",
"r+ c #CCCCCC",
"s+ c #E8E8E8",
"t+ c #F2F2F2",
"u+ c #989898",
"v+ c #FEFEFE",
"w+ c #E3E4E4",
"x+ c #F1F1F1",
"y+ c #B6B6B6",
"z+ c #DCD9D9",
"A+ c #DADADA",
"B+ c #F7F7F7",
"C+ c #E4D3D4",
"D+ c #E2D8D8",
"E+ c #D5DFE2",
"F+ c #BDCCD1",
"G+ c #CEDFE4",
"H+ c #DFE2E2",
"I+ c #E2DFDE",
"J+ c #E2DCDB",
"K+ c #D3DEE2",
"L+ c #E2D9D9",
"M+ c #F3F0F0",
"N+ c #D7D8D7",
"O+ c #CECFCE",
". + + + @ + + # + @ # + $ @ + # + + # + + % + + # + @ @ + @ # + @ @ + # + @ # + @ @ + # # + + & ",
"+ * * * = * - ; * > , * ' ) * ! ~ * { * * ] * ^ / * ( _ * : < [ } | 1 2 3 = 4 * = 5 * 6 7 * * 8 ",
"+ * 9 0 a b c d e f . g h i e j k k l e 8 f m 0 n o p f e f l e f . q r s f l e f f t a u 1 * 8 ",
"+ + 0 v v w * * 8 * * x y z A * B C * 8 * * D v v E * * 8 * * 8 * F G z H * * 8 * * I v v J * 8 ",
"@ ! 0 v v w * * 8 * * x y z A * B C * 8 * * D v v E * * 8 * * 8 * F G z H * * 8 * * I v v J * 8 ",
"+ * b w w K L L M 8 8 N O P Q 8 p R S T 8 8 U w w V 8 8 W S S X 8 Y Z P ` 8 8 .L L ..w w +.* 8 ",
"+ , 8 * * L @.@.#.* * 8 $.* 8 * B %.&.*.* * 8 * * 8 * * =.&.&.-.* F [ * 8 * * ;.@.@.>.* * 8 * 8 ",
"+ ,.8 * * L @.@.#.* * 8 $.* 8 * B %.&.*.* * 8 * * 8 * * =.&.&.-.* F [ * 8 * * ;.@.@.>.* * 8 * 8 ",
"+ * e 8 8 M #.#.'.).).!.~.8 {.8 p ].^./.(.(._.8 8 :.(.(.<.^.^.[.8 Y }.8 |.).).'.#.#.1.8 8 p * 8 ",
"+ 2.f * * 8 * * ).@.@.3.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 8.@.@.9.* * 8 * * 8 * 8 ",
"+ 0.f * * 8 * * ).@.@.3.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 8.@.@.9.* * 8 * * 8 * 8 ",
"+ * g x x N 8 8 !.3.3.a.b.c.d.8 p e.8 f.g.g.h.x x i.g.g.j.8 8 {.8 Y k.c.l.3.3.m.8 8 n.x x o.* 8 ",
"+ p.q.z z P * * 8 * * c.r.@.s.* B C * 8 * * t.z z u.* * 8 * * 8 * F v.@.w.* * 8 * * x.z z y.* 8 ",
"+ 0.q z z P * * 8 * * c.r.@.s.* B C * 8 * * t.z z u.* * 8 * * 8 * F v.@.w.* * 8 * * x.z z y.* 8 ",
"+ 9 e z.z.A.8 8 {.8 8 B.C.D.E.F.G.e.8 {.8 8 f.z.z.H.8 8 {.8 8 I.F.J.K.D.L.8 8 {.8 8 M.z.z.N.* 8 ",
"+ O.8 * * 8 * * 8 * * 8 $.* P.@.Q.C * 8 * * 8 * * 8 * * 8 * * R.@.S.[ * 8 * * 8 * * 8 * * 8 * 8 ",
"+ . k 3 3 T.3 3 T.3 3 T.U.3 V.W.X.Y.3 T.3 3 T.3 3 T.3 3 T.3 3 Z.W.`. +3 T.3 3 T.3 3 T.3 3 . * 8 ",
"+ j k .+.+++@+@+#+.+.+$+c .+$+.+%+&+@+*+.+.+$+.+.+$+.+.+=+@+@+-+.+> ;+.+$+.+.+>+@+@+,+.+.+m * 8 ",
"+ '+8 * * S &.&.^.* * 8 $.* 8 * B %.&.*.* * 8 * * 8 * * =.&.&.-.* F [ * 8 * * )+&.&.!+* * 8 * 8 ",
"+ * e 8 8 ~+{+{+]+^+^+M.~.8 {.8 p /+{+(+^+^+_+8 8 :+^+^+<+{+{+[+8 Y }.8 }+^+^+|+{+{+1+8 8 p * 8 ",
"@ 0.2+* * 8 * * (.z z g.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 3+z z 4+* * 8 * * 8 * 8 ",
"# 5+Y.* * 8 * * (.z z g.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 3+z z 4+* * 8 * * 8 * 8 ",
"+ * o 6+6+7+8 8 8+9+9+0+a+b+c+8 p e.8 H.9+9+d+e+e+f+9+9+g+8 8 {.8 Y h+b+i+9+9+j+8 8 k+6+6+l+* 8 ",
"+ '+0 v v w * * 8 * * x y z A * B C * 8 * * m+n+n+o+$ ^ 8 p+* 8 6 q+G z H * * 8 * * I v v J * 8 ",
"+ '+0 v v w * * 8 * * x y z A * B C * 8 * * m+v.n+o+$ ^ 8 ) B 8 6 q+G z H * * 8 * * I v v J * 8 ",
"+ * o 6+6+7+8 8 8+9+9+0+a+b+c+8 p e.8 H.9+9+d+e+e+f+9+9+g+8 8 {.8 Y h+b+i+9+9+j+8 8 k+6+6+l+* 8 ",
"+ $+8 * * 8 * * (.z z g.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 3+z z 4+* * 8 * * 8 * 8 ",
"+ # 8 * * 8 * * (.z z g.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 3+z z 4+* * 8 * * 8 * 8 ",
"+ * e 8 8 ~+{+{+]+^+^+M.~.8 {.8 p /+{+(+^+^+_+8 8 :+^+^+<+{+{+[+8 Y }.8 }+^+^+|+{+{+1+8 8 p * 8 ",
"+ r+8 * * S &.&.^.* * 8 $.* 8 * B %.&.*.* * 8 * * 8 * * =.&.&.-.* F [ * 8 * * )+&.&.!+* * 8 * 8 ",
"+ s+k .+.+++@+@+#+.+.+$+c .+$+.+%+&+@+*+.+.+$+.+.+$+.+.+=+@+@+-+.+> ;+.+$+.+.+>+@+@+,+.+.+m * 8 ",
"+ t+}.3 3 T.3 3 T.3 3 T.U.3 V.W.X.Y.3 T.3 3 T.3 3 T.3 3 T.3 3 Z.W.`. +3 T.3 3 T.3 3 T.3 3 . * 8 ",
"+ u+2+* * 8 * * 8 * * 8 $.* P.@.Q.C * 8 * * 8 * * 8 * * 8 * * R.@.S.[ * 8 * * 8 * * 8 * * 8 * 8 ",
"+ v+w+z.z.A.8 8 {.8 8 B.C.D.E.F.G.e.8 {.8 8 f.z.z.H.8 8 {.8 8 I.F.J.K.D.L.8 8 {.8 8 M.z.z.N.* 8 ",
"+ x+q z z P * * 8 * * c.r.@.s.* B C * 8 * * t.z z u.* * 8 * * 8 * F v.@.w.* * 8 * * x.z z y.* 8 ",
"+ } q z z P * * 8 * * c.r.@.s.* B C * 8 * * t.z z u.* * 8 * * 8 * F v.@.w.* * 8 * * x.z z y.* 8 ",
"+ * g x x N 8 8 !.3.3.a.b.c.d.8 p e.8 f.g.g.h.x x i.g.g.j.8 8 {.8 Y k.c.l.3.3.m.8 8 n.x x o.* 8 ",
"# ( Y * * 8 * * ).@.@.3.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 8.@.@.9.* * 8 * * 8 * 8 ",
"% y+r+* * 8 * * ).@.@.3.$.* 8 * B C * 4.z z 5.* * 6.z z 7.* * 8 * F [ * 8.@.@.9.* * 8 * * 8 * 8 ",
"+ * e 8 8 M #.#.'.).).!.~.8 {.8 p ].^./.(.(._.8 8 :.(.(.<.^.^.[.8 Y }.8 |.).).'.#.#.1.8 8 p * 8 ",
"+ p.8 * * L @.@.#.* * 8 $.* 8 * B %.&.*.* * 8 * * 8 * * =.&.&.-.* F [ * 8 * * ;.@.@.>.* * 8 * 8 ",
"+ = 8 * * L @.@.#.* * 8 $.* 8 * B %.&.*.* * 8 * * 8 * * =.&.&.-.* F [ * 8 * * ;.@.@.>.* * 8 * 8 ",
"+ * b w w K L L M 8 8 N O P Q 8 p R S T 8 8 U w w V 8 8 W S S X 8 Y Z P ` 8 8 .L L ..w w +.* 8 ",
"# 4 z+v v w * * 8 * * x y z A * B C * 8 * * D v v E * * 8 * * 8 * F G z H * * 8 * * I v v J * 8 ",
"+ A+0 v v w * * 8 * * x y z A * B C * 8 * * D v v E * * 8 * * 8 * F G z H * * 8 * * I v v J * 8 ",
"+ * B+C+C+D+8 8 f 8 8 E+F+G+H+8 e c 8 f 8 8 I+C+C+J+8 8 f 8 8 f 8 c G+G+K+8 8 f 8 8 L+C+C+M+* 8 ",
"+ * * * * * * * * * * * $.* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 8 ",
"N+. . . . . . . . . . . 0.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O+"};

View file

@ -20,23 +20,39 @@
#include "config.h"
#include <qapplication.h>
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include "main_window.h"
int main(int argc, char **argv)
{
#if HAVE_SETLOCALE
#ifdef HAVE_SETLOCALE
// Set locale via LC_ALL
setlocale(LC_ALL, "");
#endif
#if ENABLE_NLS
QApplication app(argc, argv);
app.setWindowIcon(QIcon(":/images/eliot.xpm"));
#ifdef ENABLE_NLS
// Set the message domain
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
// Translations for Qt's own strings
QTranslator translator;
// Set the path for the translation file
#if !defined( WIN32 )
QString path = QString(QT4LOCALEDIR);
#else
QString path = QString(LOCALEDIR) + "/qt4/";
#endif
QString lang = QLocale::system().name();
translator.load(path + "qt_" + lang);
app.installTranslator(&translator);
#endif
QApplication app(argc, argv);
MainWindow qmain;
qmain.move(200, 200);
qmain.show();

View file

@ -318,30 +318,38 @@ void MainWindow::on_action_GameSaveAs_triggered()
}
// Printing parameters
#define TOTAL_WIDTH 500
#define LINE_HEIGHT 20
#define FONT_SIZE 12
#define PEN_WIDTH 2
#define TEXT_OFFSET 10
#define SHOULD_ALIGN false
void MainWindow::on_action_GamePrint_triggered()
{
if (m_game == NULL)
return;
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName("/home/ipkiss/dev/eliot/qt-intf/linux/print.pdf");
QPrintDialog printDialog(&printer, this);
if (printDialog.exec() == QDialog::Accepted)
{
QPainter painter(&printer);
const History &history = m_game->getHistory();
const int colWidths[] = { 30, 150, 150, 70, 70 };
const char *colTitles[] = { _("N."), _("RACK"), _("SOLUTION"), _("REF"), _("PTS") };
const unsigned int nbCols = sizeof(colWidths) / sizeof(int);
// Printing parameters (XXX: these could be configurable by the users)
// Number of pixels virtually present on the page width. The bigger
// this number, the smaller the print result
static const int TOTAL_WIDTH = 700;
// Distance between 2 horizontal lines
static const int LINE_HEIGHT = 16;
// Font size, in pixels
static const int FONT_SIZE = 10;
// Width of the pen used to draw the grid lines
static const int PEN_WIDTH = 1;
// Offset of the text from the previous vertical line, in pixels
static const int TEXT_OFFSET = 10;
// Indicate whether the rack and the solution should be aligned
static const bool SHOULD_ALIGN = false;
// Columns widths
static const int colWidths[] = { 30, 120, 120, 35, 35 };
// Columns titles
static const char *colTitles[] = { _("N."), _("RACK"), _("SOLUTION"), _("REF"), _("PTS") };
static const unsigned int nbCols = sizeof(colWidths) / sizeof(int);
const unsigned int nbRows = history.getSize() + (SHOULD_ALIGN ? 1 : 2);
double scale = printer.pageRect().width() / double(TOTAL_WIDTH);
@ -353,7 +361,6 @@ void MainWindow::on_action_GamePrint_triggered()
QFont font;
font.setPixelSize(FONT_SIZE);
//QFont font(painter.font(), &painter);
painter.setFont(font);
int maxRight = 0;
@ -451,7 +458,7 @@ void MainWindow::on_action_GamePrint_triggered()
}
// Total score
curHeight += LINE_HEIGHT;
nextHeight += LINE_HEIGHT;
painter.drawText(curWidth, nextHeight, QString("%1").arg(score));
}
}

View file

@ -21,6 +21,8 @@
#include <QtGui/QStandardItemModel>
#include <QtGui/QKeyEvent>
#include <QtGui/QMessageBox>
#include <QtGui/QComboBox>
#include <QtGui/QSpinBox>
#include "new_game.h"
#include "qtcommon.h"
@ -41,21 +43,30 @@ NewGame::NewGame(QWidget *iParent)
: QDialog(iParent)
{
setupUi(this);
lineEditName->setText(_q("Player %1").arg(2));
// Initialize the model of the default players
m_model = new QStandardItemModel(2, 2, this);
m_model = new QStandardItemModel(2, 3, this);
m_model->setHeaderData(0, Qt::Horizontal, _q("Name"), Qt::DisplayRole);
m_model->setHeaderData(1, Qt::Horizontal, _q("Type"), Qt::DisplayRole);
m_model->setData(m_model->index(0, 0), _q("Player"));
m_model->setHeaderData(2, Qt::Horizontal, _q("Level"), Qt::DisplayRole);
m_model->setData(m_model->index(0, 0), _q("Player %1").arg(1));
m_model->setData(m_model->index(0, 1), _q(kHUMAN));
m_model->setData(m_model->index(1, 0), _q("Eliot"));
m_model->setData(m_model->index(1, 1), _q(kAI));
m_model->setData(m_model->index(1, 2), 100);
// Initialize the QTreeView with the model we just created
treeViewPlayers->setModel(m_model);
PlayersDelegate *delegate = new PlayersDelegate(this);
treeViewPlayers->setItemDelegateForColumn(1, delegate);
PlayersTypeDelegate *typeDelegate = new PlayersTypeDelegate(this);
treeViewPlayers->setItemDelegateForColumn(1, typeDelegate);
PlayersLevelDelegate *levelDelegate = new PlayersLevelDelegate(this);
treeViewPlayers->setItemDelegateForColumn(2, levelDelegate);
treeViewPlayers->resizeColumnToContents(2);
// Enable the Level spinbox only when the player is a computer
QObject::connect(comboBoxType, SIGNAL(currentIndexChanged(int)),
this, SLOT(enableLevelSpinBox(int)));
// Enable the Remove button only when there is a selection in the tree
QObject::connect(treeViewPlayers->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
@ -116,7 +127,10 @@ Game * NewGame::createGame(const Dictionary &iDic) const
if (type == _q(kHUMAN))
player = new HumanPlayer;
else
player = new AIPercent(1);
{
double level = m_model->data(m_model->index(num, 2)).toInt();
player = new AIPercent(level / 100.);
}
player->setName(qtw(name));
game->addPlayer(player);
}
@ -134,6 +148,12 @@ Game * NewGame::createGame(const Dictionary &iDic) const
}
void NewGame::enableLevelSpinBox(int index)
{
spinBoxLevel->setEnabled(index == 1);
}
void NewGame::enableOkButton()
{
// Enable the "Ok" button:
@ -173,6 +193,16 @@ void NewGame::on_pushButtonAdd_clicked()
// Change the contents of the row
m_model->setData(m_model->index(rowNum, 0), lineEditName->displayText());
m_model->setData(m_model->index(rowNum, 1), comboBoxType->currentText());
if (spinBoxLevel->isEnabled())
m_model->setData(m_model->index(rowNum, 2), spinBoxLevel->value());
// Increment the player ID
static int currPlayer = 2;
if (lineEditName->displayText() == _q("Player %1").arg(currPlayer))
{
++currPlayer;
lineEditName->setText(_q("Player %1").arg(currPlayer));
}
}
@ -186,13 +216,13 @@ void NewGame::on_pushButtonRemove_clicked()
PlayersDelegate::PlayersDelegate(QObject *parent)
PlayersTypeDelegate::PlayersTypeDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
QWidget *PlayersDelegate::createEditor(QWidget *parent,
QWidget *PlayersTypeDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &,
const QModelIndex &) const
{
@ -203,7 +233,7 @@ QWidget *PlayersDelegate::createEditor(QWidget *parent,
}
void PlayersDelegate::setEditorData(QWidget *editor,
void PlayersTypeDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QComboBox *combo = static_cast<QComboBox*>(editor);
@ -212,16 +242,22 @@ void PlayersDelegate::setEditorData(QWidget *editor,
}
void PlayersDelegate::setModelData(QWidget *editor,
void PlayersTypeDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
QComboBox *combo = static_cast<QComboBox*>(editor);
model->setData(index, combo->currentText());
// Adapt the level to the chosen type of player
QModelIndex levelIndex = model->index(index.row(), 2);
if (combo->currentText() == _q(NewGame::kHUMAN))
model->setData(levelIndex, QVariant());
else
model->setData(levelIndex, 100);
}
void PlayersDelegate::updateEditorGeometry(QWidget *editor,
void PlayersTypeDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &) const
{
@ -230,8 +266,56 @@ void PlayersDelegate::updateEditorGeometry(QWidget *editor,
PlayersEventFilter::PlayersEventFilter(QObject *parent)
: QObject(parent)
PlayersLevelDelegate::PlayersLevelDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
QWidget *PlayersLevelDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &,
const QModelIndex &index) const
{
// Allow changing the level only for computer players, i.e.
// if there is a level defined
if (index.model()->data(index, Qt::DisplayRole).isNull())
return NULL;
QSpinBox *editor = new QSpinBox(parent);
editor->setMinimum(0);
editor->setMaximum(100);
return editor;
}
void PlayersLevelDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
int value = index.model()->data(index, Qt::DisplayRole).toInt();
spinBox->setValue(value);
}
void PlayersLevelDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
model->setData(index, spinBox->value());
}
void PlayersLevelDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &) const
{
editor->setGeometry(option.rect);
}
PlayersEventFilter::PlayersEventFilter(QObject *parent)
: QObject(parent)
{
}

View file

@ -49,6 +49,7 @@ public:
Game * createGame(const Dictionary& iDic) const;
private slots:
void enableLevelSpinBox(int);
void enableOkButton();
void enableRemoveButton(const QItemSelection&, const QItemSelection&);
@ -63,14 +64,39 @@ private:
};
/// Delegate used for the edition of the players display
class PlayersDelegate: public QItemDelegate
/// Delegate used for the edition of the players type
class PlayersTypeDelegate: public QItemDelegate
{
Q_OBJECT;
public:
explicit PlayersDelegate(QObject *parent = 0);
virtual ~PlayersDelegate() {}
explicit PlayersTypeDelegate(QObject *parent = 0);
virtual ~PlayersTypeDelegate() {}
// Implement the needed methods
virtual QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor,
const QModelIndex &index) const;
virtual void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;
virtual void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
};
/// Delegate used for the edition of the players level
class PlayersLevelDelegate: public QItemDelegate
{
Q_OBJECT;
public:
explicit PlayersLevelDelegate(QObject *parent = 0);
virtual ~PlayersLevelDelegate() {}
// Implement the needed methods
virtual QWidget *createEditor(QWidget *parent,

View file

@ -36,12 +36,18 @@
// Convert to/from utf-8 char*
#define qfu(s) QString::fromUtf8(s)
#define qtu(s) (s).toUtf8().data()
// Convert to/from std::wstring
#define qfw(s) QString::fromStdWString(s)
#define qtw(s) (s).toStdWString().data()
// Convert to/from local encoding
#define qfl(s) QString::fromLocal8Bit(s)
#define qtl(s) (s).toLocal8Bit().data()
// Convert to/from std::wstring
#ifdef WIN32
#include "encoding.h"
#define qfw(s) qfl(convertToMb(s).c_str())
#define qtw(s) convertToWc(qtl(s))
#else
#define qfw(s) QString::fromStdWString(s)
#define qtw(s) (s).toStdWString().data()
#endif
// Translation macro to use gettext
#define _q(s) qfu(_(s))

View file

@ -13,8 +13,8 @@
<string>Eliot</string>
</property>
<property name="windowIcon" >
<iconset>
<normaloff>../../../bzr-cppdic/wxwin/eliot.xpm</normaloff>../../../bzr-cppdic/wxwin/eliot.xpm</iconset>
<iconset resource="../eliot.qrc" >
<normaloff>:/images/eliot.xpm</normaloff>:/images/eliot.xpm</iconset>
</property>
<widget class="QWidget" name="centralwidget" >
<property name="geometry" >
@ -201,6 +201,9 @@
<property name="statusTip" >
<string>_("Edit the preferences")</string>
</property>
<property name="shortcut" >
<string>Ctrl+F</string>
</property>
</action>
<action name="action_GameSave" >
<property name="text" >
@ -242,6 +245,9 @@
<property name="statusTip" >
<string>_("Show/hide the external board")</string>
</property>
<property name="shortcut" >
<string>Ctrl+E</string>
</property>
</action>
<action name="action_WindowsHistory" >
<property name="checkable" >
@ -283,7 +289,9 @@
</property>
</action>
</widget>
<resources/>
<resources>
<include location="../eliot.qrc" />
</resources>
<connections>
<connection>
<sender>action_GameQuit</sender>

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<height>327</height>
<width>470</width>
<height>390</height>
</rect>
</property>
<property name="windowTitle" >
@ -99,7 +99,7 @@
<item>
<widget class="QLineEdit" name="lineEditName" >
<property name="text" >
<string>_("Player")</string>
<string>Player 2</string>
</property>
</widget>
</item>
@ -124,6 +124,26 @@
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>_("Level:")</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxLevel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="value" >
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>