[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/qt eliot.qrc main_window.cpp main_window....
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot/qt eliot.qrc main_window.cpp main_window.... |
Date: |
Sat, 29 Nov 2008 16:41:01 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 08/11/29 16:41:01
Modified files:
qt : eliot.qrc main_window.cpp main_window.h
qt/ui : main_window.ui
Added files:
qt/images : first.xpm last.xpm next.xpm prev.xpm replay.xpm
Log message:
- The actions on the game history are now available in the menu and
the toolbar
- The toolbar can be shown/hidden via a menu entry
- Added icons for all the history actions
- Ask for confirmation before replaying a turn
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/eliot.qrc?cvsroot=eliot&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/main_window.cpp?cvsroot=eliot&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/main_window.h?cvsroot=eliot&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/images/first.xpm?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/images/last.xpm?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/images/next.xpm?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/images/prev.xpm?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/images/replay.xpm?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/ui/main_window.ui?cvsroot=eliot&r1=1.12&r2=1.13
Patches:
Index: eliot.qrc
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/eliot.qrc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- eliot.qrc 3 Sep 2008 17:28:27 -0000 1.1
+++ eliot.qrc 29 Nov 2008 16:40:59 -0000 1.2
@@ -1,5 +1,10 @@
<RCC>
<qresource>
<file>images/eliot.xpm</file>
+ <file>images/first.xpm</file>
+ <file>images/last.xpm</file>
+ <file>images/prev.xpm</file>
+ <file>images/next.xpm</file>
+ <file>images/replay.xpm</file>
</qresource>
</RCC>
Index: main_window.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/main_window.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- main_window.cpp 23 Nov 2008 16:55:29 -0000 1.18
+++ main_window.cpp 29 Nov 2008 16:41:00 -0000 1.19
@@ -153,15 +153,6 @@
emit gameChangedNonConst(NULL);
emit gameChanged(NULL);
- QObject::connect(m_ui.buttonFirst, SIGNAL(clicked()),
- this, SLOT(onGameFirst()));
- QObject::connect(m_ui.buttonPrev, SIGNAL(clicked()),
- this, SLOT(onGamePrev()));
- QObject::connect(m_ui.buttonNext, SIGNAL(clicked()),
- this, SLOT(onGameNext()));
- QObject::connect(m_ui.buttonLast, SIGNAL(clicked()),
- this, SLOT(onGameLast()));
-
// Load dictionary
QSettings qs(ORGANIZATION, PACKAGE_NAME);
QString dicPath = qs.value(PrefsDialog::kINTF_DIC_PATH, "").toString();
@@ -211,25 +202,19 @@
void MainWindow::refresh()
{
- if (m_game == NULL)
- {
- m_ui.buttonFirst->setEnabled(false);
- m_ui.buttonPrev->setEnabled(false);
- m_ui.buttonNext->setEnabled(false);
- m_ui.buttonLast->setEnabled(false);
- // XXX: tmp
- m_ui.labelTurnNb->setText("");
- }
- else
+ if (m_game != NULL)
{
bool isFirstTurn = m_game->getNavigation().isFirstTurn();
bool isLastTurn = m_game->getNavigation().isLastTurn();
- m_ui.buttonFirst->setEnabled(!isFirstTurn);
- m_ui.buttonPrev->setEnabled(!isFirstTurn);
- m_ui.buttonNext->setEnabled(!isLastTurn);
- m_ui.buttonLast->setEnabled(!isLastTurn);
- // XXX: tmp
- m_ui.labelTurnNb->setText(QString("Turn:
%1").arg(m_game->getNavigation().getCurrTurn()));
+ m_actionHistoryFirstTurn->setEnabled(!isFirstTurn);
+ m_actionHistoryPrevTurn->setEnabled(!isFirstTurn);
+ m_actionHistoryNextTurn->setEnabled(!isLastTurn);
+ m_actionHistoryLastTurn->setEnabled(!isLastTurn);
+ m_actionHistoryReplayTurn->setEnabled(!isLastTurn);
+#ifdef DEBUG
+ cout << endl << endl;
+ m_game->getNavigation().print();
+#endif
}
}
@@ -240,6 +225,11 @@
{
m_actionGameSaveAs->setEnabled(false);
m_actionGamePrint->setEnabled(false);
+ m_actionHistoryFirstTurn->setEnabled(false);
+ m_actionHistoryPrevTurn->setEnabled(false);
+ m_actionHistoryNextTurn->setEnabled(false);
+ m_actionHistoryLastTurn->setEnabled(false);
+ m_actionHistoryReplayTurn->setEnabled(false);
setWindowTitle(_q("No game") + " - Eliot");
}
else
@@ -332,12 +322,13 @@
QAction * MainWindow::addMenuAction(QMenu *menu, QString iText,
const QKeySequence &iShortcut,
QString iStatusTip, const char *iMember,
- bool iCheckable)
+ bool iCheckable, QIcon icon)
{
QAction *action = new QAction(iText, this);
action->setShortcut(iShortcut);
action->setStatusTip(iStatusTip);
action->setCheckable(iCheckable);
+ action->setIcon(icon);
QObject::connect(action, SIGNAL(triggered()), this, iMember);
menu->addAction(action);
return action;
@@ -363,6 +354,32 @@
addMenuAction(menuFile, _q("&Quit"), _q("Ctrl+Q"),
_q("Quit Eliot"), SLOT(close()));
+ QMenu *menuHistory = new QMenu(m_ui.menubar);
+ m_ui.menubar->addAction(menuHistory->menuAction());
+ menuHistory->setTitle(_q("&History"));
+ m_actionHistoryFirstTurn = addMenuAction(menuHistory, _q("&First turn"),
_q("Ctrl+Home"),
+ _q("Go to the first turn of the game"),
SLOT(onHistoryFirstTurn()),
+ false, QIcon(":/images/first.xpm"));
+ m_actionHistoryPrevTurn = addMenuAction(menuHistory, _q("&Previous turn"),
_q("Ctrl+Left"),
+ _q("Go to the previous turn of the game"),
SLOT(onHistoryPrevTurn()),
+ false, QIcon(":/images/prev.xpm"));
+ m_actionHistoryNextTurn = addMenuAction(menuHistory, _q("&Next turn"),
_q("Ctrl+Right"),
+ _q("Go to the next turn of the game"),
SLOT(onHistoryNextTurn()),
+ false, QIcon(":/images/next.xpm"));
+ m_actionHistoryLastTurn = addMenuAction(menuHistory, _q("&Last turn"),
_q("Ctrl+End"),
+ _q("Go to the last turn of the game"),
SLOT(onHistoryLastTurn()),
+ false, QIcon(":/images/last.xpm"));
+ m_actionHistoryReplayTurn = addMenuAction(menuHistory, _q("&Replay turn"),
_q("Ctrl+R"),
+ _q("Play the game from the current position, "
+ "replacing what was really played"),
SLOT(onHistoryReplayTurn()),
+ false, QIcon(":/images/replay.xpm"));
+ // Add actions to the toolbar
+ m_ui.toolBar->addAction(m_actionHistoryFirstTurn);
+ m_ui.toolBar->addAction(m_actionHistoryPrevTurn);
+ m_ui.toolBar->addAction(m_actionHistoryNextTurn);
+ m_ui.toolBar->addAction(m_actionHistoryLastTurn);
+ m_ui.toolBar->addAction(m_actionHistoryReplayTurn);
+
QMenu *menuSettings = new QMenu(m_ui.menubar);
m_ui.menubar->addAction(menuSettings->menuAction());
menuSettings->setTitle(_q("&Settings"));
@@ -374,6 +391,9 @@
QMenu *menuWindows = new QMenu(m_ui.menubar);
m_ui.menubar->addAction(menuWindows->menuAction());
menuWindows->setTitle(_q("&Windows"));
+ m_actionWindowsToolbar = addMenuAction(menuWindows, _q("&Toolbar"),
_q("Ctrl+T"),
+ _q("Show/hide the toolbar"), SLOT(onWindowsToolbar()), true);
+ m_actionWindowsToolbar->setChecked(true);
m_actionWindowsBag = addMenuAction(menuWindows, _q("&Bag"), _q("Ctrl+B"),
_q("Show/hide the remaining tiles in the bag"),
SLOT(onWindowsBag()), true);
m_actionWindowsBoard = addMenuAction(menuWindows, _q("&External board"),
_q("Ctrl+E"),
@@ -663,6 +683,15 @@
}
+void MainWindow::onWindowsToolbar()
+{
+ if (m_ui.toolBar->isVisible())
+ m_ui.toolBar->hide();
+ else
+ m_ui.toolBar->show();
+}
+
+
void MainWindow::onWindowsBag()
{
if (m_bagWindow == NULL)
@@ -747,13 +776,13 @@
"the License, or (at your option) any later version.");
// QMessageBox::about() doesn't add the nice information icon, so we create
// the box manually (not much work...)
- QMessageBox *aboutBox = new QMessageBox(QMessageBox::Information,
- _q("About Eliot"), msg,
QMessageBox::Ok, this);
- aboutBox->exec();
+ QMessageBox aboutBox(QMessageBox::Information, _q("About Eliot"),
+ msg, QMessageBox::Ok, this);
+ aboutBox.exec();
}
-void MainWindow::onGameFirst()
+void MainWindow::onHistoryFirstTurn()
{
if (m_game == NULL)
return;
@@ -763,7 +792,7 @@
}
-void MainWindow::onGamePrev()
+void MainWindow::onHistoryPrevTurn()
{
if (m_game == NULL)
return;
@@ -773,7 +802,7 @@
}
-void MainWindow::onGameNext()
+void MainWindow::onHistoryNextTurn()
{
if (m_game == NULL)
return;
@@ -783,7 +812,7 @@
}
-void MainWindow::onGameLast()
+void MainWindow::onHistoryLastTurn()
{
if (m_game == NULL)
return;
@@ -792,3 +821,24 @@
emit gameUpdated();
}
+
+void MainWindow::onHistoryReplayTurn()
+{
+ if (m_game == NULL)
+ return;
+
+ // Ask for a confirmation, because this may lead to data loss
+ QString msg = _q("Replaying this turn will modify the game history "
+ "by deleting the turns \"in the future\".");
+ QMessageBox confirmationBox(QMessageBox::Question, _q("Eliot"), msg,
+ QMessageBox::Ok | QMessageBox::Cancel, this);
+ confirmationBox.setInformativeText(_q("Do you want to continue?"));
+ int ret = confirmationBox.exec();
+ if (ret != QMessageBox::Ok)
+ return;
+
+ m_game->accessNavigation().clearFuture();
+ emit gameUpdated();
+ displayInfoMsg(_q("Future turns deleted"));
+}
+
Index: main_window.h
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/main_window.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- main_window.h 23 Nov 2008 16:55:29 -0000 1.12
+++ main_window.h 29 Nov 2008 16:41:00 -0000 1.13
@@ -67,16 +67,18 @@
void onGamePrint();
void onSettingsChooseDic();
void onSettingsPreferences();
+ void onWindowsToolbar();
void onWindowsBag();
void onWindowsBoard();
void onWindowsHistory();
void onWindowsDicTools();
void onHelpAbout();
- void onGameFirst();
- void onGamePrev();
- void onGameNext();
- void onGameLast();
+ void onHistoryFirstTurn();
+ void onHistoryPrevTurn();
+ void onHistoryNextTurn();
+ void onHistoryLastTurn();
+ void onHistoryReplayTurn();
/** Perform some updates when the game is updated */
void refresh();
@@ -109,6 +111,12 @@
/// Actions enabled or disabled depending on the game state
QAction *m_actionGamePrint;
QAction *m_actionGameSaveAs;
+ QAction *m_actionHistoryPrevTurn;
+ QAction *m_actionHistoryNextTurn;
+ QAction *m_actionHistoryFirstTurn;
+ QAction *m_actionHistoryLastTurn;
+ QAction *m_actionHistoryReplayTurn;
+ QAction *m_actionWindowsToolbar;
static const char * m_windowName;
@@ -136,7 +144,7 @@
QAction * addMenuAction(QMenu *menu, QString iText,
const QKeySequence &iShortcut,
QString iStatusTip, const char *iMember,
- bool iCheckable = false);
+ bool iCheckable = false, QIcon icon = QIcon());
/// Create the menu bar and the actions
void createMenu();
Index: ui/main_window.ui
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/ui/main_window.ui,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- ui/main_window.ui 23 Nov 2008 16:55:29 -0000 1.12
+++ ui/main_window.ui 29 Nov 2008 16:41:01 -0000 1.13
@@ -19,58 +19,6 @@
<widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" >
<item>
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <item>
- <widget class="QPushButton" name="buttonFirst" >
- <property name="text" >
- <string>First</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonPrev" >
- <property name="text" >
- <string>Prev</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonNext" >
- <property name="text" >
- <string>Next</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonLast" >
- <property name="text" >
- <string>Last</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelTurnNb" >
- <property name="text" >
- <string>Turn: </string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
<layout class="QHBoxLayout" >
<item>
<widget class="QGroupBox" name="groupBoxTest" >
@@ -121,6 +69,20 @@
</property>
</widget>
<widget class="QStatusBar" name="statusbar" />
+ <widget class="QToolBar" name="toolBar" >
+ <property name="contextMenuPolicy" >
+ <enum>Qt::ActionsContextMenu</enum>
+ </property>
+ <property name="windowTitle" >
+ <string>toolBar</string>
+ </property>
+ <attribute name="toolBarArea" >
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak" >
+ <bool>false</bool>
+ </attribute>
+ </widget>
<action name="action_WindowsBag" >
<property name="checkable" >
<bool>true</bool>
Index: images/first.xpm
===================================================================
RCS file: images/first.xpm
diff -N images/first.xpm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ images/first.xpm 29 Nov 2008 16:41:00 -0000 1.1
@@ -0,0 +1,36 @@
+/* XPM */
+static char * prev_xpm[] = {
+"16 16 17 1",
+"* c None",
+". c #000000",
+"+ c #800000",
+"@ c #008000",
+"# c #808000",
+"$ c #000080",
+"% c #800080",
+"& c #008080",
+" c #C0C0C0",
+"= c #808080",
+"- c #FF0000",
+"; c #00FF00",
+"> c #FFFF00",
+", c #0000FF",
+"' c #FF00FF",
+") c #00FFFF",
+"! c #FFFFFF",
+"****************",
+"****************",
+"****************",
+"****************",
+"**.****.****.***",
+"**.***..***..***",
+"**.**...**...***",
+"**.*....*....***",
+"**.**...**...***",
+"**.***..***..***",
+"**.****.****.***",
+"****************",
+"****************",
+"****************",
+"****************",
+"****************"};
Index: images/last.xpm
===================================================================
RCS file: images/last.xpm
diff -N images/last.xpm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ images/last.xpm 29 Nov 2008 16:41:00 -0000 1.1
@@ -0,0 +1,36 @@
+/* XPM */
+static char * next_xpm[] = {
+"16 16 17 1",
+"* c None",
+". c #000000",
+"+ c #800000",
+"@ c #008000",
+"# c #808000",
+"$ c #000080",
+"% c #800080",
+"& c #008080",
+" c #C0C0C0",
+"= c #808080",
+"- c #FF0000",
+"; c #00FF00",
+"> c #FFFF00",
+", c #0000FF",
+"' c #FF00FF",
+") c #00FFFF",
+"! c #FFFFFF",
+"****************",
+"****************",
+"****************",
+"****************",
+"**.****.****.***",
+"**..***..***.***",
+"**...**...**.***",
+"**....*....*.***",
+"**...**...**.***",
+"**..***..***.***",
+"**.****.****.***",
+"****************",
+"****************",
+"****************",
+"****************",
+"****************"};
Index: images/next.xpm
===================================================================
RCS file: images/next.xpm
diff -N images/next.xpm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ images/next.xpm 29 Nov 2008 16:41:00 -0000 1.1
@@ -0,0 +1,36 @@
+/* XPM */
+static char * play_xpm[] = {
+"16 16 17 1",
+"* c None",
+". c #000000",
+"+ c #800000",
+"@ c #008000",
+"# c #808000",
+"$ c #000080",
+"% c #800080",
+"& c #008080",
+" c #C0C0C0",
+"= c #808080",
+"- c #FF0000",
+"; c #00FF00",
+"> c #FFFF00",
+", c #0000FF",
+"' c #FF00FF",
+") c #00FFFF",
+"! c #FFFFFF",
+"****************",
+"****************",
+"***..***********",
+"***....*********",
+"***......*******",
+"***........*****",
+"***..........***",
+"***...........**",
+"***..........***",
+"***........*****",
+"***......*******",
+"***....*********",
+"***..***********",
+"****************",
+"****************",
+"****************"};
Index: images/prev.xpm
===================================================================
RCS file: images/prev.xpm
diff -N images/prev.xpm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ images/prev.xpm 29 Nov 2008 16:41:00 -0000 1.1
@@ -0,0 +1,36 @@
+/* XPM */
+static char * play_xpm[] = {
+"16 16 17 1",
+"* c None",
+". c #000000",
+"+ c #800000",
+"@ c #008000",
+"# c #808000",
+"$ c #000080",
+"% c #800080",
+"& c #008080",
+" c #C0C0C0",
+"= c #808080",
+"- c #FF0000",
+"; c #00FF00",
+"> c #FFFF00",
+", c #0000FF",
+"' c #FF00FF",
+") c #00FFFF",
+"! c #FFFFFF",
+"****************",
+"****************",
+"***********..***",
+"*********....***",
+"*******......***",
+"*****........***",
+"***..........***",
+"**...........***",
+"***..........***",
+"*****........***",
+"*******......***",
+"*********....***",
+"***********..***",
+"****************",
+"****************",
+"****************"};
Index: images/replay.xpm
===================================================================
RCS file: images/replay.xpm
diff -N images/replay.xpm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ images/replay.xpm 29 Nov 2008 16:41:00 -0000 1.1
@@ -0,0 +1,37 @@
+/* XPM */
+static char *replay_xpm[] = {
+"16 16 17 1",
+" c None",
+"B c #000000",
+"C c #800000",
+"D c #008000",
+"E c #808000",
+"F c #000080",
+"G c #800080",
+"H c #008080",
+"I c #C0C0C0",
+"J c #808080",
+"K c #FF0000",
+"L c #00FF00",
+"M c #FFFF00",
+"N c #0000FF",
+"O c #FF00FF",
+"P c #00FFFF",
+"Q c #FFFFFF",
+" ",
+" B ",
+" BB ",
+"BBB BB BB BBBBB ",
+"BBB BB BB BBBBB ",
+" BB BB ",
+" BB B ",
+" BB ",
+" BB ",
+" BB B ",
+" BB BB ",
+" BBBBBBBBBBBBBB ",
+" BBBBBBBBBBBBBB ",
+" BB ",
+" B ",
+" "
+};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/qt eliot.qrc main_window.cpp main_window....,
Olivier Teulière <=