← Back to team overview

ubuntu-sdk-bugs team mailing list archive

[Bug 1468603] [NEW] Adding ActivationQueryBase into the scope template to respond to button clicks

 

Public bug reported:

Currently, in our scope template, there is no code touching the
ActivationQueryBase, which is needed for responding the button/actions
clicks. It is needed in the rating-input PreviewWidget as well.

I would commend adding it into the template to make it more complete
though some of the scopes may not need them. A reference design is like:

action.h

#ifndef SCOPE_ACTION_H_
#define SCOPE_ACTION_H_

#include <unity/scopes/ActionMetadata.h>
#include <unity/scopes/ActivationQueryBase.h>
#include <unity/scopes/ActivationResponse.h>
#include <unity/scopes/Result.h>

class Action : public unity::scopes::ActivationQueryBase
{
public:
    Action(unity::scopes::Result const& result,
           unity::scopes::ActionMetadata const& metadata,
           std::string const& action_id);
    ~Action() = default;

     virtual unity::scopes::ActivationResponse activate() override;

private:
    std::string const action_id_;
};

#endif // SCOPE_ACTION_H_


action.cpp

`#include <scope/action.h>
#include <unity/scopes/ActivationResponse.h>
#include <unity/UnityExceptions.h>

#include <QString>
#include <QDebug>

#include <iostream>

namespace sc = unity::scopes;
using namespace std;

QString qstr_(std::string str)
{
    return QString::fromStdString(str);
}

Action::Action(const unity::scopes::Result &result,
               const unity::scopes::ActionMetadata &metadata,
               std::string const& action_id)
    : sc::ActivationQueryBase(result, metadata),
      action_id_(action_id)
{
    qDebug() << "action id: " << qstr_(action_id_);
}

sc::ActivationResponse Action::activate()
{
    qDebug() << "action id in activate: " << qstr_(action_id());

    QString review = QString("%1").arg(qstr_(action_metadata().scope_data().
                                              get_dict()["review"].get_string()));

    double rating = action_metadata().scope_data().
                          get_dict()["rating"].get_double();

    qDebug() << "review: " << review;
    qDebug() << "rating: " << rating;

    sc::ActivationResponse done(sc::ActivationResponse::ShowDash);
    cerr << "activate called" << endl;
    return done;
}

** Affects: qtcreator-plugin-ubuntu (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
SDK bug tracking, which is subscribed to qtcreator-plugin-ubuntu in
Ubuntu.
https://bugs.launchpad.net/bugs/1468603

Title:
  Adding ActivationQueryBase into the scope template to respond to
  button clicks

Status in qtcreator-plugin-ubuntu package in Ubuntu:
  New

Bug description:
  Currently, in our scope template, there is no code touching the
  ActivationQueryBase, which is needed for responding the button/actions
  clicks. It is needed in the rating-input PreviewWidget as well.

  I would commend adding it into the template to make it more complete
  though some of the scopes may not need them. A reference design is
  like:

  action.h

  #ifndef SCOPE_ACTION_H_
  #define SCOPE_ACTION_H_

  #include <unity/scopes/ActionMetadata.h>
  #include <unity/scopes/ActivationQueryBase.h>
  #include <unity/scopes/ActivationResponse.h>
  #include <unity/scopes/Result.h>

  class Action : public unity::scopes::ActivationQueryBase
  {
  public:
      Action(unity::scopes::Result const& result,
             unity::scopes::ActionMetadata const& metadata,
             std::string const& action_id);
      ~Action() = default;

       virtual unity::scopes::ActivationResponse activate() override;

  private:
      std::string const action_id_;
  };

  #endif // SCOPE_ACTION_H_

  
  action.cpp

  `#include <scope/action.h>
  #include <unity/scopes/ActivationResponse.h>
  #include <unity/UnityExceptions.h>

  #include <QString>
  #include <QDebug>

  #include <iostream>

  namespace sc = unity::scopes;
  using namespace std;

  QString qstr_(std::string str)
  {
      return QString::fromStdString(str);
  }

  Action::Action(const unity::scopes::Result &result,
                 const unity::scopes::ActionMetadata &metadata,
                 std::string const& action_id)
      : sc::ActivationQueryBase(result, metadata),
        action_id_(action_id)
  {
      qDebug() << "action id: " << qstr_(action_id_);
  }

  sc::ActivationResponse Action::activate()
  {
      qDebug() << "action id in activate: " << qstr_(action_id());

      QString review = QString("%1").arg(qstr_(action_metadata().scope_data().
                                                get_dict()["review"].get_string()));

      double rating = action_metadata().scope_data().
                            get_dict()["rating"].get_double();

      qDebug() << "review: " << review;
      qDebug() << "rating: " << rating;

      sc::ActivationResponse done(sc::ActivationResponse::ShowDash);
      cerr << "activate called" << endl;
      return done;
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qtcreator-plugin-ubuntu/+bug/1468603/+subscriptions


Follow ups

References