X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fqlibhomescreen.cpp;h=b173e332522b90860295e08a20309df6f0dd0a2c;hb=37f697decb02159b068fb8805d5d2a48644ce0e0;hp=e76a6d8c69bbe443ce02bd5a69359764cc42c3b7;hpb=98ed7f2f0897dc8d706bb43e3e2daf2a4d61f9fe;p=src%2Flibqthomescreen.git diff --git a/src/qlibhomescreen.cpp b/src/qlibhomescreen.cpp index e76a6d8..b173e33 100644 --- a/src/qlibhomescreen.cpp +++ b/src/qlibhomescreen.cpp @@ -27,6 +27,10 @@ using namespace std; #define _KEY_APPLICATION_DATA "application_id" #define _KEY_REPLY_MESSAGE "reply_message" #define _KEY_REQUEST_MESSAGE "display_message" +#define _KEY_SHORTCUT "shortcut" +#define _KEY_SHORTCUT_ID "shortcut_id" +#define _KEY_SHORTCUT_NAME "shortcut_name" +#define _KEY_POSITION "position" static QLibHomeScreen* myThis; @@ -379,4 +383,43 @@ void QLibHomeScreen::setQuickWindow(QQuickWindow *qw) HMI_NOTICE("qlibhomescreen", "connect frameSwapped signal."); m_loading = QObject::connect(mp_window, SIGNAL(frameSwapped()), this, SLOT(slotPublishSubscription())); } +} + +void QLibHomeScreen::registerShortcut(QString shortcut_id, QString shortcut_name, QString position) +{ + struct json_object* j_obj = json_object_new_object(); + struct json_object* val_id = json_object_new_string(shortcut_id.toStdString().c_str()); + struct json_object* val_name = json_object_new_string(shortcut_name.toStdString().c_str()); + struct json_object* val_position = json_object_new_string(position.toStdString().c_str()); + json_object_object_add(j_obj, _KEY_SHORTCUT_ID, val_id); + json_object_object_add(j_obj, _KEY_SHORTCUT_NAME, val_name); + json_object_object_add(j_obj, _KEY_POSITION, val_position); + + mp_hs->registerShortcut(j_obj); +} + +/** + * shortcut_id pattern: "shocut_id1,shocut_id2,shocut_id3" + * shortcut_name pattern: "shortcut_name1,shortcut_name2,shortcut_name3" + */ +void QLibHomeScreen::updateShortcut(QString shortcut_id, QString shortcut_name) +{ + QStringList id = shortcut_id.split(','); + QStringList name = shortcut_name.split(','); + if(id.size() == 0 || id.size() != name.size()) { + HMI_NOTICE("qlibhomescreen","input parameters error."); + return; + } + + // make json contents + struct json_object* arr_obj = json_object_new_array(); + for(int i = 0; i < id.size(); ++i) { + struct json_object *j_obj = json_object_new_object(); + json_object_object_add(j_obj, _KEY_SHORTCUT_ID, json_object_new_string(id[i].toStdString().c_str())); + json_object_object_add(j_obj, _KEY_SHORTCUT_NAME, json_object_new_string(name[i].toStdString().c_str())); + json_object_array_add(arr_obj, j_obj); + } + struct json_object* push_obj = json_object_new_object(); + json_object_object_add(push_obj, _KEY_SHORTCUT, arr_obj); + mp_hs->updateShortcut(push_obj); } \ No newline at end of file