About using the Advanced Docking System for Qt

David Hurka david.hurka at mailbox.org
Sat May 9 16:58:59 BST 2020


> On 9 May 2020 15:04 okular-devel-request at kde.org wrote:
> El dissabte, 2 de maig de 2020, a les 16:50:16 CEST, Andy Sardina va escriure:
> > Hi,
> > 
> >   There are many users who would like to have a split view in Okular.
> > Currently, using a QTabWidget I think implementing such a feature could be
> > difficult. My proposal is to start using the Advanced Docking System for Qt
> > <https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System> (ADS) to
> > replace the QTabWidget and from that point work in the split view
> > functionality.
> 
> It seems indeed powerful :)
> 
> I wonder if maybe "too" poweful that may get some people lost trying to use it.
> 
> One "problem" is that it seems that no distribution is packaging this at the moment from what i can see.
> 
> Have you tried looking at what other KDE software like for example kate do for their split screen functionality?
> [...]

Kate does it much simpler. The central widget can be divided with splitters, while the extra panels are docked to the window edges. Unlike the sidebar in Okular, panels can be moved to other edges, and be shown simultaneously. Unlike with QDockWidget (or ADS), panels can not be nested.

QDockWidget or ADS would be nice in Okular to show e. g. Table of Contents and Annotation panels at the same time. For split view it is probably useless, because we just want to divide the central widget into multiple central widgets of the same type. In other words, there are not enough widgets to use QDockWidget or ADS.

I think a split view implementation should follow the Kate UI, where you click “Split Horizontal”, and you get a second view next to the first view. To close the second view, you move the splitter until it collapses.

The split view UI is actually not the difficult part. Append PageView objects to the Sidebar object, and you have split view, you can easily try that. They even show synchronized annotations and everything. The difficult part is the DocumentObserver structure, which communicates the viewport through the Document object. This makes all PageViews scroll simultaneously, so you always just see the same page twice.

To implement split view, we need to separate data and presentation. We also need to separate commands and presentation, because currently many menu actions are handled by the single PageView. It is not good to have actions twice, because the second PageView kicks all actions of the first PageView from the menus, and when you remove the second PageView all actions are lost.

Anyway, thanks for your link, it’s an interesting project.

Cheers, David


More information about the Okular-devel mailing list