diff --git a/libsearch/search-app-widget-plugin/provider/data/search.qml b/libsearch/search-app-widget-plugin/provider/data/search.qml index 17ba20f..e096b43 100755 --- a/libsearch/search-app-widget-plugin/provider/data/search.qml +++ b/libsearch/search-app-widget-plugin/provider/data/search.qml @@ -25,12 +25,20 @@ AppWidget { } function updateSearchBarColor() { - var data = window.parseJson(window.datevalue); +// for (var i in window.datavalue) { +// if (i === "colorData") { +// var data = window.parseJson(window.datavalue[i]); +// searchBar.color = Qt.rgba(data.red, data.green, data.blue, data.alpha); +// placeholderText.color = data.placeHolderTextColor; +// } +// } + + var data = window.parseJson(window.datavalue["colorData"]); searchBar.color = Qt.rgba(data.red, data.green, data.blue, data.alpha); placeholderText.color = data.placeHolderTextColor; } - onDatevalueChanged: updateSearchBarColor(); + onDatavalueChanged: updateSearchBarColor(); Rectangle { id:searchBar @@ -39,10 +47,6 @@ AppWidget { height: 64 radius: searchBar.height / 2 - Component.onCompleted: { - window.updateSearchBarColor(); - } - RowLayout { id: layout anchors.fill: parent diff --git a/libsearch/search-app-widget-plugin/search.cpp b/libsearch/search-app-widget-plugin/search.cpp index 9d23e48..453fa60 100644 --- a/libsearch/search-app-widget-plugin/search.cpp +++ b/libsearch/search-app-widget-plugin/search.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise" #define TRANSPARENCY_KEY "transparency" @@ -70,12 +71,12 @@ void AppWidgetPlugin::appWidgetUpdate() obj.insert("alpha", QJsonValue(GlobalSettings::getInstance()->getValue(TRANSPARENCY_KEY).toDouble())); QString jsonData = QString(QJsonDocument(obj).toJson()); - QDBusVariant variant; - variant.setVariant(jsonData); + QVariantMap dataMap; + dataMap.insert("colorData", QVariant(jsonData)); // variant.setVariant(QGuiApplication::palette().color(QPalette::Window).name(QColor::HexArgb)); if(m_manager) { - m_manager->updateAppWidget("search", variant); + m_manager->updateAppWidget("search", dataMap); qDebug() <<"==========update style and transparency successful."; } }