From 059881155d06b7da8a7225c1dd0812f41b49f4f8 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Fri, 1 Nov 2024 08:13:12 +0100 Subject: [PATCH] feat: convert documentation of C++ types to Doxygen --- src/imports/controls/clipboard.cpp | 18 ------------ src/imports/controls/clipboard.h | 9 ++++++ src/imports/controls/color.cpp | 38 ------------------------ src/imports/controls/color.h | 28 ++++++++++++++++++ src/imports/controls/controlsutils.cpp | 40 -------------------------- src/imports/controls/controlsutils.h | 33 +++++++++++++++++++++ 6 files changed, 70 insertions(+), 96 deletions(-) diff --git a/src/imports/controls/clipboard.cpp b/src/imports/controls/clipboard.cpp index 19bcdef9..4c908d50 100644 --- a/src/imports/controls/clipboard.cpp +++ b/src/imports/controls/clipboard.cpp @@ -17,14 +17,6 @@ #include "clipboard.h" -/*! - \qmltype Clipboard - \inqmlmodule Fluid - \ingroup fluid - - \brief Clipboard. -*/ - Clipboard::Clipboard(QObject *parent) : QObject(parent) , m_clipboard(QGuiApplication::clipboard()) @@ -32,11 +24,6 @@ Clipboard::Clipboard(QObject *parent) connect(m_clipboard, &QClipboard::dataChanged, this, &Clipboard::textChanged); } -/*! - \qmlproperty string Clipboard::text - - This property holds the clipboard text. -*/ QString Clipboard::text() const { return m_clipboard->text(); @@ -47,11 +34,6 @@ void Clipboard::setText(const QString &text) m_clipboard->setText(text); } -/*! - \qmlmethod void Clipboard::clear() - - Clear the global clipboard contents. -*/ void Clipboard::clear() { m_clipboard->clear(); diff --git a/src/imports/controls/clipboard.h b/src/imports/controls/clipboard.h index 401ef4e7..11cd7dd0 100644 --- a/src/imports/controls/clipboard.h +++ b/src/imports/controls/clipboard.h @@ -18,6 +18,9 @@ #include #include +/*! + \brief Clipboard. +*/ class Clipboard : public QObject { Q_OBJECT @@ -26,8 +29,14 @@ class Clipboard : public QObject public: explicit Clipboard(QObject *parent = nullptr); + /*! + This property holds the clipboard text. + */ QString text() const; + /*! + Clear the global clipboard contents. + */ Q_INVOKABLE void clear(); public Q_SLOTS: diff --git a/src/imports/controls/color.cpp b/src/imports/controls/color.cpp index fbe33be1..755a57fc 100644 --- a/src/imports/controls/color.cpp +++ b/src/imports/controls/color.cpp @@ -14,37 +14,16 @@ #include "color.h" -/*! - \qmltype Color - \instantiates Color - \inqmlmodule Fluid - - \brief Utility functions for colors. - - Utility functions to manipulate colors. -*/ - Color::Color(QObject *parent) : QObject(parent) { } -/*! - \qmlmethod color Fluid.Controls::Color::transparent(color color, real alpha) - - A utility method for changing the \a alpha on \a color. - Returns a new object, and does not modify the original color at all. -*/ QColor Color::transparent(const QColor &color, qreal alpha) { return QColor(color.red(), color.green(), color.blue(), int(qBound(0.0, alpha, 1.0) * 255)); } -/*! - \qmlmethod color Fluid.Controls::Color::blend(color color1, color color2, real alpha) - - Blend \a color1 and \a color2 together and set alpha to \a alpha. -*/ QColor Color::blend(const QColor &color1, const QColor &color2, qreal alpha) { QColor color; @@ -54,34 +33,17 @@ QColor Color::blend(const QColor &color1, const QColor &color2, qreal alpha) return transparent(color, alpha); } -/*! - \qmlmethod real Fluid.Controls::Color::luminance(color color) - - Calculate luminance of \a color. -*/ qreal Color::luminance(const QColor &color) { return (color.redF() * 0.2126) + (color.greenF() * 0.7152) + (color.blueF() * 0.0722); } -/*! - \qmlmethod bool Fluid.Controls::Color::isDarkColor(color color) - - Returns \c true if \a color is dark and should have light content on top. -*/ bool Color::isDarkColor(const QColor &color) { auto a = 1.0 - (0.299 * color.redF() + 0.587 * color.greenF() + 0.114 * color.blueF()); return color.alphaF() > 0.0 && a >= 0.3; } -/*! - \qmlmethod color Fluid.Controls::Color::lightDark(color background, color lightColor, color darkColor) - - Select a color depending on whether \a background color is light or dark. - Returns \a lightColor if \a background is a light color, otherwise - returns \a darkColor. -*/ QColor Color::lightDark(const QColor &background, const QColor &lightColor, const QColor &darkColor) { return isDarkColor(background) ? darkColor : lightColor; diff --git a/src/imports/controls/color.h b/src/imports/controls/color.h index cc048951..5bde4899 100644 --- a/src/imports/controls/color.h +++ b/src/imports/controls/color.h @@ -18,6 +18,11 @@ #include #include +/*! + \brief Utility functions for colors. + + Utility functions to manipulate colors. +*/ class Color : public QObject { Q_OBJECT @@ -26,10 +31,33 @@ class Color : public QObject public: explicit Color(QObject *parent = nullptr); + /*! + A utility method for changing the \a alpha on \a color. + Returns a new object, and does not modify the original color at all. + */ Q_INVOKABLE QColor transparent(const QColor &color, qreal alpha); + + + /*! + Blend \a color1 and \a color2 together and set alpha to \a alpha. + */ Q_INVOKABLE QColor blend(const QColor &color1, const QColor &color2, qreal alpha); + + /*! + Calculate luminance of \a color. + */ Q_INVOKABLE qreal luminance(const QColor &color); + + /*! + Returns \c true if \a color is dark and should have light content on top. + */ Q_INVOKABLE bool isDarkColor(const QColor &color); + + /*! + Select a color depending on whether \a background color is light or dark. + Returns \a lightColor if \a background is a light color, otherwise + returns \a darkColor. + */ Q_INVOKABLE QColor lightDark(const QColor &background, const QColor &lightColor, const QColor &darkColor); diff --git a/src/imports/controls/controlsutils.cpp b/src/imports/controls/controlsutils.cpp index fc9c4b64..04be1786 100644 --- a/src/imports/controls/controlsutils.cpp +++ b/src/imports/controls/controlsutils.cpp @@ -14,57 +14,17 @@ #include "controlsutils.h" -/*! - \qmltype Fluid.Controls::Utils - \inqmlmodule Fluid - \ingroup fluid - - \brief A collection of helpful utility methods. -*/ ControlsUtils::ControlsUtils(const QUrl &baseUrl, QObject *parent) : QObject(parent) , m_baseUrl(baseUrl) { } -/*! - \qmlmethod real Fluid::Utils::scale(real percent, real start, real end) - - Scale \a percent in the range between \a start and \a end. -*/ qreal ControlsUtils::scale(qreal percent, qreal start, qreal end) { return start + ((end - start) * (percent / 100)); } -/*! - \qmlmethod url Fluid::Utils::iconUrl(string name) - - Returns an URL for the Material Design icon \a name. - Use this URL with Image or icon grouped property with controls. - - \code - import QtQuick - import Fluid as Fluid - - Image { - source: Fluid.Utils.iconUrl("action/alarm") - width: 64 - height: 64 - } - \endcode - - \code - import QtQuick - import QtQuick.Controls - import Fluid as Fluid - - Button { - icon.source: Fluid.Utils.iconUrl("action/alarm") - text: qsTr("Alarm") - } - \endcode -*/ QUrl ControlsUtils::iconUrl(const QString &name) { #if FLUID_INSTALL_ICONS == 1 diff --git a/src/imports/controls/controlsutils.h b/src/imports/controls/controlsutils.h index 65186aeb..8ee248c7 100644 --- a/src/imports/controls/controlsutils.h +++ b/src/imports/controls/controlsutils.h @@ -18,6 +18,9 @@ #include #include +/*! + \brief A collection of helpful utility methods. +*/ class ControlsUtils : public QObject { Q_OBJECT @@ -26,7 +29,37 @@ class ControlsUtils : public QObject public: explicit ControlsUtils(const QUrl &baseUrl, QObject *parent = nullptr); + /*! + Scale \a percent in the range between \a start and \a end. + */ Q_INVOKABLE qreal scale(qreal percent, qreal start, qreal end); + + /*! + Returns an URL for the Material Design icon \a name. + Use this URL with Image or icon grouped property with controls. + + \code{.qml} + import QtQuick + import Fluid as Fluid + + Image { + source: Fluid.Utils.iconUrl("action/alarm") + width: 64 + height: 64 + } + \endcode + + \code{.qml} + import QtQuick + import QtQuick.Controls + import Fluid as Fluid + + Button { + icon.source: Fluid.Utils.iconUrl("action/alarm") + text: qsTr("Alarm") + } + \endcode + */ Q_INVOKABLE QUrl iconUrl(const QString &name); static ControlsUtils *create(QQmlEngine *engine, QJSEngine *jsEngine);