~unity-api-team/hud/test-failures

« back to all changes in this revision

Viewing changes to libqtgmenu/internal/QtGActionGroup.cpp

  • Committer: Pete Woods
  • Date: 2014-03-19 23:26:48 UTC
  • Revision ID: pete.woods@canonical.com-20140319232648-c1nhfkfnvgg11xm2
Prefix handling should be more robust

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
 
73
73
void QtGActionGroup::TriggerAction( QString action_name, bool checked )
74
74
{
75
 
  QString prefix = action_name.left( action_name.indexOf( '.' ) );
 
75
  QPair<QString, QString> split = QtGMenuUtils::splitPrefixAndName(action_name);
 
76
  const QString& prefix(split.first);
 
77
 
76
78
  if( prefix != m_action_prefix )
77
79
  {
78
80
    return;
79
81
  }
80
82
 
81
 
  action_name = action_name.right( action_name.size() - action_name.indexOf( '.' ) - 1 );
82
 
  std::string action = action_name.toStdString();
 
83
  const QString& action(split.second);
 
84
  QByteArray action_utf = action.toUtf8();
83
85
 
84
86
  const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group,
85
 
      action.c_str() );
 
87
                  action_utf.constData() );
86
88
 
87
89
  if( type == nullptr )
88
90
  {
89
 
    g_action_group_activate_action( m_action_group, action.c_str(), nullptr );
 
91
    g_action_group_activate_action( m_action_group, action_utf.constData(), nullptr );
90
92
  }
91
93
  else
92
94
  {
93
95
    ///! need to evaluate and send parameter value
94
96
    if( g_variant_type_equal( type, G_VARIANT_TYPE_STRING ) )
95
97
    {
96
 
      GVariant* param = g_variant_new_string( action.c_str() );
97
 
      g_action_group_activate_action( m_action_group, action.c_str(), param );
 
98
      GVariant* param = g_variant_new_string( action_utf.constData() );
 
99
      g_action_group_activate_action( m_action_group, action_utf.constData(), param );
98
100
      g_variant_unref( param );
99
101
    }
100
102
  }