Skip to content

[DoNotMerge] ✨Use declarative macros for better Qt integration (e.g. QDS) #172

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Thiesius
Copy link

Mainly the changes that I "needed" to do for supporting Qaterial in QDS.

I'm a beginner in Qt, and I found that the documentation of the QML/Qt/QDS to be lacking some important details.
The whole merge request needs to be revisited, because in the pursue of my goal I might have been cutting too much 😃
So this is more of a "reference" to let you know, what I have needed to do. (Since I completely removed STATIC library)

I might have some time to clean this up in upcoming months. But for now I want to mostly focus on my original goal -> actually using the library 😀 . Unless there is some low hanging fruit to be picked - then I would need to know all the scenarios you want to support.


For QDS support I have added "d:/libs/Qaterial/qml" (My install dir. qml is a new install subdir for QML + plugin stuff) to the importPaths in qmlproject. And for qml2puppet I also needed to make the Qaterial.dll to be accessible from PATH, as the plugin has the dependency on it. For my convenience I have copied it right into the QDS bin dir.

On the video below you can see how the integration works (Just edited a dummy project that the QDS generates for you)

qat2.mp4

Puppet:
image


I did some other tiny fixes as well. Some of them can be probably ported to master immediately. I will try to highlight them in self-review.

Otherwise I have been able to use Qaterial in my C++ application with CLion IDE for the C++/QML part and I have used the QDS to just prototype the visuals/UI real quick.

By the way, this is a very cool library. Finally everything looks great without much effort, and my UI doesn't look like a chewed up pencil 🥳 . Thanks for the great library. Well done!

@@ -15,3 +15,5 @@ CMakeLists.txt.user
# nix files
result*
.direnv

cmake-build-*/
Copy link
Author

Choose a reason for hiding this comment

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

This is mainly for CLion. As the IDE generates in source build folder like this.

@@ -62,6 +62,9 @@ endif()

set(QATERIAL_ENABLE_INSTALL ${_default_QATERIAL_ENABLE_INSTALL} CACHE BOOL "Generate the install target")

# "d" postfix should also transitively apply to dependencies but won't affect the parent scope
set(CMAKE_DEBUG_POSTFIX "d")
Copy link
Author

Choose a reason for hiding this comment

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

This is useful so you can install both release and debug library in the install folder.

CLASS_NAME QaterialPlugin
PLUGIN_TARGET qaterialplugin
NO_PLUGIN_OPTIONAL
RESOURCE_PREFIX "/"
Copy link
Author

Choose a reason for hiding this comment

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

I had a lot of troubles with these prefixes and what not. I haven't tried to go back to individual subtargets linking into this library.

NO_PLUGIN_OPTIONAL
RESOURCE_PREFIX "/"
SOURCES ${QATERIAL_SRCS}
OUTPUT_DIRECTORY "${QATERIAL_OUTPUT_DIR}"
Copy link
Author

Choose a reason for hiding this comment

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

OUTPUT_DIRECTORY contains everything one might need to install into output "qml" dir. Haven't found some dedicated target for that or example for "how it is done in Qt".

@@ -197,18 +203,47 @@ add_library(${QATERIAL_TARGET}::${QATERIAL_TARGET} ALIAS ${QATERIAL_TARGET})

target_compile_features(${QATERIAL_TARGET} PUBLIC cxx_std_17)
target_include_directories(${QATERIAL_TARGET} PRIVATE src ${QATERIAL_ICONS_OUTPUT_FOLDER})
# Glob all include directories in src Qaterial
Copy link
Author

Choose a reason for hiding this comment

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

The next section is needed, because the generated files always include the "parent header" with not prefix. Looks a bit hacky though. There could be better solution.

This is related:
https://forum.qt.io/topic/158392/problem-with-qml_element-for-classes-in-subfolder-of-project

install(DIRECTORY ${QATERIAL_OUTPUT_DIR}
DESTINATION ${CMAKE_INSTALL_PREFIX}/qml/
FILES_MATCHING PATTERN "*.qml" PATTERN "qmldir" PATTERN "*.qmltypes" PATTERN "*.dll" PATTERN "*.so"
)
Copy link
Author

Choose a reason for hiding this comment

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

Installs all that is needed for QDS into QML dir.

@@ -17,32 +17,23 @@ file(GLOB_RECURSE QATERIAL_QML_FILES
)

set(SINGLETON_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Calendar.qml
Copy link
Author

Choose a reason for hiding this comment

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

Bug I think, This can also be probably split and merged immediately.

@@ -22,5 +22,4 @@ Qaterial.Dialog

parent: Overlay.overlay
property int dialogImplicitWidth: Qaterial.Style.dialog.implicitWidth
implicitWidth: Math.floor(Math.min(parent.width - 2 * Qaterial.Style.card.horizontalPadding, dialogImplicitWidth))
Copy link
Author

Choose a reason for hiding this comment

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

I had to remove this line because my AlertDialogs had a cut headers.

E.g. "Failed to blah glah flah" would become "Failed to blah gla..."

Not sure if this is a correct place to treat this, but it works 😄

@@ -49,51 +49,12 @@ static quint8 _minor = 0;
static bool registeredTypes = false;
static bool registeredRes = false;

void __Qaterial_registerIconsSingleton();
Copy link
Author

Choose a reason for hiding this comment

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

This section can be probably purged more thoroughly. Didn't investigate as I'm not calling anything from here in my C++ code.

@@ -32,15 +33,15 @@
namespace qaterial {

// Behave like QQuickIcon (that is private)
class QATERIAL_API_ IconDescription : public QObject
class QATERIAL_API_ IconDescription : public QQuickItem
Copy link
Author

Choose a reason for hiding this comment

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

I think QDS was whining about something here.

Copy link
Owner

Choose a reason for hiding this comment

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

This is odd, to me QQuickItem is really only when your object have some kind of visual or a size. Which isn't the case here

@OlivierLDff
Copy link
Owner

Thank you for the work and the research to fix things.

I don't know anything about QDS and never used it. I always felt just coding qml is dead simple enough. Using QDS feels like something you need when you don't wireframe/prototype your UI with a tool like figma, which is a bad practice.

Please note that this library is mainly in maintenance mode for my company's projects, we do not whish to add new features in here (Maybe a v2 in the future). I will leave some review to your comments if you want to open small PRs about what can be merged. I might also need to update Qt version in the CI


# ───── QATERIAL TARGET ─────

qt_policy(SET QTP0004 NEW)
Copy link
Owner

Choose a reason for hiding this comment

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

This is neat since Qt6.8, thank you for the discovery I missed it. I guess it won't change much in here, but I have some projects that may be affected so I can remove lots of CMake code.

@OlivierLDff
Copy link
Owner

After going thru your PR I see couple of things that could be split in different PRs:

  • Update to Qt6 new macros and stuff (Qaterial was originally written for Qt5). Everything QML_ELEMENT related.
  • Some update from Qt6.8 with the new QTP0004 policy that cut lots of CMake code
  • Some bug fixes in qml files
  • The rest that is QDS/install related

I also need to update some actions in the CI (updating Qt version, updating stuff related to gha cache, ...)

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.

2 participants