From 4716453e97602e60f58865692f7dc714f5f992e9 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Thu, 18 Jun 2015 22:26:10 +0200 Subject: Implemented togglable debug mode --- daemon/daemon.cpp | 12 ++++-------- daemon/settings.h | 6 +++++- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'daemon') diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index 85af751..78050d3 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -50,18 +50,14 @@ int main(int argc, char *argv[]) app.setApplicationName("pebble"); // Use the same appname as the UI. app.setOrganizationName(""); - QStringList filterRules; - - filterRules << (argc > 1 and QString("-d") == argv[0] ? - "*.debug=false" : "*.debug=true"); - - // Init logging should be called after app object creation - QLoggingCategory::setFilterRules(filterRules.join("\n")); - QLoggingCategory l("main"); qCDebug(l) << argv[0] << APP_VERSION; Settings settings; + + QLoggingCategory::setFilterRules(settings.property("debug").toBool() ? + "*.debug=true" : "*.debug=false"); + Manager manager(&settings); Q_UNUSED(manager); diff --git a/daemon/settings.h b/daemon/settings.h index a247dc5..4534a54 100644 --- a/daemon/settings.h +++ b/daemon/settings.h @@ -21,6 +21,7 @@ class Settings : public MDConfGroup Q_PROPERTY(bool notificationsOther MEMBER notificationsOther NOTIFY notificationsOtherChanged) Q_PROPERTY(bool notificationsAll MEMBER notificationsAll NOTIFY notificationsAllChanged) Q_PROPERTY(QString accountToken MEMBER accountToken NOTIFY accountTokenChanged) + Q_PROPERTY(bool debug MEMBER debug NOTIFY debugChanged) QString profileWhenConnected; QString profileWhenDisconnected; @@ -36,6 +37,7 @@ class Settings : public MDConfGroup bool notificationsOther; bool notificationsAll; QString accountToken; + bool debug; public: explicit Settings(QObject *parent = 0) : @@ -50,7 +52,8 @@ public: notificationsTwitter(true), notificationsFacebook(true), notificationsOther(true), - notificationsAll(false) + notificationsAll(false), + debug(false) { resolveMetaObject(); QMetaObject::invokeMethod(this, "propertyChanged", Qt::DirectConnection); @@ -72,6 +75,7 @@ signals: void notificationsOtherChanged(); void notificationsAllChanged(); void accountTokenChanged(); + void debugChanged(); }; #endif // SETTINGS_H -- cgit v1.2.3