-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Conversation
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make QtQuick optional
There was a problem hiding this comment.
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() | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, thanks
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. |
yes, QOwnNotes still builds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is "QON"?
Is this necessary? In my opinion, Qmake is obsolete and CMake is superior |
QON = QOwnNotes 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... |
Sorry for the abbreviation. 😅 |
It's alright 😅 now I know what it means 😉 |
Add code to
MarkdownHighlighter
to make it a QML module if QtQuick was found.Should close #158