diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0cfb527..0c60c62 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,26 +1,24 @@
qt_add_executable(LiriCalculator
WIN32 MACOSX_BUNDLE
- main/main.cpp
- filehandler/filehandler.cpp filehandler/filehandler.h
+ main.cpp
+ filehandler.cpp filehandler.h
)
qt_add_qml_module(LiriCalculator
URI Application
VERSION 2.0
QML_FILES
- engine/qmldir
- engine/math.js
- engine/MathJs.qml
- ui/qmldir
- ui/ButtonsPanel.qml
- ui/ButtonsView.qml
- ui/CalculationLine.qml
- ui/CalculationZone.qml
- ui/HistoryPanel.qml
- ui/Main.qml
- ui/NavButton.qml
- ui/Shortcuts.qml
- ui/Styles.qml
+ qml/ButtonsPanel.qml
+ qml/ButtonsView.qml
+ qml/CalculationLine.qml
+ qml/CalculationZone.qml
+ qml/HistoryPanel.qml
+ qml/Main.qml
+ qml/math.js
+ qml/MathJs.qml
+ qml/NavButton.qml
+ qml/Shortcuts.qml
+ qml/Styles.qml
RESOURCES
icons/icon.png
)
diff --git a/src/engine/MathJs.qml b/src/engine/MathJs.qml
deleted file mode 100644
index 7c5844e..0000000
--- a/src/engine/MathJs.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Canonical, Ltd.
- *
- * 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; version 3.
- *
- * 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 .
- */
-
-import QtQml 2.0
-import "math.js" as MathJs
-
-QtObject {
- property var mathJs: MathJs.mathJs;
-}
diff --git a/src/engine/qmldir b/src/engine/qmldir
deleted file mode 100644
index 1330752..0000000
--- a/src/engine/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-module engine
diff --git a/src/filehandler/filehandler.cpp b/src/filehandler.cpp
similarity index 100%
rename from src/filehandler/filehandler.cpp
rename to src/filehandler.cpp
diff --git a/src/filehandler/filehandler.h b/src/filehandler.h
similarity index 96%
rename from src/filehandler/filehandler.h
rename to src/filehandler.h
index 78de31a..38df9e3 100644
--- a/src/filehandler/filehandler.h
+++ b/src/filehandler.h
@@ -3,6 +3,7 @@
#include
#include
+#include
QT_BEGIN_NAMESPACE
class QTextDocument;
@@ -12,6 +13,7 @@ QT_END_NAMESPACE
class FileHandler : public QObject
{
Q_OBJECT
+ QML_ELEMENT
Q_PROPERTY(QQuickTextDocument *document READ document WRITE setDocument NOTIFY documentChanged)
Q_PROPERTY(QString fileName READ fileName NOTIFY fileUrlChanged)
diff --git a/src/main/main.cpp b/src/main.cpp
similarity index 93%
rename from src/main/main.cpp
rename to src/main.cpp
index 8b14787..7fd6ebf 100644
--- a/src/main/main.cpp
+++ b/src/main.cpp
@@ -33,8 +33,6 @@
#include
#include
-#include "../filehandler/filehandler.h"
-
using namespace Qt::StringLiterals;
int main(int argc, char *argv[])
@@ -72,16 +70,11 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("debug"), false);
#endif
- qmlRegisterType("filehandler", 1, 0, "FileHandler");
-
// Quit on error
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
QCoreApplication::instance(), QCoreApplication::quit,
Qt::QueuedConnection);
- // setup qml imports
- engine.addImportPath(QStringLiteral("qrc:/"));
-
// load main ui
engine.loadFromModule("Application", "Main");
diff --git a/src/ui/ButtonsPanel.qml b/src/qml/ButtonsPanel.qml
similarity index 98%
rename from src/ui/ButtonsPanel.qml
rename to src/qml/ButtonsPanel.qml
index 1e02b79..420b6ba 100644
--- a/src/ui/ButtonsPanel.qml
+++ b/src/qml/ButtonsPanel.qml
@@ -26,8 +26,6 @@ import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import Fluid.Controls
-import ".."
-import "../engine"
Rectangle {
id: buttonsPanel
diff --git a/src/ui/ButtonsView.qml b/src/qml/ButtonsView.qml
similarity index 99%
rename from src/ui/ButtonsView.qml
rename to src/qml/ButtonsView.qml
index 8cc9631..ef160b1 100644
--- a/src/ui/ButtonsView.qml
+++ b/src/qml/ButtonsView.qml
@@ -26,8 +26,6 @@ import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import Fluid.Controls
-import ".."
-
Rectangle {
id: buttonsView
diff --git a/src/ui/CalculationLine.qml b/src/qml/CalculationLine.qml
similarity index 100%
rename from src/ui/CalculationLine.qml
rename to src/qml/CalculationLine.qml
diff --git a/src/ui/CalculationZone.qml b/src/qml/CalculationZone.qml
similarity index 100%
rename from src/ui/CalculationZone.qml
rename to src/qml/CalculationZone.qml
diff --git a/src/ui/HistoryPanel.qml b/src/qml/HistoryPanel.qml
similarity index 98%
rename from src/ui/HistoryPanel.qml
rename to src/qml/HistoryPanel.qml
index 5c7aee6..d74fdee 100644
--- a/src/ui/HistoryPanel.qml
+++ b/src/qml/HistoryPanel.qml
@@ -26,8 +26,6 @@ import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import Fluid.Controls
-import ".."
-import "../engine"
Rectangle {
id: historyPanel
diff --git a/src/ui/Main.qml b/src/qml/Main.qml
similarity index 93%
rename from src/ui/Main.qml
rename to src/qml/Main.qml
index c89f0f5..1518ffd 100644
--- a/src/ui/Main.qml
+++ b/src/qml/Main.qml
@@ -29,9 +29,8 @@ import QtQuick.Controls
import Fluid.Controls as FluidControls
import Fluid.Controls
import Qt.labs.platform
-import filehandler
-import ".."
-import "../engine"
+import Application
+import "math.js" as MathJs
ApplicationWindow {
id: root
@@ -59,6 +58,9 @@ ApplicationWindow {
title: 'Calculator'
Component.onCompleted: {
+ MathJs.mathJs.config({
+ number: 'BigNumber'
+ });
calculationZone.retrieveFormulaFocus();
retrieveHistory();
}
@@ -74,20 +76,6 @@ ApplicationWindow {
property alias history: root.history
}
- property var mathJs: mathJsLoader.item ? mathJsLoader.item.mathJs : null;
-
- Loader {
- id: mathJsLoader
- source: "../engine/MathJs.qml"
- asynchronous: true
- active: true
- onLoaded: {
- mathJs.config({
- number: 'BigNumber'
- });
- }
- }
-
CalculationZone {
id: calculationZone
anchors.top: parent.top
@@ -322,10 +310,10 @@ ApplicationWindow {
var NUMBER_LENGTH_LIMIT = 14;
if (bigNumberToFormat.toString().length > NUMBER_LENGTH_LIMIT) {
- var resultLength = mathJs.format(bigNumberToFormat, {exponential: {lower: 1e-10, upper: 1e10},
+ var resultLength = MathJs.mathJs.format(bigNumberToFormat, {exponential: {lower: 1e-10, upper: 1e10},
precision: NUMBER_LENGTH_LIMIT}).toString().length;
- return mathJs.format(bigNumberToFormat, {exponential: {lower: 1e-10, upper: 1e10},
+ return MathJs.mathJs.format(bigNumberToFormat, {exponential: {lower: 1e-10, upper: 1e10},
precision: (NUMBER_LENGTH_LIMIT - resultLength + NUMBER_LENGTH_LIMIT)}).toString();
}
return bigNumberToFormat.toString()
@@ -333,7 +321,7 @@ ApplicationWindow {
function calculate(formula, wantArray) {
try {
- var res = mathJs.eval(formula);
+ var res = MathJs.mathJs.eval(formula);
if (!wantArray) {
res = formatBigNumber(res);
}
diff --git a/src/ui/NavButton.qml b/src/qml/NavButton.qml
similarity index 100%
rename from src/ui/NavButton.qml
rename to src/qml/NavButton.qml
diff --git a/src/ui/Shortcuts.qml b/src/qml/Shortcuts.qml
similarity index 100%
rename from src/ui/Shortcuts.qml
rename to src/qml/Shortcuts.qml
diff --git a/src/ui/Styles.qml b/src/qml/Styles.qml
similarity index 100%
rename from src/ui/Styles.qml
rename to src/qml/Styles.qml
diff --git a/src/engine/math.js b/src/qml/math.js
similarity index 100%
rename from src/engine/math.js
rename to src/qml/math.js
diff --git a/src/ui/qmldir b/src/ui/qmldir
deleted file mode 100644
index f8e4b05..0000000
--- a/src/ui/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-module ui