Use wxString rather than QString methods

It's preferable to use code which is simpler to understand to wx
developers not necessarily familiar with Qt API and which can also be
reused with the other ports if necessary.

In this particular case, using wxString::AfterFirst() also results in
shorter and more clear code too.

See https://github.com/wxWidgets/wxWidgets/pull/1544
This commit is contained in:
Vadim Zeitlin
2019-09-27 13:51:01 +02:00
parent 8339f12636
commit 41caeebd8c

View File

@@ -174,15 +174,11 @@ wxQtAction::wxQtAction( wxMenu *parent, int id, const wxString &text, const wxSt
void wxQtAction::UpdateShortcutsFromLabel(const wxString& text)
{
#if wxUSE_ACCEL
QString qlabel = wxQtConvertString( text );
int index = qlabel.lastIndexOf( QChar( '\t' ) );
if ( index != -1 )
const wxString accelStr = text.AfterFirst('\t');
if ( !accelStr.empty() )
{
QList<QKeySequence> shortcuts;
QString shortcut_key = qlabel.remove( 0, index+1 );
shortcuts.append( QKeySequence( shortcut_key ) );
shortcuts.append( QKeySequence( wxQtConvertString(accelStr) ) );
setShortcuts( shortcuts );
}
#endif // wxUSE_ACCEL