99#include < varianthelper.h>
1010
1111#include < QDBusPendingCallWatcher>
12+ #include < QLoggingCategory>
13+
14+ Q_LOGGING_CATEGORY (proxy, " fcitx5.configtool.proxy" )
1215
1316using namespace deepin::fcitx5configtool;
1417
@@ -17,14 +20,16 @@ Fcitx5ConfigProxyPrivate::Fcitx5ConfigProxyPrivate(Fcitx5ConfigProxy *parent,
1720 const QString &path)
1821 : q(parent), dbusprovider(dbus), path(path)
1922{
20- qDebug ( ) << " Initializing Fcitx5ConfigProxy for path:" << path;
23+ qCDebug (proxy ) << " Entering Fcitx5ConfigProxyPrivate constructor for path:" << path;
2124 timer = new QTimer (q);
2225 timer->setInterval (1000 );
2326 timer->setSingleShot (true );
2427 connect (timer, &QTimer::timeout, q, &Fcitx5ConfigProxy::save);
28+ qCDebug (proxy) << " Exiting Fcitx5ConfigProxyPrivate constructor" ;
2529}
2630
2731QStringList Fcitx5ConfigProxyPrivate::formatKey (const QString &shortcut) {
32+ qCDebug (proxy) << " Formatting key from shortcut:" << shortcut;
2833 QStringList list;
2934 for (const auto &key : shortcut.split (" +" )) {
3035 if (key.trimmed ().toLower () == " control" )
@@ -57,10 +62,12 @@ QStringList Fcitx5ConfigProxyPrivate::formatKey(const QString &shortcut) {
5762 list.removeAll (" Shift_R" );
5863 }
5964 }
65+ qCDebug (proxy) << " Formatted key list:" << list;
6066 return list;
6167}
6268
6369QString Fcitx5ConfigProxyPrivate::formatKeys (const QStringList &keys) {
70+ qCDebug (proxy) << " Formatting keys from list:" << keys;
6471 QStringList list;
6572 for (const auto &key : keys) {
6673 if (key.trimmed ().toLower () == " ctrl" )
@@ -117,20 +124,23 @@ QVariant Fcitx5ConfigProxyPrivate::readDBusValue(const QVariant &value) {
117124Fcitx5ConfigProxy::Fcitx5ConfigProxy (fcitx::kcm::DBusProvider *dbus, const QString &path, QObject *parent)
118125 : QObject (parent), d (new Fcitx5ConfigProxyPrivate (this , dbus, path))
119126{
120- qDebug ( ) << " Fcitx5ConfigProxy created for path:" << path;
127+ qCDebug (proxy ) << " Entering Fcitx5ConfigProxy constructor for path:" << path;
121128}
122129
123130Fcitx5ConfigProxy::~Fcitx5ConfigProxy () = default ;
124131
125132void Fcitx5ConfigProxy::clear ()
126133{
134+ qCDebug (proxy) << " Entering clear" ;
127135 d->configValue .clear ();
128136 d->configTypes .clear ();
129137 Q_EMIT requestConfigFinished ();
138+ qCDebug (proxy) << " Exiting clear" ;
130139}
131140
132141QVariantList Fcitx5ConfigProxy::globalConfigTypes () const
133142{
143+ qCDebug (proxy) << " Entering globalConfigTypes" ;
134144 QVariantList list;
135145 for (const auto &type : d->configTypes ) {
136146 if (type.name () == " GlobalConfig" ) {
@@ -143,11 +153,13 @@ QVariantList Fcitx5ConfigProxy::globalConfigTypes() const
143153 break ;
144154 }
145155 }
156+ qCDebug (proxy) << " Exiting globalConfigTypes with" << list.size () << " items" ;
146157 return list;
147158}
148159
149160QVariantList Fcitx5ConfigProxy::globalConfigOptions (const QString &type, bool all) const
150161{
162+ qCDebug (proxy) << " Entering globalConfigOptions for type" << type << " all:" << all;
151163 QVariantList list;
152164 QString currentType = type+" $" +type+" Config" ;
153165 for (const auto &configType : d->configTypes ) {
@@ -212,11 +224,13 @@ QVariantList Fcitx5ConfigProxy::globalConfigOptions(const QString &type, bool al
212224 }
213225 break ;
214226 }
227+ qCDebug (proxy) << " Exiting globalConfigOptions with" << list.size () << " items" ;
215228 return list;
216229}
217230
218231QVariant Fcitx5ConfigProxy::globalConfigOption (const QString &type, const QString &optionName) const
219232{
233+ qCDebug (proxy) << " Entering globalConfigOption for type" << type << " option:" << optionName;
220234 QVariantMap item;
221235 QString currentType = type+" $" +type+" Config" ;
222236 for (const auto &configType : d->configTypes ) {
@@ -280,11 +294,13 @@ QVariant Fcitx5ConfigProxy::globalConfigOption(const QString &type, const QStrin
280294 }
281295 break ;
282296 }
297+ qCDebug (proxy) << " Exiting globalConfigOption with item" << item;
283298 return item;
284299}
285300
286301void Fcitx5ConfigProxy::restoreDefault (const QString &type)
287302{
303+ qCDebug (proxy) << " Entering restoreDefault for type" << type;
288304 QString currentType = type+" $" +type+" Config" ;
289305 for (const auto &configType : d->configTypes ) {
290306 if (configType.name () != currentType)
@@ -295,13 +311,14 @@ void Fcitx5ConfigProxy::restoreDefault(const QString &type)
295311 }
296312 break ;
297313 }
314+ qCDebug (proxy) << " Exiting restoreDefault" ;
298315}
299316
300317void Fcitx5ConfigProxy::requestConfig (bool sync)
301318{
302- qDebug ( ) << " Requesting config for path: " << d->path << " sync: " << sync;
319+ qCDebug (proxy ) << " Entering requestConfig for path" << d->path << " with sync" << sync;
303320 if (!d->dbusprovider ->controller ()) {
304- qWarning ( ) << " DBus controller not available" ;
321+ qCWarning (proxy ) << " DBus controller not available for requestConfig " ;
305322 return ;
306323 }
307324 auto call = d->dbusprovider ->controller ()->GetConfig (d->path );
@@ -311,20 +328,22 @@ void Fcitx5ConfigProxy::requestConfig(bool sync)
311328 this ,
312329 &Fcitx5ConfigProxy::onRequestConfigFinished);
313330 if (sync) {
331+ qCDebug (proxy) << " Waiting for requestConfig to finish" ;
314332 watcher->waitForFinished ();
315333 }
334+ qCDebug (proxy) << " Exiting requestConfig" ;
316335}
317336
318337void Fcitx5ConfigProxy::onRequestConfigFinished (QDBusPendingCallWatcher *watcher)
319338{
320- qDebug ( ) << " Processing config response for path: " << d->path ;
339+ qCDebug (proxy ) << " Entering onRequestConfigFinished for path" << d->path ;
321340 watcher->deleteLater ();
322341 QDBusPendingReply<QDBusVariant, fcitx::FcitxQtConfigTypeList> reply = *watcher;
323342 if (reply.isError ()) {
324- qWarning ( ) << " Failed to get config:" << reply.error ();
343+ qCWarning (proxy ) << " Failed to get config for path " << d-> path << " Error :" << reply.error ();
325344 return ;
326345 }
327- qDebug ( ) << " Successfully received config for path:" << d->path ;
346+ qCInfo (proxy ) << " Successfully received config for path:" << d->path ;
328347 d->configTypes = reply.argumentAt <1 >();
329348
330349 auto value = reply.argumentAt <0 >().variant ();
@@ -333,39 +352,44 @@ void Fcitx5ConfigProxy::onRequestConfigFinished(QDBusPendingCallWatcher *watcher
333352 std::swap (d->configValue , allMap);
334353
335354 Q_EMIT requestConfigFinished ();
355+ qCDebug (proxy) << " Exiting onRequestConfigFinished" ;
336356}
337357
338358QVariant Fcitx5ConfigProxy::value (const QString &path) const
339359{
340- qDebug ( ) << " Getting value for config path:" << path;
360+ qCDebug (proxy ) << " Entering value for path:" << path;
341361 return fcitx::kcm::readVariant (d->configValue , path);
342362}
343363
344364void Fcitx5ConfigProxy::setValue (const QString &path, const QVariant &value, bool isKey)
345365{
346- qDebug ( ) << " Setting value for config path:" << path << " isKey:" << isKey;
366+ qCDebug (proxy ) << " Setting value for config path:" << path << " isKey:" << isKey;
347367 if (value == this ->value (path)) {
348- qDebug ( ) << " Value unchanged, skipping update" ;
368+ qCDebug (proxy ) << " Value unchanged, skipping update for path: " << path ;
349369 return ;
350370 }
351371 if (isKey) {
372+ qCDebug (proxy) << " Formatting keys for path:" << path;
352373 auto keys = d->formatKeys (value.toStringList ());
353374 fcitx::kcm::writeVariant (d->configValue , path, keys);
354375 } else {
376+ qCDebug (proxy) << " Writing value for path:" << path;
355377 fcitx::kcm::writeVariant (d->configValue , path, value);
356378 }
357379 d->timer ->start ();
380+ qCDebug (proxy) << " Exiting setValue" ;
358381}
359382
360383void Fcitx5ConfigProxy::save ()
361384{
362- qDebug ( ) << " Saving config changes for path:" << d->path ;
385+ qCDebug (proxy ) << " Entering save for path:" << d->path ;
363386 if (!d->dbusprovider ->controller ()) {
364- qWarning ( ) << " DBus controller not available" ;
387+ qCWarning (proxy ) << " DBus controller not available for save " ;
365388 return ;
366389 }
367390
368391 QDBusVariant var (d->configValue );
369392 d->dbusprovider ->controller ()->SetConfig (d->path , var);
370393 requestConfig (false );
394+ qCDebug (proxy) << " Exiting save" ;
371395}
0 commit comments