[SCM] knights packaging branch, master, updated. upstream/2.2.0-14-g11e1936
José Manuel Santamaría Lema
santa-guest at alioth.debian.org
Fri Feb 18 17:35:45 UTC 2011
The following commit has been merged in the master branch:
commit 11e1936e92734005e4fac780094e21f4dbdc18f7
Author: José Manuel Santamaría Lema <panfaust at gmail.com>
Date: Fri Feb 18 17:04:22 2011 +0100
Add 04_stop_clock_game_over.diff
---
debian/changelog | 1 +
debian/patches/04_stop_clock_game_over.diff | 224 +++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 226 insertions(+), 0 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 178281f..5ddb303 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,7 @@ knights (2.2.0-1) UNRELEASED; urgency=low
* Remove 01_add_categories_to_desktop_file.diff, no longer needed.
* Add 02_no_hotnewstuff.diff.
* Add 03_dont_crash_fics.diff.
+ * Add 04_stop_clock_game_over.diff.
-- José Manuel Santamaría Lema <panfaust at gmail.com> Thu, 17 Feb 2011 12:29:35 +0100
diff --git a/debian/patches/04_stop_clock_game_over.diff b/debian/patches/04_stop_clock_game_over.diff
new file mode 100644
index 0000000..1119d09
--- /dev/null
+++ b/debian/patches/04_stop_clock_game_over.diff
@@ -0,0 +1,224 @@
+Author: José Manuel Santamaría Lema <panfaust at gmail.com>
+Description: This patch stops the clock when game finish.
+Forwarded: no
+--- a/src/knights.cpp
++++ b/src/knights.cpp
+@@ -170,6 +170,8 @@
+
+ connect ( m_view, SIGNAL ( activePlayerChanged ( Color ) ), playerClock, SLOT ( setActivePlayer ( Color ) ) );
+ connect ( m_view, SIGNAL ( displayedPlayerChanged ( Color ) ), playerClock, SLOT ( setDisplayedPlayer ( Color ) ) );
++ connect ( m_view, SIGNAL ( gameNew () ), playerClock, SLOT ( enableClock() ) );
++ connect ( m_view, SIGNAL ( gameOver () ), playerClock, SLOT ( disableClock() ) );
+
+ bool protocolEmitsGameOver = m_protocol && m_protocol->supportedFeatures() & Protocol::GameOver;
+ if ( !protocolEmitsGameOver )
+--- a/src/knightsview.cpp
++++ b/src/knightsview.cpp
+@@ -87,6 +87,7 @@
+ kDebug() << "Received gameOver() from " << sender()->metaObject()->className();
+ QString text;
+ QString caption;
++ emit gameOver();
+ if ( winner == NoColor )
+ {
+ text = i18n ( "The game ended in a draw" );
+--- a/src/knightsview.h
++++ b/src/knightsview.h
+@@ -84,6 +84,10 @@
+ void activePlayerChanged ( Color );
+ void displayedPlayerChanged ( Color );
+
++ //Other signals
++
++ void gameOver();
++
+ private slots:
+ void settingsChanged();
+ void resizeScene();
+--- a/src/clockwidget.cpp
++++ b/src/clockwidget.cpp
+@@ -6,7 +6,7 @@
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License or (at your option) version 3 or any later version
+- accepted by the membership of KDE e.V. (or its successor approved
++ accepted by the membership of KDE e.V. (or its successor approved
+ by the membership of KDE e.V.), which shall act as a proxy
+ defined in Section 14 of version 3 of the license.
+
+@@ -40,6 +40,7 @@
+
+ m_timeIncrement[White] = 0;
+ m_timeIncrement[Black] = 0;
++ m_disabled = false;
+ }
+
+ ClockWidget::~ClockWidget()
+@@ -49,15 +50,17 @@
+
+ void ClockWidget::setActivePlayer ( Color color )
+ {
+- killTimer ( m_timerId[m_activePlayer] );
+- if ( !m_started [ color ] )
+- {
+- m_started [ color ] = true;
+- return;
++ if (!m_disabled) {
++ killTimer ( m_timerId[m_activePlayer] );
++ if ( !m_started [ color ] )
++ {
++ m_started [ color ] = true;
++ return;
++ }
++ incrementTime ( m_activePlayer, m_timeIncrement[m_activePlayer] );
++ m_timerId[color] = startTimer ( timerInterval );
++ m_activePlayer = color;
+ }
+- incrementTime ( m_activePlayer, m_timeIncrement[m_activePlayer] );
+- m_timerId[color] = startTimer ( timerInterval );
+- m_activePlayer = color;
+ }
+
+ void ClockWidget::setDisplayedPlayer ( Color color )
+@@ -83,20 +86,22 @@
+
+ void ClockWidget::setCurrentTime ( Color color, const QTime& time )
+ {
+- m_currentTime[color] = time;
++ if (!m_disabled) {
++ m_currentTime[color] = time;
++
++ const int miliSeconds = time.hour() * 3600 * 1000 + time.minute() * 60 * 1000 + time.second() * 1000 + time.msec();
++ const int units = miliSeconds / timerInterval;
++ QProgressBar* bar = ( color == White ) ? ui->progressW : ui->progressB;
++ if ( units > bar->maximum() )
++ {
++ bar->setMaximum ( units );
++ }
++ bar->setValue ( units );
++ bar->setFormat ( time.toString( QLatin1String("h:mm:ss") ) );
+
+- const int miliSeconds = time.hour() * 3600 * 1000 + time.minute() * 60 * 1000 + time.second() * 1000 + time.msec();
+- const int units = miliSeconds / timerInterval;
+- QProgressBar* bar = ( color == White ) ? ui->progressW : ui->progressB;
+- if ( units > bar->maximum() )
+- {
+- bar->setMaximum ( units );
++ Clock* clock = ( color == White ) ? ui->clockW : ui->clockB;
++ clock->setTime ( time );
+ }
+- bar->setValue ( units );
+- bar->setFormat ( time.toString( QLatin1String("h:mm:ss") ) );
+-
+- Clock* clock = ( color == White ) ? ui->clockW : ui->clockB;
+- clock->setTime ( time );
+ }
+
+ void ClockWidget::setTimeLimit ( Color color, const QTime& time )
+@@ -124,43 +129,63 @@
+
+ void ClockWidget::incrementTime ( Color color, int miliseconds )
+ {
+- switch ( color )
+- {
+- case White:
+- setCurrentTime ( White, m_currentTime[White].addMSecs ( miliseconds ) );
+- if ( ui->progressW->value() <= 0 )
+- {
+- emit timeOut ( White );
+- emit opponentTimeOut ( Black );
+- }
+- break;
+- case Black:
+- setCurrentTime ( Black, m_currentTime[Black].addMSecs ( miliseconds ) );
+- if ( ui->progressB->value() <= 0 )
+- {
+- emit timeOut ( Black );
+- emit opponentTimeOut ( White );
+- }
+- break;
+- default:
+- break;
++ if (!m_disabled) {
++ switch ( color )
++ {
++ case White:
++ setCurrentTime ( White, m_currentTime[White].addMSecs ( miliseconds ) );
++ if ( ui->progressW->value() <= 0 )
++ {
++ emit timeOut ( White );
++ emit opponentTimeOut ( Black );
++ }
++ break;
++ case Black:
++ setCurrentTime ( Black, m_currentTime[Black].addMSecs ( miliseconds ) );
++ if ( ui->progressB->value() <= 0 )
++ {
++ emit timeOut ( Black );
++ emit opponentTimeOut ( White );
++ }
++ break;
++ default:
++ break;
++ }
+ }
+ }
+
+ void Knights::ClockWidget::timerEvent ( QTimerEvent* event )
+ {
+ Q_UNUSED ( event )
+- incrementTime ( m_activePlayer, -timerInterval );
++ if (!m_disabled) {
++ incrementTime ( m_activePlayer, -timerInterval );
++ }
+ }
+
+ void ClockWidget::pauseClock()
+ {
+- killTimer ( m_timerId[m_activePlayer] );
++ if (!m_disabled) {
++ killTimer ( m_timerId[m_activePlayer] );
++ }
+ }
+
+ void ClockWidget::resumeClock()
+ {
+- m_timerId[m_activePlayer] = startTimer ( timerInterval );
++ if (!m_disabled) {
++ m_timerId[m_activePlayer] = startTimer ( timerInterval );
++ }
++}
++
++void ClockWidget::disableClock()
++{
++ killTimer ( m_timerId[Black] );
++ killTimer ( m_timerId[White] );
++ m_disabled = true;
++}
++
++void ClockWidget::enableClock()
++{
++ m_disabled = false;
+ }
+
+ // kate: indent-mode cstyle; space-indent on; indent-width 4; replace-tabs on; replace-tabs on; replace-tabs on;
+--- a/src/clockwidget.h
++++ b/src/clockwidget.h
+@@ -56,6 +56,9 @@
+ void pauseClock();
+ void resumeClock();
+
++ void disableClock();
++ void enableClock();
++
+ Q_SIGNALS:
+ void timeOut ( Color );
+ void opponentTimeOut ( Color );
+@@ -73,6 +76,7 @@
+ QMap<Color, QGroupBox*> m_box;
+ QMap<Color, int> m_timeIncrement;
+ QMap<Color, bool> m_started;
++ bool m_disabled;
+ };
+ }
+
diff --git a/debian/patches/series b/debian/patches/series
index ea39d55..1b043e5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
02_no_hotnewstuff.diff
03_dont_crash_fics.diff
+04_stop_clock_game_over.diff
--
knights packaging
More information about the pkg-kde-commits
mailing list