Update seed, theme and script from net in UI qmlfrontend
authorunc0rr
Thu, 26 Nov 2015 20:11:54 +0300
branchqmlfrontend
changeset 11437 97e3e62ea5f9
parent 11436 80a9b14bb8d3
child 11438 bca9afcc3a72
Update seed, theme and script from net in UI
hedgewars/uFLGameConfig.pas
qmlFrontend/qml/qmlFrontend/GameConfig.qml
qmlFrontend/qml/qmlFrontend/HWComboBox.qml
qmlFrontend/themeiconprovider.cpp
--- a/hedgewars/uFLGameConfig.pas	Wed Nov 25 22:10:01 2015 +0300
+++ b/hedgewars/uFLGameConfig.pas	Thu Nov 26 20:11:54 2015 +0300
@@ -336,7 +336,9 @@
     if seed <> currentConfig.seed then
     begin
         currentConfig.seed:= seed;
-        sendUI(mtSeed, @seed[1], length(seed))
+        sendUI(mtSeed, @seed[1], length(seed));
+
+        getPreview()
     end
 end;
 
--- a/qmlFrontend/qml/qmlFrontend/GameConfig.qml	Wed Nov 25 22:10:01 2015 +0300
+++ b/qmlFrontend/qml/qmlFrontend/GameConfig.qml	Thu Nov 26 20:11:54 2015 +0300
@@ -55,6 +55,11 @@
                      HWEngine.setTheme(themeName.text)
                  }
             }
+
+            Connections {
+                target: HWEngine
+                onThemeChanged: cbTheme.showItem({"iconSource" : "image://theme/" + theme, "text" : theme});
+            }
         }
     }
 
@@ -85,6 +90,10 @@
                      HWEngine.setScript(scriptName.text)
                  }
             }
+            Connections {
+                target: HWEngine
+                onScriptChanged: scriptsModel.showItem({"iconSource" : "", "text" : script});
+            }
         }
     }
 
--- a/qmlFrontend/qml/qmlFrontend/HWComboBox.qml	Wed Nov 25 22:10:01 2015 +0300
+++ b/qmlFrontend/qml/qmlFrontend/HWComboBox.qml	Thu Nov 26 20:11:54 2015 +0300
@@ -54,5 +54,10 @@
         }
     }
 
+    function showItem(item) {
+        cbIcon.source = item.iconSource
+        cbText.text = item.text
+    }
+
     onClicked: selection.visibility = Window.Windowed
 }
--- a/qmlFrontend/themeiconprovider.cpp	Wed Nov 25 22:10:01 2015 +0300
+++ b/qmlFrontend/themeiconprovider.cpp	Thu Nov 26 20:11:54 2015 +0300
@@ -28,9 +28,9 @@
     char * bufptr = buf.data();
     uint32_t fileSize = getThemeIcon(id.toUtf8().data(), bufptr, buf.size());
     buf.truncate(fileSize);
-    qDebug() << "ThemeIconProvider file size = " << fileSize;
+    //qDebug() << "ThemeIconProvider file size = " << fileSize;
 
-    QImage img = QImage::fromData(buf);
+    QImage img = fileSize ? QImage::fromData(buf) : QImage(16, 16, QImage::Format_ARGB32);
 
     if (size)
         *size = img.size();