فهرست منبع

CPack/IFW: Add option for ProductImages URLs

Add a `CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS` variable for them.
Julien Marrec 1 سال پیش
والد
کامیت
3331c7032f

+ 10 - 0
Help/cpack_gen/ifw.rst

@@ -275,6 +275,16 @@ Package
 
  This feature is available for QtIFW 4.0.0 and later.
 
+.. variable:: CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS
+
+ .. versionadded:: 3.31
+
+ A list of URLs associated with the ProductImages.
+ Only used if  ``CPACK_IFW_PACKAGE_PRODUCT_IMAGES`` is defined
+ and it has the same size.
+
+ This feature is available for QtIFW 4.0.0 and later.
+
 .. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM
 
  .. versionadded:: 3.23

+ 8 - 0
Help/release/dev/cpack-ifw-product-images.rst

@@ -0,0 +1,8 @@
+cpack-ifw-product-images
+------------------------
+
+* The :cpack_gen:`CPack IFW Generator` gained the new
+  :variable:`CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS` variable to
+  specify images associated with entries of
+  :variable:`CPACK_IFW_PACKAGE_PRODUCT_IMAGES`.
+  This feature is available for QtIFW 4.0 and newer.

+ 25 - 1
Source/CPack/IFW/cmCPackIFWInstaller.cxx

@@ -323,6 +323,25 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
                               this->ProductImages.end());
   }
 
+  if (!this->ProductImages.empty()) {
+    if (cmValue productUrls =
+          this->GetOption("CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS")) {
+      this->ProductImageUrls.clear();
+      cmExpandList(productUrls, this->ProductImageUrls);
+      if (this->ProductImageUrls.size() != this->ProductImages.size()) {
+        cmCPackIFWLogger(
+          WARNING,
+          "Option \"CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS\" will be skipped "
+          "because it contains "
+            << this->ProductImageUrls.size()
+            << " elements while \"CPACK_IFW_PACKAGE_PRODUCT_IMAGES\" "
+               "contains "
+            << this->ProductImages.size() << " elements." << std::endl);
+        this->ProductImageUrls.clear();
+      }
+    }
+  }
+
   // Run program, run program arguments, and run program description
   if (cmValue program = this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM")) {
     this->RunProgram = *program;
@@ -621,12 +640,17 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
   // Product images (copy to config dir)
   if (!this->IsVersionLess("4.0") && !this->ProductImages.empty()) {
     xout.StartElement("ProductImages");
-    for (auto const& srcImg : this->ProductImages) {
+    const bool hasProductImageUrl = !this->ProductImageUrls.empty();
+    for (size_t i = 0; i < this->ProductImages.size(); ++i) {
       xout.StartElement("ProductImage");
+      auto const& srcImg = this->ProductImages[i];
       std::string name = cmSystemTools::GetFilenameName(srcImg);
       std::string dstImg = this->Directory + "/config/" + name;
       cmsys::SystemTools::CopyFileIfDifferent(srcImg, dstImg);
       xout.Element("Image", name);
+      if (hasProductImageUrl) {
+        xout.Element("Url", this->ProductImageUrls.at(i));
+      }
       xout.EndElement(); // </ProductImage>
     }
     xout.EndElement(); // </ProductImages>

+ 4 - 0
Source/CPack/IFW/cmCPackIFWInstaller.h

@@ -124,6 +124,10 @@ public:
   /// A list of images to be shown on PerformInstallationPage.
   std::vector<std::string> ProductImages;
 
+  /// A list of associated URLs linked to images to be shown on
+  /// PerformInstallationPage.
+  std::vector<std::string> ProductImageUrls;
+
   /// Command executed after the installer is done if the user accepts the
   /// action
   std::string RunProgram;