Allow action description to be different from tooltip
The tooltip should be short and easy to read, the description can be longer and more detailed.
This commit is contained in:
parent
8b8586f54b
commit
e17cd5abc6
|
@ -248,7 +248,7 @@ void PANEL_HOTKEYS_EDITOR::dumpHotkeys()
|
||||||
stream << wxT( " |" ) << endl;
|
stream << wxT( " |" ) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << wxT( " | " ) << hk.m_Actions[0]->GetDescription( false ) << endl;
|
stream << wxT( " | " ) << hk.m_Actions[0]->GetDescription() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << wxT( "|===" ) << endl << endl;
|
stream << wxT( "|===" ) << endl << endl;
|
||||||
|
|
|
@ -170,7 +170,7 @@ wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry
|
||||||
wxString menuLabel = aOverrideLabel.IsEmpty() ? aAction.GetMenuItem() : aOverrideLabel;
|
wxString menuLabel = aOverrideLabel.IsEmpty() ? aAction.GetMenuItem() : aOverrideLabel;
|
||||||
|
|
||||||
wxMenuItem* item = new wxMenuItem( this, aAction.GetUIId(), menuLabel,
|
wxMenuItem* item = new wxMenuItem( this, aAction.GetUIId(), menuLabel,
|
||||||
aAction.GetDescription(),
|
aAction.GetTooltip(),
|
||||||
aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
|
aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
|
||||||
if( !!icon )
|
if( !!icon )
|
||||||
AddBitmapToMenuItem( item, KiBitmap( icon ) );
|
AddBitmapToMenuItem( item, KiBitmap( icon ) );
|
||||||
|
|
|
@ -130,7 +130,7 @@ void ACTION_TOOLBAR_PALETTE::AddAction( const TOOL_ACTION& aAction )
|
||||||
button->SetBitmap( normalBmp );
|
button->SetBitmap( normalBmp );
|
||||||
button->SetDisabledBitmap( disabledBmp );
|
button->SetDisabledBitmap( disabledBmp );
|
||||||
button->SetPadding( padding );
|
button->SetPadding( padding );
|
||||||
button->SetToolTip( aAction.GetDescription() );
|
button->SetToolTip( aAction.GetTooltip() );
|
||||||
button->AcceptDragInAsClick();
|
button->AcceptDragInAsClick();
|
||||||
|
|
||||||
m_buttons[aAction.GetUIId()] = button;
|
m_buttons[aAction.GetUIId()] = button;
|
||||||
|
@ -237,7 +237,7 @@ void ACTION_TOOLBAR::Add( const TOOL_ACTION& aAction, bool aIsToggleEntry, bool
|
||||||
|
|
||||||
AddTool( toolId, wxEmptyString, bmp, MakeDisabledBitmap( bmp ),
|
AddTool( toolId, wxEmptyString, bmp, MakeDisabledBitmap( bmp ),
|
||||||
aIsToggleEntry ? wxITEM_CHECK : wxITEM_NORMAL,
|
aIsToggleEntry ? wxITEM_CHECK : wxITEM_NORMAL,
|
||||||
aAction.GetDescription(), wxEmptyString, nullptr );
|
aAction.GetTooltip(), wxEmptyString, nullptr );
|
||||||
|
|
||||||
m_toolKinds[ toolId ] = aIsToggleEntry;
|
m_toolKinds[ toolId ] = aIsToggleEntry;
|
||||||
m_toolActions[ toolId ] = &aAction;
|
m_toolActions[ toolId ] = &aAction;
|
||||||
|
@ -251,7 +251,7 @@ void ACTION_TOOLBAR::AddButton( const TOOL_ACTION& aAction )
|
||||||
wxBitmap bmp = KiScaledBitmap( aAction.GetIcon(), GetParent() );
|
wxBitmap bmp = KiScaledBitmap( aAction.GetIcon(), GetParent() );
|
||||||
|
|
||||||
AddTool( toolId, wxEmptyString, bmp, MakeDisabledBitmap( bmp ),
|
AddTool( toolId, wxEmptyString, bmp, MakeDisabledBitmap( bmp ),
|
||||||
wxITEM_NORMAL, aAction.GetDescription(), wxEmptyString, nullptr );
|
wxITEM_NORMAL, aAction.GetTooltip(), wxEmptyString, nullptr );
|
||||||
|
|
||||||
m_toolKinds[ toolId ] = false;
|
m_toolKinds[ toolId ] = false;
|
||||||
m_toolActions[ toolId ] = &aAction;
|
m_toolActions[ toolId ] = &aAction;
|
||||||
|
@ -333,7 +333,7 @@ void ACTION_TOOLBAR::doSelectAction( ACTION_GROUP* aGroup, const TOOL_ACTION& aA
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update the item information
|
// Update the item information
|
||||||
item->SetShortHelp( aAction.GetDescription() );
|
item->SetShortHelp( aAction.GetTooltip() );
|
||||||
item->SetBitmap( KiScaledBitmap( aAction.GetIcon(), GetParent() ) );
|
item->SetBitmap( KiScaledBitmap( aAction.GetIcon(), GetParent() ) );
|
||||||
#if wxCHECK_VERSION( 3, 1, 6 )
|
#if wxCHECK_VERSION( 3, 1, 6 )
|
||||||
item->SetDisabledBitmap(
|
item->SetDisabledBitmap(
|
||||||
|
|
|
@ -85,6 +85,9 @@ TOOL_ACTION::TOOL_ACTION( const TOOL_ACTION_ARGS& aArgs ) :
|
||||||
if( aArgs.m_param.has_value() )
|
if( aArgs.m_param.has_value() )
|
||||||
m_param = aArgs.m_param;
|
m_param = aArgs.m_param;
|
||||||
|
|
||||||
|
if( aArgs.m_description.has_value() )
|
||||||
|
m_description = aArgs.m_description;
|
||||||
|
|
||||||
ACTION_MANAGER::GetActionList().push_back( this );
|
ACTION_MANAGER::GetActionList().push_back( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +130,17 @@ wxString TOOL_ACTION::GetMenuItem() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString TOOL_ACTION::GetDescription( bool aIncludeHotkey ) const
|
wxString TOOL_ACTION::GetDescription() const
|
||||||
|
{
|
||||||
|
// If no description provided, use the tooltip without a hotkey
|
||||||
|
if( !m_description.has_value() )
|
||||||
|
return GetTooltip( false );
|
||||||
|
|
||||||
|
return wxGetTranslation( m_description.value() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString TOOL_ACTION::GetTooltip( bool aIncludeHotkey ) const
|
||||||
{
|
{
|
||||||
wxString tooltip = wxGetTranslation( m_tooltip );
|
wxString tooltip = wxGetTranslation( m_tooltip );
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ void WIDGET_HOTKEY_LIST::updateFromClientData()
|
||||||
const HOTKEY& changed_hk = hkdata->GetChangedHotkey();
|
const HOTKEY& changed_hk = hkdata->GetChangedHotkey();
|
||||||
wxString label = changed_hk.m_Actions[ 0 ]->GetLabel();
|
wxString label = changed_hk.m_Actions[ 0 ]->GetLabel();
|
||||||
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
|
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
|
||||||
wxString description = changed_hk.m_Actions[ 0 ]->GetDescription( false );
|
wxString description = changed_hk.m_Actions[ 0 ]->GetDescription();
|
||||||
|
|
||||||
if( label.IsEmpty() )
|
if( label.IsEmpty() )
|
||||||
label = changed_hk.m_Actions[ 0 ]->GetName();
|
label = changed_hk.m_Actions[ 0 ]->GetName();
|
||||||
|
|
|
@ -122,6 +122,15 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the action.
|
||||||
|
*/
|
||||||
|
TOOL_ACTION_ARGS& Description( wxString aDescription )
|
||||||
|
{
|
||||||
|
m_description = aDescription;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bitmap to use as the icon for the action in toolbars and menus.
|
* The bitmap to use as the icon for the action in toolbars and menus.
|
||||||
*/
|
*/
|
||||||
|
@ -174,6 +183,7 @@ protected:
|
||||||
|
|
||||||
std::optional<wxString> m_menuText;
|
std::optional<wxString> m_menuText;
|
||||||
std::optional<wxString> m_tooltip;
|
std::optional<wxString> m_tooltip;
|
||||||
|
std::optional<wxString> m_description;
|
||||||
|
|
||||||
std::optional<BITMAPS> m_icon;
|
std::optional<BITMAPS> m_icon;
|
||||||
|
|
||||||
|
@ -275,7 +285,8 @@ public:
|
||||||
|
|
||||||
wxString GetLabel() const;
|
wxString GetLabel() const;
|
||||||
wxString GetMenuItem() const;
|
wxString GetMenuItem() const;
|
||||||
wxString GetDescription( bool aIncludeHotkey = true ) const;
|
wxString GetTooltip( bool aIncludeHotkey = true ) const;
|
||||||
|
wxString GetDescription() const;
|
||||||
|
|
||||||
TOOL_ACTION_SCOPE GetScope() const { return m_scope; }
|
TOOL_ACTION_SCOPE GetScope() const { return m_scope; }
|
||||||
|
|
||||||
|
@ -353,8 +364,10 @@ protected:
|
||||||
int m_hotKey; // The current hotkey (post-user-settings-application)
|
int m_hotKey; // The current hotkey (post-user-settings-application)
|
||||||
const std::string m_legacyName; // Name for reading legacy hotkey settings
|
const std::string m_legacyName; // Name for reading legacy hotkey settings
|
||||||
|
|
||||||
wxString m_label;
|
wxString m_label; // Menu label
|
||||||
wxString m_tooltip;
|
wxString m_tooltip; // User-facing tooltip help text
|
||||||
|
std::optional<wxString> m_description; // Description of the action
|
||||||
|
|
||||||
BITMAPS m_icon; // Icon for the menu entry
|
BITMAPS m_icon; // Icon for the menu entry
|
||||||
|
|
||||||
int m_id; // Unique ID for maps. Assigned by ACTION_MANAGER.
|
int m_id; // Unique ID for maps. Assigned by ACTION_MANAGER.
|
||||||
|
|
|
@ -68,7 +68,7 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
|
||||||
btn->SetBitmap( aBitmap );
|
btn->SetBitmap( aBitmap );
|
||||||
btn->SetDisabledBitmap( wxBitmap( aBitmap.ConvertToImage().ConvertToGreyscale() ) );
|
btn->SetDisabledBitmap( wxBitmap( aBitmap.ConvertToImage().ConvertToGreyscale() ) );
|
||||||
btn->SetPadding( 5 );
|
btn->SetPadding( 5 );
|
||||||
btn->SetToolTip( aAction.GetDescription() );
|
btn->SetToolTip( aAction.GetTooltip() );
|
||||||
|
|
||||||
auto handler =
|
auto handler =
|
||||||
[&]( wxEvent& aEvent )
|
[&]( wxEvent& aEvent )
|
||||||
|
@ -88,7 +88,7 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers()
|
||||||
wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() );
|
wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetLabel() );
|
||||||
wxStaticText* help;
|
wxStaticText* help;
|
||||||
|
|
||||||
label->SetToolTip( aAction.GetDescription() );
|
label->SetToolTip( aAction.GetTooltip() );
|
||||||
label->SetFont( titleFont );
|
label->SetFont( titleFont );
|
||||||
|
|
||||||
help = new wxStaticText( this, wxID_ANY, aHelpText );
|
help = new wxStaticText( this, wxID_ANY, aHelpText );
|
||||||
|
|
Loading…
Reference in New Issue