simgunz added a comment.
I have tested this patch and added some inline comments. It seems to me that ToggleActionMenu requires way more external code to make it work, compared to ToolAction, which is quite automated. I think that some things could be made default in ToggleActionMenu, and some aspect hidden as well e.g. manage the QActionGroup internally without having the user have to manage it and set the action eveytime. I tried it by only adding the actions to it and it does not work, no menu is shown. Adding the signal connection is also not enough. After that I gave up for now (I am lazy). But I think it needs to be a little more user-friendly. INLINE COMMENTS > pageview.cpp:660 > + d->aMouseModeMenu = new ToggleActionMenu( this ); > + d->aMouseModeMenu->setDelayed( false ); > + d->aMouseModeMenu->setStickyMenu( false ); setDelayed and setStickyMenu shoule be defaults, without having to set them here. > pageview.cpp:667 > + ac->addAction( QStringLiteral( "mouse_selecttools" ), d->aMouseModeMenu > ); > + connect( d->aMouseModeMenu->menu(), &QMenu::triggered, > + d->aMouseModeMenu, &ToggleActionMenu::setDefaultAction ); Can't this connection be defined inside ToggleActionMenu? > pageview.cpp:671 > + // Use the current mouse mode action as default action, or Text > Selection by default. > + QAction* enabledMouseModeAction = > d->mouseModeActionGroup->checkedAction(); > + if ( enabledMouseModeAction && > d->aMouseModeMenu->menu()->actions().contains( enabledMouseModeAction ) ) All the code below, cannot be managed inside ToggleActionMenu? > toggleactionmenu.h:47 > +public: > + explicit ToggleActionMenu( QWidget *parent ); > + ToggleActionMenu( const QString &text, QWidget * parent ); Make parent a QObject to make it more general. I would use this in AnnotationActionHandler which is not a QWidget. REPOSITORY R223 Okular REVISION DETAIL https://phabricator.kde.org/D21755 To: davidhurka, #okular Cc: simgunz, aacid, #vdg, okular-devel, fbampaloukas, joaonetto, tfella, ngraham, darcyshen