Commit 9ed37d77 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Drop plugin system

* Move to qrc ressources for QML file
* Remove plugin loader code and instead use PagePool
* Remove usage of context property and instead move to QML Singleton
parent cc5f92bd
add_subdirectory(plugins)
qt5_add_resources(KALGEBRAMOBILE_SRCS resources.qrc)
add_executable(kalgebramobile pluginsmodel.cpp
add_executable(kalgebramobile
../src/consolemodel.cpp
clipboard.cpp
kalgebramobile.cpp main.cpp ${KALGEBRAMOBILE_SRCS})
kalgebramobile.cpp
main.cpp
${KALGEBRAMOBILE_SRCS})
target_link_libraries(kalgebramobile Qt5::Qml Qt5::Quick Qt5::Gui
KF5::CoreAddons KF5::I18n KF5::Analitza KF5::AnalitzaGui KF5::AnalitzaPlot)
......
......@@ -22,8 +22,7 @@ import QtQuick.Controls 2.5
import org.kde.analitza 1.0
import org.kde.kirigami 2.6 as Kirigami
Kirigami.AboutPage
{
Kirigami.AboutPage {
aboutData: {
"displayName": i18n("KAlgebra Mobile"),
"productName": "kalgebramobile",
......
......@@ -23,10 +23,8 @@ import QtQml.Models 2.10
import QtQuick.Dialogs 1.0
import org.kde.analitza 1.0
import org.kde.kalgebra.mobile 1.0
import widgets 1.0
KAlgebraPage
{
KAlgebraPage {
id: page
ListModel { id: itemModel }
......@@ -36,7 +34,7 @@ KAlgebraPage
ConsoleModel {
id: consoleModel
variables: app.variables
variables: App.variables
onMessage: {
itemModel.append({ result: msg, expression: result.toString() })
input.selectAll()
......@@ -117,17 +115,17 @@ KAlgebraPage
]
actions: [
Kirigami.Action {
enabled: app.functionsModel().canAddFunction(expression, 2, app.variables)
enabled: App.functionsModel().canAddFunction(expression, 2, App.variables)
text: i18n("2D Plot")
onTriggered: {
app.functionsModel().addFunction(expression, 2, app.variables)
App.functionsModel().addFunction(expression, 2, App.variables)
}
},
Kirigami.Action {
enabled: app.functionsModel().canAddFunction(expression, 4, app.variables)
enabled: App.functionsModel().canAddFunction(expression, 4, App.variables)
text: i18n("3D Plot")
onTriggered: {
app.functionsModel().addFunction(expression, 4, app.variables)
App.functionsModel().addFunction(expression, 4, App.variables)
}
}
]
......
......@@ -19,21 +19,19 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
import org.kde.analitza 1.0
import widgets 1.0
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kalgebra.mobile 1.0
import QtQuick.Controls 2.5
KAlgebraPage
{
KAlgebraPage {
id: page
anchors.margins: 0
function updateGraph() {
view.model.clear();
view.resetViewport();
view.addFunction(operators.data(operators.index(chosebox.currentIndex,3)), app.variables);
view.addFunction(operators.data(operators.index(chosebox.currentIndex,3)), App.variables);
}
ColumnLayout {
id: descriptioncol
......
......@@ -22,10 +22,9 @@ import QtQuick.Dialogs 1.0
import QtQuick.Controls 2.3
import org.kde.kirigami 2.5 as Kirigami
import org.kde.analitza 1.0
import widgets 1.0
import org.kde.kalgebra.mobile 1.0
KAlgebraPage
{
KAlgebraPage {
id: page
leftPadding: 0
......@@ -77,7 +76,7 @@ KAlgebraPage
Graph2D {
id: view
anchors.fill: parent
model: app.functionsModel()
model: App.functionsModel()
Kirigami.OverlaySheet {
id: dialog
......@@ -92,25 +91,25 @@ KAlgebraPage
Component.onCompleted: selectAll()
onAccepted: {
input.selectAll()
view.addFunction(input.text, app.variables)
view.addFunction(input.text, App.variables)
}
}
Button {
icon.name: "list-add"
onClicked: {
input.selectAll()
view.addFunction(input.text, app.variables)
view.addFunction(input.text, App.variables)
}
}
}
contentItem: Kirigami.CardsListView {
delegate: Kirigami.Card { contentItem: Label { text: model.description } }
model: app.functionsModel()
model: App.functionsModel()
footer: Button {
text: i18n("Clear All")
onClicked: {
app.functionsModel().clear();
App.functionsModel().clear();
view.resetViewport();
}
}
......
......@@ -20,12 +20,11 @@ import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.0
import org.kde.analitza 1.1
import widgets 1.0
import QtQuick.Controls 2.5
import org.kde.kalgebra.mobile 1.0
import org.kde.kirigami 2.5 as Kirigami
KAlgebraPage
{
KAlgebraPage {
id: page
leftPadding: 0
......@@ -65,7 +64,7 @@ KAlgebraPage
{
id: view
anchors.fill: parent
model: app.functionsModel()
model: App.functionsModel()
Kirigami.OverlaySheet {
id: dialog
......@@ -80,7 +79,7 @@ KAlgebraPage
Component.onCompleted: selectAll()
onAccepted: {
input.selectAll()
var err = app.functionsModel().addFunction(input.text, 4, app.variables)
var err = App.functionsModel().addFunction(input.text, 4, App.variables)
if (err.length>0)
console.warn("errors:", err)
}
......@@ -89,7 +88,7 @@ KAlgebraPage
icon.name: "list-add"
onClicked: {
input.selectAll()
var err = view.addFunction(input.text, app.variables)
var err = view.addFunction(input.text, App.variables)
if (err.length>0)
console.warn("errors:", err)
}
......
......@@ -19,15 +19,14 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.analitza 1.0
import widgets 1.0
import QtQuick.Controls 2.5
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kalgebra.mobile 1.0
KAlgebraPage
{
KAlgebraPage {
Analitza {
id: a
variables: app.variables
variables: App.variables
}
function calculateTable() {
......
......@@ -18,15 +18,15 @@
import QtQuick 2.0
import org.kde.analitza 1.0
import widgets 1.0
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kalgebra.mobile 1.0
import QtQuick.Controls 2.5 as QQC2
KAlgebraPage
{
Kirigami.CardsListView {
anchors.fill: parent
model: VariablesModel { variables: app.variables }
model: VariablesModel { variables: App.variables }
currentIndex: -1
delegate: Kirigami.Card {
contentItem: QQC2.Label { text: model.whatsThis }
......
......@@ -18,7 +18,7 @@
import QtQuick 2.2
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.0 as Kirigami
import org.kde.kirigami 2.14 as Kirigami
import org.kde.analitza 1.0
import org.kde.kalgebra.mobile 1.0
......@@ -32,6 +32,10 @@ Kirigami.ApplicationWindow
readonly property int columnWidth: Kirigami.Units.gridUnit * 13
wideScreen: width > columnWidth * 5
Kirigami.PagePool {
id: mainPagePool
}
globalDrawer: Kirigami.GlobalDrawer {
id: drawer
......@@ -43,51 +47,51 @@ Kirigami.ApplicationWindow
titleIcon: "qrc:/kalgebra.svgz"
drawerOpen: true
Instantiator {
delegate: Kirigami.Action {
id: action
text: title
iconName: decoration
property Component component
onTriggered: {
if (!component)
component = Qt.createComponent(model.path, action)
if (component.status == Component.Error) {
console.log("error", component.errorString());
return;
}
try {
rootItem.pageStack.replace(component, {title: title})
} catch(e) {
console.log("error", e)
}
}
actions: [
Kirigami.PagePoolAction {
icon.name: "utilities-terminal"
text: i18n("Calculator")
page: "qrc:/Console.qml"
pagePool: mainPagePool
},
Kirigami.PagePoolAction {
icon.name: "draw-bezier-curves"
text: i18n("Graph 2D")
page: "qrc:/Plot2D.qml"
pagePool: mainPagePool
},
Kirigami.PagePoolAction {
icon.name: "adjustrgb"
text: i18n("Graph 3D")
page: "qrc:/Plot3D.qml"
pagePool: mainPagePool
},
Kirigami.PagePoolAction {
icon.name: "kspread"
text: i18n("Value Tables")
page: "qrc:/Tables.qml"
pagePool: mainPagePool
},
Kirigami.PagePoolAction {
icon.name: "document-properties"
text: i18n("Variables")
page: "qrc:/VariablesView.qml"
pagePool: mainPagePool
},
Kirigami.PagePoolAction {
icon.name: "documentation"
text: i18n("Dictionary")
page: "qrc:/Dictionary.qml"
pagePool: mainPagePool
},
Kirigami.PagePoolAction {
icon.name: "help-about"
text: i18n("About KAlgebra")
page: "qrc:/About.qml"
pagePool: mainPagePool
}
model: PluginsModel {}
onObjectAdded: {
var acts = [];
for(var v in drawer.actions) {
acts.push(drawer.actions[v]);
}
acts.splice(index, 0, object)
drawer.actions = acts;
}
onObjectRemoved: {
var acts = [];
for(var v in drawer.actions) {
acts.push(drawer.actions[v]);
}
drawer.actions.splice(drawer.actions.indexOf(object), 1)
drawer.actions = acts;
}
}
actions: []
]
}
Component.onCompleted: {
drawer.actions[0].trigger()
}
pageStack.initialPage: mainPagePool.loadPage("qrc:/Console.qml")
}
......@@ -25,8 +25,8 @@
#include "../src/consolemodel.h"
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <qqml.h>
#include "pluginsmodel.h"
#include "clipboard.h"
using namespace Analitza;
......@@ -43,7 +43,6 @@ KAlgebraMobile::KAlgebraMobile(QObject* parent)
s_self=this;
const auto uri = "org.kde.kalgebra.mobile";
qmlRegisterType<PluginsModel>("org.kde.kalgebra.mobile", 1, 0, "PluginsModel");
qmlRegisterType<ConsoleModel>("org.kde.kalgebra.mobile", 1, 0, "ConsoleModel");
qmlRegisterType<QSortFilterProxyModel>("org.kde.kalgebra.mobile", 1, 0, "QSortFilterProxyModel");
qmlRegisterUncreatableType<QAbstractItemModel>("org.kde.kalgebra.mobile", 1, 0, "QAbstractItemModel", "no");
......
......@@ -35,7 +35,6 @@
#include "kalgebramobile.h"
#include "kalgebra_version.h"
#include "pluginsmodel.h"
Q_DECL_EXPORT int main(int argc, char *argv[])
{
......@@ -57,21 +56,13 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
parser.process(app);
about.processCommandLine(&parser);
}
KAlgebraMobile widget;
const QString pluginsDir = PluginsModel::pluginsDirectoryPath();
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("app"), &widget);
engine.addImportPath(pluginsDir);
#ifdef __ANDROID__
engine.addImportPath(QStringLiteral("assets:/qml"));
#endif
qmlRegisterSingletonInstance("org.kde.kalgebra.mobile", 1, 0, "App", &widget);
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(QUrl::fromLocalFile(pluginsDir + QStringLiteral("/widgets/KAlgebraMobile.qml")));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
add_subdirectory(widgets)
set(QML_SRC Console.qml Plot2D.qml Plot3D.qml Tables.qml Dictionary.qml
About.qml VariablesView.qml)
install(FILES ${QML_SRC}
kalgebraabout.json kalgebraconsole.json kalgebraplot2d.json kalgebraplot3d.json
kalgebratables.json kalgebravariables.json kalgebradictionary.json
DESTINATION ${KDE_INSTALL_DATADIR}/kalgebramobile/plugins/
)
ADD_CUSTOM_TARGET(QML SOURCES ${QML_SRC})
{
"KPlugin": {
"Authors": [
{
"Name": "Aleix Pol Gonzalez",
"Name[ca@valencia]": "Aleix Pol Gonzalez",
"Name[ca]": "Aleix Pol Gonzalez",
"Name[cs]": "Aleix Pol Gonzalez",
"Name[de]": "Aleix Pol Gonzalez",
"Name[el]": "Aleix Pol Gonzalez",
"Name[en_GB]": "Aleix Pol Gonzalez",
"Name[es]": "Aleix Pol Gonzalez",
"Name[et]": "Aleix Pol Gonzalez",
"Name[fi]": "Aleix Pol Gonzalez",
"Name[fr]": "Aleix Pol Gonzalez",
"Name[gl]": "Aleix Pol Gonzalez",
"Name[it]": "Aleix Pol Gonzalez",
"Name[ko]": "Aleix Pol Gonzalez",
"Name[nl]": "Aleix Pol Gonzalez",
"Name[nn]": "Aleix Pol Gonzalez",
"Name[pl]": "Aleix Pol Gonzalez",
"Name[pt]": "Aleix Pol Gonzalez",
"Name[pt_BR]": "Aleix Pol Gonzalez",
"Name[ru]": "Aleix Pol Gonzalez",
"Name[sk]": "Aleix Pol Gonzalez",
"Name[sl]": "Aleix Pol Gonzalez",
"Name[sv]": "Aleix Pol Gonzalez",
"Name[uk]": "Aleix Pol Gonzalez",
"Name[x-test]": "xxAleix Pol Gonzalezxx",
"Name[zh_CN]": "Aleix Pol Gonzalez",
"Name[zh_TW]": "Aleix Pol Gonzalez"
}
],
"Icon": "help-about",
"Name": "About KAlgebra",
"Name[ca@valencia]": "Quant al KAlgebra",
"Name[ca]": "Quant al KAlgebra",
"Name[cs]": "O aplikaci KAlgebra",
"Name[de]": "Über KAlgebra",
"Name[el]": "Σχετικά με το KAlgebra",
"Name[en_GB]": "About KAlgebra",
"Name[es]": "Acerca de KAlgebra",
"Name[et]": "KAlgebra teave",
"Name[fi]": "Tietoa KAlgebrasta",
"Name[fr]": "À propos de KAlgebra",
"Name[gl]": "Sobre KAlgebra",
"Name[it]": "Informazioni su KAlgebra",
"Name[ko]": "KAlgebra 정보",
"Name[nl]": "Over KAlgebra",
"Name[nn]": "Om KAlgebra",
"Name[pl]": "O KAlgebrze",
"Name[pt]": "Acerca do KAlgebra",
"Name[pt_BR]": "Sobre o KAlgebra",
"Name[ru]": "О KAlgebra",
"Name[sk]": "O KAlgebra",
"Name[sl]": "O KAlgebri",
"Name[sv]": "Om Kalgebra",
"Name[uk]": "Про KAlgebra",
"Name[x-test]": "xxAbout KAlgebraxx",
"Name[zh_CN]": "关于 KAlgebra",
"Name[zh_TW]": "關於 KAlgebra"
},
"X-KAlgebra-Priority": "-10",
"X-KDE-PluginInfo-Name": "About.qml"
}
{
"KPlugin": {
"Authors": [
{
"Name": "Aleix Pol Gonzalez",
"Name[ca@valencia]": "Aleix Pol Gonzalez",
"Name[ca]": "Aleix Pol Gonzalez",
"Name[cs]": "Aleix Pol Gonzalez",
"Name[de]": "Aleix Pol Gonzalez",
"Name[el]": "Aleix Pol Gonzalez",
"Name[en_GB]": "Aleix Pol Gonzalez",
"Name[es]": "Aleix Pol Gonzalez",
"Name[et]": "Aleix Pol Gonzalez",
"Name[fi]": "Aleix Pol Gonzalez",
"Name[fr]": "Aleix Pol Gonzalez",
"Name[gl]": "Aleix Pol Gonzalez",
"Name[it]": "Aleix Pol Gonzalez",
"Name[ko]": "Aleix Pol Gonzalez",
"Name[nl]": "Aleix Pol Gonzalez",
"Name[nn]": "Aleix Pol Gonzalez",
"Name[pl]": "Aleix Pol Gonzalez",
"Name[pt]": "Aleix Pol Gonzalez",
"Name[pt_BR]": "Aleix Pol Gonzalez",
"Name[ru]": "Aleix Pol Gonzalez",
"Name[sk]": "Aleix Pol Gonzalez",
"Name[sl]": "Aleix Pol Gonzalez",
"Name[sv]": "Aleix Pol Gonzalez",
"Name[uk]": "Aleix Pol Gonzalez",
"Name[x-test]": "xxAleix Pol Gonzalezxx",
"Name[zh_CN]": "Aleix Pol Gonzalez",
"Name[zh_TW]": "Aleix Pol Gonzalez"
}
],
"Description": "Scientific calculator",
"Description[ca@valencia]": "Calculadora científica",
"Description[ca]": "Calculadora científica",
"Description[cs]": "Vědecká kalkulačka",
"Description[de]": "Wissenschaftlicher Taschenrechner",
"Description[el]": "Επιστημονική αριθμομηχανή",
"Description[en_GB]": "Scientific calculator",
"Description[es]": "Calculadora científica",
"Description[et]": "Teaduslik kalkulaator",
"Description[fi]": "Tieteellinen laskin",
"Description[fr]": "Calculatrice scientifique",
"Description[gl]": "Calculadora científica",
"Description[it]": "Calcolatrice scientifica",
"Description[ko]": "공학용 계산기",
"Description[nl]": "Wetenschappelijke rekenmachine",
"Description[nn]": "Vitskapleg kalkulator",
"Description[pl]": "Kalkulator naukowy",
"Description[pt]": "Calculadora científica",
"Description[pt_BR]": "Calculadora científica",
"Description[ru]": "Инженерный калькулятор",
"Description[sk]": "Vedecká kalkulačka",
"Description[sl]": "Znanstveno računalo",
"Description[sv]": "Vetenskaplig räknare",
"Description[uk]": "Інженерний калькулятор",
"Description[x-test]": "xxScientific calculatorxx",
"Description[zh_CN]": "科学计算器",
"Description[zh_TW]": "科學計算機",
"Icon": "utilities-terminal",
"Name": "Calculator",
"Name[ca@valencia]": "Calculadora",
"Name[ca]": "Calculadora",
"Name[cs]": "Kalkulačka",
"Name[de]": "Rechner",
"Name[el]": "Αριθμομηχανή",
"Name[en_GB]": "Calculator",
"Name[es]": "Calculadora",
"Name[et]": "Kalkulaator",
"Name[fi]": "Laskin",
"Name[fr]": "Calculatrice",
"Name[gl]": "Calculadora",
"Name[it]": "Calcolatrice",
"Name[ko]": "계산기",
"Name[nl]": "Rekenmachine",
"Name[nn]": "Kalkulator",
"Name[pl]": "Kalkulator",
"Name[pt]": "Calculadora",
"Name[pt_BR]": "Calculadora",
"Name[ru]": "Калькулятор",
"Name[sk]": "Kalkulačka",
"Name[sl]": "Računalo",
"Name[sv]": "Räknare",
"Name[uk]": "Калькулятор",
"Name[x-test]": "xxCalculatorxx",
"Name[zh_CN]": "计算器",
"Name[zh_TW]": "計算機"
},
"X-KAlgebra-Priority": "1000",
"X-KDE-PluginInfo-Name": "Console.qml"
}
{
"KPlugin": {
"Authors": [
{
"Name": "Artur Puzio",
"Name[ca@valencia]": "Artur Puzio",
"Name[ca]": "Artur Puzio",
"Name[cs]": "Artur Puzio",
"Name[de]": "Artur Puzio",
"Name[el]": "Artur Puzio",
"Name[en_GB]": "Artur Puzio",
"Name[es]": "Artur Puzio",
"Name[et]": "Artur Puzio",
"Name[fi]": "Artur Puzio",
"Name[fr]": "Artur Puzio",
"Name[gl]": "Artur Puzio",
"Name[it]": "Artur Puzio",
"Name[ko]": "Artur Puzio",
"Name[nl]": "Artur Puzio",
"Name[nn]": "Artur Puzio",
"Name[pl]": "Artur Puzio",
"Name[pt]": "Artur Puzio",