Git commit d82965a669e2b1996f3d9c93d286d32b9f597477 by Albert Astals Cid. Committed on 11/08/2014 at 20:47. Pushed by aacid into branch 'frameworks'.
Initial KF5 port of blinken M +27 -4 CMakeLists.txt M +1 -1 doc/CMakeLists.txt M +1 -1 doc/index.docbook M +1 -1 icons/CMakeLists.txt M +11 -7 src/CMakeLists.txt M +3 -1 src/blinken.cpp M +13 -8 src/highscoredialog.cpp M +2 -2 src/highscoredialog.h M +19 -11 src/main.cpp http://commits.kde.org/blinken/d82965a669e2b1996f3d9c93d286d32b9f597477 diff --git a/CMakeLists.txt b/CMakeLists.txt index a7a682e..5d07820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,35 @@ project(blinken) -find_package(KDE4 REQUIRED) -include(KDE4Defaults) -include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}) +cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) + +# minimal Qt requirement +set (QT_MIN_VERSION "5.2.0") + +# ECM +find_package (ECM 0.0.9 REQUIRED NO_MODULE) + +# where to look first for cmake modules +set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + +find_package (Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Widgets Svg) + +find_package (KF5 REQUIRED COMPONENTS + XmlGui WidgetsAddons CoreAddons ConfigWidgets I18n ItemViews IconThemes Service DocTools KDELibs4Support +) + +find_package (Phonon4Qt5) + +include(KDEInstallDirs) +include(KDECompilerSettings) +include(KDECMakeSettings) +include(FeatureSummary) +include(ECMInstallIcons) -set(CMAKE_MODULE_PATH ${blinken_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) +# global include directories +include_directories (${CMAKE_CURRENT_BINARY_DIR}) + add_subdirectory( doc ) add_subdirectory( src ) add_subdirectory( images ) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index a293490..5622d2f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,4 +1,4 @@ ########### install files ############### # -kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR blinken) +kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR blinken) \ No newline at end of file diff --git a/doc/index.docbook b/doc/index.docbook index 224ebde..0cffa90 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1,5 +1,5 @@ <?xml version="1.0" ?> -<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [ +<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdex.dtd" [ <!ENTITY blinken "<application>Blinken</application>"> <!ENTITY kappname "&blinken;"> <!ENTITY package "kdeedu"> diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 2693884..0934911 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1,2 +1,2 @@ -kde4_install_icons( ${ICON_INSTALL_DIR} ) +ecm_install_icons( ${ICON_INSTALL_DIR} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e5e254..4156152 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,17 +12,21 @@ set(blinken_SRCS button.cpp ) -kde4_add_kcfg_files(blinken_SRCS settings.kcfgc ) +kconfig_add_kcfg_files(blinken_SRCS settings.kcfgc ) -#uncomment this if oxygen icons for blinken are available -#kde4_add_app_icon(blinken_SRCS "${CMAKE_INSTALL_PREFIX}/share/icons/oxygen/*/apps/blinken.png") -kde4_add_app_icon(blinken_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-app-blinken.png") +add_executable(blinken ${blinken_SRCS}) -kde4_add_executable(blinken ${blinken_SRCS}) +MESSAGE(${PHONON_LIBRARIES}) +target_link_libraries(blinken + KF5::I18n + KF5::XmlGui + Qt5::Svg + ${KDE4_KDEUI_LIBS} + ${PHONON_LIBRARIES} + ) -target_link_libraries(blinken ${KDE4_KIO_LIBS} ${KDE4_PHONON_LIBS}) +install(TARGETS blinken EXPORT blinken ${INSTALL_TARGETS_DEFAULT_ARGS} ) -install(TARGETS blinken ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### diff --git a/src/blinken.cpp b/src/blinken.cpp index 168eee9..a7efb56 100644 --- a/src/blinken.cpp +++ b/src/blinken.cpp @@ -18,12 +18,14 @@ #include <kaction.h> #include <kconfig.h> +#include <kglobal.h> #include <khelpmenu.h> #include <kinputdialog.h> #include <kfontutils.h> #include <klocale.h> #include <kmessagebox.h> #include <kmenu.h> +#include <kshortcut.h> #include <kstandarddirs.h> #include <KComponentData> @@ -66,7 +68,7 @@ blinken::blinken() : m_overHighscore(false), m_overQuit(false), m_overCentralTex connect(&m_game, SIGNAL(phaseChanged()), this, SLOT(update())); connect(&m_game, SIGNAL(highlight(blinkenGame::color, bool)), this, SLOT(highlight(blinkenGame::color, bool))); - m_helpMenu = new KHelpMenu(this, KGlobal::mainComponent().aboutData()); + m_helpMenu = new KHelpMenu(this, KAboutData::applicationData()); m_helpMenu->menu(); // ensures the actions are created for (int i = 0; i < 3; i++) m_overLevels[i] = false; diff --git a/src/highscoredialog.cpp b/src/highscoredialog.cpp index 4ddd1e5..5a92e4a 100644 --- a/src/highscoredialog.cpp +++ b/src/highscoredialog.cpp @@ -9,14 +9,16 @@ #include "highscoredialog.h" +#include <qdialogbuttonbox.h> #include <qpainter.h> #include <qpixmap.h> #include <qtabbar.h> +#include <QVBoxLayout> #include <kconfig.h> #include <kfontutils.h> #include <klocale.h> -#include <kglobal.h> +#include <ksharedconfig.h> #include <ktabwidget.h> #include "counter.h" @@ -134,14 +136,17 @@ class myTabWidget : public KTabWidget /* highScoreDialog */ -highScoreDialog::highScoreDialog(QWidget *parent, QSvgRenderer *renderer) : KDialog(parent) +highScoreDialog::highScoreDialog(QWidget *parent, QSvgRenderer *renderer) : QDialog(parent) { - setCaption(i18nc("@title:window the highest scores for each level are shown", "Highscores")); - setButtons(Close); + setWindowTitle(i18nc("@title:window the highest scores for each level are shown", "Highscores")); + setLayout(new QVBoxLayout(this)); m_tw = new myTabWidget(this); - setMainWidget(m_tw); - + layout()->addWidget(m_tw); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); + layout()->addWidget(buttonBox); + highScoreManager hsm; m_tw -> addTab(new scoresWidget(0, hsm.scores(0), renderer), i18nc("@title:group High scores Level 1 tab title", "Level 1")); @@ -202,7 +207,7 @@ void highScoreManager::addScore(int level, int score, const QString &name) m_scores[level].insert(it, qMakePair(score, name)); m_scores[level].erase(--m_scores[level].end()); - KConfigGroup cfg(KGlobal::config(), QString("Level%1").arg(level + 1)); + KConfigGroup cfg(KSharedConfig::openConfig(), QString("Level%1").arg(level + 1)); int j; for (it = m_scores[level].begin(), j = 1; it != m_scores[level].end(); ++it, j++) { @@ -229,7 +234,7 @@ void highScoreManager::update() } for (int i = 1; i <= 3; i++) { - KConfigGroup cfg(KGlobal::config(), QString("Level%1").arg(i)); + KConfigGroup cfg(KSharedConfig::openConfig(), QString("Level%1").arg(i)); for (int j = 1; j <= 5; j++) { m_scores[i-1].append(qMakePair(cfg.readEntry(QString("Score%1").arg(j),QVariant(0)).toInt(),cfg.readEntry(QString("Name%1").arg(j),QString()))); diff --git a/src/highscoredialog.h b/src/highscoredialog.h index 270129b..0d1a315 100644 --- a/src/highscoredialog.h +++ b/src/highscoredialog.h @@ -13,13 +13,13 @@ #include <qpair.h> #include <qlist.h> -#include <kdialog.h> +#include <qdialog.h> class QSvgRenderer; class myTabWidget; -class highScoreDialog : private KDialog +class highScoreDialog : private QDialog { public: highScoreDialog(QWidget *parent, QSvgRenderer *renderer); diff --git a/src/main.cpp b/src/main.cpp index 4751294..2eefbc4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,23 +10,31 @@ #include "blinken.h" #include <kaboutdata.h> -#include <kcmdlineargs.h> -#include <klocale.h> +#include <klocalizedstring.h> #include <kstandarddirs.h> -#include <kapplication.h> +#include <qapplication.h> +#include <qcommandlineparser.h> #include <QFontDatabase> #include <QFontInfo> int main(int argc, char *argv[]) { - KAboutData about("blinken", 0, ki18n("Blinken"), "0.3", ki18n("A memory enhancement game"), KAboutData::License_GPL, ki18n("? 2005-2007 Albert Astals Cid\n? 2005-2007 Danny Allen")); - about.addAuthor(ki18n("Albert Astals Cid"), ki18n("Coding"), "aacid at kde.org"); - about.addAuthor(ki18n("Danny Allen"), ki18n("Design, Graphics and Sounds"), "danny at dannyallen.co.uk"); - about.addCredit(ki18n("Steve Jordi"), ki18n("GPL'ed his 'Steve' font so that we could use it"), "steve at sjordi.com"); - KCmdLineArgs::init(argc, argv, &about); - KApplication app; - app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); + KLocalizedString::setApplicationDomain("blinken"); + + QApplication app(argc, argv); + KAboutData about("blinken", i18n("Blinken"), "0.3", i18n("A Geography learning program"), KAboutLicense::GPL, i18n("? 2005-2007 Albert Astals Cid\n? 2005-2007 Danny Allen")); + about.addAuthor(i18n("Albert Astals Cid"), i18n("Coding"), "aacid at kde.org"); + about.addAuthor(i18n("Danny Allen"), i18n("Design, Graphics and Sounds"), "danny at dannyallen.co.uk"); + about.addCredit(i18n("Steve Jordi"), i18n("GPL'ed his 'Steve' font so that we could use it"), "steve at sjordi.com"); + + KAboutData::setApplicationData(about); + + QCommandLineParser parser; + parser.addVersionOption(); + about.setupCommandLine(&parser); + parser.process(app); + about.processCommandLine(&parser); QFont f("Steve", 12, QFont::Normal, true); // Works with Steve may need some tweaking to work with other fonts @@ -35,6 +43,6 @@ int main(int argc, char *argv[]) QFontDatabase::addApplicationFont(KStandardDirs::locate("appdata", "fonts/steve.ttf")); } - app.setTopWidget(new blinken()); + new blinken(); return app.exec(); }
