Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QML and QML Example #187

Merged
merged 2 commits into from
Jul 7, 2023
Merged

Add QML and QML Example #187

merged 2 commits into from
Jul 7, 2023

Conversation

tim-gromeyer
Copy link
Contributor

@tim-gromeyer tim-gromeyer commented Jul 5, 2023

Add code to MarkdownHighlighter to make it a QML module if QtQuick was found.

Should close #158

tim-gromeyer and others added 2 commits July 5, 2023 11:47
Make qmarkdowntextedit static...

Update build.yml

Update build.yml

Link to  Qml

`qmlplugin`: Link to Qml

Try to fix build

MAKE IT WORK!!!!!

Remove old file

Revert workflow changes

Remove old file, sync qmarkdowntextedit.cpp/h with upstream

Dont't force static

Add missing `highlightingEnabled` - function

Move qml stuff into seperate folder, make Quick dependency optional

Add missing file

Don't force Qt6, might work with Qt5

Made it work with Qt 5.12

Fix build if Qt Quick is not installed

Remove unneeded include

Remove old code

Add missing `highlightingEnabled` - function
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16) # Qt requires CMake 3.16
cmake_minimum_required(VERSION 3.16) # Qt requires CMake 3.16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't ask me what changed here. I don't know and I'm not aware that I changed anything there.

@@ -16,6 +16,7 @@ option(QMARKDOWNTEXTEDIT_EXE "Build test executable" ON)
# find qt
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Quick)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make QtQuick optional

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

add_executable(QtQuickExample examples/qml/example.cpp examples/qml/ressources.qrc)
target_link_libraries(QtQuickExample PRIVATE Qt${QT_VERSION_MAJOR}::Quick qmarkdowntextedit)
endif()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If QtQuick was found, build the example

@@ -19,6 +19,10 @@
#include <QSyntaxHighlighter>
#include <QTextCharFormat>

#ifdef QT_QUICK_LIB
#include <QQuickTextDocument>
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If QtQuick was found, include QQuickTextDocument

Q_EMIT textDocumentChanged();
};
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If QtQuick was found, add a textDocument property to allow usage in/with QML and using the QTextDocument from QML's TextEdit

Q_PROPERTY(QQuickTextDocument *textDocument READ textDocument WRITE
setTextDocument NOTIFY textDocumentChanged)

QQuickTextDocument *m_quickDocument = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary to store this I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, because of inline QQuickTextDocument *textDocument() const { return m_quickDocument; };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, thanks

@pbek pbek requested a review from Waqar144 July 5, 2023 11:05
@pbek
Copy link
Owner

pbek commented Jul 5, 2023

I wonder if this also would work with qmake.

@Waqar144
Copy link
Contributor

Waqar144 commented Jul 5, 2023

I wonder if this also would work with qmake.

It will work for QON i.e., would not break the build. But QMake support for this feature will need to be added of course.

@pbek
Copy link
Owner

pbek commented Jul 5, 2023

yes, QOwnNotes still builds

Copy link
Owner

@pbek pbek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tim-gromeyer
Copy link
Contributor Author

It will work for QON i.e.

What is "QON"?

But QMake support for this feature will need to be added of course.

Is this necessary? In my opinion, Qmake is obsolete and CMake is superior

@pbek
Copy link
Owner

pbek commented Jul 6, 2023

QON = QOwnNotes
the project this library was implemented for in the beginning

QOwnNotes uses qmake, but is no QML app.

@tim-gromeyer
Copy link
Contributor Author

tim-gromeyer commented Jul 6, 2023

QON = QOwnNotes
the project this library was implemented for in the beginning

QOwnNotes uses qmake, but is no QML app.

Yes, I know this one. I just didn't know what QON stands for. I actually contributed to QON and took some inspiration from the source code

But is it necessary to add Qmake support? I don't even have it installed on my system...

@pbek
Copy link
Owner

pbek commented Jul 6, 2023

Sorry for the abbreviation. 😅

@tim-gromeyer
Copy link
Contributor Author

It's alright 😅 now I know what it means 😉

@pbek pbek merged commit bb3bcd3 into pbek:develop Jul 7, 2023
@tim-gromeyer tim-gromeyer deleted the qml branch August 24, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

is it possible to use this plugin in a qml script?
3 participants