Make ACBF library data accesible from QML and update Peruse Creator to edit them.
ClosedPublic

Authored by woltherav on Sep 15 2018, 8:44 PM.

Details

Reviewers
leinir
Summary

I was tracking this in T9657 .

Basically, the acbf library needed all sorts of stuff to be able to access metadata and extra pagedata.

Given that I am not too great with QML yet, I thought I'd also update Peruse Creator, as that would demonstrate the properties can be read and written in a sensible manner.

There's still a bit to do, and some paper cuts to polish, but I am pretty far already, so hence this review request :)

What has been done:

Metadata page:
The metadata page can now edit (almost) everything in the metadata section.

  • I removed the multi-language stuff here because I suspect we are better off making a seperate translation gui?
  • DocumentInfo ID is generated as a random UUID and the creation date is written upon writing, so those didn't need to be made editable.
  • Body background color should proly also go here.
  • I didn't add reading direction yet.
  • Editing the publishing date isn't as nice as I had hoped.
  • Version needs a floating point box, but QML doesn't have one, so I'll have to think about what can be done there.

Pages now have a 'edit' page, which is BookPage put into place. You can edit page info here, as well as make frames, textareas and jumps.

  • Clicking once on the page will start a page area selection mode. Clicking a second time confirms the selection and asks what kind of area you want to make.
    • This was done because the click+drag activates Kirigami's swipe mechanic, it is not very touch friendly however.
    • Textareas still need a bit of work, they don't show up unless you've made one textarea, went back to the pages section and then go back to the page.
    • Textareas will also need to create a default language layer entry to get conform files.
    • you can only make rectangles right now, but we'll proly need Qt 5.11 for showing anything more complex, as that has the 'Shape' object.
  • Areas will show up in the page info list, where you can edit them a little and remove them.
    • The swap is kinda broken :< (Requires QQmlListProperty and that is just too difficult to implement for me.)
  • Pages should probably try to inherit the page color from the body value.

Anyway I am pretty proud of how far I've gotten :p

Diff Detail

Repository
R157 Peruse
Lint
Lint Skipped
Unit
Unit Tests Skipped
woltherav requested review of this revision.Sep 15 2018, 8:44 PM
woltherav created this revision.

Frame/Textarea/Jump swap seems broken because I build up those repeaters from the count of those values, but if the count stays the same, the repeater has no need to change, so they effectively don't update.

So I tried using QQmlListProperty again, for frames, and while this builds:

in page.cpp

QQmlListProperty<Frame> Page::frameList()
{
    return QQmlListProperty<Frame>(this, nullptr, &Page::frameCount, &Page::frameAt);
}

Frame * Page::frame(int index) const
{
    return d->frames.at(index);
}

Frame *Page::frameAt(QQmlListProperty<Frame> *list, int index)
{
    Page* page = qobject_cast<Page*>(list->object);
    if (page) {
        return page->frames().at(index);
    }
    return nullptr;
}

int Page::frameCount(QQmlListProperty<Frame> *list)
{
    Page* page = qobject_cast<Page*>(list->object);
    if (page) {
        return page->frames().size();
    }
    return 0;
}

and page.h

 Q_PROPERTY(QQmlListProperty<Frame> frameList READ frameList NOTIFY frameCountChanged)
 
 [...]

 QQmlListProperty<Frame> frameList();

 static Frame* frameAt(QQmlListProperty<Frame> *list, int index);
 static int frameCount(QQmlListProperty<Frame> *list);

Q_SIGNAL void frameCountChanged();

It also needs a property registery? But I can't for the life of me figure out how to set that up, when I copy qmlplugin to the acbf folder it complains it cannot find the qmlengine type despite including QtQml/QQmlEngine. I am giving up on this now.

Will try to continue with the other items.

woltherav edited the summary of this revision. (Show Details)Sep 17 2018, 11:45 AM

It also needs a property registery? But I can't for the life of me figure out how to set that up, when I copy qmlplugin to the acbf folder it complains it cannot find the qmlengine type despite including QtQml/QQmlEngine. I am giving up on this now.

Ah, yes, quite... i never really intended libacbf to be a QML plugin, it was supposed to be a generic Qt library for handling ACBF files... But, i guess there's nothing really to stop us turning it into one such, it /would/ make life easier in some ways. I imagine the reason it's breaking (or certainly part of it) is that libacbf is only linked against Qt5::Core, but to create a QML plugin you also need to link against Qt5::Qml. It would, perhaps, also make packaging a little easier in some ways. It does mean changing the cmakelists.txt for libacbf to produce a QML plugin rather than a normal library. The problem with doing that is that the peruse plugin is linked against libacbf, which you can't do with a qml plugin. Hm, it... looks like there might be a chicken/egg issue developing here... There is the option that emitting the signal for count changing twice would work, one for removing the two items being swapped, and one once they've been reinserted in their new locations? It's a little ugly, perhaps, but i'm thinking it would probably work...

src/acbf/AcbfAuthor.h
64

Thinking that we'd probably want the signals to be pluralised as well... it's both true, and more consistent, which seems like a good thing to me :)

src/acbf/AcbfContentrating.h
43

too many () in these two :) (don't want the extra parentheses at the end)

src/acbf/AcbfDocumentinfo.cpp
66

i thought this was supposed to be the creation date of the comic (or the file), not the modified date? That's why i had it set as an editable property... but i'm fine with this as well, just want to be sure that's the intention in ACBF :)

src/acbf/AcbfPublishinfo.h
43

Perhaps this is more akin to the use of createDate i was imagining... So yes, maybe what you have changed it to (modified date) is, in fact, what we need out of that property :)

woltherav updated this revision to Diff 41843.Sep 17 2018, 2:15 PM
woltherav marked 4 inline comments as done.
woltherav edited the summary of this revision. (Show Details)

Okay, updated with the changed you suggested. (And all my own changes I thought were really necessary.)

I am not sure whether to pursue the page area swapping now. I've hidden the actions for now as it is a bit too difficult for me to make sensible decisions here.

src/acbf/AcbfDocumentinfo.cpp
66

Well, we still need it as an editable property when getting the data, and maybe when we're converting the data from a different source, but when writing the data it just isn't as necessary.

src/acbf/AcbfPublishinfo.h
43

Yes, the idea is to keep track of when the book was published, and when the current document was changed. If 'when document first made' was all that relevant, then the version history would keep those dates too. I think modified is just so that a cataloguing mechanism can check if it should probably replace an older version with the newer version.

woltherav updated this revision to Diff 41855.Sep 17 2018, 4:19 PM

I forgot to save a file.

leinir accepted this revision.Sep 18 2018, 10:28 AM

Okay, updated with the changed you suggested. (And all my own changes I thought were really necessary.)

Looks great! :)

I am not sure whether to pursue the page area swapping now. I've hidden the actions for now as it is a bit too difficult for me to make sensible decisions here.

Right, let's get this in and then make that decision - never was keen on having things hanging around in review for too long, and this is already a vast improvement on what was there before :)

This revision is now accepted and ready to land.Sep 18 2018, 10:28 AM

I actually did manage to get the swap working just now, I replaced the counts with stringlists with the points of the frames(which should be useful for debug as well :) )

I'll go merge in a bit!

I actually did manage to get the swap working just now, I replaced the counts with stringlists with the points of the frames(which should be useful for debug as well :) )

That sounds... interesting ;) i look forward to seeing how you're doing that :D

I'll go merge in a bit!

Great! :)

woltherav closed this revision.Sep 18 2018, 11:01 AM

Okay, added the commit where I did the last change (labels for volumes and numbers in sequences), and the commit where I added the last thing we discussed :)