Store colors in human-readable form
authorunc0rr
Thu, 18 Apr 2013 21:25:38 +0400
changeset 8920 caa614af152d
parent 8919 67214340fa53
child 8921 e5db2a42e7e8
child 8922 b3874fa07e77
Store colors in human-readable form
QTfrontend/gameuiconfig.cpp
QTfrontend/util/DataManager.cpp
--- a/QTfrontend/gameuiconfig.cpp	Thu Apr 18 17:37:50 2013 +0400
+++ b/QTfrontend/gameuiconfig.cpp	Thu Apr 18 21:25:38 2013 +0400
@@ -25,6 +25,7 @@
 #include <QNetworkProxy>
 #include <QNetworkProxyFactory>
 #include <utility>
+#include <QVariant>
 
 #include "gameuiconfig.h"
 #include "hwform.h"
@@ -156,7 +157,7 @@
     { // load colors
         QStandardItemModel * model = DataManager::instance().colorsModel();
         for(int i = model->rowCount() - 1; i >= 0; --i)
-            model->item(i)->setData(value(QString("colors/color%1").arg(i), model->item(i)->data()));
+            model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data()).toString()));
     }
 
     { // load binds
@@ -319,7 +320,7 @@
     { // save colors
         QStandardItemModel * model = DataManager::instance().colorsModel();
         for(int i = model->rowCount() - 1; i >= 0; --i)
-            setValue(QString("colors/color%1").arg(i), model->item(i)->data());
+            setValue(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>().name());
     }
 
     sync();
--- a/QTfrontend/util/DataManager.cpp	Thu Apr 18 17:37:50 2013 +0400
+++ b/QTfrontend/util/DataManager.cpp	Thu Apr 18 21:25:38 2013 +0400
@@ -26,6 +26,7 @@
 #include <QStandardItemModel>
 #include <QFileInfo>
 #include <QSettings>
+#include <QColor>
 
 #include "hwconsts.h"
 #include "HWApplication.h"
@@ -183,7 +184,12 @@
                 sNew.setIniCodec("UTF-8");
 
                 foreach(const QString & key, sOld.allKeys())
-                    sNew.setValue(key, sOld.value(key));
+                {
+                    if(key.startsWith("colors/color"))
+                        sNew.setValue(key, sOld.value(key).value<QColor>().name());
+                    else
+                        sNew.setValue(key, sOld.value(key));
+                }
             }
         }