Commit 2540e2e3 authored by Garvit Khatri's avatar Garvit Khatri

First approach towards porting to kf5

parent 7d3255c1
project(kreversi)
cmake_minimum_required(VERSION 2.8.12)
if(NOT COMPILING_KDEGAMES)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
include(MacroLibrary)
find_package(KDEGames 4.9.0 REQUIRED)
find_package(ECM 0.0.11 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories(${KDEGAMES_INCLUDE_DIRS} ${KDEGAMES_INCLUDE_DIR}/highscore ${KDE4_INCLUDES} ${QDBUS_INCLUDE_DIRS})
endif(NOT COMPILING_KDEGAMES)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Widgets Qml Quick QuickWidgets Svg Test)
find_package(KF5 REQUIRED COMPONENTS
CoreAddons
Config
ItemModels
WidgetsAddons
WindowSystem
Codecs
Archive
Config
DBusAddons
DNSSD
Declarative
I18n
GuiAddons
Service
ConfigWidgets
ItemViews
IconThemes
Completion
JobWidgets
TextWidgets
GlobalAccel
XmlGui
Crash
Bookmarks
KIO
NotifyConfig
NewStuff
KDELibs4Support)
find_package(KDeclarative REQUIRED)
find_package(KF5KDEGames 4.9.0 REQUIRED)
include(FeatureSummary)
include(ECMInstallIcons)
include(KDEInstallDirs)
include(KDECompilerSettings)
include(KDECMakeSettings)
include_directories(${KDEGAMES_INCLUDE_DIRS} ${KDEGAMES_INCLUDE_DIR}/highscore ${KDE4_INCLUDES} ${QDBUS_INCLUDE_DIRS})
#find_package(KDeclarative REQUIRED)
add_subdirectory( pics )
add_subdirectory( sounds )
......@@ -35,21 +70,19 @@ set(kreversi_SRCS
mainwindow.cpp
main.cpp )
kde4_add_ui_files(kreversi_SRCS startgamedialog.ui)
qt5_wrap_ui(kreversi_SRCS startgamedialog.ui)
kde4_add_kcfg_files(kreversi_SRCS preferences.kcfgc)
kconfig_add_kcfg_files(kreversi_SRCS preferences.kcfgc)
kde4_add_app_icon(kreversi_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/hi*-app-kreversi.png")
kde4_add_executable(kreversi ${kreversi_SRCS})
add_executable(kreversi ${kreversi_SRCS})
target_link_libraries(kreversi Qt5::Svg Qt5::Declarative KF5::Declarative KF5::XmlGui KF5::TextWidgets KF5KDEGames)
target_link_libraries(kreversi kdegames ${KDE4_KDEUI_LIBS}
${QT_QTDECLARATIVE_LIBRARY} ${KDECLARATIVE_LIBRARIES})
install(TARGETS kreversi ${INSTALL_TARGETS_DEFAULT_ARGS} )
########### install files ###############
install( PROGRAMS kreversi.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
#install( FILES kreversi.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
install( FILES kreversiui.rc DESTINATION ${DATA_INSTALL_DIR}/kreversi )
install( FILES kreversiui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kreversi )
install( DIRECTORY qml DESTINATION ${DATA_INSTALL_DIR}/kreversi )
......@@ -22,8 +22,8 @@
********************************************************************/
#include "colorscheme.h"
ColorScheme::ColorScheme(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
ColorScheme::ColorScheme(QQuickItem *parent) :
QQuickItem(parent)
{
}
......
......@@ -24,18 +24,18 @@
#ifndef COLORSCHEME_H
#define COLORSCHEME_H
#include <QDeclarativeItem>
#include <QQuickItem>
#include <KColorScheme>
#include <QColor>
class ColorScheme : public QDeclarativeItem
class ColorScheme : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QColor background READ background NOTIFY placeHolder)
Q_PROPERTY(QColor foreground READ foreground NOTIFY placeHolder)
Q_PROPERTY(QColor border READ border NOTIFY placeHolder)
public:
ColorScheme(QDeclarativeItem *parent = 0);
ColorScheme(QQuickItem *parent = 0);
QColor background() const;
QColor foreground() const;
......
########### install files ###############
#
#
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kreversi)
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kreversi)
kde4_install_icons( ${ICON_INSTALL_DIR} )
kde4_install_icons( ${ICON_INSTALL_DIR} )
ecm_install_icons(${ICON_INSTALL_DIR})
ecm_install_icons(${ICON_INSTALL_DIR})
......@@ -22,9 +22,8 @@
*******************************************************************
*/
#include <KApplication>
#include <KLocale>
#include <KCmdLineArgs>
#include <QApplication>
#include <KLocalizedString>
#include <KAboutData>
#include <highscores.h>
......@@ -34,33 +33,28 @@ static const char description[] = I18N_NOOP("KDE Reversi Board Game");
int main(int argc, char **argv)
{
KAboutData aboutData("kreversi", 0, ki18n("KReversi"),
"2.0", ki18n(description), KAboutData::License_GPL,
ki18n("(c) 1997-2000, Mario Weilguni\n(c) 2004-2006, Inge Wallin\n(c) 2006, Dmitry Suzdalev"),
KLocalizedString(), "http://games.kde.org/kreversi");
aboutData.addAuthor(ki18n("Mario Weilguni"), ki18n("Original author"), "mweilguni@sime.com");
aboutData.addAuthor(ki18n("Inge Wallin"), ki18n("Original author"), "inge@lysator.liu.se");
aboutData.addAuthor(ki18n("Dmitry Suzdalev"), ki18n("Game rewrite for KDE4. Current maintainer."), "dimsuz@gmail.com");
aboutData.addCredit(ki18n("Simon Hürlimann"), ki18n("Action refactoring"));
aboutData.addCredit(ki18n("Mats Luthman"), ki18n("Game engine, ported from his JAVA applet."));
aboutData.addCredit(ki18n("Arne Klaassen"), ki18n("Original raytraced chips."));
aboutData.addCredit(ki18n("Mauricio Piacentini"), ki18n("Vector chips and background for KDE4."));
aboutData.addCredit(ki18n("Brian Croom"), ki18n("Port rendering code to KGameRenderer"), "brian.s.croom@gmail.com");
aboutData.addCredit(ki18n("Denis Kuplyakov"), ki18n("Port rendering code to QML, redesign and a lot of improvements"), "dener.kup@gmail.com");
QApplication application(argc, argv);
KCmdLineArgs::init(argc, argv, &aboutData);
KAboutData aboutData(i18n("kreversi"), i18n("KReversi"),
"2.0", i18n(description), KAboutLicense::GPL,
i18n("(c) 1997-2000, Mario Weilguni\n(c) 2004-2006, Inge Wallin\n(c) 2006, Dmitry Suzdalev"),
QString(), i18n("http://games.kde.org/kreversi"));
aboutData.addAuthor(i18n("Mario Weilguni"), i18n("Original author"), "mweilguni@sime.com");
aboutData.addAuthor(i18n("Inge Wallin"), i18n("Original author"), "inge@lysator.liu.se");
aboutData.addAuthor(i18n("Dmitry Suzdalev"), i18n("Game rewrite for KDE4. Current maintainer."), "dimsuz@gmail.com");
aboutData.addCredit(i18n("Simon Hürlimann"), i18n("Action refactoring"));
aboutData.addCredit(i18n("Mats Luthman"), i18n("Game engine, ported from his JAVA applet."));
aboutData.addCredit(i18n("Arne Klaassen"), i18n("Original raytraced chips."));
aboutData.addCredit(i18n("Mauricio Piacentini"), i18n("Vector chips and background for KDE4."));
aboutData.addCredit(i18n("Brian Croom"), i18n("Port rendering code to KGameRenderer"), "brian.s.croom@gmail.com");
aboutData.addCredit(i18n("Denis Kuplyakov"), i18n("Port rendering code to QML, redesign and a lot of improvements"), "dener.kup@gmail.com");
KCmdLineOptions options;
options.add("demo", ki18n("Start with demo game playing"));
KCmdLineArgs::addCmdLineOptions(options);
KAboutData::setApplicationData(aboutData);
KApplication application;
KGlobal::locale()->insertCatalog(QLatin1String("libkdegames"));
if (application.isSessionRestored()) {
RESTORE(KReversiMainWindow)
} else {
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KReversiMainWindow *mainWin = new KReversiMainWindow(0, args->isSet("demo"));
args->clear();
mainWin->show();
......@@ -70,4 +64,3 @@ int main(int argc, char **argv)
return application.exec();
}
......@@ -29,7 +29,7 @@
#include <KLocale>
#include <KMessageBox>
#include <KStandardDirs>
#include <KStatusBar>
#include <QStatusBar>
#include <KActionCollection>
#include <KStandardGameAction>
#include <KExtHighscore>
......@@ -53,9 +53,12 @@ KReversiMainWindow::KReversiMainWindow(QWidget* parent, bool startDemo)
m_provider = new KgThemeProvider();
m_provider->discoverThemes("appdata", QLatin1String("pics"));
statusBar()->insertItem(i18n("Press start game!"), COMMON_STATUSBAR_ID);
statusBar()->insertItem("", BLACK_STATUSBAR_ID);
statusBar()->insertItem("", WHITE_STATUSBAR_ID);
common->setText(i18n("Press start game!"));
statusBar()->insertPermanentWidget(COMMON_STATUSBAR_ID, common);
black->setText(i18n(""));
statusBar()->insertPermanentWidget(BLACK_STATUSBAR_ID, black);
white->setText(i18n(""));
statusBar()->insertPermanentWidget(WHITE_STATUSBAR_ID, white);
// initialize difficulty stuff
Kg::difficulty()->addStandardLevelRange(
......@@ -91,7 +94,7 @@ KReversiMainWindow::KReversiMainWindow(QWidget* parent, bool startDemo)
// load saved settings
loadSettings();
setupGUI(qApp->desktop()->availableGeometry().size() * 0.7);
// setupGUI(qApp->desktop()->availableGeometry().size() * 0.7);
m_historyDock->hide();
}
......@@ -341,32 +344,23 @@ void KReversiMainWindow::showEvent(QShowEvent*)
void KReversiMainWindow::updateStatusBar()
{
if (m_game->isGameOver()) {
statusBar()->changeItem(i18n("GAME OVER"), COMMON_STATUSBAR_ID);
common->setText(i18n("GAME OVER"));
}
if (m_nowPlayingInfo.type[Black] == GameStartInformation::AI
&& m_nowPlayingInfo.type[White] == GameStartInformation::AI) { // using Black White names
statusBar()->changeItem(i18n("%1: %2",
Utils::colorToString(Black),
m_game->playerScore(Black)), BLACK_STATUSBAR_ID);
statusBar()->changeItem(i18n("%1: %2",
Utils::colorToString(White),
m_game->playerScore(White)), WHITE_STATUSBAR_ID);
black->setText(i18n("%1: %2", Utils::colorToString(Black), m_game->playerScore(Black)));
white->setText(i18n("%1: %2", Utils::colorToString(White), m_game->playerScore(White)));
if (!m_game->isGameOver()) {
statusBar()->changeItem(i18n("%1 turn",
Utils::colorToString(m_game->currentPlayer())),
COMMON_STATUSBAR_ID);
common->setText(i18n("%1 turn", Utils::colorToString(m_game->currentPlayer())));
}
} else { // using player's names
statusBar()->changeItem(i18n("%1: %2", m_nowPlayingInfo.name[Black],
m_game->playerScore(Black)), BLACK_STATUSBAR_ID);
statusBar()->changeItem(i18n("%1: %2", m_nowPlayingInfo.name[White],
m_game->playerScore(White)), WHITE_STATUSBAR_ID);
black->setText(i18n("%1: %2", m_nowPlayingInfo.name[Black], m_game->playerScore(Black)));
white->setText(i18n("%1: %2", m_nowPlayingInfo.name[White], m_game->playerScore(White)));
if (!m_game->isGameOver() && m_game->currentPlayer() != NoColor) {
statusBar()->changeItem(i18n("%1's turn",
m_nowPlayingInfo.name[m_game->currentPlayer()]), COMMON_STATUSBAR_ID);
common->setText(i18n("%1's turn", m_nowPlayingInfo.name[m_game->currentPlayer()]));
}
}
}
......
......@@ -40,6 +40,8 @@
#include <kreversigame.h>
#include <kreversiview.h>
#include <QLabel>
class KReversiGame;
class KReversiView;
......@@ -94,5 +96,9 @@ private:
KToggleAction *m_showMovesAct;
KSelectAction *m_animSpeedAct;
KToggleAction *m_coloredChipsAct;
QPointer<QLabel> black = new QLabel;
QPointer<QLabel> white = new QLabel;
QPointer<QLabel> common = new QLabel;
};
#endif
......@@ -30,8 +30,11 @@
#include <KDebug>
#include <QSvgRenderer>
#include <KLocalizedString>
#include <QPainter>
#include <QGraphicsDropShadowEffect>
StartGameDialog::StartGameDialog(QWidget *parent, KgThemeProvider *provider) :
KDialog(parent),
ui(new Ui::StartGameDialog), m_provider(provider), m_chipsPrefix(BlackWhite)
......@@ -56,16 +59,16 @@ StartGameDialog::StartGameDialog(QWidget *parent, KgThemeProvider *provider) :
ui->whiteTypeGroup->setId(ui->whiteHuman, GameStartInformation::Human);
ui->whiteTypeGroup->setId(ui->whiteAI, GameStartInformation::AI);
ui->whiteAI->setIcon(KIcon("computer"));
ui->whiteHuman->setIcon(KIcon("user-identity"));
ui->whiteAI->setIcon(QIcon::fromTheme("computer"));
ui->whiteHuman->setIcon(QIcon::fromTheme("user-identity"));
ui->blackTypeGroup->setId(ui->blackHuman, GameStartInformation::Human);
ui->blackTypeGroup->setId(ui->blackAI, GameStartInformation::AI);
ui->blackAI->setIcon(KIcon("computer"));
ui->blackHuman->setIcon(KIcon("user-identity"));
ui->blackAI->setIcon(QIcon::fromTheme("computer"));
ui->blackHuman->setIcon(QIcon::fromTheme("user-identity"));
QList< const KgDifficultyLevel * > diffList = Kg::difficulty()->levels();
const KIcon icon("games-difficult");
const QIcon icon("games-difficult");
for (int i = 0; i < diffList.size(); i++) {
ui->blackSkill->addItem(icon, diffList.at(i)->title());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment