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
Widgets
Sql
XmlPatterns
Quick
QuickWidgets
)
find_package(KF5 CONFIG REQUIRED COMPONENTS
Config
CoreAddons
Declarative
I18n
KDELibs4Support
NewStuff
......
......@@ -26,8 +26,6 @@ set(ARTIKULATE_VERSION_MAJOR 0)
set(ARTIKULATE_VERSION_MINOR 4)
set(ARTIKULATE_VERSION_PATCH 50)
find_package(KDeclarative REQUIRED)
# set config files after packages are searched
configure_file("${artikulate_SOURCE_DIR}/version.h.cmake" "${artikulate_BINARY_DIR}/version.h" @ONLY)
......@@ -115,8 +113,6 @@ set(artikulate_SRCS
ui/sounddevicedialogpage.cpp
ui/appearencedialogpage.cpp
ui/resourcesdialogpage.cpp
declarativeitems/applicationbackground.cpp
)
qt5_wrap_ui (artikulate_SRCS
ui/resourcesdialogpage.ui
......@@ -133,7 +129,9 @@ target_link_libraries(artikulate
${KDECLARATIVE_LIBRARIES}
${KDE4_PLASMA_LIBS}
${KDE4_KIO_LIBS}
${QT_QTDECLARATIVE_LIBRARY}
Qt5::Quick
Qt5::QuickWidgets
KF5::Declarative
KF5::NewStuff
)
......
......@@ -33,7 +33,6 @@
#include "core/trainingsession.h"
#include "core/player.h"
#include "core/recorder.h"
#include "declarativeitems/applicationbackground.h"
#include "models/coursemodel.h"
#include "models/coursefiltermodel.h"
#include "models/languagemodel.h"
......@@ -54,12 +53,11 @@
#include "liblearnerprofile/src/learninggoal.h"
#include "liblearnerprofile/src/models/learninggoalmodel.h"
#include <kdeclarative.h>
#include <qdeclarative.h>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlEngine>
#include <KDeclarative/KDeclarative>
#include <QGraphicsDropShadowEffect>
#include <QScriptValue>
#include <QScriptEngine>
Application::Application()
: KApplication(true)
......@@ -101,5 +99,4 @@ void Application::registerQmlTypes()
qmlRegisterType<LearnerProfile::LearningGoalModel>("artikulate", 1, 0, "LearningGoalModel");
qmlRegisterType<MainWindow>("artikulate", 1, 0, "MainWindow");
qmlRegisterType<ApplicationBackground>("artikulate", 1, 0, "ApplicationBackground");
}
......@@ -24,8 +24,6 @@
#include <KApplication>
class QDeclarativeEngine;
class Application : public KApplication
{
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 @@
#include <KGlobal>
#include <KIcon>
#include <KLocale>
#include <kdeclarative.h>
#include <KDeclarative/KDeclarative>
#include <KConfigDialog>
#include <QDebug>
#include <KStandardAction>
......@@ -48,10 +48,11 @@
#include <KNS3/DownloadDialog>
#include <QGraphicsObject>
#include <QDeclarativeItem>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDeclarativeProperty>
#include <QQuickItem>
#include <QQuickView>
#include <QQmlContext>
#include <QQmlProperty>
#include <QQuickWidget>
#include <QCloseEvent>
#include <QtCore/QCoreApplication>
#include <QtCore/QPointer>
......@@ -61,7 +62,7 @@ using namespace LearnerProfile;
MainWindow::MainWindow()
: KXmlGuiWindow(0)
, m_view(new QDeclarativeView(this))
, m_widget(new QQuickWidget(this)) //FIXME set MainWindow*
, m_trainingProfile(new Profile(this))
, m_editorProfile(new Profile(this))
, m_resourceManager(new ResourceManager(this))
......@@ -70,8 +71,6 @@ MainWindow::MainWindow()
{
setWindowIcon(KIcon("artikulate")); // FIXME not present yet
setWindowTitle(qAppName());
setCentralWidget(m_view);
setAutoSaveSettings();
// load saved sound settings
......@@ -82,8 +81,8 @@ MainWindow::MainWindow()
m_resourceManager->loadCourseResources();
m_resourceManager->registerLearningGoals(m_profileManager);
KDeclarative m_kdeclarative;
m_kdeclarative.setDeclarativeEngine(m_view->engine());
KDeclarative::KDeclarative m_kdeclarative;
m_kdeclarative.setDeclarativeEngine(m_widget->engine());
m_kdeclarative.initialize();
m_kdeclarative.setupBindings(); //TODO use result for determining touch/desktop version
......@@ -91,22 +90,21 @@ MainWindow::MainWindow()
setupActions();
// set view
m_view->resize(QSize(800, 600));
m_view->setStyleSheet("background-color: transparent;");
m_view->rootContext()->setContextObject(this);
m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_widget->resize(QSize(800, 600));
m_widget->setStyleSheet("background-color: transparent;");
m_widget->rootContext()->setContextObject(this);
m_view->rootContext()->setContextProperty("userProfile", m_trainingProfile); //TODO deprecated
m_view->rootContext()->setContextProperty("editorProfile", m_editorProfile); //TODO rename
m_view->rootContext()->setContextProperty("trainingSession", m_trainingSession); //TODO needed at top level?
m_view->rootContext()->setContextProperty("profileManager", m_profileManager);
m_widget->rootContext()->setContextProperty("userProfile", m_trainingProfile); //TODO deprecated
m_widget->rootContext()->setContextProperty("editorProfile", m_editorProfile); //TODO rename
m_widget->rootContext()->setContextProperty("trainingSession", m_trainingSession); //TODO needed at top level?
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
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
updateTrainingPhraseFont();
......@@ -117,11 +115,13 @@ MainWindow::MainWindow()
}
// 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
QObject *phraseText = m_view->rootObject()->findChild<QObject*>("phraseText");
QObject *phraseText = m_widget->rootObject()->findChild<QObject*>("phraseText");
phraseText->setProperty("font", Settings::trainingPhraseFont());
setCentralWidget(m_widget);
}
MainWindow::~MainWindow()
......@@ -168,21 +168,21 @@ void MainWindow::setupActions()
void MainWindow::showCourseEditor()
{
m_view->rootObject()->setProperty("viewMode", Editor);
m_widget->rootObject()->setProperty("viewMode", Editor);
// untoggle editor view mode
emit modeChanged(true);
}
void MainWindow::closeCourseEditor()
{
m_view->rootObject()->setProperty("viewMode", Trainer);
m_widget->rootObject()->setProperty("viewMode", Trainer);
// toggle editor view mode
emit modeChanged(false);
}
void MainWindow::switchMode()
{
if (m_view->rootObject()->property("viewMode") == Trainer){
if (m_widget->rootObject()->property("viewMode") == Trainer){
showCourseEditor();
}
else {
......@@ -223,7 +223,7 @@ void MainWindow::showSettingsDialog()
void MainWindow::updateTrainingPhraseFont()
{
QObject *phraseText = m_view->rootObject()->findChild<QObject*>("phraseText");
QObject *phraseText = m_widget->rootObject()->findChild<QObject*>("phraseText");
if (!phraseText) {
qDebug() << "no phraseText context object found, aborting";
return;
......@@ -234,7 +234,7 @@ void MainWindow::updateTrainingPhraseFont()
void MainWindow::updateKcfgUseContributorResources()
{
m_view->rootContext()->setContextProperty("kcfg_UseContributorResources", Settings::useCourseRepository());
m_widget->rootContext()->setContextProperty("kcfg_UseContributorResources", Settings::useCourseRepository());
}
void MainWindow::downloadNewStuff()
......
......@@ -28,7 +28,8 @@
class Profile;
class KActionCollection;
class KMenu;
class QDeclarativeView;
class QQuickView;
class QQuickWidget;
namespace LearnerProfile {
class ProfileManager;
......@@ -78,7 +79,7 @@ signals:
void modeChanged(bool);
private:
QDeclarativeView *m_view;
QQuickWidget *m_widget;
Profile *m_trainingProfile, *m_editorProfile;
ResourceManager *m_resourceManager;
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