Added a bunch of documentation

This commit is contained in:
Daniel Ziltener 2022-02-14 11:22:40 +01:00
parent 22163c534e
commit 3c5b923c6d
2 changed files with 581 additions and 535 deletions

View File

@ -11,7 +11,7 @@
(import (qml lowlevel))
(import (scheme base))
(import coops coops-primitive-objects coops-extras coops-utils srfi-1 srfi-69 object-evict)
@("This should appear as library doc.")
@("A library to simplify usage of QML user interfaces from Chicken.")
(export application-dir-path
process-events
process-events-timed
@ -162,12 +162,19 @@
parent
)
(begin
;; Enums
@(== "Enums")
@(=== "Usage")
@("When a method requires an enum value, it can be handed to it using the enum's procedure plus the enum value keyword. Example:")
@(script "(qt-connection-type auto:)")
(define-class <Enum> ()
((val accessor: val)))
(define-class <QEventLoopProcessEventFlag> (<Enum>))
(define (qevent-loop-process-event-flag val) @("Event flags")
(define (qevent-loop-process-event-flag val) @("QEventLoopProcessEventFlag flags. Available values: process-all-events:, exclude-user-input-events:, process-exclude-socket-notifiers:, and process-all-events-wait-for-more-events:.")
(case val
((process-all-events:)
(make <QEventLoopProcessEventFlag> 'val DosQEventLoopProcessEventFlagProcessAllEvents))
@ -179,7 +186,7 @@
(make <QEventLoopProcessEventFlag> 'val DosQEventLoopProcessEventFlagProcessAllEventsWaitForMoreEvents))))
(define-class <QtConnectionType> (<Enum>))
(define (qt-connection-type val)
(define (qt-connection-type val) @("QConnectionType flags. Available values: auto:, direct:, queued:, blocking:, and unique:.")
(case val
((auto:)
(make <QtConnectionType> 'val DosQtConnectionTypeAutoConnection))
@ -193,13 +200,13 @@
(make <QtConnectionType> 'val DosQtConnectionTypeUniqueConnection))))
(define-class <QQuickViewResizeMode> (<Enum>))
(define (qquick-view-resize-mode val)
(define (qquick-view-resize-mode val) @("QQuickViewResizeMode flags. Available values: side-view-to-root-object:, and size-root-object-to-view:.")
(case val
((size-view-to-root-object:) (make <QQuickViewResizeMode> 'val #x0))
((size-root-object-to-view:) (make <QQuickViewResizeMode> 'val #x1))))
(define-class <QItemDataRole> (<Enum>))
(define (qitem-data-role val)
(define (qitem-data-role val) @("QItemDataRole flags. Available values: display:, decoration:, edit:, tool-tip:, status-tip:, whats-this:, font:, text-alignment:, background:, foreground:, check-state:, accessible-text:, accessible-description:, size-hint:, and initial-sort-order:.")
(case val
((display:) (make <QItemDataRole> 'val 0))
((decoration:) (make <QItemDataRole> 'val 1))
@ -218,43 +225,45 @@
((initial-sort-order:) (make <QItemDataRole> 'val 14))))
(define-class <QtOrientation> (<Enum>))
(define (qt-orientation val)
(define (qt-orientation val) @("QOrientation flags. Available values: horizontal:, and vertical:.")
(case val
((horizontal:) (make <QtOrientation> 'val #x01))
((vertical:) (make <QtOrientation> 'val #x02))))
;; Helpers
(define (application-dir-path)
@(== "Helpers")
(define (application-dir-path) @((@to "the application dir path"))
(dos_qcoreapplication_application_dir_path))
(define-method (process-events (flag <QEventLoopProcessEventFlag>))
(define-method (process-events (flag <QEventLoopProcessEventFlag>)) @("Runs the QML event processing once until all queued events are processed.")
(dos_qcoreapplication_process_events (val flag)))
(define-method (process-events-timed (flag <QEventLoopProcessEventFlag>) (timed <integer>))
(define-method (process-events-timed (flag <QEventLoopProcessEventFlag>) (timed <integer>)) @("Runs the QML event processing until all queued events are processed or the timeout has run out.")
(dos_qcoreapplication_process_events_timed (val flag) timed))
(define (gui-application-create)
(define (gui-application-create) @("Initializes the QGuiApplication.")
(dos_qguiapplication_create))
(define (gui-application-exec)
(define (gui-application-exec) @("Executes the QGuiApplication. WARNING: This will block the Chicken process!")
(dos_qguiapplication_exec))
(define (gui-application-quit)
(define (gui-application-quit) @("Quits the QGuiApplication.")
(dos_qguiapplication_quit))
(define (gui-application-delete)
(define (gui-application-delete) @("Deletes the QGuiApplication.")
(dos_qguiapplication_delete))
(define (qapplication-create)
(define (qapplication-create) @("Initializes the QApplication.")
(dos_qapplication_create))
(define (qapplication-exec)
(define (qapplication-exec) @("Executes the QApplication. WARNING: This will block the Chicken process!")
(dos_qapplication_exec))
(define (qapplication-quit)
(define (qapplication-quit) @("Quits the QApplication.")
(dos_qapplication_quit))
(define (qapplication-delete)
(define (qapplication-delete) @("Deletes the QApplication.")
(dos_qapplication_delete))
(define (qquickstyle-set-style style)
(define (qquickstyle-set-style style) @("Sets the QQuickStyle, see https://doc.qt.io/qt-5/qquickstyle.html#setStyle for details.")
(dos_qquickstyle_set_style style))
(define (qquickstyle-set-fallback-style style)
(define (qquickstyle-set-fallback-style style) @("Sets the fallback style with QQuickStyle, see https://doc.qt.io/qt-5/qquickstyle.html#setFallbackStyle for details.")
(dos_qquickstyle_set_fallback_style style))
;; Objects
@(== "Classes")
(define callback-registry
(make-hash-table))
@ -265,6 +274,8 @@
(refcount (hash-table-ref ht ptr))
0))
@(=== "<QMLBase>")
@("A base class you can't directly use yourself, but it provides facilities like a refcounter to delete the companion pointer once it is not needed anymore.")
(define-class <QMLBase> ()
((ptr accessor: ptr initform: #f)))
(define-method (delete-pointer (qbase <QMLBase>))
@ -295,38 +306,71 @@
(define-class <QObject> (<QMLBase>))
@(=== "<QVariant>")
@("This class is used to pass and return value types to and from Qt, and offers a decent range of possible types.")
(define-class <QVariant> (<QMLBase>)
((ptr accessor: ptr)))
(define (new-QVariant)
(define (new-QVariant) @("Creates a blank QVariant with no content."
(@to "<QVariant>"))
(make <QVariant> 'ptr (dos_qvariant_create)))
(define-method (qvariant (val <integer>))
(define-method (qvariant (val <integer>)) @("Creates a QVariant with an integer."
(val "The integer to store")
(@to "<QVariant>"))
(make <QVariant> 'ptr (dos_qvariant_create_int val)))
(define-method (qvariant (val <boolean>))
(define-method (qvariant (val <boolean>)) @("Creates a QVariant with a boolean."
(val "The boolean to store")
(@to "<QVariant>"))
(make <QVariant> 'ptr (dos_qvariant_create_bool val)))
(define-method (qvariant (val <string>))
(define-method (qvariant (val <string>)) @("Creates a QVariant with a string."
(val "The string to store")
(@to "<QVariant>"))
(make <QVariant> 'ptr (dos_qvariant_create_string val)))
(define-method (qvariant (val <QObject>))
(define-method (qvariant (val <QObject>)) @("Creates a QVariant with a QObject."
(val "The QObject to store")
(@to "<QVariant>"))
(make <QVariant> 'ptr (dos_qvariant_create_qobject (ptr val))))
(define-method (qvariant (val <flonum>))
(define-method (qvariant (val <flonum>)) @("Creates a QVariant with a float."
(val "The float to store")
(@to "<QVariant>"))
(make <QVariant> 'ptr (dos_qvariant_create_float val)))
(define-method (set (qv <QVariant>) (val <integer>))
(define-method (set (qv <QVariant>) (val <integer>)) @("Sets the QVariant value to the specified integer."
(qv "The QVariant to modify")
(val "The integer to store")
(@to "void"))
(dos_qvariant_setInt (ptr qv) val))
(define-method (set (qv <QVariant>) (val <boolean>))
(define-method (set (qv <QVariant>) (val <boolean>)) @("Sets the QVariant value to the specified boolean."
(qv "The QVariant to modify")
(val "The booleant o store")
(@to "void"))
(dos_qvariant_setBool (ptr qv) val))
(define-method (set (qv <QVariant>) (val <flonum>))
(define-method (set (qv <QVariant>) (val <flonum>)) @("Sets the QVariant value to the specified float."
(qv "The QVariant to modify")
(val "The float to store")
(@to "void"))
(dos_qvariant_setFloat (ptr qv) val))
(define-method (set (qv <QVariant>) (val <string>))
(define-method (set (qv <QVariant>) (val <string>)) @("Sets the QVariant value to the specified string."
(qv "The QVariant to modify")
(val "The string to store")
(@to "void"))
(dos_qvariant_setString (ptr qv) val))
(define-method (set (qv <QVariant>) (val <QObject>))
(define-method (set (qv <QVariant>) (val <QObject>)) @("Sets the QVariant value to the specified QObject."
(qv "The QVariant to modify")
(val "The QObject to store")
(@to "void"))
(dos_qvariant_setQObject (ptr qv) (ptr val)))
(define-method (to (qv <QVariant>) (target <keyword>))
(define-method (to (qv <QVariant>) (target <keyword>)) @("Extracts the QVariant's value."
(qv "The QVariant to read")
(target "The target format; available are integer:, boolean:, string:, flonum:, and qobject:")
(@to "target format"))
(case target
((integer:) (dos_qvariant_toInt (ptr qv)))
((boolean:) (dos_qvariant_toBool (ptr qv)))
((string:) (dos_qvariant_toString (ptr qv)))
((flonum:) (dos_qvariant_toFloat (ptr qv)))
((qobject:) (dos_qvariant_toQObject (ptr qv)))))
(define-method (is-null? (qv <QVariant>))
(define-method (is-null? (qv <QVariant>)) @("Checks if the QVariant's value is null."
(qv "The QVariant to check")
(@to "boolean"))
(dos_qvariant_isnull (ptr qv)))
(define-method (assign (qv <QVariant>) (other <QVariant>))
(dos_qvariant_assign (ptr qv) (ptr other)))
@ -617,4 +661,4 @@
(define-method (parent (qatm <QAbstractTableModel>) (child <QModelIndex>))
(dos_qabstracttablemodel_parent (ptr qatm) (ptr child)))
)
)
)

2
scripts/gen-doc.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
chalk -m ./qml.core.scm > readme.wiki