Redesign of Widget API #235
letsfindaway
started this conversation in
Ideas
Replies: 2 comments
-
|
I was even thinking of further splitting the
but the three |
Beta Was this translation helpful? Give feedback.
0 replies
-
Item manipulationMore functions for manipulating items could be possible:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Rationale
The current web widget APi is divided into two parts:
widgetAPI, mainly with functions to retrieve general information about the widget.sankoreAPI with functions to interact with the board.But the split is not very clear. E.g.
sankore.resize()could just as well belog to thewidgetAPI.sankore.showMessage()is neither related to the widget nor to the board. It is also questionable whether thepreferencerelated functions would not better belong to the widget, as they already did some time ago.I general, the name
sankoreis something people will only understand if they know the history of OpenBoard.Also the current way to expose the
asyncfunctions is more a patch than a feature.Before creating more extensions to the API, we should think of a redesign of the API structure. We can do this in a way, which keeps the current API as it is, but adds a new, much better structured API including new functions. The previous API can then be deprecated.
API structure
The API could be structured along the following topics:
I would propose to expose the API behind a single
window.apiobject as follows:window.api.applwindow.api.metawindow.api.widgetwindow.api.docwindow.api.boardNote that
windowcan be omitted when using an API function, so it would be sufficient to access a function e.g. asapi.board.setTool().Asynchronous functions
I would also like to have a more natural interaction with asynchronous functions. As described in the Wiki and documented in the Qt documentation an asynchronous function is exposed by the
QWebChannelmechanism as a function with an additional callback parameter. The current API adds another layer on top of this to convert this to a function returning aPromise.I would like to make the
Promisebased calls the main way to expose the function in the API. So retrieving a property should just look like this:API
Proposal based on current API and proposal for extension. Some of the Slots listed below should perhaps better be functions returning a success value.
applProperties
appl.langSignals
Slots
appl.openURLappl.showMessageFunctions
metaProperties
meta.idmeta.namemeta.descriptionmeta.authormeta.authorEmailmeta.authorHrefmeta.versionSignals
Slots
Functions
widgetProperties
widget.uuidwidget.widthwidget.heightwidget.dropDataSignals
widget.onenterwidget.onleavewidget.onremoveSlots
widget.resizewidget.setPreferencewidget.enableDropOnWidgetFunctions
widget.preferencewidget.preferenceKeysdocProperties
doc.pageCountdoc.currentPageNumberSignals
Slots
Functions
doc.pageThumbnaildoc.nextPagedoc.previousPagedoc.gotoPagedoc.insertPagedoc.deletePagedoc.deletePagesdoc.movePagedoc.copyPageboardProperties
Signals
Slots
board.setToolboard.setPenColorboard.setMarkerColorboard.zoomboard.pan(was:move)board.moveToboard.drawLineToboard.eraseLineToboard.clearboard.setBackgroundboard.addObjectboard.centerOnboard.addTextFunctions
Beta Was this translation helpful? Give feedback.
All reactions