aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRatchanan Srirattanamet <ratchanan@ubports.com>2023-06-15 01:25:39 +0700
committerRatchanan Srirattanamet <ratchanan@ubports.com>2023-07-11 16:36:56 +0700
commit0defce2e357d171ff7400555779210eb9a9788be (patch)
tree277ace6cc89d03650e368ce15839f1b9c7f2f370
parent24cc4eefb93849302985559958c5392c9ea81552 (diff)
downloadqmenumodel-0defce2e357d171ff7400555779210eb9a9788be.tar.gz
qmenumodel-0defce2e357d171ff7400555779210eb9a9788be.tar.bz2
qmenumodel-0defce2e357d171ff7400555779210eb9a9788be.zip
ayatanamenumodel: add support for {u,}int of all sizespersonal/peat-psuwit/uint16
To support more menu type, add support for all integer sizes and signedness. In particular this enables support for org.ayatana. indicator.level and org.ayatana.indicator.progress (need uint16). Bug-UBports: https://gitlab.com/ubports/development/core/packaging/ayatana-indicators/ayatana-indicator-bluetooth/-/issues/3
-rw-r--r--libqmenumodel/src/ayatanamenumodel.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/libqmenumodel/src/ayatanamenumodel.cpp b/libqmenumodel/src/ayatanamenumodel.cpp
index 39ce0bc..9ab0ff4 100644
--- a/libqmenumodel/src/ayatanamenumodel.cpp
+++ b/libqmenumodel/src/ayatanamenumodel.cpp
@@ -584,7 +584,12 @@ static QVariant attributeToQVariant(GVariant *value, const QString &type)
{
QVariant result;
- if (type == "int") {
+ if (type == "int16") {
+ if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT16)) {
+ result = QVariant(g_variant_get_int16(value));
+ }
+ }
+ else if (type == "int32" || type == "int") {
if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) {
result = QVariant(g_variant_get_int32(value));
}
@@ -594,6 +599,21 @@ static QVariant attributeToQVariant(GVariant *value, const QString &type)
result = QVariant((qlonglong)g_variant_get_int64(value));
}
}
+ else if (type == "uint16") {
+ if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT16)) {
+ result = QVariant(g_variant_get_uint16(value));
+ }
+ }
+ else if (type == "uint32") {
+ if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT32)) {
+ result = QVariant(g_variant_get_uint32(value));
+ }
+ }
+ else if (type == "uint64") {
+ if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64)) {
+ result = QVariant((quint64)g_variant_get_uint64(value));
+ }
+ }
else if (type == "bool") {
if (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) {
result = QVariant(g_variant_get_boolean(value));