Creating a new album from a custom InputDialog
The AlbumListPage
needs some data to display. The next step is to be able to add a new album. To do this, at some point we will have to call an AlbumModel
function from QML to add this new album. Before building the UI, we have to make a small modification in gallery-core
.
The AlbumModel
function is already available in QML. However, we cannot directly call AlbumModel::addAlbum(const Album& album)
from the QML code; the QML engine will not recognize the function and will throw an error TypeError: Property 'addAlbum' of object AlbumModel(...) is not a function. This can be fixed by simply decorating the desired function with the Q_INVOKABLE
macro (as we did for PictureModel::setAlbumId()
).
Nonetheless, there is another issue here: Album
is a C++ class which is not recognized in QML. If we wanted to have full access to Album
in QML, it would involve important modifications to the class:
Force
Album
class to inherit from theQObject
class.Add...