The current annotation toolbar is not very flexible and can benefit from some modernization.
Some of the problems are:
- Custom toolbar UI not integrated with the other Qt toolbars
- Impossibility to change the color/font of the annotations on the fly (it is necessary to create a new tool with the desired color/font)
- Some tools are missing from the toolbar by default (e.g. squiggle underline, delete text, rectangle, ...)
- To keep an annotation tool selected one need to double click on an annotation (not intuitive/no tips for the user) (BUG: 358057)
- Incoherence between annotation icons used and one in config dialogs (BUG: 358065)
Note: This task has evolved from problems in the annotation configuration dialogs to usability problems in the annotation toolbar itself.
**To-do**
- [x] Select and use text annotations (highlighter, underline, squiggle, strike out)
- [x] Select and use note annotations (typewriter, inline note, popup note)
- [x] Select and use drawing annotations (freehand line, straight line, rectangle, ellipse, polygon)
- [x] Select and use stamp annotation (see also T8074) [possibly disable this button for PDF documents, see 383651]
- [x] Pin annotation / The annotation remains selected after use if the pin button is checked
- [x] Change (outer) color and opacity of annotations [Draft code in place for now]
- [x] Change inner color and opacity of annotations
- [x] Change size of lines (freehand, straight line, geometrical shapes)
- [x] Change icon of popup note
- [x] Change font of notes annotations (typewriter, inline note, popup note?)
- [x] Change straight line line extensions ( via Advanced settings)
- [x] Add mechanism to save annotation tools with custom options (favorite tools) See T8076#186855
- [x] Save state of pin action
- [x] Prevent changing the annotation type of builtin annotations, when using the advanced setting menu (wait for D10859)
- [x] Add real value of opacity and line width to the list of action if it is not one of the default values (e.g. if it was set with the advanced settings menu)
- [x] Set width combo icons (generate programatically see D21364#469241)
- [x] Activate line width action in one click (not just clicking on the down arrow)
- [x] Click on a selected annotation should deselect it (see https://codereview.qt-project.org/c/qt/qtbase/+/255770)
- [x] Selecting an annotation should switch to Browse mode
- [x] Set default location of annotation toolbar under the main toolbar
- [x] Show/hide toolbar from menu
- [x] Set meaningful default shortcuts for implicit and/or explicit tools
- [x] Set tooltips everywhere
- [x] Add i18nc everywhere
- [x] Reimplement code to enable/disable tools or text tools if document not editable
- [x] Rename and move PageViewToolBar, not part of PageView anymore
- [ ] Remove legacy code left hanging around after the changes
- [ ] Clean and refactor code
- [x] Properly manage the upgrade of the configuration file during the upgrade of okular (in particular the `AnnotationTools` key).
**Discuss**
- [ ] Default toolbar aspect should be icons only or text alongside icons? (in this second case we need to shrink it)
- [ ] Add a menu entry to the context menu of 'favorite tools action' to open favorite annotation config dialog (how?)
- [ ] Stamp action shows the default action (Okular icon) by default, so it may not be clear to the user that it is the stamp action. How to workaround this? A possibility is to use `KSelectAction` in `KSelectAction::MenuMode` but in this case the action is never shown as checked.
**Delegate**
- [ ] Create proper icons for all annotation (see BUG: [[ https://bugs.kde.org/show_bug.cgi?id=408283 | 408283 ]])
- [ ] Update documentation
**Future improvements**
- [ ] Make color selectors a list of default colors with an option to select a custom color via a FileChooser
**Test Plan**
//Annotation actions// Highlighter, Underline, Squiggle, Strike out, Typewriter, Inline note, Popup note, Freehand line, Arrow, Straight line, Rectangle, Ellipse, Polygon, Stamp
//Favorite annotation actions// Favorites, Add to favorites
//Annotation config actions// Line width, Color, Inner color, Opacity, Font, Annotation settings
- No annotation action selected: Favorites is enabled, Add to favorites is disabled, Annotation config actions are disabled, Pin action is enabled
- Click an annotation action when none selected: browse mode is selected, it is possible to use the annotation tool, the config actions are enabled and their values set to the ones for the current annotation (taken from okularpartrc)
- Click a selected annotation action: the action is unchecked
- Click ESC: the selected annotation action is unchecked
- The current document is an image: Highlighter, Underline, Squiggle, Strike out are disabled
- The current document is protected: All annotations are disabled
- The annotation systems works when multiple Okular tabs are open
- The state of Pin action is remembered across Okular launches
- In Configure Okular > Annotations it is possible to only configure the favorite annotations
- Keys 1-9,0 select the (builtin) Annotation actions
- Keys Alt+1-9,0 select the favorite annotation actions
- If a custom Line Width or Opacity is set through the Annotation Settings dialog, its value appears as a new checked action in the Line width or Opacity menu
- If a custom stamp is selected through the Annotation Settings dialog, its name or filename (without path) appears as a new checked action in the Stamp menu
- Selecting a favorite action selected the corresponding action and loads its config values (color, line width, ...)
- All actions have tooltips (some change based on the fact that the icon is enabled or not)