QTfrontend/gameuiconfig.cpp
changeset 8346 3443e0de2c9d
parent 8325 ecd51650d5d8
child 8350 14b938faec69
--- a/QTfrontend/gameuiconfig.cpp	Fri Dec 28 23:54:42 2012 +0100
+++ b/QTfrontend/gameuiconfig.cpp	Sat Dec 29 22:50:10 2012 +0100
@@ -52,6 +52,13 @@
 
     connect(Form->ui.pageOptions->CBFrontendMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool)));
 
+    for(int i = 0; i < BINDS_NUMBER; i++)
+    {
+        m_binds.append(BindAction());
+        m_binds[i].action = cbinds[i].action;
+        m_binds[i].strbind = cbinds[i].strbind;
+    }
+
     //Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt());
     resizeToConfigValues();
 
@@ -135,6 +142,15 @@
         for(int i = model->rowCount() - 1; i >= 0; --i)
             model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>()).value<QColor>()));
     }
+
+    { // load binds
+        QStandardItemModel * binds = DataManager::instance().bindsModel();
+        for(int i = 0; i < BINDS_NUMBER; i++)
+        {
+            m_binds[i].strbind = value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString();
+            if (m_binds[i].strbind.isEmpty() || m_binds[i].strbind == "default") m_binds[i].strbind = cbinds[i].strbind;
+        }
+    }
 }
 
 void GameUIConfig::reloadVideosValues(void)
@@ -581,3 +597,16 @@
 {
     return Form->ui.pageOptions->checkRecordAudio->isChecked();
 }
+
+// Gets a bind for a bindID
+QString GameUIConfig::bind(int bindID)
+{
+    return m_binds[bindID].strbind;
+}
+
+// Sets a bind for a bindID and saves it
+void GameUIConfig::setBind(int bindID, QString & strbind)
+{
+    m_binds[bindID].strbind = strbind;
+    setValue(QString("Binds/%1").arg(m_binds[bindID].action), strbind);
+}