Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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

clean up

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