Commit fd5a2efb authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Compile changes for QtQuick porting to Qt5.

parent bf039714
...@@ -38,10 +38,13 @@ find_package(Qt5 REQUIRED COMPONENTS ...@@ -38,10 +38,13 @@ find_package(Qt5 REQUIRED COMPONENTS
Widgets Widgets
Sql Sql
XmlPatterns XmlPatterns
Quick
QuickWidgets
) )
find_package(KF5 CONFIG REQUIRED COMPONENTS find_package(KF5 CONFIG REQUIRED COMPONENTS
Config Config
CoreAddons CoreAddons
Declarative
I18n I18n
KDELibs4Support KDELibs4Support
NewStuff NewStuff
......
...@@ -26,8 +26,6 @@ set(ARTIKULATE_VERSION_MAJOR 0) ...@@ -26,8 +26,6 @@ set(ARTIKULATE_VERSION_MAJOR 0)
set(ARTIKULATE_VERSION_MINOR 4) set(ARTIKULATE_VERSION_MINOR 4)
set(ARTIKULATE_VERSION_PATCH 50) set(ARTIKULATE_VERSION_PATCH 50)
find_package(KDeclarative REQUIRED)
# set config files after packages are searched # set config files after packages are searched
configure_file("${artikulate_SOURCE_DIR}/version.h.cmake" "${artikulate_BINARY_DIR}/version.h" @ONLY) configure_file("${artikulate_SOURCE_DIR}/version.h.cmake" "${artikulate_BINARY_DIR}/version.h" @ONLY)
...@@ -115,8 +113,6 @@ set(artikulate_SRCS ...@@ -115,8 +113,6 @@ set(artikulate_SRCS
ui/sounddevicedialogpage.cpp ui/sounddevicedialogpage.cpp
ui/appearencedialogpage.cpp ui/appearencedialogpage.cpp
ui/resourcesdialogpage.cpp ui/resourcesdialogpage.cpp
declarativeitems/applicationbackground.cpp
) )
qt5_wrap_ui (artikulate_SRCS qt5_wrap_ui (artikulate_SRCS
ui/resourcesdialogpage.ui ui/resourcesdialogpage.ui
...@@ -133,7 +129,9 @@ target_link_libraries(artikulate ...@@ -133,7 +129,9 @@ target_link_libraries(artikulate
${KDECLARATIVE_LIBRARIES} ${KDECLARATIVE_LIBRARIES}
${KDE4_PLASMA_LIBS} ${KDE4_PLASMA_LIBS}
${KDE4_KIO_LIBS} ${KDE4_KIO_LIBS}
${QT_QTDECLARATIVE_LIBRARY} Qt5::Quick
Qt5::QuickWidgets
KF5::Declarative
KF5::NewStuff KF5::NewStuff
) )
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "core/trainingsession.h" #include "core/trainingsession.h"
#include "core/player.h" #include "core/player.h"
#include "core/recorder.h" #include "core/recorder.h"
#include "declarativeitems/applicationbackground.h"
#include "models/coursemodel.h" #include "models/coursemodel.h"
#include "models/coursefiltermodel.h" #include "models/coursefiltermodel.h"
#include "models/languagemodel.h" #include "models/languagemodel.h"
...@@ -54,12 +53,11 @@ ...@@ -54,12 +53,11 @@
#include "liblearnerprofile/src/learninggoal.h" #include "liblearnerprofile/src/learninggoal.h"
#include "liblearnerprofile/src/models/learninggoalmodel.h" #include "liblearnerprofile/src/models/learninggoalmodel.h"
#include <kdeclarative.h> #include <QQmlComponent>
#include <QQmlContext>
#include <qdeclarative.h> #include <QQmlEngine>
#include <KDeclarative/KDeclarative>
#include <QGraphicsDropShadowEffect> #include <QGraphicsDropShadowEffect>
#include <QScriptValue>
#include <QScriptEngine>
Application::Application() Application::Application()
: KApplication(true) : KApplication(true)
...@@ -101,5 +99,4 @@ void Application::registerQmlTypes() ...@@ -101,5 +99,4 @@ void Application::registerQmlTypes()
qmlRegisterType<LearnerProfile::LearningGoalModel>("artikulate", 1, 0, "LearningGoalModel"); qmlRegisterType<LearnerProfile::LearningGoalModel>("artikulate", 1, 0, "LearningGoalModel");
qmlRegisterType<MainWindow>("artikulate", 1, 0, "MainWindow"); qmlRegisterType<MainWindow>("artikulate", 1, 0, "MainWindow");
qmlRegisterType<ApplicationBackground>("artikulate", 1, 0, "ApplicationBackground");
} }
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include <KApplication> #include <KApplication>
class QDeclarativeEngine;
class Application : public KApplication class Application : public KApplication
{ {
Q_OBJECT Q_OBJECT
......
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "applicationbackground.h"
#include <QApplication>
#include <QPainter>
#include <plasma/theme.h>
ApplicationBackground::ApplicationBackground(QDeclarativeItem *parent)
: QDeclarativeItem(parent)
{
setFlag(QDeclarativeItem::ItemHasNoContents, false);
}
void ApplicationBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
{
const QColor appBgColor = QApplication::palette().color(QPalette::Window);
QColor color = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
const int similarity = qAbs(appBgColor.lightness() - color.lightness());
color.setAlpha(qMax(0, similarity - 50));
painter->fillRect(boundingRect(), color);
}
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef APPLICATIONBACKGROUND_H
#define APPLICATIONBACKGROUND_H
#include <QDeclarativeItem>
class ApplicationBackground : public QDeclarativeItem
{
Q_OBJECT
public:
explicit ApplicationBackground(QDeclarativeItem *parent = 0);
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*);
};
#endif // APPLICATIONBACKGROUND_H
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <KGlobal> #include <KGlobal>
#include <KIcon> #include <KIcon>
#include <KLocale> #include <KLocale>
#include <kdeclarative.h> #include <KDeclarative/KDeclarative>
#include <KConfigDialog> #include <KConfigDialog>
#include <QDebug> #include <QDebug>
#include <KStandardAction> #include <KStandardAction>
...@@ -48,10 +48,11 @@ ...@@ -48,10 +48,11 @@
#include <KNS3/DownloadDialog> #include <KNS3/DownloadDialog>
#include <QGraphicsObject> #include <QGraphicsObject>
#include <QDeclarativeItem> #include <QQuickItem>
#include <QDeclarativeView> #include <QQuickView>
#include <QDeclarativeContext> #include <QQmlContext>
#include <QDeclarativeProperty> #include <QQmlProperty>
#include <QQuickWidget>
#include <QCloseEvent> #include <QCloseEvent>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QPointer> #include <QtCore/QPointer>
...@@ -61,7 +62,7 @@ using namespace LearnerProfile; ...@@ -61,7 +62,7 @@ using namespace LearnerProfile;
MainWindow::MainWindow() MainWindow::MainWindow()
: KXmlGuiWindow(0) : KXmlGuiWindow(0)
, m_view(new QDeclarativeView(this)) , m_widget(new QQuickWidget(this)) //FIXME set MainWindow*
, m_trainingProfile(new Profile(this)) , m_trainingProfile(new Profile(this))
, m_editorProfile(new Profile(this)) , m_editorProfile(new Profile(this))
, m_resourceManager(new ResourceManager(this)) , m_resourceManager(new ResourceManager(this))
...@@ -70,8 +71,6 @@ MainWindow::MainWindow() ...@@ -70,8 +71,6 @@ MainWindow::MainWindow()
{ {
setWindowIcon(KIcon("artikulate")); // FIXME not present yet setWindowIcon(KIcon("artikulate")); // FIXME not present yet
setWindowTitle(qAppName()); setWindowTitle(qAppName());
setCentralWidget(m_view);
setAutoSaveSettings(); setAutoSaveSettings();
// load saved sound settings // load saved sound settings
...@@ -82,8 +81,8 @@ MainWindow::MainWindow() ...@@ -82,8 +81,8 @@ MainWindow::MainWindow()
m_resourceManager->loadCourseResources(); m_resourceManager->loadCourseResources();
m_resourceManager->registerLearningGoals(m_profileManager); m_resourceManager->registerLearningGoals(m_profileManager);
KDeclarative m_kdeclarative; KDeclarative::KDeclarative m_kdeclarative;
m_kdeclarative.setDeclarativeEngine(m_view->engine()); m_kdeclarative.setDeclarativeEngine(m_widget->engine());
m_kdeclarative.initialize(); m_kdeclarative.initialize();
m_kdeclarative.setupBindings(); //TODO use result for determining touch/desktop version m_kdeclarative.setupBindings(); //TODO use result for determining touch/desktop version
...@@ -91,22 +90,21 @@ MainWindow::MainWindow() ...@@ -91,22 +90,21 @@ MainWindow::MainWindow()
setupActions(); setupActions();
// set view // set view
m_view->resize(QSize(800, 600)); m_widget->resize(QSize(800, 600));
m_view->setStyleSheet("background-color: transparent;"); m_widget->setStyleSheet("background-color: transparent;");
m_view->rootContext()->setContextObject(this); m_widget->rootContext()->setContextObject(this);
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_view->rootContext()->setContextProperty("userProfile", m_trainingProfile); //TODO deprecated m_widget->rootContext()->setContextProperty("userProfile", m_trainingProfile); //TODO deprecated
m_view->rootContext()->setContextProperty("editorProfile", m_editorProfile); //TODO rename m_widget->rootContext()->setContextProperty("editorProfile", m_editorProfile); //TODO rename
m_view->rootContext()->setContextProperty("trainingSession", m_trainingSession); //TODO needed at top level? m_widget->rootContext()->setContextProperty("trainingSession", m_trainingSession); //TODO needed at top level?
m_view->rootContext()->setContextProperty("profileManager", m_profileManager); m_widget->rootContext()->setContextProperty("profileManager", m_profileManager);
m_view->rootContext()->setContextProperty("kcfg_UseContributorResources", Settings::useCourseRepository()); m_widget->rootContext()->setContextProperty("kcfg_UseContributorResources", Settings::useCourseRepository());
m_view->setStyleSheet("background-color: transparent;"); m_widget->setStyleSheet("background-color: transparent;");
// set starting screen // set starting screen
m_view->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/Main.qml"))); m_widget->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/Main.qml")));
// settings from kcfg values // settings from kcfg values
updateTrainingPhraseFont(); updateTrainingPhraseFont();
...@@ -117,11 +115,13 @@ MainWindow::MainWindow() ...@@ -117,11 +115,13 @@ MainWindow::MainWindow()
} }
// set initial view // set initial view
m_view->rootObject()->setProperty("viewMode", Trainer); m_widget->rootObject()->setProperty("viewMode", Trainer);
// set font for the phrase in trainer to default from kcfg file // set font for the phrase in trainer to default from kcfg file
QObject *phraseText = m_view->rootObject()->findChild<QObject*>("phraseText"); QObject *phraseText = m_widget->rootObject()->findChild<QObject*>("phraseText");
phraseText->setProperty("font", Settings::trainingPhraseFont()); phraseText->setProperty("font", Settings::trainingPhraseFont());
setCentralWidget(m_widget);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -168,21 +168,21 @@ void MainWindow::setupActions() ...@@ -168,21 +168,21 @@ void MainWindow::setupActions()
void MainWindow::showCourseEditor() void MainWindow::showCourseEditor()
{ {
m_view->rootObject()->setProperty("viewMode", Editor); m_widget->rootObject()->setProperty("viewMode", Editor);
// untoggle editor view mode // untoggle editor view mode
emit modeChanged(true); emit modeChanged(true);
} }
void MainWindow::closeCourseEditor() void MainWindow::closeCourseEditor()
{ {
m_view->rootObject()->setProperty("viewMode", Trainer); m_widget->rootObject()->setProperty("viewMode", Trainer);
// toggle editor view mode // toggle editor view mode
emit modeChanged(false); emit modeChanged(false);
} }
void MainWindow::switchMode() void MainWindow::switchMode()
{ {
if (m_view->rootObject()->property("viewMode") == Trainer){ if (m_widget->rootObject()->property("viewMode") == Trainer){
showCourseEditor(); showCourseEditor();
} }
else { else {
...@@ -223,7 +223,7 @@ void MainWindow::showSettingsDialog() ...@@ -223,7 +223,7 @@ void MainWindow::showSettingsDialog()
void MainWindow::updateTrainingPhraseFont() void MainWindow::updateTrainingPhraseFont()
{ {
QObject *phraseText = m_view->rootObject()->findChild<QObject*>("phraseText"); QObject *phraseText = m_widget->rootObject()->findChild<QObject*>("phraseText");
if (!phraseText) { if (!phraseText) {
qDebug() << "no phraseText context object found, aborting"; qDebug() << "no phraseText context object found, aborting";
return; return;
...@@ -234,7 +234,7 @@ void MainWindow::updateTrainingPhraseFont() ...@@ -234,7 +234,7 @@ void MainWindow::updateTrainingPhraseFont()
void MainWindow::updateKcfgUseContributorResources() void MainWindow::updateKcfgUseContributorResources()
{ {
m_view->rootContext()->setContextProperty("kcfg_UseContributorResources", Settings::useCourseRepository()); m_widget->rootContext()->setContextProperty("kcfg_UseContributorResources", Settings::useCourseRepository());
} }
void MainWindow::downloadNewStuff() void MainWindow::downloadNewStuff()
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
class Profile; class Profile;
class KActionCollection; class KActionCollection;
class KMenu; class KMenu;
class QDeclarativeView; class QQuickView;
class QQuickWidget;
namespace LearnerProfile { namespace LearnerProfile {
class ProfileManager; class ProfileManager;
...@@ -78,7 +79,7 @@ signals: ...@@ -78,7 +79,7 @@ signals:
void modeChanged(bool); void modeChanged(bool);
private: private:
QDeclarativeView *m_view; QQuickWidget *m_widget;
Profile *m_trainingProfile, *m_editorProfile; Profile *m_trainingProfile, *m_editorProfile;
ResourceManager *m_resourceManager; ResourceManager *m_resourceManager;
TrainingSession *m_trainingSession; TrainingSession *m_trainingSession;
......
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