Commit 48b49555 authored by Xuetian Weng's avatar Xuetian Weng
Browse files

kimpanel: add radio and check type support in ibus backend and dataengine

parent 4f16c37b
......@@ -260,7 +260,8 @@ static QByteArray
ibus_property_args_to_propstr (const char *key,
const char *label,
const char *icon,
const char *tooltip)
const char *tooltip,
const char *hint = "")
{
QByteArray propstr("/IBus/");
QByteArray str(key);
......@@ -275,6 +276,8 @@ ibus_property_args_to_propstr (const char *key,
propstr += app->normalizeIconName(QByteArray(icon).replace(':', '-'));
propstr += prop_sep;
propstr += QByteArray(tooltip).replace(':', '-').constData();
propstr += prop_sep;
propstr += QByteArray(hint).replace(':', '-').constData();
return propstr;
}
......@@ -336,10 +339,24 @@ ibus_property_to_propstr (IBusProperty *property,
label = ibus_text_get_text(ibus_property_get_label(property));
}
const char* hint = "";
if (ibus_property_get_prop_type(property) == PROP_TYPE_TOGGLE) {
if (ibus_property_get_state(property) != PROP_STATE_CHECKED) {
hint = "disable";
}
} else if (ibus_property_get_prop_type(property) == PROP_TYPE_RADIO) {
if (ibus_property_get_state(property) == PROP_STATE_CHECKED) {
hint = "checked";
}
}
return ibus_property_args_to_propstr(ibus_property_get_key (property),
label,
icon,
tooltip);
tooltip,
hint);
}
static QByteArray
......
......@@ -84,6 +84,8 @@ Item {
enabled: actionItem.type != "title" && ("enabled" in actionItem ? actionItem.enabled : true)
separator: actionItem.type == "separator"
icon: actionItem.icon ? actionItem.icon : null
checkable: actionItem.hint == "checked"
checked: actionItem.hint == "checked"
onClicked: {
actionClicked(actionItem.actionId, actionItem.actionArgument);
......
......@@ -28,9 +28,12 @@ Item {
property string icon;
property string label;
property string tip;
property string hint;
signal triggered;
property int iconSize: units.roundToIconSize(Math.min(parent.width, parent.height))
opacity: 'disable' == hint ? 0.3 : 1
function extractLabelString(l) {
if (l.length >= 2 && l.charCodeAt(0) < 127 && l.charCodeAt(1) < 127) {
return l.substring(0, 2);
......
......@@ -83,6 +83,7 @@ Item {
label: model.label
tip: model.tip
icon: model.icon
hint: model.hint
onTriggered : clickHandler(model.key)
}
}
......@@ -110,7 +111,7 @@ Item {
menu.timestamp = menuData["timestamp"];
var actionList = [];
for (var i = 0; i < menuData["props"].length; i++ ) {
actionList.push({"actionId": menuData["props"][i].key, "icon": menuData["props"][i].icon, "text": menuData["props"][i].label});
actionList.push({"actionId": menuData["props"][i].key, "icon": menuData["props"][i].icon, "text": menuData["props"][i].label, hint: menuData["props"][i].hint});
}
if (actionList.length > 0) {
menu.actionList = actionList;
......@@ -146,7 +147,8 @@ Item {
var itemData = {'key': data[i].key,
'icon': data[i].icon,
'label': data[i].label,
'tip': data[i].tip };
'tip': data[i].tip,
'hint': data[i].hint };
if (i < count) {
list.set(i, itemData);
} else {
......
......@@ -177,14 +177,7 @@ static KimpanelProperty String2Property(const QString &str)
result.label = list.at(1);
result.icon = list.at(2);
result.tip = list.at(3);
//X {
//X result.state = KimpanelProperty::None;
//X int n = list.at(4).toInt();
//X if (n & KimpanelProperty::Active)
//X result.state &= KimpanelProperty::Active;
//X if (n & KimpanelProperty::Visible)
//X result.state &= KimpanelProperty::Visible;
//X }
result.hint = list.size() >= 4 ? list.at(4) : "";
return result;
}
......
......@@ -40,28 +40,21 @@ struct TextAttribute {
};
struct KimpanelProperty {
enum State {
None = 0,
Active = 1,
Visible = (1 << 1)
};
Q_DECLARE_FLAGS(States, State)
KimpanelProperty() { }
KimpanelProperty(QString key, QString label, QString icon, QString tip, int state) {
KimpanelProperty(QString key, QString label, QString icon, QString tip, QString hint) {
this->key = key;
this->label = label;
this->tip = tip;
this->icon = icon;
this->state = (State) state;
this->hint = hint;
}
QString key;
QString label;
QString icon;
QString tip;
States state;
QString hint;
QVariantMap toMap() const {
QVariantMap map;
......@@ -69,11 +62,10 @@ struct KimpanelProperty {
map["label"] = label;
map["icon"] = icon;
map["tip"] = tip;
map["state"] = (int) state;
map["hint"] = hint;
return map;
}
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KimpanelProperty::States)
struct KimpanelLookupTable {
struct Entry {
......@@ -87,4 +79,4 @@ struct KimpanelLookupTable {
bool has_next;
};
#endif // KIMPANEL_AGENTTYPE_H
\ No newline at end of file
#endif // KIMPANEL_AGENTTYPE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment