So my rough ideas are the following. Split everything into qt/widgets stuff on one side, which handle mouse/key events, drawing, basically all the display relevant stuff, and purely pencil specific things: tools, colors, layers, and the object (document) itself.
The different parts communicate mostly through signals and slots, and can thus be wired by a parent object. In this case I think the editor class is a good place to start.
I figure we should have something like the following classes:
the scribblearea is purely there to manage displaying a view into the current document, and forwarding events (mouse, tablet, key) to the tool manager. It changes cursors when the tool changes cursor. Nothing else goes on in the scribble area, so it shouldn't do much more than that.
a tool manager that manages the tools. This tool manager handles switching tools, using an instant tool when holding a key (space for hand, etc...), and resizing the current tool. That way, the scribble area just has to forward events to the tool manager and not worry about which tool is currently active. It also signals when a tool is switched, or when a tool needs to update its cursor. That way, the scribblearea can change its cursor, the toolset can change the currently selected tool, the attribute display can display the new attributes, and the color manager can display the new color.
The tool manager actually hands off the events to the strokemanager, which keeps information about which points where clicked, smoothing the curve, etc... It can also be used in conjunction with the painter (see below).
the tools handled by the tool manager are pretty much what they are right now, except that I think we could maybe use the QT property system, which allows reflection (what attributes does a tool have, etc...) to handle attribute changes.
the color manager manages the colors, updating the current tool, the color picker, the palette (basically linking them all together).
the layer manager handles the layers of the current document (most of it is done by the editor at the moment). It can thus give back information about which keyframes are available, what should be displayed at which frame, etc... It receives events from the timeline, and gives back information to the timeline and the painter. I think all the layer information should actually be part of the Object (document), and the layer managers uses that information to compute some more application relevant information.
now one thing that I really would like to have is a class called Painter, which handles the displaying of the current frame and the current stroke. It would handle the tiling, making temp pixmaps to compose different layers, and also have the drawing algorithms for different tools (although that could maybe be extracted out). Basically it would take the whole drawing part out of scribblearea and move it to its own place, so that we can more easily change how things are composed, and also offload it to another thread to keep the main thread responsive to drawing events. It would finally create a pixmap that just needs to be displayed by the scribblearea.