[knights] patch for new kdegames version in rawhide
Julian Aloofi
julian at fedoraproject.org
Fri Jun 15 15:04:06 UTC 2012
commit a90a24f1c0c12f40b6417056a2d40d868c921333
Author: Julian Aloofi <julian.aloofi at googlemail.com>
Date: Fri Jun 15 16:36:16 2012 +0200
patch for new kdegames version in rawhide
knights-kdegames5.patch | 1104 +++++++++++++++++++++++++++++++++++++++++++++++
knights.spec | 19 +-
2 files changed, 1115 insertions(+), 8 deletions(-)
---
diff --git a/knights-kdegames5.patch b/knights-kdegames5.patch
new file mode 100644
index 0000000..a33e12d
--- /dev/null
+++ b/knights-kdegames5.patch
@@ -0,0 +1,1104 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e952eea..bf2d595 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,9 +1,8 @@
+ project(Knights)
+
+ find_package(KDE4 REQUIRED)
+-find_package(LibKDEGames REQUIRED)
++find_package(KDEGames REQUIRED)
+ include (KDE4Defaults)
+-# TODO: check for gnuchess
+
+ set(CMAKE_CXX_FLAGS_PROFILE "-fprofile-arcs -ftest-coverage -pg")
+ add_definitions( -DQT_NO_CAST_FROM_ASCII )
+@@ -12,23 +11,6 @@ add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+
+ include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} ${KDEGAMES_INCLUDE_DIRS} )
+
+-if (${KDE_VERSION} VERSION_GREATER "4.6.0")
+- option(KGR "Use KGameRenderer" ON)
+- option(OCS_ABOUT "Use the social about dialog" ON)
+-endif (${KDE_VERSION} VERSION_GREATER "4.6.0")
+-
+-if (${KDE_VERSION} VERSION_GREATER "4.7.0")
+- option(MESSAGE_WIDGET "Use a new styled widget for offers" ON)
+-endif (${KDE_VERSION} VERSION_GREATER "4.7.0")
+-
+-set(QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
+-if (${QT_VERSION} VERSION_GREATER "4.6.0")
+- option(ANIMATIONS "Use Qt Animations" ON)
+-endif()
+-
+-macro_log_feature(ANIMATIONS "Qt Animation Framework" "Support for property animations in Qt"
+- "http://qt.nokia.com" FALSE "4.6.0" "Animated moving of pieces")
+-
+ add_subdirectory( src )
+ add_subdirectory( icons )
+ add_subdirectory( themes )
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 8acd8f5..6d77801 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -1,7 +1,6 @@
+ set(knights_SRCS
+ core/pos.cpp
+ core/move.cpp
+- core/renderer.cpp
+ core/item.cpp
+ core/piece.cpp
+
+@@ -35,26 +34,6 @@ set(knights_SRCS
+ main.cpp
+ )
+
+-if (KGR)
+- add_definitions(-DWITH_KGR)
+-endif (KGR)
+-
+-if (OCS_ABOUT)
+- add_definitions(-DWITH_OCS)
+-endif (OCS_ABOUT)
+-
+-if (${QT_VERSION} VERSION_GREATER "4.6.0")
+- add_definitions(-DWITH_QT_46)
+-endif()
+-
+-if (ANIMATIONS)
+- add_definitions(-DWITH_ANIMATIONS)
+-endif()
+-
+-if (MESSAGE_WIDGET)
+- add_definitions(-DWITH_KMW)
+-endif()
+-
+ kde4_add_ui_files(knights_SRCS
+ knightsview_base.ui
+ prefs_base.ui
+@@ -76,8 +55,6 @@ kde4_add_executable(knights ${knights_SRCS})
+
+ target_link_libraries(knights ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_PLASMA_LIBS} ${KDE4_SOLID_LIBS} ${KDEGAMES_LIBRARY} ${QT_QTNETWORK_LIBRARY})
+
+-#add_subdirectory(qml)
+-
+ install(TARGETS knights ${INSTALL_TARGETS_DEFAULT_ARGS} )
+
+ ########### install files ###############
+diff --git a/src/board.cpp b/src/board.cpp
+index 3fdf3fc..775cfd8 100644
+--- a/src/board.cpp
++++ b/src/board.cpp
+@@ -24,11 +24,14 @@
+
+ #include "core/pos.h"
+ #include "core/move.h"
++#include "core/item.h"
+ #include "rules/rules.h"
++
+ #include "ui_promotiondialog.h"
+ #include "gamemanager.h"
+
+-#include <KGameTheme>
++#include <KgTheme>
++#include <KGameRenderer>
+ #include <KDebug>
+ #include <KDialog>
+
+@@ -40,8 +43,6 @@
+ #include <QtGui/QGraphicsView>
+ #include <QtCore/qmath.h>
+
+-#include "core/item.h"
+-#include "core/renderer.h"
+
+ using namespace Knights;
+
+@@ -68,9 +69,10 @@ const QString blackLettersKey = QLatin1String ( "BlackLetters" );
+ const QString whiteNumbersKey = QLatin1String ( "WhiteNumbers" );
+ const QString blackNumbersKey = QLatin1String ( "BlackNumbers" );
+
+-Board::Board ( QObject* parent ) : QGraphicsScene ( parent )
++Board::Board ( KgThemeProvider* provider, QObject* parent ) : QGraphicsScene ( parent ),
++m_themeProvider(provider)
+ {
+- renderer = new Renderer ( Settings::theme() );
++ renderer = new KGameRenderer ( m_themeProvider );
+ m_background = 0;
+ selectedPiece = 0;
+ draggedPiece = 0;
+@@ -78,6 +80,8 @@ Board::Board ( QObject* parent ) : QGraphicsScene ( parent )
+ m_currentPlayer = White;
+ updateTheme();
+ m_dragActive = false;
++
++ connect (provider, SIGNAL(currentThemeChanged(const KgTheme*)), SLOT(updateTheme()));
+ }
+
+ Board::~Board()
+@@ -495,22 +499,6 @@ void Board::addMarker ( const Pos& pos, const QString& spriteKey )
+
+ void Board::updateTheme()
+ {
+- renderer->setTheme ( Settings::theme() );
+-#if not defined WITH_KGR
+- // Using QGraphicsSvgItems, loading a new file and then resizing does not work
+- // instead, we have to delete every item and re-create it
+- foreach ( Piece* p, m_grid )
+- {
+- addPiece ( p->pieceType(), p->color(), m_grid.key ( p ) );
+- delete p;
+- }
+- // If the user is changing the theme, he/she probably already saw any current markers
+- qDeleteAll ( markers );
+- markers.clear();
+-
+- qDeleteAll ( m_tiles );
+- m_tiles.clear();
+-#endif
+ delete m_background;
+ if ( renderer->spriteExists ( backgroundKey ) )
+ {
+@@ -730,5 +718,6 @@ PieceType Board::getPromotedType()
+ }
+ return Queen;
+ }
++
+ #include "board.moc"
+ // kate: indent-mode cstyle; space-indent on; indent-width 4; replace-tabs on; replace-tabs on; replace-tabs on;
+diff --git a/src/board.h b/src/board.h
+index 1839c52..d464bd1 100644
+--- a/src/board.h
++++ b/src/board.h
+@@ -25,6 +25,8 @@
+ #include "core/piece.h"
+ #include "core/move.h"
+
++#include <KgThemeProvider>
++
+ #include <QtGui/QGraphicsScene>
+ #include <QtCore/QMap>
+ #include <QtCore/QSet>
+@@ -55,14 +57,14 @@ namespace Knights
+ Motion
+ };
+
+- Board ( QObject* parent = 0 );
++ Board ( KgThemeProvider* provider, QObject* parent = 0 );
+ virtual ~Board();
+
+ void populate();
+
+ static bool isInBoard ( const Pos& pos );
+ Colors playerColors() const;
+-
++
+ private:
+ Rules *m_rules;
+ Grid m_grid;
+@@ -72,7 +74,8 @@ namespace Knights
+ Item* m_background;
+ bool m_displayBorders;
+ bool m_displayNotations;
+- Renderer* renderer;
++ KGameRenderer* renderer;
++ KgThemeProvider* m_themeProvider;
+
+ void addPiece ( PieceType type, Color color, const Pos& pos );
+ void addMarker ( const Pos& pos, MarkerType type );
+diff --git a/src/core/item.cpp b/src/core/item.cpp
+index e4e7378..30fe74e 100644
+--- a/src/core/item.cpp
++++ b/src/core/item.cpp
+@@ -22,13 +22,12 @@
+ #include "item.h"
+ #include "board.h"
+ #include "settings.h"
++
+ #include <KDebug>
+
+-#ifdef WITH_ANIMATIONS
+-# include <QtCore/QPropertyAnimation>
+-# include <QtCore/QParallelAnimationGroup>
+-# include <qmath.h>
+-#endif
++#include <QtCore/QPropertyAnimation>
++#include <QtCore/QParallelAnimationGroup>
++#include <qmath.h>
+
+ using namespace Knights;
+
+@@ -36,8 +35,7 @@ static const int fastAnimationDuration = 150;
+ static const int normalAnimationDuration = 250;
+ static const int slowAnimationDuration = 400;
+
+-#if defined WITH_KGR
+-Item::Item ( Renderer* renderer, const QString &key, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parentItem ) : KGameRenderedObjectItem ( renderer, key, parentItem )
++Item::Item ( KGameRenderer* renderer, const QString &key, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parentItem ) : KGameRenderedObjectItem ( renderer, key, parentItem )
+ {
+ setBoardPos ( boardPos );
+ if ( scene )
+@@ -46,55 +44,6 @@ Item::Item ( Renderer* renderer, const QString &key, QGraphicsScene* scene, Pos
+ }
+ }
+
+-#else // WITH_KGR
+-
+-#include <QtSvg/QSvgRenderer>
+-
+-Item::Item ( Renderer* renderer, const QString &key, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parentItem )
+- : QGraphicsSvgItem ( parentItem )
+-#if not defined WITH_QT_46
+- , m_rotation(0.0)
+-#endif
+-{
+- setSharedRenderer ( renderer );
+- setSpriteKey ( key );
+- setBoardPos ( boardPos );
+- setCacheMode ( DeviceCoordinateCache );
+- if ( scene )
+- {
+- scene->addItem ( this );
+- }
+-}
+-
+-void Item::setRenderSize ( const QSize& size )
+-{
+- resetTransform();
+- QRectF normalSize = renderer()->boundsOnElement ( spriteKey() );
+- qreal xScale = size.width() / normalSize.width();
+- qreal yScale = size.height() / normalSize.height();
+- prepareGeometryChange();
+- setTransform ( QTransform().scale ( xScale, yScale ) );
+-#if not defined WITH_QT_46
+- rotate(m_rotation);
+-#endif
+-}
+-
+-QSize Item::renderSize() const
+-{
+- return transform().mapRect ( boundingRect() ).size().toSize();
+-}
+-
+-void Item::setSpriteKey ( const QString& key )
+-{
+- setElementId ( key );
+-}
+-
+-QString Item::spriteKey() const
+-{
+- return elementId();
+-}
+-#endif // WITH_KGR
+-
+ Item::~Item()
+ {
+ if ( scene() )
+@@ -115,7 +64,6 @@ void Item::setBoardPos ( const Pos& pos )
+
+ void Item::move ( const QPointF& pos, qreal tileSize, bool animated )
+ {
+-#if defined WITH_ANIMATIONS
+ if ( !animated || Settings::animationSpeed() == Settings::EnumAnimationSpeed::Instant )
+ {
+ setPos ( pos );
+@@ -144,16 +92,10 @@ void Item::move ( const QPointF& pos, qreal tileSize, bool animated )
+ anim->setEndValue ( pos );
+ anim->start ( QAbstractAnimation::DeleteWhenStopped );
+ }
+-#else
+- Q_UNUSED ( animated );
+- Q_UNUSED ( tileSize );
+- setPos ( pos );
+-#endif
+ }
+
+ void Item::resize ( const QSize& size, bool animated )
+ {
+-#if defined WITH_ANIMATIONS
+ if ( !animated || Settings::animationSpeed() == Settings::EnumAnimationSpeed::Instant )
+ {
+ setRenderSize ( size );
+@@ -181,15 +123,10 @@ void Item::resize ( const QSize& size, bool animated )
+ anim->setEndValue ( size );
+ anim->start ( QAbstractAnimation::DeleteWhenStopped );
+ }
+-#else
+- Q_UNUSED ( animated );
+- setRenderSize ( size );
+-#endif
+ }
+
+ void Item::moveAndResize ( const QPointF& pos, qreal tileSize, const QSize& size, bool animated )
+ {
+-#if defined WITH_ANIMATIONS
+ if ( !animated || Settings::animationSpeed() == Settings::EnumAnimationSpeed::Instant )
+ {
+ setPos ( pos );
+@@ -226,29 +163,6 @@ void Item::moveAndResize ( const QPointF& pos, qreal tileSize, const QSize& size
+ group->addAnimation ( sizeAnimation );
+ group->start ( QAbstractAnimation::DeleteWhenStopped );
+ }
+-#else
+- Q_UNUSED ( animated );
+- Q_UNUSED ( tileSize );
+- setPos ( pos );
+- setRenderSize ( size );
+-#endif
+-}
+-
+-#if not defined WITH_QT_46
+-
+-void Item::setRotation ( qreal angle )
+-{
+- kDebug() << angle;
+- m_rotation = angle;
+-}
+-
+-qreal Item::rotation()
+-{
+- return m_rotation;
+ }
+
+-#endif
+-
+-
+-
+ // kate: indent-mode cstyle; space-indent on; indent-width 4; replace-tabs on; replace-tabs on;
+diff --git a/src/core/item.h b/src/core/item.h
+index 9b5b557..f05bfde 100644
+--- a/src/core/item.h
++++ b/src/core/item.h
+@@ -22,44 +22,23 @@
+ #ifndef KNIGHTS_ITEM_H
+ #define KNIGHTS_ITEM_H
+
+-#include "renderer.h"
+ #include "pos.h"
+
+-#ifdef WITH_KGR
+-#define ItemBaseType KGameRenderedObjectItem
+ #include <KGameRenderedObjectItem>
+-#else
+-#define ItemBaseType QGraphicsSvgItem
+-#include <QtSvg/QGraphicsSvgItem>
+-#endif
+
+ namespace Knights
+ {
+
+- class Item : public ItemBaseType
++ class Item : public KGameRenderedObjectItem
+ {
+ Q_OBJECT
+ Q_PROPERTY ( Pos boardPos READ boardPos WRITE setBoardPos )
+ Q_PROPERTY ( QSize renderSize READ renderSize WRITE setRenderSize )
+
+ public:
+- Item ( Renderer* renderer, const QString& key, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parentItem = 0 );
++ Item ( KGameRenderer* renderer, const QString& key, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parentItem = 0 );
+ virtual ~Item();
+
+-#if not defined WITH_KGR
+- // Duplicating the KGameRenderedObjectItem API to minimize #ifdef's in Board
+- void setRenderSize ( const QSize& size );
+- QSize renderSize() const;
+- void setSpriteKey ( const QString& key );
+- QString spriteKey() const;
+-
+-# ifndef WITH_QT_46
+- void setRotation ( qreal angle );
+- qreal rotation();
+-# endif
+-
+-#endif // WITH_KGR
+-
+ void setBoardPos ( const Pos& pos );
+ Pos boardPos() const;
+
+@@ -70,9 +49,6 @@ namespace Knights
+ private:
+ Pos m_pos;
+
+-#ifndef WITH_QT_46
+- qreal m_rotation;
+-#endif
+ };
+ }
+ #endif // KNIGHTS_ITEM_H
+diff --git a/src/core/piece.cpp b/src/core/piece.cpp
+index df73cea..4564ae8 100644
+--- a/src/core/piece.cpp
++++ b/src/core/piece.cpp
+@@ -23,10 +23,6 @@
+
+ #include <KLocale>
+
+-#include <QtGui/QPainter>
+-#include <QtGui/QStyleOption>
+-#include <QtSvg/QSvgRenderer>
+-
+ namespace Knights
+ {
+
+@@ -119,7 +115,7 @@ namespace Knights
+ }
+
+
+- Piece::Piece ( Renderer* renderer, PieceType type, Color color, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parent ) :
++ Piece::Piece ( KGameRenderer* renderer, PieceType type, Color color, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parent ) :
+ Item ( renderer, spriteKey ( type, color ), scene, boardPos, parent )
+ {
+ m_color = color;
+diff --git a/src/core/piece.h b/src/core/piece.h
+index 3be1f30..0bbc0ce 100644
+--- a/src/core/piece.h
++++ b/src/core/piece.h
+@@ -55,7 +55,7 @@ namespace Knights
+ {
+ Q_OBJECT
+ public:
+- Piece ( Renderer* renderer, PieceType type, Color color, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parent = 0 );
++ Piece ( KGameRenderer* renderer, PieceType type, Color color, QGraphicsScene* scene, Pos boardPos, QGraphicsItem* parent = 0 );
+ virtual ~Piece();
+
+ PieceType pieceType();
+diff --git a/src/core/renderer.cpp b/src/core/renderer.cpp
+deleted file mode 100644
+index 14e688b..0000000
+--- a/src/core/renderer.cpp
++++ /dev/null
+@@ -1,71 +0,0 @@
+-/*
+- This file is part of Knights, a chess board for KDE SC 4.
+- Copyright 2009,2010,2011 Miha Čančula <miha at noughmad.eu>
+-
+- This program is free software; you can redistribute it and/or
+- 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
+- by the membership of KDE e.V.), which shall act as a proxy
+- defined in Section 14 of version 3 of the license.
+-
+- This program is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- GNU General Public License for more details.
+-
+- You should have received a copy of the GNU General Public License
+- along with this program. If not, see <http://www.gnu.org/licenses/>.
+-*/
+-
+-#include "renderer.h"
+-
+-using namespace Knights;
+-
+-#if defined WITH_KGR
+-
+-Renderer::Renderer ( const QString& defaultTheme ) : KGameRenderer ( QLatin1String("themes/default.desktop") )
+-{
+- setTheme ( defaultTheme );
+-}
+-Renderer::~Renderer ()
+-{
+-
+-}
+-
+-#else
+-#include <KGameTheme>
+-
+-Renderer::Renderer ( const QString& defaultTheme )
+-{
+- m_theme = new KGameTheme;
+- setTheme ( defaultTheme );
+-}
+-
+-Renderer::~Renderer()
+-{
+- delete m_theme;
+-}
+-
+-bool Renderer::spriteExists ( const QString& key )
+-{
+- return elementExists ( key );
+-}
+-
+-QRectF Renderer::boundsOnSprite ( const QString& key )
+-{
+- return boundsOnElement ( key );
+-}
+-
+-void Renderer::setTheme ( const QString& theme )
+-{
+- if ( !m_theme->load ( theme ) )
+- {
+- m_theme->loadDefault();
+- }
+- load ( m_theme->graphics() );
+-}
+-
+-#endif // WITH_KGR
+-// kate: indent-mode cstyle; space-indent on; indent-width 4; replace-tabs on; replace-tabs on;
+diff --git a/src/core/renderer.h b/src/core/renderer.h
+deleted file mode 100644
+index deace54..0000000
+--- a/src/core/renderer.h
++++ /dev/null
+@@ -1,59 +0,0 @@
+-/*
+- This file is part of Knights, a chess board for KDE SC 4.
+- Copyright 2009,2010,2011 Miha Čančula <miha at noughmad.eu>
+-
+- This program is free software; you can redistribute it and/or
+- 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
+- by the membership of KDE e.V.), which shall act as a proxy
+- defined in Section 14 of version 3 of the license.
+-
+- This program is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+- GNU General Public License for more details.
+-
+- You should have received a copy of the GNU General Public License
+- along with this program. If not, see <http://www.gnu.org/licenses/>.
+-*/
+-
+-#ifndef KNIGHTS_RENDERER_H
+-#define KNIGHTS_RENDERER_H
+-
+-#include "kdeversion.h"
+-#if defined WITH_KGR
+-#include <KGameRenderer>
+-#define RendererBaseType KGameRenderer
+-#else
+-#include <QtSvg/QSvgRenderer>
+-#define RendererBaseType QSvgRenderer
+-#endif
+-
+-class KGameTheme;
+-
+-namespace Knights
+-{
+- class Renderer : public RendererBaseType
+- {
+- Q_OBJECT
+- public:
+- Renderer ( const QString& defaultTheme );
+- virtual ~Renderer();
+-
+-#if not defined WITH_KGR
+- bool spriteExists ( const QString& key );
+- QRectF boundsOnSprite ( const QString& key );
+-
+- public Q_SLOTS:
+- void setTheme ( const QString& theme );
+- private:
+- KGameTheme* m_theme;
+-#endif
+-
+- };
+-}
+-
+-#endif // KNIGHTS_RENDERER_H
+-// kate: indent-mode cstyle; space-indent on; indent-width 4; replace-tabs on;
+diff --git a/src/gamemanager.cpp b/src/gamemanager.cpp
+index 1028dfc..b7019b3 100644
+--- a/src/gamemanager.cpp
++++ b/src/gamemanager.cpp
+@@ -38,6 +38,7 @@
+ #include <KMessageBox>
+ #include <KStandardGuiItem>
+ #include <KApplication>
++#include <KgDifficulty>
+
+ #include <QStack>
+ #include <QTimer>
+@@ -85,6 +86,7 @@ public:
+ QString filename;
+ Color winner;
+ bool winnerNotified;
++ bool initComplete;
+
+ int nextOfferId();
+ };
+@@ -308,6 +310,7 @@ void Manager::initialize()
+ {
+ Q_D(GameManager);
+ d->gameStarted = false;
++ d->initComplete = false;
+ d->winnerNotified = false;
+ d->running = false;
+ d->activePlayer = White;
+@@ -463,7 +466,11 @@ void Manager::protocolInitSuccesful()
+ Protocol::white()->setPlayerName ( i18nc ( "The player of this color", "White" ) );
+ Protocol::black()->setPlayerName ( i18nc ( "The player of this color", "Black" ) );
+ }
+- emit initComplete();
++ if (!d->initComplete)
++ {
++ d->initComplete = true;
++ emit initComplete();
++ }
+ }
+ }
+ }
+@@ -471,7 +478,9 @@ void Manager::protocolInitSuccesful()
+ void Manager::startGame()
+ {
+ Q_D(GameManager);
+- levelChanged ( KGameDifficulty::level() );
++ kDebug() << d->gameStarted << QThread::currentThread();
++ Q_ASSERT(!d->gameStarted);
++ levelChanged ( Kg::difficulty()->currentLevel() );
+ Protocol::white()->startGame();
+ Protocol::black()->startGame();
+ d->gameStarted = true;
+@@ -852,33 +861,34 @@ bool Manager::canLocalMove() const
+ return false;
+ }
+
+-void Manager::levelChanged ( KGameDifficulty::standardLevel level )
++void Manager::levelChanged ( const KgDifficultyLevel* level )
+ {
++ kDebug();
+ int depth = 0;
+ int size = 32;
+- switch ( level )
++ switch ( level->standardLevel() )
+ {
+- case KGameDifficulty::VeryEasy:
++ case KgDifficultyLevel::VeryEasy:
+ depth = 1;
+ break;
+
+- case KGameDifficulty::Easy:
++ case KgDifficultyLevel::Easy:
+ depth = 3;
+ break;
+
+- case KGameDifficulty::Medium:
++ case KgDifficultyLevel::Medium:
+ depth = 8;
+ break;
+
+- case KGameDifficulty::Hard:
++ case KgDifficultyLevel::Hard:
+ depth = 16;
+ break;
+
+- case KGameDifficulty::VeryHard:
++ case KgDifficultyLevel::VeryHard:
+ depth = 32;
+ break;
+
+- case KGameDifficulty::Configurable:
++ case KgDifficultyLevel::Custom:
+ // Open the dialog for the user to specify custom difficulty parameters
+ if ( !getCustomDifficulty(&depth, &size) )
+ {
+diff --git a/src/gamemanager.h b/src/gamemanager.h
+index 0ed47aa..fe7f883 100644
+--- a/src/gamemanager.h
++++ b/src/gamemanager.h
+@@ -24,16 +24,16 @@
+
+ #include <core/piece.h>
+ #include <core/move.h>
+-
+-#include <QtCore/QObject>
+-#include <QtCore/QTime>
++#include "offerwidget.h"
+
+ #include <KGlobal>
+-#include "offerwidget.h"
+-#include <KGameDifficulty>
++
++#include <QObject>
++#include <QTime>
+ #include <QStack>
+
+ class QAbstractListModel;
++class KgDifficultyLevel;
+
+ namespace Knights {
+
+@@ -169,7 +169,7 @@ public slots:
+
+ void setTimeRunning(bool running);
+
+- void levelChanged ( KGameDifficulty::standardLevel level );
++ void levelChanged ( const KgDifficultyLevel* level );
+ void setDifficulty ( int searchDepth, int memorySize );
+
+ void saveGameHistoryAs(const QString& filename);
+diff --git a/src/knights.cpp b/src/knights.cpp
+index 0cd9821..b1de8b9 100644
+--- a/src/knights.cpp
++++ b/src/knights.cpp
+@@ -24,10 +24,15 @@
+ #include "core/piece.h"
+ #include "proto/xboardprotocol.h"
+ #include "proto/ficsprotocol.h"
++#include "proto/localprotocol.h"
++#include "rules/chessrules.h"
++#include "gamemanager.h"
+ #include "knightsview.h"
+ #include "settings.h"
+ #include "gamedialog.h"
+ #include "clockwidget.h"
++#include "historywidget.h"
++#include "enginesettings.h"
+
+ #include <KConfigDialog>
+ #include <KStatusBar>
+@@ -35,24 +40,19 @@
+ #include <KActionCollection>
+ #include <KStandardAction>
+ #include <KToggleAction>
+-#include <KGameThemeSelector>
+-#include <KStandardGameAction>
+ #include <KLocale>
+ #include <KMessageBox>
+ #include <KFileDialog>
+-
+-#include <QtGui/QDropEvent>
+-#include <QtCore/QTimer>
+-#include <QtGui/QDockWidget>
+-#include "proto/localprotocol.h"
+ #include <KUser>
+-#include "gamemanager.h"
+-#include "rules/chessrules.h"
+-#include <KGameDifficulty>
++#include <KgDifficulty>
++#include <KgThemeSelector>
++#include <KStandardGameAction>
++
++#include <QDropEvent>
++#include <QTimer>
++#include <QDockWidget>
+ #include <QListView>
+ #include <QStringListModel>
+-#include "historywidget.h"
+-#include "enginesettings.h"
+
+ const char* DontAskDiscard = "dontAskInternal";
+
+@@ -61,7 +61,8 @@ namespace Knights
+ MainWindow::MainWindow()
+ : KXmlGuiWindow(),
+ m_view ( new KnightsView ( this ) ),
+- m_clockDock ( 0 )
++ m_clockDock ( 0 ),
++ m_themeProvider ( new KgThemeProvider ( "Theme", this ) )
+ {
+ // accept dnd
+ setAcceptDrops ( true );
+@@ -81,17 +82,10 @@ namespace Knights
+ // add a status bar
+ statusBar()->show();
+
+- KGameDifficulty::init( this, Manager::self(), SLOT (levelChanged(KGameDifficulty::standardLevel)) );
+- KGameDifficulty::addStandardLevel ( KGameDifficulty::VeryEasy );
+- KGameDifficulty::addStandardLevel ( KGameDifficulty::Easy );
+- KGameDifficulty::addStandardLevel ( KGameDifficulty::Medium );
+- KGameDifficulty::addStandardLevel ( KGameDifficulty::Hard );
+- KGameDifficulty::addStandardLevel ( KGameDifficulty::VeryHard );
+- KGameDifficulty::addStandardLevel ( KGameDifficulty::Configurable );
+- KGameDifficulty::setRestartOnChange ( KGameDifficulty::NoRestartOnChange );
++ connect (Kg::difficulty(), SIGNAL(currentLevelChanged(const KgDifficultyLevel*)), Manager::self(), SLOT(levelChanged(const KgDifficultyLevel*)));
+
+- KGameDifficulty::standardLevel level = (KGameDifficulty::standardLevel)Settings::computerDifficulty();
+- KGameDifficulty::setLevel ( level );
++ Kg::difficulty()->addStandardLevelRange ( KgDifficultyLevel::VeryEasy, KgDifficultyLevel::VeryHard );
++ Kg::difficulty()->addLevel ( new KgDifficultyLevel ( 0, "custom", i18n("Custom"), false ) );
+
+ // a call to KXmlGuiWindow::setupGUI() populates the GUI
+ // with actions, using KXMLGUI.
+@@ -99,6 +93,7 @@ namespace Knights
+ // mainwindow to automatically save settings if changed: window size,
+ // toolbar position, icon size, etc.
+ setupGUI();
++ KgDifficultyGUI::init( this );
+
+ // make all the docks invisible.
+ // Show required docks after the game protocols are selected
+@@ -117,7 +112,6 @@ namespace Knights
+
+ MainWindow::~MainWindow()
+ {
+- Settings::setComputerDifficulty ( (int)KGameDifficulty::level() );
+ }
+
+ void MainWindow::setupActions()
+@@ -419,15 +413,17 @@ void MainWindow::showFicsSpectateDialog()
+ Manager::self()->setRules ( new ChessRules );
+ Manager::self()->startGame();
+
++ m_themeProvider->discoverThemes ( "appdata", QLatin1String ( "themes" ) );
++
+ if (m_loadFileName.isEmpty())
+ {
+- m_view->setupBoard();
++ m_view->setupBoard(m_themeProvider);
+ }
+ else
+ {
+ int speed = Settings::animationSpeed();
+ Settings::setAnimationSpeed ( Settings::EnumAnimationSpeed::Instant );
+- m_view->setupBoard();
++ m_view->setupBoard(m_themeProvider);
+
+ Manager::self()->loadGameHistoryFrom ( m_loadFileName );
+ setCaption ( m_loadFileName );
+@@ -500,9 +496,7 @@ void MainWindow::showFicsSpectateDialog()
+ KConfigDialog *dialog = new KConfigDialog ( this, QLatin1String ( "settings" ), Settings::self() );
+ QWidget *generalSettingsDlg = new QWidget;
+ ui_prefs_base.setupUi ( generalSettingsDlg );
+-#if not defined WITH_ANIMATIONS
+- ui_prefs_base.animationGroup->hide();
+-#endif
++
+ dialog->addPage ( generalSettingsDlg, i18n ( "General" ), QLatin1String ( "games-config-options" ) );
+ connect ( dialog, SIGNAL (settingsChanged(QString)), m_view, SLOT (settingsChanged()) );
+
+@@ -514,7 +508,7 @@ void MainWindow::showFicsSpectateDialog()
+ ui_prefs_access.setupUi ( accessDlg );
+ dialog->addPage ( accessDlg, i18n( "Accessibility"), QLatin1String("preferences-desktop-accessibility") );
+
+- QWidget* themeDlg = new KGameThemeSelector ( dialog, Settings::self(), KGameThemeSelector::NewStuffEnableDownload );
++ QWidget* themeDlg = new KgThemeSelector ( m_themeProvider, KgThemeSelector::EnableNewStuffDownload, dialog );
+ dialog->addPage ( themeDlg, i18n ( "Theme" ), QLatin1String ( "games-config-theme" ) );
+ dialog->setAttribute ( Qt::WA_DeleteOnClose );
+
+diff --git a/src/knights.h b/src/knights.h
+index dee78af..3e6c110 100644
+--- a/src/knights.h
++++ b/src/knights.h
+@@ -25,11 +25,13 @@
+ #include "ui_prefs_base.h"
+ #include "ui_prefs_access.h"
+ #include "proto/protocol.h"
++#include <KgDifficulty>
+
+ #include <KXmlGuiWindow>
+
+ class QStringListModel;
+ class KToggleAction;
++class KgThemeProvider;
+
+ namespace Knights
+ {
+@@ -102,6 +104,7 @@ namespace Knights
+ KToggleAction *m_toolbarAction;
+ KToggleAction *m_statusbarAction;
+ QMap<QByteArray, Protocol::Feature> protocolFeatures;
++ KgThemeProvider* m_themeProvider;
+
+ QString m_loadFileName;
+ QString m_fileName;
+diff --git a/src/knights.kcfg b/src/knights.kcfg
+index dbf5dad..23db3ba 100644
+--- a/src/knights.kcfg
++++ b/src/knights.kcfg
+@@ -4,7 +4,6 @@
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile />
+- <include>KGameDifficulty</include>
+ <group name="KGameTheme">
+ <entry name="Theme" type="String">
+ <label>Theme file for the board</label>
+@@ -135,10 +134,6 @@
+ <label>the last selected program for player 2</label>
+ <default>gnuchess</default>
+ </entry>
+- <entry name="computerDifficulty" type="Int">
+- <label>the skill of computer players</label>
+- <default code="true">KGameDifficulty::Medium</default>
+- </entry>
+ <entry name="computerSearchDepth" type="Int">
+ <label>the search depth of computer engines, when the difficulty is set to Configurable</label>
+ <default>29</default>
+diff --git a/src/knightsview.cpp b/src/knightsview.cpp
+index 76e868a..5451eb9 100644
+--- a/src/knightsview.cpp
++++ b/src/knightsview.cpp
+@@ -67,9 +67,9 @@ KnightsView::~KnightsView()
+ delete ui;
+ }
+
+-void KnightsView::setupBoard()
++void KnightsView::setupBoard(KgThemeProvider* provider)
+ {
+- m_board = new Board ( this );
++ m_board = new Board ( provider, this );
+ ui->canvas->setScene ( m_board );
+ resizeScene();
+ kDebug() << Manager::self();
+diff --git a/src/knightsview.h b/src/knightsview.h
+index fed6125..40df529 100644
+--- a/src/knightsview.h
++++ b/src/knightsview.h
+@@ -26,6 +26,7 @@
+ #include "core/piece.h"
+ #include <QtGui/QWidget>
+
++class KgThemeProvider;
+ namespace Ui
+ {
+ class KnightsView;
+@@ -34,6 +35,7 @@ namespace Ui
+ namespace Knights
+ {
+
++
+ struct Offer;
+
+ class Protocol;
+@@ -97,7 +99,7 @@ struct Offer;
+ void showAllOffersToggled();
+
+ public slots:
+- void setupBoard();
++ void setupBoard(KgThemeProvider* provider);
+ void clearBoard();
+ void gameOver ( Color winner );
+ void showPopup ( const Offer& offer );
+diff --git a/src/main.cpp b/src/main.cpp
+index 62e09f5..2e3df68 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -35,18 +35,10 @@ int main ( int argc, char **argv )
+ {
+ KAboutData about ( "knights", 0, ki18n ( "Knights" ), version, ki18n ( description ),
+ KAboutData::License_GPL, ki18n ( "(C) 2009-2011 Miha Čančula" ), KLocalizedString(), "miha at noughmad.eu" );
+-#if defined WITH_OCS
+ about.addAuthor ( ki18n ( "Miha Čančula" ), KLocalizedString(), "miha at noughmad.eu", "http://noughmad.eu", "noughmad" );
+-#else
+- about.addAuthor ( ki18n ( "Miha Čančula" ), KLocalizedString(), "miha at noughmad.eu", "http://noughmad.eu" );
+-#endif
+ about.addCredit ( ki18n ( "Troy Corbin" ), ki18n ( "Original Knights for KDE3 and theme author" ), "troy at pedanticwebspaces.com" );
+ about.addCredit ( ki18n ( "Dave Kaye" ), ki18n ( "Help with new theme features and rendering without KGameRenderer" ) );
+-#if defined WITH_OCS
+ about.addCredit ( ki18n ( "Thomas Kamps" ), ki18n ( "Clock displaying the remaining time" ), QByteArray(), QByteArray(), "cpttom" );
+-#else
+- about.addCredit ( ki18n ( "Thomas Kamps" ), ki18n ( "Clock displaying the remaining time" ) );
+-#endif
+ KCmdLineArgs::init ( argc, argv, &about );
+
+ KCmdLineOptions options;
+diff --git a/src/offerwidget.cpp b/src/offerwidget.cpp
+index f877f7d..0993ae2 100644
+--- a/src/offerwidget.cpp
++++ b/src/offerwidget.cpp
+@@ -22,12 +22,9 @@
+ #include "offerwidget.h"
+ #include "gamemanager.h"
+ #include "ui_popup.h"
+-#include <KStandardAction>
+
+ using namespace Knights;
+
+-#if defined WITH_KMW
+-
+ OfferWidget::OfferWidget(const Knights::Offer& offer, QWidget* parent, Qt::WindowFlags f): KMessageWidget(offer.text, parent)
+ {
+ Q_UNUSED(f)
+@@ -50,39 +47,6 @@ OfferWidget::~OfferWidget()
+
+ }
+
+-#else
+-
+-OfferWidget::OfferWidget(const Offer& offer, QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
+-{
+- offerId = offer.id;
+- ui = new Ui::Popup;
+- ui->setupUi(this);
+-
+- ui->closeButton->setIcon ( KIcon(QLatin1String( "dialog-close" )) );
+- connect ( ui->acceptButton, SIGNAL(clicked(bool)), SLOT(acceptClicked()) );
+-
+- if ( offer.action == ActionNone )
+- {
+- ui->acceptButton->hide();
+- ui->declineButton->hide();
+- }
+- else
+- {
+- ui->acceptButton->setIcon ( KIcon(QLatin1String( "dialog-ok" )) );
+- ui->declineButton->setIcon ( KIcon(QLatin1String( "edit-delete" )) );
+- connect ( ui->declineButton, SIGNAL(clicked(bool)), SLOT(declineClicked()) );
+- connect ( ui->closeButton, SIGNAL(clicked(bool)), SLOT(closeClicked()) );
+- }
+- ui->label->setText ( offer.text );
+-}
+-
+-OfferWidget::~OfferWidget()
+-{
+- delete ui;
+-}
+-
+-#endif
+-
+ int OfferWidget::id() const
+ {
+ return offerId;
+diff --git a/src/offerwidget.h b/src/offerwidget.h
+index 7e430b6..cdf08a4 100644
+--- a/src/offerwidget.h
++++ b/src/offerwidget.h
+@@ -22,13 +22,7 @@
+ #ifndef KNIGHTS_OFFERWIDGET_H
+ #define KNIGHTS_OFFERWIDGET_H
+
+-#if defined WITH_KMW
+-# include <KMessageWidget>
+-# define OfferWidgetBase KMessageWidget
+-#else
+-# include <QWidget>
+-# define OfferWidgetBase QWidget
+-#endif
++#include <KMessageWidget>
+
+ namespace Ui
+ {
+@@ -47,7 +41,7 @@ namespace Knights {
+ };
+
+
+-class OfferWidget : public OfferWidgetBase
++class OfferWidget : public KMessageWidget
+ {
+ Q_OBJECT
+
+diff --git a/src/rules/chessrules.cpp b/src/rules/chessrules.cpp
+index a59a9d2..3e993e4 100644
+--- a/src/rules/chessrules.cpp
++++ b/src/rules/chessrules.cpp
+@@ -323,6 +323,8 @@ bool ChessRules::isAttacked ( const Pos& pos, Color color, Grid* grid )
+
+ bool ChessRules::isAttacking ( const Pos& attackingPos )
+ {
++ Q_ASSERT(m_grid->contains(attackingPos));
++ Q_ASSERT(m_grid->value(attackingPos));
+ const Color pieceColor = m_grid->value ( attackingPos )->color();
+ const Color kingColor = oppositeColor ( pieceColor );
+ return legalAttackMoves ( attackingPos, m_grid ).contains ( Move ( attackingPos, kingPos[kingColor] ) );
+diff --git a/src/rules/rules.h b/src/rules/rules.h
+index 9a8d76e..032cde4 100644
+--- a/src/rules/rules.h
++++ b/src/rules/rules.h
+@@ -58,7 +58,7 @@ namespace Knights
+ {
+ }
+
+- virtual void setGrid ( QMap<Pos, Piece*>* grid )
++ virtual void setGrid ( Grid* grid )
+ {
+ kDebug() << "Setting Grid";
+ m_grid = grid;
diff --git a/knights.spec b/knights.spec
index 8423ecb..f72ccfa 100644
--- a/knights.spec
+++ b/knights.spec
@@ -1,6 +1,6 @@
Name: knights
Version: 2.4.2
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: A chess board for KDE
Group: Amusements/Games
@@ -8,7 +8,11 @@ Group: Amusements/Games
License: GPLv2 or GPLv3
URL: http://kde-apps.org/content/show.php/Knights?content=122046
Source0: http://dl.dropbox.com/u/2888238/Knights/%{name}-%{version}.tar.bz2
-BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+# this patch was generated from the upstream branch to port knights to the
+# new kdegames API at
+# https://projects.kde.org/projects/extragear/games/knights/repository/show?rev=kdegames-porting
+# and will be removed as soon as upstream makes an official release targeting the new API
+Patch0: knights-kdegames5.patch
BuildRequires: kdegames-devel
BuildRequires: gettext
@@ -27,6 +31,7 @@ checking, themes, and nice animations
%prep
%setup -q
+%patch0 -p1
%build
@@ -73,15 +78,13 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
+* Fri Jun 15 2012 Julian Aloofi <julian at fedoraproject.org> 2.4.2-2
+- apply patch to build against the new KDEgames API
+- removed the buildroot tag
+
* Mon Apr 30 2012 Julian Aloofi <julian at fedoraproject.org> 2.4.2-1
- update to latest upstream release
-* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.4.0-3
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
-
-* Wed Dec 28 2011 Julian Aloofi <julian at fedoraproject.org> 2.4.0-2
-- included a missing dbus rule
-
* Sat Nov 12 2011 Julian Aloofi <julian at fedoraproject.org> 2.4.0-1
- update to latest upstream release
More information about the scm-commits
mailing list