Commit 532cdc42 authored by camilo higuita's avatar camilo higuita

clean up

parent 132b0221
......@@ -222,7 +222,7 @@ else()
KF5::Attica
KF5::SyntaxHighlighting
Qt5::WebEngine
/usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kquicksyntaxhighlighter/libkquicksyntaxhighlighterplugin.so
# /usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kquicksyntaxhighlighter/libkquicksyntaxhighlighterplugin.so
)
endif()
# set(CMAKE_AUTORCC ON)
......
......@@ -4,8 +4,6 @@ import QtQuick.Layouts 1.3
import org.kde.mauikit 1.0 as Maui
import org.kde.kirigami 2.6 as Kirigami
import org.kde.kquicksyntaxhighlighter 0.1
import SyntaxHighlighterUtil 1.0
import DocumentHandler 1.0
import "private"
Item
......@@ -26,7 +24,7 @@ Item
property alias canRedo: body.canRedo
property alias headBar: _editorToolBar
DocumentHandler
Maui.DocumentHandler
{
id: document
document: body.textDocument
......@@ -46,11 +44,11 @@ Item
onLoaded:
{
body.text = text
var formatName = SyntaxHighlighterUtil.getLanguageNameFromFileName(document.fileName);
for (var i=0; i<languagesListModel.count; i++) {
if (languagesListModel.get(i).text === formatName) {
var formatName = document.syntaxHighlighterUtil.getLanguageNameFromFileName(document.fileName);
for (var i=0; i<languagesListModel.count; i++)
{
if (languagesListModel.get(i).text === formatName)
{
languagesListComboBox.currentIndex = i;
}
}
......@@ -152,7 +150,8 @@ Item
leftContent: [
ComboBox {
ComboBox
{
id: languagesListComboBox
model: languagesListModel
font.pointSize: fontSizes.small
......@@ -256,7 +255,8 @@ Item
documentMenu.popup()
}
KQuickSyntaxHighlighter {
KQuickSyntaxHighlighter
{
id: syntaxHighlighter
textEdit: body
}
......@@ -266,7 +266,7 @@ Item
}
Component.onCompleted: {
var languages = SyntaxHighlighterUtil.getLanguageNameList();
var languages = document.syntaxHighlighterUtil.getLanguageNameList();
for (var index in languages) {
languagesListModel.append({text: languages[index]});
......
......@@ -49,21 +49,11 @@
#include "mauikde.h"
#endif
#ifdef STATIC_MAUIKIT
#include "kquicksyntaxhighlighter/kquicksyntaxhighlighter.h"
#endif
#if defined Q_OS_ANDROID || defined APPIMAGE_PACKAGE
#include <QIcon>
#include <QQuickStyle>
#endif
/**
* Global Variables
*/
SyntaxHighlighterUtil *syntaxHighlighterUtil = nullptr;
QUrl MauiKit::componentUrl(const QString &fileName) const
{
#ifdef MAUI_APP
......@@ -129,23 +119,12 @@ void MauiKit::registerTypes(const char *uri)
qmlRegisterType(componentUrl(QStringLiteral("SyncDialog.qml")), uri, 1, 0, "SyncDialog"); //to be rename to accountsDialog
/** EDITOR CONTROLS **/
qmlRegisterType<DocumentHandler>("DocumentHandler", 1, 0, "DocumentHandler");
qmlRegisterType<DocumentHandler>(uri, 1, 0, "DocumentHandler");
qmlRegisterType<SyntaxHighlighterUtil>();
qmlRegisterType(componentUrl(QStringLiteral("Editor.qml")), uri, 1, 0, "Editor");
#ifdef STATIC_MAUIKIT
qmlRegisterType<KQuickSyntaxHighlighter>("org.kde.kquicksyntaxhighlighter", 0, 1, "KQuickSyntaxHighlighter");
#endif
qmlRegisterSingletonType<SyntaxHighlighterUtil>("SyntaxHighlighterUtil", 1, 0, "SyntaxHighlighterUtil",
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
if (syntaxHighlighterUtil == nullptr) {
syntaxHighlighterUtil = new SyntaxHighlighterUtil();
}
return syntaxHighlighterUtil;
});
/** PLATFORMS SPECIFIC CONTROLS **/
#ifdef Q_OS_ANDROID
......@@ -184,7 +163,6 @@ void MauiKit::registerTypes(const char *uri)
return MauiApp::instance();
});
/** HELPERS **/
qmlRegisterSingletonType<Handy>(uri, 1, 0, "Handy",
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* {
......
......@@ -62,6 +62,17 @@
#include <QDebug>
#include <QUrl>
#include "syntaxhighlighterutil.h"
/**
* Global Variables
*/
#ifdef STATIC_MAUIKIT
#include "kquicksyntaxhighlighter/kquicksyntaxhighlighter.h"
#endif
SyntaxHighlighterUtil *DocumentHandler::syntaxHighlighterUtil = nullptr;
DocumentHandler::DocumentHandler(QObject *parent)
: QObject(parent)
, m_document(nullptr)
......@@ -300,6 +311,14 @@ QUrl DocumentHandler::fileUrl() const
return m_fileUrl;
}
SyntaxHighlighterUtil * DocumentHandler::getSyntaxHighlighterUtil()
{
if (!DocumentHandler::syntaxHighlighterUtil)
DocumentHandler::syntaxHighlighterUtil = new SyntaxHighlighterUtil();
return DocumentHandler::syntaxHighlighterUtil;
}
void DocumentHandler::load(const QUrl &fileUrl)
{
......
......@@ -61,6 +61,7 @@ class QTextDocument;
class QQuickTextDocument;
QT_END_NAMESPACE
class SyntaxHighlighterUtil;
class DocumentHandler : public QObject
{
Q_OBJECT
......@@ -85,6 +86,8 @@ class DocumentHandler : public QObject
Q_PROPERTY(QString fileName READ fileName NOTIFY fileUrlChanged)
Q_PROPERTY(QString fileType READ fileType NOTIFY fileUrlChanged)
Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged)
Q_PROPERTY(SyntaxHighlighterUtil * syntaxHighlighterUtil READ getSyntaxHighlighterUtil CONSTANT FINAL)
public:
explicit DocumentHandler(QObject *parent = nullptr);
......@@ -130,6 +133,8 @@ public:
QString fileName() const;
QString fileType() const;
QUrl fileUrl() const;
static SyntaxHighlighterUtil * getSyntaxHighlighterUtil();
public Q_SLOTS:
void load(const QUrl &fileUrl);
......@@ -174,6 +179,8 @@ private:
QFont m_font;
int m_fontSize;
QUrl m_fileUrl;
static SyntaxHighlighterUtil *syntaxHighlighterUtil;
};
#endif // DOCUMENTHANDLER_H
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