Changeset View
Standalone View
ui/toolaction.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 42 | { | |||
---|---|---|---|---|---|
44 | if ( !toolBar ) | 44 | if ( !toolBar ) | ||
45 | return nullptr; | 45 | return nullptr; | ||
46 | 46 | | |||
47 | QToolButton *button = new QToolButton( toolBar ); | 47 | QToolButton *button = new QToolButton( toolBar ); | ||
48 | button->setAutoRaise( true ); | 48 | button->setAutoRaise( true ); | ||
49 | button->setFocusPolicy( Qt::NoFocus ); | 49 | button->setFocusPolicy( Qt::NoFocus ); | ||
50 | button->setIconSize( toolBar->iconSize() ); | 50 | button->setIconSize( toolBar->iconSize() ); | ||
51 | button->setToolButtonStyle( toolBar->toolButtonStyle() ); | 51 | button->setToolButtonStyle( toolBar->toolButtonStyle() ); | ||
52 | button->setPopupMode( QToolButton::DelayedPopup ); | 52 | button->setPopupMode( QToolButton::MenuButtonPopup ); | ||
53 | button->setMenu( new QMenu( button ) ); | 53 | button->setMenu( new QMenu( button ) ); | ||
54 | button->setCheckable( true ); | 54 | button->setCheckable( true ); | ||
55 | connect(toolBar, &QToolBar::iconSizeChanged, button, &QToolButton::setIconSize); | 55 | connect(toolBar, &QToolBar::iconSizeChanged, button, &QToolButton::setIconSize); | ||
56 | connect(toolBar, &QToolBar::toolButtonStyleChanged, button, &QToolButton::setToolButtonStyle); | 56 | connect(toolBar, &QToolBar::toolButtonStyleChanged, button, &QToolButton::setToolButtonStyle); | ||
57 | connect(button, &QToolButton::triggered, toolBar, &QToolBar::actionTriggered); | 57 | connect(button, &QToolButton::triggered, toolBar, &QToolBar::actionTriggered); | ||
58 | connect( button->menu(), &QMenu::triggered, this, &ToolAction::slotNewDefaultAction ); | 58 | connect( button->menu(), &QMenu::triggered, this, &ToolAction::slotNewDefaultAction ); | ||
59 | 59 | | |||
60 | m_buttons.append( button ); | 60 | m_buttons.append( button ); | ||
61 | 61 | | |||
62 | if ( !m_actions.isEmpty() ) | 62 | if ( !m_actions.isEmpty() ) | ||
63 | { | 63 | { | ||
64 | button->setDefaultAction( m_actions.first() ); | 64 | button->setDefaultAction( m_actions.first() ); | ||
65 | foreach ( QAction *action, m_actions ) | 65 | foreach ( QAction *action, m_actions ) | ||
66 | { | 66 | { | ||
67 | button->menu()->addAction( action ); | 67 | button->menu()->addAction( action ); | ||
68 | if ( action->isChecked() ) | 68 | if ( action->isChecked() ) | ||
69 | button->setDefaultAction( action ); | 69 | button->setDefaultAction( action ); | ||
70 | } | 70 | } | ||
71 | button->setToolTip( i18n("Click to use the current selection tool\nClick and hold to choose another selection tool") ); | | |||
davidhurka: Why remove this tooltip?
To make ToolAction (or my inferior ToggleActionMenu) more universal… | |||||
That tooltip does not appear anywhere in the UI in practice, at least I have not manage to make it appear. Have you? Now I am using ToolAction to show other things, so the tooltips, if needed, need to be set outside. Still a TODO. Where is ToggleActionMenu defined? simgunz: That tooltip does not appear anywhere in the UI in practice, at least I have not manage to make… | |||||
The tooltip should become visible when you hover the toolbar button with the three selection tools. It’s in the main toolbar by default. See also D21622. On my Okular it worked, on yours not? ToggleActionMenu is still a TODO in D21755. ;) What will you use ToolAction for? In that case I probably shouldn’t break it. davidhurka: The tooltip should become visible when you hover the toolbar button with the three selection… | |||||
Currently the tooltip appears only if any of the selection tools is already selected, while it does not appear if another action like "Browse" is selected. Moreover it made sense when one had to click and hold to show the menu, which was quite unintuitive, now that it is enough to click on the arrow, I believe it is redundant. simgunz: Currently the tooltip appears only if any of the selection tools is already selected, while it… | |||||
72 | } | 71 | } | ||
73 | 72 | | |||
74 | return button; | 73 | return button; | ||
75 | } | 74 | } | ||
76 | 75 | | |||
77 | void ToolAction::slotNewDefaultAction( QAction *action ) | 76 | void ToolAction::slotNewDefaultAction( QAction *action ) | ||
78 | { | 77 | { | ||
79 | foreach ( QToolButton *button, m_buttons ) | 78 | foreach ( QToolButton *button, m_buttons ) | ||
80 | if ( button ) | 79 | if ( button ) | ||
81 | { | 80 | { | ||
82 | button->setDefaultAction( action ); | 81 | button->setDefaultAction( action ); | ||
83 | button->setToolTip( i18n("Click to use the current selection tool\nClick and hold to choose another selection tool") ); | | |||
84 | } | 82 | } | ||
85 | } | 83 | } | ||
86 | 84 | | |||
87 | #include "moc_toolaction.cpp" | 85 | #include "moc_toolaction.cpp" |
Why remove this tooltip?
To make ToolAction (or my inferior ToggleActionMenu) more universal to use it for a Change Colors feature, it would be nice if tooltips are not needed anymore.