diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df8d2cf..5b7a618 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,83 +1,86 @@ ecm_setup_version(${KDE_APPLICATIONS_VERSION} VARIABLE_PREFIX KANAGRAM VERSION_HEADER kanagram_version.h) set(kanagram_SRCS kanagramconfigdialog.cpp kanagramgame.cpp main.cpp mainwindow.cpp mainsettings.cpp vocabsettings.cpp vocabedit.cpp ) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) ki18n_wrap_ui(kanagram_SRCS vocabsettingswidget.ui vocabeditwidget.ui mainsettingswidget.ui ) file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/*-apps-kanagram.png") ecm_add_app_icon(cantor_SRCS ICONS ${ICONS_SRCS}) kconfig_add_kcfg_files(kanagram_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/kanagramsettings.kcfgc) # qt5_add_dbus_interfaces(kanagram_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml ) ecm_add_app_icon(kanagram_SRCS ICONS ${CMAKE_SOURCE_DIR}/icons/16-apps-kanagram.png ${CMAKE_SOURCE_DIR}/icons/32-apps-kanagram.png ${CMAKE_SOURCE_DIR}/icons/64-apps-kanagram.png ${CMAKE_SOURCE_DIR}/icons/128-app-kanagram.png ) -add_executable(kanagram ${kanagram_SRCS}) + +if (Qt5QuickCompiler_FOUND AND COMPILE_QML) + qtquick_compiler_add_resources(kanagram_qml_SRCS qml.qrc) +else () + qt5_add_resources(kanagram_qml_SRCS qml.qrc) +endif() + +add_executable(kanagram ${kanagram_SRCS} ${kanagram_qml_SRCS}) target_link_libraries(kanagram Qt5::Quick Qt5::Core KF5::CoreAddons KF5::I18n KF5::NewStuff KF5::SonnetCore KF5::Declarative KF5::Crash LibKEduVocDocumentImport__KEduVocDocument ) if (Qt5TextToSpeech_FOUND) target_link_libraries(kanagram Qt5::TextToSpeech) endif() install( FILES kanagram.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} ) install( FILES kanagram.knsrc DESTINATION ${KDE_INSTALL_CONFDIR} ) -install( - DIRECTORY ui/ - DESTINATION ${KDE_INSTALL_DATADIR}/kanagram/ui) - install( FILES org.kde.kanagram.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install( TARGETS kanagram ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9bb5168..c8c686d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,121 +1,120 @@ /*************************************************************************** * This file is part of the Kanagram project * * Copyright 2011 Sebastian Kügler * * Copyright 2011 Marco Martin * * Copyright 2012 Laszlo Papp * * Copyright 2014 Jeremy Whiting * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "mainwindow.h" #include "kanagramgame.h" #include "kanagramsettings.h" #include "kanagramconfigdialog.h" #include #include #include #include #include #include #include MainWindow::MainWindow() : m_game(new KanagramGame()) ,m_helpMenu(new KHelpMenu(nullptr)) { setResizeMode(QQuickView::SizeRootObjectToView); qCDebug(KANAGRAM) << "Created game and engine helper"; rootContext()->setContextProperty(QStringLiteral("kanagramGame"), m_game); rootContext()->setContextProperty(QStringLiteral("application"), qApp); rootContext()->setContextProperty(QStringLiteral("mainwindow"), this); qCDebug(KANAGRAM) << "Set all context properties"; KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.setupBindings(); qCDebug(KANAGRAM) << "Setup declarative engine"; KConfigGroup windowConfig = config(QStringLiteral("Window")); if (windowConfig.hasKey("geometry")) { setGeometry(windowConfig.readEntry("geometry", QRect())); setWindowState(Qt::WindowState(windowConfig.readEntry("windowState").toInt())); } - QString location = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("ui/main.qml")); - setSource(QUrl::fromLocalFile(location)); + setSource(QUrl("qrc:/qml/ui/main.qml")); qCDebug(KANAGRAM) << "Set qml file location"; connect(m_game, &KanagramGame::titleChanged, this, &MainWindow::categoryChanged); categoryChanged(); } MainWindow::~MainWindow() { KConfigGroup windowConfig = config(QStringLiteral("Window")); windowConfig.writeEntry("geometry", geometry()); windowConfig.writeEntry("windowState", int(windowState())); delete m_helpMenu; delete m_game; } KConfigGroup MainWindow::config(const QString &group) { return KConfigGroup(KSharedConfig::openConfig(qApp->applicationName() + "rc"), group); } void MainWindow::showAboutKanagram() { m_helpMenu->aboutApplication(); } void MainWindow::showAboutKDE() { m_helpMenu->aboutKDE(); } void MainWindow::showHandbook() { m_helpMenu->appHelpActivated(); } void MainWindow::showSettings() { if (!KConfigDialog::showDialog(QStringLiteral("settings"))) { m_configDialog = new KanagramConfigDialog( NULL, QStringLiteral("settings"), KanagramSettings::self() ); connect(m_configDialog, &KConfigDialog::settingsChanged, m_game, &KanagramGame::reloadSettings); connect(m_configDialog, &KConfigDialog::accepted, m_game, &KanagramGame::refreshVocabularyList); m_configDialog->resize(600, 500); m_configDialog->show(); } } void MainWindow::categoryChanged() { setTitle(m_game->documentTitle()); } diff --git a/src/qml.qrc b/src/qml.qrc new file mode 100644 index 0000000..b5eef3b --- /dev/null +++ b/src/qml.qrc @@ -0,0 +1,26 @@ + + + ui/main.qml + ui/Blackboard.qml + ui/LetterButton.qml + ui/images/background.jpg + ui/images/chalkboard.png + ui/images/header.png + ui/icons/1player.png + ui/icons/2player.png + ui/icons/about-kanagram.png + ui/icons/about-kde.png + ui/icons/arrow-light.svgz + ui/icons/close.png + ui/icons/hint.png + ui/icons/kanagram-handbook.png + ui/icons/left-arrow.png + ui/icons/on-off-light.svgz + ui/icons/question-light.svgz + ui/icons/reveal.png + ui/icons/right-arrow.png + ui/icons/spanner-light.svgz + ui/icons/timer.png + ui/icons/wikipedia.png + +