From dc3db3b5ac29769aa4ab571a670d26e2fc7b6bf6 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul.cercueil@analog.com>
Date: Tue, 21 Jun 2016 17:42:45 +0200
Subject: [PATCH 09/22] gr-qtgui: Fix PyQt[4,5] include in XMLs for GRC

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
---
 gr-qtgui/grc/CMakeLists.txt                                      | 9 ++++++++-
 .../grc/{qtgui_ber_sink_b.xml => qtgui_ber_sink_b.xml.cmakein}   | 2 +-
 .../grc/{qtgui_block_tree.xml => qtgui_block_tree.xml.cmakein}   | 0
 .../grc/{qtgui_check_box.xml => qtgui_check_box.xml.cmakein}     | 2 +-
 gr-qtgui/grc/{qtgui_chooser.xml => qtgui_chooser.xml.cmakein}    | 4 ++--
 .../{qtgui_const_sink_x.xml => qtgui_const_sink_x.xml.cmakein}   | 2 +-
 .../{qtgui_edit_box_msg.xml => qtgui_edit_box_msg.xml.cmakein}   | 2 +-
 gr-qtgui/grc/{qtgui_entry.xml => qtgui_entry.xml.cmakein}        | 2 +-
 .../grc/{qtgui_freq_sink_x.xml => qtgui_freq_sink_x.xml.cmakein} | 2 +-
 ...i_histogram_sink_x.xml => qtgui_histogram_sink_x.xml.cmakein} | 2 +-
 gr-qtgui/grc/{qtgui_label.xml => qtgui_label.xml.cmakein}        | 2 +-
 .../grc/{qtgui_number_sink.xml => qtgui_number_sink.xml.cmakein} | 2 +-
 .../grc/{qtgui_push_button.xml => qtgui_push_button.xml.cmakein} | 2 +-
 gr-qtgui/grc/{qtgui_range.xml => qtgui_range.xml.cmakein}        | 0
 gr-qtgui/grc/{qtgui_sink_x.xml => qtgui_sink_x.xml.cmakein}      | 2 +-
 .../grc/{qtgui_tab_widget.xml => qtgui_tab_widget.xml.cmakein}   | 2 +-
 .../{qtgui_time_raster_x.xml => qtgui_time_raster_x.xml.cmakein} | 2 +-
 .../grc/{qtgui_time_sink_x.xml => qtgui_time_sink_x.xml.cmakein} | 2 +-
 .../{qtgui_vector_sink_f.xml => qtgui_vector_sink_f.xml.cmakein} | 2 +-
 ...i_waterfall_sink_x.xml => qtgui_waterfall_sink_x.xml.cmakein} | 2 +-
 20 files changed, 26 insertions(+), 19 deletions(-)
 rename gr-qtgui/grc/{qtgui_ber_sink_b.xml => qtgui_ber_sink_b.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_block_tree.xml => qtgui_block_tree.xml.cmakein} (100%)
 rename gr-qtgui/grc/{qtgui_check_box.xml => qtgui_check_box.xml.cmakein} (97%)
 rename gr-qtgui/grc/{qtgui_chooser.xml => qtgui_chooser.xml.cmakein} (98%)
 rename gr-qtgui/grc/{qtgui_const_sink_x.xml => qtgui_const_sink_x.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_edit_box_msg.xml => qtgui_edit_box_msg.xml.cmakein} (98%)
 rename gr-qtgui/grc/{qtgui_entry.xml => qtgui_entry.xml.cmakein} (97%)
 rename gr-qtgui/grc/{qtgui_freq_sink_x.xml => qtgui_freq_sink_x.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_histogram_sink_x.xml => qtgui_histogram_sink_x.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_label.xml => qtgui_label.xml.cmakein} (97%)
 rename gr-qtgui/grc/{qtgui_number_sink.xml => qtgui_number_sink.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_push_button.xml => qtgui_push_button.xml.cmakein} (97%)
 rename gr-qtgui/grc/{qtgui_range.xml => qtgui_range.xml.cmakein} (100%)
 rename gr-qtgui/grc/{qtgui_sink_x.xml => qtgui_sink_x.xml.cmakein} (98%)
 rename gr-qtgui/grc/{qtgui_tab_widget.xml => qtgui_tab_widget.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_time_raster_x.xml => qtgui_time_raster_x.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_time_sink_x.xml => qtgui_time_sink_x.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_vector_sink_f.xml => qtgui_vector_sink_f.xml.cmakein} (99%)
 rename gr-qtgui/grc/{qtgui_waterfall_sink_x.xml => qtgui_waterfall_sink_x.xml.cmakein} (99%)

diff --git a/gr-qtgui/grc/CMakeLists.txt b/gr-qtgui/grc/CMakeLists.txt
index d56158ac70..d01bcc52c4 100644
--- a/gr-qtgui/grc/CMakeLists.txt
+++ b/gr-qtgui/grc/CMakeLists.txt
@@ -18,5 +18,12 @@
 # Boston, MA 02110-1301, USA.
 
 ########################################################################
-file(GLOB xml_files "*.xml")
+file(GLOB xml_cmakein_files "*.xml.cmakein")
+
+foreach(xml_cmakein_file IN ITEMS ${xml_cmakein_files})
+	get_filename_component(FILE_NAME ${xml_cmakein_file} NAME_WE)
+	configure_file(${xml_cmakein_file} "${CMAKE_CURRENT_BINARY_DIR}/${FILE_NAME}.xml" @ONLY)
+	set(xml_files ${xml_files} "${CMAKE_CURRENT_BINARY_DIR}/${FILE_NAME}.xml")
+endforeach(xml_cmakein_file)
+
 install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "qtgui_python")
diff --git a/gr-qtgui/grc/qtgui_ber_sink_b.xml b/gr-qtgui/grc/qtgui_ber_sink_b.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_ber_sink_b.xml
rename to gr-qtgui/grc/qtgui_ber_sink_b.xml.cmakein
index 085bf282be..91a87ce595 100644
--- a/gr-qtgui/grc/qtgui_ber_sink_b.xml
+++ b/gr-qtgui/grc/qtgui_ber_sink_b.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Bercurve Sink</name>
   <key>qtgui_bercurve_sink</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <import>import numpy</import>
diff --git a/gr-qtgui/grc/qtgui_block_tree.xml b/gr-qtgui/grc/qtgui_block_tree.xml.cmakein
similarity index 100%
rename from gr-qtgui/grc/qtgui_block_tree.xml
rename to gr-qtgui/grc/qtgui_block_tree.xml.cmakein
diff --git a/gr-qtgui/grc/qtgui_check_box.xml b/gr-qtgui/grc/qtgui_check_box.xml.cmakein
similarity index 97%
rename from gr-qtgui/grc/qtgui_check_box.xml
rename to gr-qtgui/grc/qtgui_check_box.xml.cmakein
index ccee59dd92..9edacb24d8 100644
--- a/gr-qtgui/grc/qtgui_check_box.xml
+++ b/gr-qtgui/grc/qtgui_check_box.xml.cmakein
@@ -8,7 +8,7 @@
 <block>
 	<name>QT GUI Check Box</name>
 	<key>variable_qtgui_check_box</key>
-	<import>from PyQt5 import Qt</import>
+	<import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
 	<var_make>self.$(id) = $(id) = $value</var_make>
 	<make>#set $win = '_%s_check_box'%$id
 #if not $label()
diff --git a/gr-qtgui/grc/qtgui_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml.cmakein
similarity index 98%
rename from gr-qtgui/grc/qtgui_chooser.xml
rename to gr-qtgui/grc/qtgui_chooser.xml.cmakein
index f79bb8ccb3..40c782bede 100644
--- a/gr-qtgui/grc/qtgui_chooser.xml
+++ b/gr-qtgui/grc/qtgui_chooser.xml.cmakein
@@ -8,8 +8,8 @@
 <block>
 	<name>QT GUI Chooser</name>
 	<key>variable_qtgui_chooser</key>
-	<import>from PyQt5 import Qt</import>
-	<import>from PyQt5.QtCore import QObject, pyqtSlot</import>
+	<import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
+	<import>from PyQt@DESIRED_QT_VERSION@.QtCore import QObject, pyqtSlot</import>
 	<var_make>self.$(id) = $(id) = $value</var_make>
 	<make>#slurp
 #set $all_options = [$option0, $option1, $option2, $option3, $option4][:int($num_opts())]
diff --git a/gr-qtgui/grc/qtgui_const_sink_x.xml b/gr-qtgui/grc/qtgui_const_sink_x.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_const_sink_x.xml
rename to gr-qtgui/grc/qtgui_const_sink_x.xml.cmakein
index 10f82cce82..6fa725acb1 100644
--- a/gr-qtgui/grc/qtgui_const_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_const_sink_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Constellation Sink</name>
   <key>qtgui_const_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <make>#set $win = 'self._%s_win'%$id
diff --git a/gr-qtgui/grc/qtgui_edit_box_msg.xml b/gr-qtgui/grc/qtgui_edit_box_msg.xml.cmakein
similarity index 98%
rename from gr-qtgui/grc/qtgui_edit_box_msg.xml
rename to gr-qtgui/grc/qtgui_edit_box_msg.xml.cmakein
index d77a4b3e1b..75ff93349f 100644
--- a/gr-qtgui/grc/qtgui_edit_box_msg.xml
+++ b/gr-qtgui/grc/qtgui_edit_box_msg.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Message Edit Box</name>
   <key>qtgui_edit_box_msg</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <make>#set $win = 'self._%s_win'%$id
diff --git a/gr-qtgui/grc/qtgui_entry.xml b/gr-qtgui/grc/qtgui_entry.xml.cmakein
similarity index 97%
rename from gr-qtgui/grc/qtgui_entry.xml
rename to gr-qtgui/grc/qtgui_entry.xml.cmakein
index fc0f4089d1..da61ee723a 100644
--- a/gr-qtgui/grc/qtgui_entry.xml
+++ b/gr-qtgui/grc/qtgui_entry.xml.cmakein
@@ -8,7 +8,7 @@
 <block>
 	<name>QT GUI Entry</name>
 	<key>variable_qtgui_entry</key>
-	<import>from PyQt5 import Qt</import>
+	<import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
 	<import>from gnuradio import eng_notation</import>
 	<var_make>self.$(id) = $(id) = $value</var_make>
 	<make>#set $win = 'self._%s_tool_bar'%$id
diff --git a/gr-qtgui/grc/qtgui_freq_sink_x.xml b/gr-qtgui/grc/qtgui_freq_sink_x.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_freq_sink_x.xml
rename to gr-qtgui/grc/qtgui_freq_sink_x.xml.cmakein
index ed39db7781..aaf0d75271 100644
--- a/gr-qtgui/grc/qtgui_freq_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_freq_sink_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Frequency Sink</name>
   <key>qtgui_freq_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>from gnuradio.filter import firdes</import>
   <import>import sip</import>
diff --git a/gr-qtgui/grc/qtgui_histogram_sink_x.xml b/gr-qtgui/grc/qtgui_histogram_sink_x.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_histogram_sink_x.xml
rename to gr-qtgui/grc/qtgui_histogram_sink_x.xml.cmakein
index 9e3dcb104f..d04a44da13 100644
--- a/gr-qtgui/grc/qtgui_histogram_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_histogram_sink_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Histogram Sink</name>
   <key>qtgui_histogram_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <make>#set $win = 'self._%s_win'%$id
diff --git a/gr-qtgui/grc/qtgui_label.xml b/gr-qtgui/grc/qtgui_label.xml.cmakein
similarity index 97%
rename from gr-qtgui/grc/qtgui_label.xml
rename to gr-qtgui/grc/qtgui_label.xml.cmakein
index 946cee36ab..c546e09dcc 100644
--- a/gr-qtgui/grc/qtgui_label.xml
+++ b/gr-qtgui/grc/qtgui_label.xml.cmakein
@@ -9,7 +9,7 @@
 <block>
   <name>QT GUI Label</name>
   <key>variable_qtgui_label</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import eng_notation</import>
   <var_make>self.$(id) = $(id) = $value</var_make>
   <make>#set $win = 'self._%s_tool_bar'%$id
diff --git a/gr-qtgui/grc/qtgui_number_sink.xml b/gr-qtgui/grc/qtgui_number_sink.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_number_sink.xml
rename to gr-qtgui/grc/qtgui_number_sink.xml.cmakein
index 06837493c3..d4b4c5808f 100644
--- a/gr-qtgui/grc/qtgui_number_sink.xml
+++ b/gr-qtgui/grc/qtgui_number_sink.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Number Sink</name>
   <key>qtgui_number_sink</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <make>#set $win = 'self._%s_win'%$id
diff --git a/gr-qtgui/grc/qtgui_push_button.xml b/gr-qtgui/grc/qtgui_push_button.xml.cmakein
similarity index 97%
rename from gr-qtgui/grc/qtgui_push_button.xml
rename to gr-qtgui/grc/qtgui_push_button.xml.cmakein
index 49c2e9d6f0..d99f230acf 100644
--- a/gr-qtgui/grc/qtgui_push_button.xml
+++ b/gr-qtgui/grc/qtgui_push_button.xml.cmakein
@@ -8,7 +8,7 @@
 <block>
 	<name>QT GUI Push Button</name>
 	<key>variable_qtgui_push_button</key>
-	<import>from PyQt5 import Qt</import>
+	<import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
 	<var_make>self.$(id) = $(id) = $value</var_make>
 	<make>#set $win = '_%s_push_button'%$id
 #if not $label()
diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml.cmakein
similarity index 100%
rename from gr-qtgui/grc/qtgui_range.xml
rename to gr-qtgui/grc/qtgui_range.xml.cmakein
diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml.cmakein
similarity index 98%
rename from gr-qtgui/grc/qtgui_sink_x.xml
rename to gr-qtgui/grc/qtgui_sink_x.xml.cmakein
index a9bc469cd2..1c75921a75 100644
--- a/gr-qtgui/grc/qtgui_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_sink_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Sink</name>
   <key>qtgui_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>from gnuradio.filter import firdes</import>
   <import>import sip</import>
diff --git a/gr-qtgui/grc/qtgui_tab_widget.xml b/gr-qtgui/grc/qtgui_tab_widget.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_tab_widget.xml
rename to gr-qtgui/grc/qtgui_tab_widget.xml.cmakein
index 805542cc8b..f5a1a73cdc 100644
--- a/gr-qtgui/grc/qtgui_tab_widget.xml
+++ b/gr-qtgui/grc/qtgui_tab_widget.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
 	<name>QT GUI Tab Widget</name>
 	<key>qtgui_tab_widget</key>
-	<import>from PyQt5 import Qt</import>
+	<import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
 	<make>#set $win = 'self.%s'%$id
 Qt.QTabWidget()
 #set $all_labels = [$label0, $label1, $label2, $label3, $label4,
diff --git a/gr-qtgui/grc/qtgui_time_raster_x.xml b/gr-qtgui/grc/qtgui_time_raster_x.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_time_raster_x.xml
rename to gr-qtgui/grc/qtgui_time_raster_x.xml.cmakein
index d458f67eb9..94b7ef136a 100644
--- a/gr-qtgui/grc/qtgui_time_raster_x.xml
+++ b/gr-qtgui/grc/qtgui_time_raster_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Time Raster Sink</name>
   <key>qtgui_time_raster_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <make>#set $win = 'self._%s_win'%$id
diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_time_sink_x.xml
rename to gr-qtgui/grc/qtgui_time_sink_x.xml.cmakein
index d4347950ea..d239917907 100644
--- a/gr-qtgui/grc/qtgui_time_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_time_sink_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Time Sink</name>
   <key>qtgui_time_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>from gnuradio.filter import firdes</import>
   <import>import sip</import>
diff --git a/gr-qtgui/grc/qtgui_vector_sink_f.xml b/gr-qtgui/grc/qtgui_vector_sink_f.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_vector_sink_f.xml
rename to gr-qtgui/grc/qtgui_vector_sink_f.xml.cmakein
index 0f456323bf..8b928eb7ea 100644
--- a/gr-qtgui/grc/qtgui_vector_sink_f.xml
+++ b/gr-qtgui/grc/qtgui_vector_sink_f.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Vector Sink</name>
   <key>qtgui_vector_sink_f</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>import sip</import>
   <make>#set $win = 'self._%s_win'%$id
diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml.cmakein
similarity index 99%
rename from gr-qtgui/grc/qtgui_waterfall_sink_x.xml
rename to gr-qtgui/grc/qtgui_waterfall_sink_x.xml.cmakein
index a684492246..d198ca084a 100644
--- a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml.cmakein
@@ -7,7 +7,7 @@
 <block>
   <name>QT GUI Waterfall Sink</name>
   <key>qtgui_waterfall_sink_x</key>
-  <import>from PyQt5 import Qt</import>
+  <import>from PyQt@DESIRED_QT_VERSION@ import Qt</import>
   <import>from gnuradio import qtgui</import>
   <import>from gnuradio.filter import firdes</import>
   <import>import sip</import>
-- 
2.11.0

