Переглянути джерело

fix: listing properties wasn't working, fixes #364

Almamu 1 рік тому
батько
коміт
bbba30a618

+ 3 - 2
src/WallpaperEngine/Application/WallpaperApplication.cpp

@@ -233,8 +233,9 @@ void WallpaperApplication::setupPropertiesForProject (const Project& project) {
             cur->update (override->second);
         }
 
-        if (this->m_context.settings.general.onlyListProperties)
-            sLog.out (cur->toString ());
+        if (this->m_context.settings.general.onlyListProperties) {
+            sLog.out (cur->dump ());
+        }
     }
 }
 

+ 89 - 0
src/WallpaperEngine/Data/Model/Property.h

@@ -31,6 +31,7 @@ class Property : public DynamicValue, public TypeCaster, public PropertyData {
 
     using DynamicValue::update;
     virtual void update(const std::string& value) = 0;
+    virtual std::string dump () const = 0;
 };
 
 class PropertySlider final : public Property, SliderData {
@@ -43,6 +44,19 @@ class PropertySlider final : public Property, SliderData {
     void update(const std::string& value) override {
         this->update (std::stof (value));
     }
+
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - slider" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tMin: " << this->min << std::endl
+           << "\tMax: " << this->max << std::endl
+           << "\tStep: " << this->step << std::endl
+           << "\tValue: " << this->toString () << std::endl;
+
+        return ss.str ();
+    }
 };
 
 class PropertyBoolean final : public Property {
@@ -55,6 +69,16 @@ class PropertyBoolean final : public Property {
     void update(const std::string& value) override {
         this->update (value == "true" || value == "1");
     }
+
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - boolean" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->toString () << std::endl;
+
+        return ss.str ();
+    }
 };
 
 class PropertyColor final : public Property {
@@ -108,6 +132,16 @@ class PropertyColor final : public Property {
         // finally parse the string as a float vector
         this->update (VectorBuilder::parse <glm::vec3> (copy));
     }
+
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - color" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->toString () << std::endl;
+
+        return ss.str ();
+    }
 };
 
 class PropertyCombo final : public Property, ComboData {
@@ -127,6 +161,21 @@ class PropertyCombo final : public Property, ComboData {
         }
     }
 
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - combo" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->toString () << std::endl
+           << "Values: " << std::endl;
+
+        for (const auto& [key, value] : this->values) {
+            ss << "\t\t" << key << " = " << value << std::endl;
+        }
+
+        return ss.str ();
+    }
+
   private:
     std::string m_value;
 };
@@ -143,6 +192,16 @@ class PropertyText final : public Property {
     [[nodiscard]] std::string toString () const override {
         return this->text;
     }
+
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - text" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->toString () << std::endl;
+
+        return ss.str ();
+    }
 };
 
 class PropertySceneTexture final : public Property {
@@ -155,6 +214,16 @@ class PropertySceneTexture final : public Property {
         this->m_value = value;
     }
 
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - scene texture" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->m_value << std::endl;
+
+        return ss.str ();
+    }
+
   private:
     std::string m_value;
 };
@@ -169,6 +238,16 @@ class PropertyFile final : public Property {
         this->m_value = value;
     }
 
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - file" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->m_value << std::endl;
+
+        return ss.str ();
+    }
+
   private:
     std::string m_value;
 };
@@ -183,6 +262,16 @@ class PropertyTextInput final : public Property {
         this->m_value = value;
     }
 
+    std::string dump () const override {
+        std::stringstream ss;
+
+        ss << this->name << " - textinput" << std::endl
+           << "\tText: " << this->text << std::endl
+           << "\tValue: " << this->m_value << std::endl;
+
+        return ss.str ();
+    }
+
   private:
     std::string m_value;
 };

+ 8 - 6
src/main.cpp

@@ -20,7 +20,7 @@ void initLogging () {
 }
 
 int main (int argc, char* argv[]) {
-    //try {
+    try {
         // if type parameter is specified, this is a subprocess, so no logging should be enabled from our side
         bool enableLogging = true;
         const std::string typeZygote = "--type=zygote";
@@ -44,11 +44,13 @@ int main (int argc, char* argv[]) {
 
         WallpaperEngine::Application::ApplicationContext appContext (argc, argv);
 
+        app = new WallpaperEngine::Application::WallpaperApplication (appContext);
+
         // halt if the list-properties option was specified
-        if (appContext.settings.general.onlyListProperties)
+        if (appContext.settings.general.onlyListProperties) {
+            delete app;
             return 0;
-
-        app = new WallpaperEngine::Application::WallpaperApplication (appContext);
+        }
 
         // attach signals to gracefully stop
         std::signal (SIGINT, signalhandler);
@@ -66,8 +68,8 @@ int main (int argc, char* argv[]) {
         delete app;
 
         return 0;
-    /*} catch (const std::exception& e) {
+    } catch (const std::exception& e) {
         std::cerr << e.what () << std::endl;
         return 1;
-    }*/
+    }
 }