summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnuj Pahuja <[email protected]>2014-06-22 23:48:29 +0530
committerAnuj Pahuja <[email protected]>2014-06-22 23:48:29 +0530
commitcd742fc363d1f4bcb43a299f20a79533b0c36bcc (patch)
treede7ca9c4455cfb40c96389bb346960ee69627e17
parent38ae4d195d5de78d3ec4c0f1da9026526b6a0a34 (diff)
Initial port to KF5
-rw-r--r--CMakeLists.txt34
-rw-r--r--data/pictures/CMakeLists.txt2
-rw-r--r--doc/CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/aientity.cpp6
-rw-r--r--src/aientity.h2
-rw-r--r--src/audioplayer.cpp4
-rw-r--r--src/battlefieldview.cpp2
-rw-r--r--src/entity.h4
-rw-r--r--src/main.cpp81
-rw-r--r--src/mainwindow.cpp20
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/message.h6
-rw-r--r--src/networkdialog.cpp29
-rw-r--r--src/networkdialog.h11
-rw-r--r--src/networkentity.cpp6
-rw-r--r--src/networkentity.h2
-rw-r--r--src/playfield.cpp17
-rw-r--r--src/playfield.h2
-rw-r--r--src/seaview.cpp2
-rw-r--r--src/simplemenu.cpp10
-rw-r--r--src/simplemenu.h4
-rw-r--r--src/uientity.cpp6
-rw-r--r--src/uientity.h2
-rw-r--r--src/welcomescreen.cpp2
25 files changed, 146 insertions, 124 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2485ff5..abd2e4e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,17 +1,33 @@
project(knavalbattle)
-if(NOT COMPILING_KDEGAMES)
- find_package(KDE4 REQUIRED)
- include(KDE4Defaults)
- include(MacroLibrary)
- find_package(KDEGames 4.9.0 REQUIRED)
+cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
+set (QT_MIN_VERSION "5.2.0")
- add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
- add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
- include_directories(${KDEGAMES_INCLUDE_DIRS} ${KDE4_INCLUDES} ${QDBUS_INCLUDE_DIRS})
-endif(NOT COMPILING_KDEGAMES)
+find_package(ECM 0.0.9 REQUIRED CONFIG)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+set(DATA_INSTALL_DIR "/usr/local/share")
+
+find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Widgets Qml Quick 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(KDEGames 4.9.0 REQUIRED)
+
+include(FeatureSummary)
+include(ECMInstallIcons)
+include(KDEInstallDirs)
+include(KDECompilerSettings)
+include(KDECMakeSettings)
+
+add_definitions(${QT_DEFINITIONS})
+add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+include_directories(${KDEGAMES_INCLUDE_DIRS} ${KDE4_INCLUDES} ${QDBUS_INCLUDE_DIRS})
add_subdirectory(src)
add_subdirectory(data)
add_subdirectory(doc)
add_subdirectory(kconf_update)
+
+feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) \ No newline at end of file
diff --git a/data/pictures/CMakeLists.txt b/data/pictures/CMakeLists.txt
index 3059bfd..616963d 100644
--- a/data/pictures/CMakeLists.txt
+++ b/data/pictures/CMakeLists.txt
@@ -4,5 +4,5 @@ default.desktop
default_theme.svgz
DESTINATION ${DATA_INSTALL_DIR}/knavalbattle/pictures)
-kde4_install_icons(${ICON_INSTALL_DIR})
+ecm_install_icons(${ICON_INSTALL_DIR})
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 8faf409..dc9cf1c 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,3 +1,3 @@
########### install files ###############
#
-kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR knavalbattle)
+kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR knavalbattle)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 556cf15..eadeee4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(Phonon4Qt5 REQUIRED)
+
include_directories(${CMAKE_SOURCE_DIR}/libkdegames/highscore ${CMAKE_CURRENT_SOURCE_DIR}/kwelcomescreen)
set(knavalbattle_SRCS
@@ -41,12 +43,12 @@ set(knavalbattle_SRCS
welcomescreen.cpp)
-kde4_add_kcfg_files(knavalbattle_SRCS settingsbase.kcfgc)
+kconfig_add_kcfg_files(knavalbattle_SRCS settingsbase.kcfgc)
-kde4_add_app_icon(knavalbattle_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../data/pictures/hi*-app-knavalbattle.png")
-kde4_add_executable(knavalbattle ${knavalbattle_SRCS} ${kwelcomescreen_SRCS})
+#kde4_add_app_icon(knavalbattle_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../data/pictures/hi*-app-knavalbattle.png") TODO Port!
+add_executable(knavalbattle ${knavalbattle_SRCS} ${kwelcomescreen_SRCS})
-target_link_libraries(knavalbattle ${QT_QTXML_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_PHONON_LIBS} ${KDE4_KDNSSD_LIBS} kdegames)
+target_link_libraries(knavalbattle Qt5::Xml Qt5::Qml Qt5::Network KF5::KDELibs4Support KF5::TextWidgets KF5::DNSSD Phonon::phonon4qt5 kdegames)
install(TARGETS knavalbattle ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( FILES knavalbattleui.rc DESTINATION ${DATA_INSTALL_DIR}/knavalbattle )
diff --git a/src/aientity.cpp b/src/aientity.cpp
index e1c8d37..3ee78f7 100644
--- a/src/aientity.cpp
+++ b/src/aientity.cpp
@@ -15,7 +15,7 @@
#include <KgDifficulty>
-#include <KIcon>
+#include <QIcon>
AIEntity::AIEntity(Sea::Player player, Sea* sea, SeaView *seaview)
: Entity(player, seaview, sea->battleShipsConfiguration())
@@ -97,9 +97,9 @@ void AIEntity::getShoot()
}
}
-KIcon AIEntity::icon() const
+QIcon AIEntity::icon() const
{
- return KIcon( QLatin1String( "roll" ));
+ return QIcon( QLatin1String( "roll" ));
}
#include "aientity.moc"
diff --git a/src/aientity.h b/src/aientity.h
index bfd3a7a..774b0d9 100644
--- a/src/aientity.h
+++ b/src/aientity.h
@@ -36,7 +36,7 @@ public:
virtual void hit(Shot* shot);
virtual void notifyGameOptions(bool ask);
- virtual KIcon icon() const;
+ virtual QIcon icon() const;
public slots:
virtual void notifyAbort() { }
virtual void notifyRestartPlacing(Sea::Player player) { };
diff --git a/src/audioplayer.cpp b/src/audioplayer.cpp
index c5b5ef0..8e152c0 100644
--- a/src/audioplayer.cpp
+++ b/src/audioplayer.cpp
@@ -9,7 +9,7 @@
#include "audioplayer.h"
-#include <Phonon/MediaObject>
+#include <phonon/MediaObject>
#include <KStandardDirs>
AudioPlayer::AudioPlayer(QObject* parent)
@@ -39,7 +39,7 @@ void AudioPlayer::play(Sea::Player player, const HitInfo& info)
if (!sound.isEmpty()) {
qDebug() << "****** playing" << m_dir.filePath(sound);
- m_media->setCurrentSource(m_dir.filePath(sound));
+ m_media->setCurrentSource(QUrl::fromLocalFile(m_dir.filePath(sound)));
m_media->play();
}
}
diff --git a/src/battlefieldview.cpp b/src/battlefieldview.cpp
index 28da696..4d27906 100644
--- a/src/battlefieldview.cpp
+++ b/src/battlefieldview.cpp
@@ -12,8 +12,6 @@
#include <QMouseEvent>
#include <QSizePolicy>
-#include <kicon.h>
-
#include "kbsrenderer.h"
#include "sprite.h"
#include "animator.h"
diff --git a/src/entity.h b/src/entity.h
index 92b8670..974069b 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -17,7 +17,7 @@
#include "ships.h"
class Shot;
-class KIcon;
+class QIcon;
class Entity : public QObject
{
@@ -60,7 +60,7 @@ public:
QString nick() const { return m_nick; }
CompatibilityLevel compatibilityLevel() const { return m_level; }
- virtual KIcon icon() const = 0;
+ virtual QIcon icon() const = 0;
virtual void setNick(const QString& nick);
signals:
void shoot(int player, const Coord& c);
diff --git a/src/main.cpp b/src/main.cpp
index d1ffb45..95e0e94 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,10 +10,11 @@
*/
#include <kapplication.h>
-#include <klocale.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
-#include <kurl.h>
+
+#include <QUrl>
+#include <QtCore/QCommandLineParser>
#include "mainwindow.h"
#include "coord.h"
@@ -21,47 +22,48 @@
int main(int argc, char** argv)
{
- KAboutData aboutData("knavalbattle", 0, ki18n("Naval Battle"), "2.0",
- ki18n("The KDE ship sinking game"), KAboutData::License_GPL,
- ki18n("(c) 2000-2005 Nikolas Zimmermann, Daniel Molkentin\n"
- "(c) 2007 Paolo Capriotti"), KLocalizedString(), "http://games.kde.org/kbattleship" );
+ KAboutData aboutData(QStringLiteral("knavalbattle"), i18n("Naval Battle"), QStringLiteral("2.0"),
+ i18n("The KDE ship sinking game"), KAboutLicense::GPL,
+ i18n("(c) 2000-2005 Nikolas Zimmermann, Daniel Molkentin\n"
+ "(c) 2007 Paolo Capriotti"), QString(), QStringLiteral("http://games.kde.org/kbattleship") );
- aboutData.addAuthor(ki18n("Paolo Capriotti"), ki18n("Current maintainer"), "[email protected]");
- aboutData.addAuthor(ki18n("Nikolas Zimmermann"), ki18n("Project Founder, GUI Handling, Client/Server"), "[email protected]");
- aboutData.addAuthor(ki18n("Daniel Molkentin"), ki18n("Dialog Stuff, Client/Server"), "[email protected]");
- aboutData.addAuthor(ki18n("Kevin Krammer"), ki18n("Computer Player"), "[email protected]");
+ aboutData.addAuthor(i18n("Paolo Capriotti"), i18n("Current maintainer"), QStringLiteral("[email protected]"));
+ aboutData.addAuthor(i18n("Nikolas Zimmermann"), i18n("Project Founder, GUI Handling, Client/Server"), QStringLiteral("[email protected]"));
+ aboutData.addAuthor(i18n("Daniel Molkentin"), i18n("Dialog Stuff, Client/Server"), QStringLiteral("[email protected]"));
+ aboutData.addAuthor(i18n("Kevin Krammer"), i18n("Computer Player"), QStringLiteral("[email protected]"));
- aboutData.addCredit(ki18n("Johann Ollivier Lapeyre"), ki18n("Game artwork"), "[email protected]");
- aboutData.addCredit(ki18n("Eugene Trounev"), ki18n("Background"), "[email protected]");
- aboutData.addCredit(ki18n("Robert Wadley"), ki18n("Artwork for some of the ships"), "[email protected]");
- aboutData.addCredit(ki18n("Riccardo Iaconelli"), ki18n("Welcome screen"), "[email protected]");
- aboutData.addCredit(ki18n("Benjamin Adler"), ki18n("Icon"), "[email protected]");
- aboutData.addCredit(ki18n("Nils Trzebin"), ki18n("Sounds"), "[email protected]");
- aboutData.addCredit(ki18n("Elmar Hoefner"), ki18n("GFX"), "[email protected]");
- aboutData.addCredit(ki18n("Lukas Tinkl"), ki18n("Non-Latin1 Support"), "[email protected]");
- aboutData.addCredit(ki18n("Malte Starostik"), ki18n("Various improvements"), "[email protected]");
- aboutData.addCredit(ki18n("Albert Astals Cid"), ki18n("Various improvements and bugfixes"), "[email protected]");
- aboutData.addCredit(ki18n("John Tapsell"), ki18n("Various improvements and bugfixes"), "[email protected]");
- aboutData.addCredit(ki18n("Inge Wallin"), ki18n("Bugfixes and refactoring"), "[email protected]");
- aboutData.addCredit(ki18n("Jakub Stachowski"), ki18n("DNS-SD discovery"), "[email protected]");
- aboutData.addCredit(ki18n("Roney Gomes"), ki18n("Porting to KGameRenderer and QGraphicsView"), "[email protected]");
+ aboutData.addCredit(i18n("Johann Ollivier Lapeyre"), i18n("Game artwork"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Eugene Trounev"), i18n("Background"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Robert Wadley"), i18n("Artwork for some of the ships"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Riccardo Iaconelli"), i18n("Welcome screen"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Benjamin Adler"), i18n("Icon"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Nils Trzebin"), i18n("Sounds"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Elmar Hoefner"), i18n("GFX"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Lukas Tinkl"), i18n("Non-Latin1 Support"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Malte Starostik"), i18n("Various improvements"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Albert Astals Cid"), i18n("Various improvements and bugfixes"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("John Tapsell"), i18n("Various improvements and bugfixes"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Inge Wallin"), i18n("Bugfixes and refactoring"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Jakub Stachowski"), i18n("DNS-SD discovery"), QStringLiteral("[email protected]"));
+ aboutData.addCredit(i18n("Roney Gomes"), i18n("Porting to KGameRenderer and QGraphicsView"), QStringLiteral("[email protected]"));
- KCmdLineArgs::init(argc, argv, &aboutData);
-
- KCmdLineOptions options;
- options.add("!+[URL]", ki18n("URL of a Naval Battle game server to connect to after startup"));
- KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
- KApplication app;
- KGlobal::locale()->insertCatalog( QLatin1String( "libkdegames" ));
+ QApplication::setApplicationName(i18n("knavalbattle"));
+ QApplication app(argc, argv);
+
+ //KCmdLineOptions options;
+ //options.add("!+[URL]", ki18n("URL of a Naval Battle game server to connect to after startup")); TODO Port, use QCommandLineParser?
+ //KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+
+
+ KLocalizedString::setApplicationDomain("libkdegames" );
qRegisterMetaType<Coord>("Coord");
- KUrl url;
- KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
-
- if (args->count() > 0) {
- for (int i = 0; i < args->count(); ++i) {
- url = KUrl(args->url(i));
+ QUrl url;
+
+ if (argc > 0) {
+ for (int i = 0; i < argc; ++i) {
+ url = QUrl(QUrl::fromUserInput(argv[i]));
if (!url.isValid())
continue;
@@ -69,10 +71,9 @@ int main(int argc, char** argv)
break;
}
}
- args->clear();
-
+
MainWindow* window = new MainWindow(url);
-// StatsWidget* window = new StatsWidget(0, 0);
+ //StatsWidget* window = new StatsWidget(0, 0);
window->show();
return app.exec();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9d62dde..43330d4 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -11,9 +11,10 @@
#include "mainwindow.h"
-#include <KAction>
+#include <QAction>
+#include <QIcon>
+
#include <KActionCollection>
-#include <KIcon>
#include <KLocalizedString>
#include <KStandardAction>
#include <KStandardGameAction>
@@ -25,7 +26,7 @@
#include "simplemenu.h"
#include "animator.h"
-MainWindow::MainWindow(const KUrl& url)
+MainWindow::MainWindow(const QUrl& url)
{
m_main = new PlayField(this, statusBar());
@@ -59,18 +60,21 @@ void MainWindow::setupActions()
KStandardGameAction::quit(this, SLOT(close()), actionCollection());
- KAction* action;
- action = new KAction(KIcon( QLatin1String( SimpleMenu::iconLocal) ), i18n("&Single Player"), this);
+ QAction* action;
+ action = new QAction(i18n("&Single Player"), this);
+ action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconLocal)));
actionCollection()->addAction("game_local", action);
connect(action, SIGNAL(triggered()), m_main, SLOT(localGame()));
- action = new KAction(KIcon( QLatin1String( SimpleMenu::iconServer) ), i18n("&Host Game..."), this);
+ action = new QAction(i18n("&Host Game..."), this);
+ action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconServer)));
actionCollection()->addAction("game_create_server", action);
connect(action, SIGNAL(triggered()), m_main, SLOT(createServer()));
- action = new KAction(KIcon( QLatin1String( SimpleMenu::iconClient) ), i18n("&Connect to Game..."), this);
+ action = new QAction(i18n("&Connect to Game..."), this);
+ action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconClient))),
actionCollection()->addAction("game_create_client", action);
connect(action, SIGNAL(triggered()), m_main, SLOT(createClient()));
// settings
- action = new KAction(i18n("Change &Nickname..."), this);
+ action = new QAction(i18n("Change &Nickname..."), this);
actionCollection()->addAction("options_nickname", action);
connect(action, SIGNAL(triggered()), m_main, SLOT(changeNick()));
action = new KToggleAction(i18n("&Play Sounds"), this);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index dbbc6c2..234397a 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -15,14 +15,14 @@
class PlayField;
-class KUrl;
+class QUrl;
class MainWindow : public KXmlGuiWindow
{
Q_OBJECT
PlayField* m_main;
public:
- explicit MainWindow(const KUrl& url);
+ explicit MainWindow(const QUrl& url);
protected:
void setupActions();
private slots:
diff --git a/src/message.h b/src/message.h
index 03fcd2a..816d9ba 100644
--- a/src/message.h
+++ b/src/message.h
@@ -10,21 +10,21 @@
#ifndef MESSAGE_H
#define MESSAGE_H
-#include <ksharedptr.h>
+#include <QExplicitlySharedDataPointer>
#include "ship.h"
#include "ships.h"
class MessageVisitor;
-class Message : public KShared
+class Message : public QSharedData
{
public:
virtual ~Message() { }
virtual void accept(MessageVisitor& visitor) const = 0;
};
-typedef KSharedPtr<Message> MessagePtr;
+typedef QExplicitlySharedDataPointer<Message> MessagePtr;
class HeaderMessage : public Message
{
diff --git a/src/networkdialog.cpp b/src/networkdialog.cpp
index 5289264..3819454 100644
--- a/src/networkdialog.cpp
+++ b/src/networkdialog.cpp
@@ -15,19 +15,20 @@
#include <QTcpServer>
#include <QVBoxLayout>
#include <QHBoxLayout>
+#include <QPushButton>
+
#include <KComboBox>
-#include <KNumInput>
+#include <KPluralHandlingSpinBox>
#include <KLineEdit>
#include <KLocalizedString>
-#include <KPushButton>
#include <KSeparator>
-#include <DNSSD/ServiceBrowser>
-#include <DNSSD/ServiceModel>
-#include <DNSSD/PublicService>
+#include <KDNSSD/DNSSD/ServiceBrowser>
+#include <KDNSSD/DNSSD/ServiceModel>
+#include <KDNSSD/DNSSD/PublicService>
#include "settings.h"
-NetworkDialog::NetworkDialog(bool client, QWidget* parent, const KUrl* url)
+NetworkDialog::NetworkDialog(bool client, QWidget* parent, const QUrl* url)
: KDialog(parent)
, m_publisher(0), m_client(client)
{
@@ -65,8 +66,8 @@ NetworkDialog::NetworkDialog(bool client, QWidget* parent, const KUrl* url)
if (m_client) {
tmp = new QLabel(i18n("&Join game:"), main);
m_games=new KComboBox(main);
- DNSSD::ServiceBrowser* browser=new DNSSD::ServiceBrowser("_kbattleship._tcp", true);
- m_games->setModel(new DNSSD::ServiceModel(browser, this));
+ KDNSSD::ServiceBrowser* browser=new KDNSSD::ServiceBrowser("_kbattleship._tcp", true);
+ m_games->setModel(new KDNSSD::ServiceModel(browser, this));
tmp->setBuddy(m_games);
tmpLayout = new QHBoxLayout;
tmpLayout->addWidget(tmp);
@@ -93,7 +94,7 @@ NetworkDialog::NetworkDialog(bool client, QWidget* parent, const KUrl* url)
// port
const int port = ( url && url->port() != -1 )? url->port(): Settings::port();
tmp = new QLabel(i18n("&Port:"), main);
- m_port = new KIntSpinBox(main);
+ m_port = new KPluralHandlingSpinBox(main);
m_port->setRange(1, 99999);
m_port->setValue(port);
tmp->setBuddy(m_port);
@@ -123,7 +124,7 @@ NetworkDialog::NetworkDialog(bool client, QWidget* parent, const KUrl* url)
// port
tmp = new QLabel(i18n("&Port:"), main);
- m_port = new KIntSpinBox(main);
+ m_port = new KPluralHandlingSpinBox(main);
m_port->setRange(1, 99999);
m_port->setValue(Settings::port());
tmp->setBuddy(m_port);
@@ -156,7 +157,7 @@ void NetworkDialog::savePreferences()
Settings::setHostname(hostname());
}
Settings::setPort(port());
- Settings::self()->writeConfig();
+ Settings::self()->save();
}
void NetworkDialog::serviceSelected(int idx)
@@ -164,7 +165,7 @@ void NetworkDialog::serviceSelected(int idx)
if (idx==-1) {
return;
}
- DNSSD::RemoteService::Ptr service=m_games->itemData(idx,DNSSD::ServiceModel::ServicePtrRole ).value<DNSSD::RemoteService::Ptr>();
+ KDNSSD::RemoteService::Ptr service=m_games->itemData(idx,KDNSSD::ServiceModel::ServicePtrRole ).value<KDNSSD::RemoteService::Ptr>();
m_hostname->setText(service->hostName());
m_port->setValue(service->port());
}
@@ -197,7 +198,7 @@ QTcpSocket* NetworkDialog::socket() const
void NetworkDialog::slotButtonClicked(int code)
{
if (code == Ok) {
- KPushButton* b = button(Ok);
+ QPushButton* b = button(Ok);
b->setEnabled(false);
m_feedback->show();
@@ -212,7 +213,7 @@ void NetworkDialog::slotButtonClicked(int code)
m_feedback->setText(i18n("Waiting for an incoming connection..."));
QTcpServer* server = new QTcpServer;
connect(server, SIGNAL(newConnection()), this, SLOT(serverOK()));
- m_publisher=new DNSSD::PublicService(nickname(), "_kbattleship._tcp", m_port->value());
+ m_publisher=new KDNSSD::PublicService(nickname(), "_kbattleship._tcp", m_port->value());
m_publisher->publishAsync();
server->listen(QHostAddress::Any, static_cast<quint16>(m_port->value()));
diff --git a/src/networkdialog.h b/src/networkdialog.h
index 168da23..c974944 100644
--- a/src/networkdialog.h
+++ b/src/networkdialog.h
@@ -12,13 +12,14 @@
#define NETWORKDIALOG_H
#include <KDialog>
+#include <QUrl>
class KComboBox;
-class KIntSpinBox;
+class KPluralHandlingSpinBox;
class KLineEdit;
class QLabel;
class QTcpSocket;
-namespace DNSSD { class PublicService; }
+namespace KDNSSD { class PublicService; }
class NetworkDialog : public KDialog
{
@@ -26,10 +27,10 @@ Q_OBJECT
KLineEdit* m_nickname;
KLineEdit* m_hostname;
QTcpSocket* m_socket;
- KIntSpinBox* m_port;
+ KPluralHandlingSpinBox* m_port;
QLabel* m_feedback;
KComboBox* m_games;
- DNSSD::PublicService* m_publisher;
+ KDNSSD::PublicService* m_publisher;
bool m_client;
QString hostname() const;
@@ -45,7 +46,7 @@ private slots:
protected:
void slotButtonClicked(int);
public:
- explicit NetworkDialog(bool client, QWidget* parent = 0, const KUrl* url = 0);
+ explicit NetworkDialog(bool client, QWidget* parent = 0, const QUrl* url = 0);
~NetworkDialog();
QString nickname() const;
diff --git a/src/networkentity.cpp b/src/networkentity.cpp
index c795099..5b6d1de 100644
--- a/src/networkentity.cpp
+++ b/src/networkentity.cpp
@@ -15,7 +15,7 @@
#include "settings.h"
#include "seaview.h"
-#include <KIcon>
+#include <QIcon>
#include <klocalizedstring.h>
NetworkEntity::NetworkEntity(Sea::Player player, Sea* sea, SeaView* seaview, Protocol* protocol, bool client)
@@ -317,9 +317,9 @@ void NetworkEntity::visit(const GameOptionsMessage& msg)
}
-KIcon NetworkEntity::icon() const
+QIcon NetworkEntity::icon() const
{
- return KIcon( QLatin1String( "network-workgroup" ));
+ return QIcon( QLatin1String( "network-workgroup" ));
}
#include "networkentity.moc"
diff --git a/src/networkentity.h b/src/networkentity.h
index 0ad2eb6..09a75ea 100644
--- a/src/networkentity.h
+++ b/src/networkentity.h
@@ -43,7 +43,7 @@ public:
virtual void notifyRestart(Sea::Player);
virtual void hit(Shot* shot);
- virtual KIcon icon() const;
+ virtual QIcon icon() const;
private slots:
void received(MessagePtr msg);
virtual void notifyAbort();
diff --git a/src/playfield.cpp b/src/playfield.cpp
index eee56e2..f0114f6 100644
--- a/src/playfield.cpp
+++ b/src/playfield.cpp
@@ -14,8 +14,8 @@
#include <QStatusBar>
#include <QVBoxLayout>
#include <QDebug>
+#include <QInputDialog>
-#include <KInputDialog>
#include <KLocale>
#include <KMessageBox>
#include <KScoreDialog>
@@ -230,30 +230,30 @@ void PlayField::gameOver(Sea::Player winner)
void PlayField::changeNick()
{
- QString nick = KInputDialog::getText(i18n("Change Nickname"), i18n("Enter new nickname:"), Settings::findNick());
+ QString nick = QInputDialog::getText(this, i18n("Change Nickname"), i18n("Enter new nickname:"), QLineEdit::Normal, Settings::findNick());
if (!nick.isEmpty()) {
Settings::setNickname(nick);
- Settings::self()->writeConfig();
+ Settings::self()->save();
}
}
void PlayField::toggleSounds(bool enable)
{
Settings::setEnableSounds(enable);
- Settings::self()->writeConfig();
+ Settings::self()->save();
m_player->setActive(enable);
}
void PlayField::toggleAdjacent(bool enable)
{
Settings::setAdjacentShips(enable);
- Settings::self()->writeConfig();
+ Settings::self()->save();
}
void PlayField::toggleMultiple(bool enable)
{
Settings::setSeveralShips(enable);
- Settings::self()->writeConfig();
+ Settings::self()->save();
}
void PlayField::restartRequested()
@@ -322,10 +322,9 @@ void PlayField::startPlacingShips()
void PlayField::restartPlacingShips(Sea::Player player)
{
m_status_bar->showMessage(i18n("You can't place your remaining ships."));
- KMessageBox restartYesNo;
KGuiItem buttonRestart=KStandardGuiItem::yes(); buttonRestart.setText(i18n("Restart"));
KGuiItem buttonAbort=KStandardGuiItem::no(); buttonAbort.setText(i18n("Abort"));
- int res=restartYesNo.warningYesNo(this, i18n("You can't place your remaining ships. Please restart placing ships or abort game"), i18n("Restart placing ships"), buttonRestart, buttonAbort);
+ int res=KMessageBox::warningYesNo(this, i18n("You can't place your remaining ships. Please restart placing ships or abort game"), i18n("Restart placing ships"), buttonRestart, buttonAbort);
if (res == KMessageBox::Yes) {
startPlacingShips();
m_controller->notifyRestartPlacingShips(player);
@@ -376,7 +375,7 @@ void PlayField::createClient()
createAuxMenu()->createClient();
}
-void PlayField::createClient(const KUrl& url)
+void PlayField::createClient(const QUrl& url)
{
createAuxMenu()->createClient(url);
}
diff --git a/src/playfield.h b/src/playfield.h
index 5766022..d1653bd 100644
--- a/src/playfield.h
+++ b/src/playfield.h
@@ -42,7 +42,7 @@ Q_OBJECT
public:
PlayField(QWidget* parent, QStatusBar*);
~PlayField();
- void createClient(const KUrl& url);
+ void createClient(const QUrl& url);
public slots:
void highscores();
void gameOver(Sea::Player winner);
diff --git a/src/seaview.cpp b/src/seaview.cpp
index 139497a..3078364 100644
--- a/src/seaview.cpp
+++ b/src/seaview.cpp
@@ -12,7 +12,7 @@
#include <QMouseEvent>
#include <QObject>
-#include <KIcon>
+#include <QIcon>
#include "battlefieldview.h"
#include "button.h"
diff --git a/src/simplemenu.cpp b/src/simplemenu.cpp
index f8c96c9..6b1a90b 100644
--- a/src/simplemenu.cpp
+++ b/src/simplemenu.cpp
@@ -10,9 +10,9 @@
#include "simplemenu.h"
#include <QTcpSocket>
+#include <QIcon>
#include <KLocalizedString>
-#include <KIcon>
#include "button.h"
#include "chatwidget.h"
@@ -40,9 +40,9 @@ SimpleMenu::SimpleMenu(QWidget* parent, WelcomeScreen* screen)
{
if (m_screen) {
// create buttons
- m_local_game_btn = m_screen->addButton(0, 0, KIcon( QLatin1String( iconLocal) ), i18n("Single Player" ));
- m_server_btn = m_screen->addButton(0, 1, KIcon( QLatin1String( iconServer) ), i18n("Host Network Game" ));
- m_client_btn = m_screen->addButton(0, 2, KIcon( QLatin1String( iconClient) ), i18n("Connect to Network Game" ));
+ m_local_game_btn = m_screen->addButton(0, 0, QIcon( QLatin1String( iconLocal) ), i18n("Single Player" ));
+ m_server_btn = m_screen->addButton(0, 1, QIcon( QLatin1String( iconServer) ), i18n("Host Network Game" ));
+ m_client_btn = m_screen->addButton(0, 2, QIcon( QLatin1String( iconClient) ), i18n("Connect to Network Game" ));
// create connections
connect(m_local_game_btn, SIGNAL(clicked()),
@@ -83,7 +83,7 @@ void SimpleMenu::createServer()
}
}
-void SimpleMenu::createClient(const KUrl& url)
+void SimpleMenu::createClient(const QUrl& url)
{
QWidget* parent_widget = qobject_cast<QWidget*>(parent());
Q_ASSERT(parent_widget);
diff --git a/src/simplemenu.h b/src/simplemenu.h
index a393cf3..bd1e426 100644
--- a/src/simplemenu.h
+++ b/src/simplemenu.h
@@ -20,7 +20,7 @@ class Button;
class QTcpSocket;
class Entity;
class Protocol;
-class KUrl;
+class QUrl;
class SimpleMenu : public QObject
{
@@ -51,7 +51,7 @@ public:
void setupController(Controller* controller, Entity* old_opponent,
SeaView* sea, ChatWidget* chat, bool ask = false);
- void createClient(const KUrl& url);
+ void createClient(const QUrl& url);
Entity* player(int p) { return p == 0 ? m_player1 : m_player2; }
diff --git a/src/uientity.cpp b/src/uientity.cpp
index 58b1810..fa21d17 100644
--- a/src/uientity.cpp
+++ b/src/uientity.cpp
@@ -12,7 +12,7 @@
#include "shot.h"
#include "ship.h"
-#include <KIcon>
+#include <QIcon>
#include <QList>
UIEntity::UIEntity(Sea::Player player, Sea* sea, SeaView* view)
@@ -85,9 +85,9 @@ void UIEntity::drawShoot(Sea::Player player, const Coord& c, const HitInfo& info
}
}
-KIcon UIEntity::icon() const
+QIcon UIEntity::icon() const
{
- return KIcon( QLatin1String( "user-identity" ));
+ return QIcon( QLatin1String( "user-identity" ));
}
#include "uientity.moc"
diff --git a/src/uientity.h b/src/uientity.h
index b999d69..e700890 100644
--- a/src/uientity.h
+++ b/src/uientity.h
@@ -38,7 +38,7 @@ public:
virtual void registerHit(Sea::Player, const Coord&) { }
virtual void registerMiss(Sea::Player, const Coord&) { }
- virtual KIcon icon() const;
+ virtual QIcon icon() const;
public slots:
virtual void notifyAbort() { }
virtual void notifyRestartPlacing(Sea::Player player) { };
diff --git a/src/welcomescreen.cpp b/src/welcomescreen.cpp
index f00dc14..c7e9152 100644
--- a/src/welcomescreen.cpp
+++ b/src/welcomescreen.cpp
@@ -10,8 +10,8 @@
#include "welcomescreen.h"
#include <QDebug>
+#include <QIcon>
-#include <kicon.h>
#include <klocale.h>
#include "button.h"