Commit 92512bc1 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

First approach to a kf5 port

parent ab03884e
project(kalgebra)
cmake_minimum_required(VERSION 2.8.11)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
set(CMAKE_MODULE_PATH ${kalgebra_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
find_package(ECM 0.0.9 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
find_package(Analitza REQUIRED)
macro_optional_find_package(LibKdeEdu)
find_library(QTMML_LIBRARY qtmmlwidget)
find_package(Qt5 5.2 REQUIRED NO_MODULE COMPONENTS Widgets Qml Quick Xml Svg OpenGL PrintSupport Test)
find_package(KF5 5.0.0 REQUIRED MODULE COMPONENTS CMake Compiler InstallDirs)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${LIBKDEEDU_INCLUDE_DIR}/qtmml ${ANALITZA_INCLUDE_DIR})
find_package(Analitza REQUIRED)
find_package(KConfig REQUIRED)
find_package(KDeclarative)
# macro_optional_find_package(LibKdeEdu)
# find_library(QTMML_LIBRARY qtmmlwidget)
macro_optional_find_package(OpenGL)
macro_bool_to_01(OPENGL_FOUND HAVE_OPENGL)
macro_log_feature(OPENGL_FOUND "OpenGL" "Support for 3D graphs in KAlgebra" "http://mesa3d.sourceforge.net" FALSE "" "")
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${ANALITZA_INCLUDE_DIR}
${CMAKE_INSTALL_PREFIX}/include/KDE #FIXME
)
remove_definitions(-DQT_NO_CAST_TO_ASCII)
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
remove_definitions(-DQT_NO_KEYWORDS)
macro_log_feature(QTMML_LIBRARY "QtMathML Widget" "Supports displaying some formulas in a mathematic form" "http://doc.qt.nokia.com/solutions/4/qtmmlwidget/qtmmlwidget.html" FALSE "" "")
find_package(OpenGL)
set(HAVE_OPENGL ${OPENGL_FOUND})
# macro_log_feature(OPENGL_FOUND "OpenGL" "Support for 3D graphs in KAlgebra" "http://mesa3d.sourceforge.net" FALSE "" "")
# macro_log_feature(QTMML_LIBRARY "QtMathML Widget" "Supports displaying some formulas in a mathematic form" "http://doc.qt.nokia.com/solutions/4/qtmmlwidget/qtmmlwidget.html" FALSE "" "")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config-kalgebra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config-kalgebra.h)
......@@ -25,13 +36,12 @@ set(MOBILE_BACKEND "kde" CACHE STRING "Backend to install, currently. Check /mob
if(QTMML_LIBRARY AND NOT MOBILE_BACKEND STREQUAL "harmattan")
add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(plasmoids)
endif(QTMML_LIBRARY AND NOT MOBILE_BACKEND STREQUAL "harmattan")
add_subdirectory(src)
add_subdirectory(plasmoids)
add_subdirectory(icons)
add_subdirectory(utils)
macro_optional_add_subdirectory(mobile)
add_subdirectory(mobile)
add_custom_target(commandsdoc
${CMAKE_CURRENT_BINARY_DIR}/utils/docbook_analitzacommands commands.docbook
......@@ -40,7 +50,7 @@ add_custom_target(commandsdoc
COMMENT "Generating commands docbook information"
)
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
macro_display_feature_log()
endif (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
# if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
# macro_display_feature_log()
# endif (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
kde4_install_icons( ${ICON_INSTALL_DIR} )
# kde4_install_icons( ${ICON_INSTALL_DIR} )
......@@ -5,12 +5,13 @@ if(${MOBILE_BACKEND} STREQUAL "kde")
add_definitions(-DKDECOMPONENTS)
endif(${MOBILE_BACKEND} STREQUAL "kde")
qt4_add_resources(KALGEBRAMOBILE_SRCS resources.qrc)
kde4_add_executable(kalgebramobile pluginsmodel.cpp
qt5_add_resources(KALGEBRAMOBILE_SRCS resources.qrc)
add_executable(kalgebramobile pluginsmodel.cpp
kalgebramobile.cpp main.cpp ${KALGEBRAMOBILE_SRCS})
target_link_libraries(kalgebramobile ${KDE4_KDECORE_LIBS} ${QT_QTDECLARATIVE_LIBRARY}
${QT_QTGUI_LIBRARY} ${ANALITZA_LIBRARY} ${ANALITZAGUI_LIBRARY} ${ANALITZAPLOT_LIBRARY})
target_link_libraries(kalgebramobile Qt5::Qml Qt5::Quick Qt5::Gui
KF5::KConfigCore
${ANALITZA_LIBRARY} ${ANALITZAGUI_LIBRARY} ${ANALITZAPLOT_LIBRARY})
add_definitions("-DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\"")
......@@ -18,7 +19,7 @@ set(DESKTOPFILE_INSTALL ${XDG_APPS_INSTALL_DIR})
if(${MOBILE_BACKEND} STREQUAL "harmattan")
set(DESKTOPFILE_INSTALL ${XDG_APPS_INSTALL_DIR}/..)
elseif(${MOBILE_BACKEND} STREQUAL "kde")
target_link_libraries(kalgebramobile kdeclarative)
target_link_libraries(kalgebramobile KF5::KDeclarative)
endif(${MOBILE_BACKEND} STREQUAL "harmattan")
set(DESKTOPFILE kalgebramobile.desktop)
......@@ -26,5 +27,5 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/kalgebramobile${MOBILE_BACKEND}.desktop)
set(DESKTOPFILE kalgebramobile${MOBILE_BACKEND}.desktop)
endif()
install(TARGETS kalgebramobile ${INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS ${DESKTOPFILE} DESTINATION ${DESKTOPFILE_INSTALL} )
# install(TARGETS kalgebramobile ${INSTALL_TARGETS_DEFAULT_ARGS})
# install(PROGRAMS ${DESKTOPFILE} DESTINATION ${DESKTOPFILE_INSTALL} )
......@@ -5,14 +5,16 @@ include_directories(
${CMAKE_BINARY_DIR}
)
kde4_add_library(analitzadeclarativeplugin SHARED analitzadeclarativeplugin.cpp graph2dmobile.cpp analitzawrapper.cpp)
add_library(analitzadeclarativeplugin SHARED analitzadeclarativeplugin.cpp graph2dmobile.cpp analitzawrapper.cpp)
target_link_libraries(analitzadeclarativeplugin ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${ANALITZA_LIBRARY} ${ANALITZAGUI_LIBRARY} ${ANALITZAPLOT_LIBRARY})
target_link_libraries(analitzadeclarativeplugin
Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick
${ANALITZA_LIBRARY} ${ANALITZAGUI_LIBRARY} ${ANALITZAPLOT_LIBRARY})
install(TARGETS analitzadeclarativeplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/analitza)
install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/analitza)
install(TARGETS analitzadeclarativeplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/analitza)
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/analitza)
install( FILES
qml/Graph2D.qml
DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/analitza
)
\ No newline at end of file
DESTINATION ${QML_INSTALL_DIR}/org/kde/analitza
)
......@@ -22,7 +22,7 @@
#include <analitzagui/variablesmodel.h>
#include <analitza/variables.h>
#include <graph2dmobile.h>
#include <QtDeclarative/QDeclarativeItem>
#include <QQuickItem>
void AnalitzaDeclarativePlugin::registerTypes(const char* uri)
{
......
......@@ -19,13 +19,14 @@
#ifndef ANALITZADECLARATIVEPLUGIN_H
#define ANALITZADECLARATIVEPLUGIN_H
#include <QDeclarativeExtensionPlugin>
#include <QQmlExtensionPlugin>
class AnalitzaDeclarativePlugin : public QDeclarativeExtensionPlugin
class AnalitzaDeclarativePlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
virtual void registerTypes(const char* uri);
};
Q_EXPORT_PLUGIN2(analitzadeclarativeplugin, AnalitzaDeclarativePlugin);
#endif // ANALITZADECLARATIVEPLUGIN_H
......@@ -19,7 +19,7 @@
#ifndef ANALITZAWRAPPER_H
#define ANALITZAWRAPPER_H
#include <QtCore/QObject>
#include <QObject>
#include <QVariant>
#include <analitza/expression.h>
......@@ -38,7 +38,7 @@ class ExpressionWrapper : public QObject
void setText(const QString& exp);
public slots:
public Q_SLOTS:
QString toString() const;
bool isCorrect() const;
QVariant value() const;
......
......@@ -18,7 +18,6 @@
#include "graph2dmobile.h"
#include <QPainter>
#include <QStyleOption>
#include <QEvent>
#include <analitza/variables.h>
#include <analitzaplot/planecurve.h>
......@@ -28,18 +27,17 @@
using namespace Analitza;
Graph2DMobile::Graph2DMobile(QDeclarativeItem* parent)
: QDeclarativeItem(parent), Plotter2D(boundingRect().size())
Graph2DMobile::Graph2DMobile(QQuickItem* parent)
: QQuickPaintedItem(parent), Plotter2D(boundingRect().size())
, m_dirty(true), m_currentFunction(-1)
{
setSize(QSizeF(100,100));
setFlag(QGraphicsItem::ItemHasNoContents, false);
defViewport = QRectF(QPointF(-12., 10.), QSizeF(24., -20.));
resetViewport();
}
void Graph2DMobile::paint(QPainter* p, const QStyleOptionGraphicsItem* options, QWidget* )
void Graph2DMobile::paint(QPainter* p)
{
// qDebug() << "hellooo" << boundingRect();
if(boundingRect().size().isEmpty())
......@@ -128,4 +126,4 @@ QStringList Graph2DMobile::addFunction(const QString& expression, Analitza::Vari
}
return err;
}
\ No newline at end of file
}
......@@ -20,14 +20,15 @@
#ifndef GRAPH2DMOBILE_H
#define GRAPH2DMOBILE_H
#include <QDeclarativeItem>
#include <QtQuick/QQuickPaintedItem>
#include <analitzaplot/plotter2d.h>
#include <QPixmap>
namespace Analitza {
class Variables;
}
class Graph2DMobile : public QDeclarativeItem, public Analitza::Plotter2D
class Graph2DMobile : public QQuickPaintedItem, public Analitza::Plotter2D
{
Q_OBJECT
Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel)
......@@ -37,26 +38,26 @@ class Graph2DMobile : public QDeclarativeItem, public Analitza::Plotter2D
Q_PROPERTY(bool currentFunction READ currentFunction WRITE setCurrentFunction)
Q_PROPERTY(bool ticksShown READ ticksShownAtAll WRITE setTicksShownAtAll)
public:
Graph2DMobile(QDeclarativeItem* parent = 0);
Graph2DMobile(QQuickItem* parent = 0);
virtual void forceRepaint();
virtual void viewportChanged() {}
virtual void modelChanged();
virtual int currentFunction() const { return m_currentFunction; }
virtual void paint(QPainter* p, const QStyleOptionGraphicsItem* options, QWidget* w);
virtual void paint(QPainter* painter);
void setCurrentFunction(int f) { m_currentFunction = f; }
bool ticksShownAtAll() const { return ticksShown()!=0; }
void setTicksShownAtAll(bool shown) { setTicksShown(shown ? Qt::Vertical|Qt::Horizontal : Qt::Orientations(0));}
public slots:
public Q_SLOTS:
void translate(qreal x, qreal y);
void scale(qreal s, int x, int y);
void resetViewport();
QStringList addFunction(const QString& expression, Analitza::Variables* vars=0);
private slots:
private Q_SLOTS:
void updateFuncs(const QModelIndex& start, const QModelIndex& end);
void addFuncs(const QModelIndex& parent, int start, int end);
void removeFuncs(const QModelIndex& parent, int start, int end);
......
import QtQuick 1.1
import QtQuick 2.0
import org.kde.analitza 1.0
Graph2DView {
......
......@@ -22,7 +22,7 @@
#include <analitza/variables.h>
#include <analitza/expression.h>
#include <qdeclarative.h>
#include <qqml.h>
#include "pluginsmodel.h"
using namespace Analitza;
......
......@@ -38,16 +38,16 @@ class KAlgebraMobile : public QObject
static KAlgebraMobile* self();
void notifyVariablesChanged() { variablesChanged(); }
public slots:
public Q_SLOTS:
Analitza::PlotsModel* functionsModel();
Analitza::Variables* variables() const;
private slots:
private Q_SLOTS:
void functionRemoved(const QModelIndex& parent, int start, int end);
void functionModified(const QModelIndex& idxA, const QModelIndex& idxB);
void functionInserted(const QModelIndex& parent, int start, int end);
signals:
Q_SIGNALS:
void variablesChanged();
private:
......
......@@ -16,21 +16,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include <KApplication>
#include <QGuiApplication>
#include <KAboutData>
#include <KCmdLineArgs>
#include <KStandardDirs>
#ifdef KDECOMPONENTS
#include <kdeclarative.h>
#include <kdeclarative/kdeclarative.h>
#endif
#include <QDebug>
#include <QFileInfo>
#include <QDir>
#include <QDeclarativeView>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <QStandardPaths>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
#include <QIcon>
#include "kalgebramobile.h"
......@@ -41,34 +42,33 @@ int main(int argc, char *argv[])
// KAboutData::License_GPL, ki18n("(C) 2006-2010 Aleix Pol Gonzalez"));
// about.addAuthor( ki18n("Aleix Pol Gonzalez"), KLocalizedString(), "aleixpol@kde.org" );
// KCmdLineArgs::init(argc, argv, &about);
QApplication app(argc, argv);
QGuiApplication app(argc, argv);
app.setApplicationName("kalgebramobile");
app.setWindowIcon(QIcon::fromTheme("kalgebra"));
// app.setWindowIcon(QIcon::fromTheme("kalgebra"));
KAlgebraMobile widget;
QDeclarativeView view;
view.setWindowTitle("KAlgebra Mobile");
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
QQuickView view;
view.setTitle(view.tr("KAlgebra Mobile"));
view.engine()->rootContext()->setContextProperty("app", &widget);
// KGlobal::dirs()->addResourceDir("appdata", PREFIX "/share/apps");
#ifdef KDECOMPONENTS
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(view.engine());
kdeclarative.initialize();
// kdeclarative.setDeclarativeEngine(view.engine());
// kdeclarative.initialize();
//binds things like kconfig and icons
kdeclarative.setupBindings();
// kdeclarative.setupBindings();
#endif
QString main = KStandardDirs::locate("appdata", "plugins/widgets/KAlgebraMobile.qml");
QString main = QStandardPaths::locate(QStandardPaths::DataLocation, "plugins/widgets/KAlgebraMobile.qml");
// QString main = KStandardDirs::locate("appdata", "plugins/Tables.qml");
QDir dir = QFileInfo(main).dir();
dir.cdUp();
view.engine()->addImportPath(dir.path());
view.setSource(main);
view.setSource(QUrl::fromLocalFile(main));
#if defined(__arm__) && !defined(ANDROID)
view.showFullScreen();
......
import QtQuick 1.0
import QtQuick 2.0
import org.kde.analitza 1.0
import widgets 1.0
......
import QtQuick 1.0
import QtQuick 2.0
import org.kde.analitza 1.0
import widgets 1.0
......
import QtQuick 1.0
import QtQuick 2.0
import org.kde.analitza 1.0
import widgets 1.0
......
import QtQuick 1.0
import QtQuick 2.0
import org.kde.analitza 1.0
import widgets 1.0
......
import QtQuick 1.0
import QtQuick 2.0
import org.kde.analitza 1.0
import widgets 1.0
......
import QtQuick 1.0
import QtQuick 2.0
Button
{
......
import QtQuick 1.0
import QtQuick 2.0
Component {
Row {
......
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