From e4af04c0728020ef3f59e39048833c367a7893fd Mon Sep 17 00:00:00 2001 From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk> Date: Wed, 3 Jan 2018 12:06:19 +0000 Subject: [PATCH] Added resources used in algorithm dialogs. Re #21281 --- .gitignore | 1 + qt/CMakeLists.txt | 15 +++++++++++++++ qt/applications/workbench/CMakeLists.txt | 15 --------------- qt/python/CMakeLists.txt | 12 ++++++++++++ .../widgets/algorithmselector/__init__.py | 1 + qt/python/resources.qrc | 10 ++++++++++ 6 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 qt/python/resources.qrc diff --git a/.gitignore b/.gitignore index aba6b76f8ef..36b0a8d9cd5 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,7 @@ build/ .builds *.egg-info/ qt/python/mantidqt/utils/qt/plugins.py +qt/python/mantidqt/resources.py qt/applications/workbench/workbench/app/resources.py # Visual C++ cache files diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 82b42ecd9bc..74408b6efd8 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -34,6 +34,21 @@ function ( add_python_package pkg_name ) ) endfunction () +# Resource compiler +if ( NOT PYRCC5_CMD ) + # Newer versions of PyQt5 have a pyrcc_main python module, whereas older + # versions have a pyrcc5 executable. We prefer calling the python module. + execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import PyQt5.pyrcc_main" RESULT_VARIABLE _status) + if ( _status EQUAL 0 ) + set ( PYRCC5_CMD ${PYTHON_EXECUTABLE} -m PyQt5.pyrcc_main CACHE string "Command line to use to run the PyQt5 resource compiler" ) + else () + find_file ( PYRCC5_CMD "pyrcc5" ) + if ( NOT PYRCC5_CMD ) + message ( FATAL_ERROR "Unable to find PyQt5 resource compiler. Tried PyQt5.pyrcc_main & pyrcc5" ) + endif() + endif () +endif() + ########################################################################### # Qt-based targets ########################################################################### diff --git a/qt/applications/workbench/CMakeLists.txt b/qt/applications/workbench/CMakeLists.txt index 4ba7dd67855..a280d52fa91 100644 --- a/qt/applications/workbench/CMakeLists.txt +++ b/qt/applications/workbench/CMakeLists.txt @@ -1,21 +1,6 @@ # Create egg link to binary output directory add_python_package ( workbench EXECUTABLE ) -# Resource compiler -if ( NOT PYRCC5_CMD ) - # Newer versions of PyQt5 have a pyrcc_main python module, whereas older - # versions have a pyrcc5 executable. We prefer calling the python module. - execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import PyQt5.pyrcc_main" RESULT_VARIABLE _status) - if ( _status EQUAL 0 ) - set ( PYRCC5_CMD ${PYTHON_EXECUTABLE} -m PyQt5.pyrcc_main CACHE string "Command line to use to run the PyQt5 resource compiler" ) - else () - find_file ( PYRCC5_CMD "pyrcc5" ) - if ( NOT PYRCC5_CMD ) - message ( FATAL_ERROR "Unable to find PyQt5 resource compiler. Tried PyQt5.pyrcc_main & pyrcc5" ) - endif() - endif () -endif() - # Configure resources data in place for ease of development. The output # file is added to the toplevel gitignore set ( _qrc_file ${CMAKE_CURRENT_LIST_DIR}/resources.qrc ) diff --git a/qt/python/CMakeLists.txt b/qt/python/CMakeLists.txt index 34cc0c20a0a..9fa3a2f3bd2 100644 --- a/qt/python/CMakeLists.txt +++ b/qt/python/CMakeLists.txt @@ -23,6 +23,17 @@ if ( ENABLE_WORKBENCH ) # Create egg link to binary output directory for mantidqt add_python_package ( mantidqt ) + # Configure resources data in place for ease of development. The output + # file is added to the toplevel gitignore + set ( _qrc_file ${CMAKE_CURRENT_LIST_DIR}/resources.qrc ) + set ( _output_res_py ${CMAKE_CURRENT_LIST_DIR}/mantidqt/resources.py ) + add_custom_command ( OUTPUT ${_output_res_py} + COMMAND ${PYRCC5_CMD} -o ${_output_res_py} ${_qrc_file} + COMMENT "Generating mantidqt resources module" + DEPENDS ${_qrc_file} + ) + add_custom_target ( mantidqt_resources ALL DEPENDS ${_output_res_py} ) + # Now add any compiled sip targets add_subdirectory ( mantidqt/widgets ) @@ -30,6 +41,7 @@ if ( ENABLE_WORKBENCH ) add_dependencies ( mantidqt mantidqt_widgetscoreqt5 mantidqt_widgetscoreqt4 + mantidqt_resources ) ########################################################################## diff --git a/qt/python/mantidqt/widgets/algorithmselector/__init__.py b/qt/python/mantidqt/widgets/algorithmselector/__init__.py index 0b3cd787166..a4d2797b424 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/__init__.py +++ b/qt/python/mantidqt/widgets/algorithmselector/__init__.py @@ -17,3 +17,4 @@ # flake8: noqa from .widget import AlgorithmSelectorWidget +from mantidqt import resources diff --git a/qt/python/resources.qrc b/qt/python/resources.qrc new file mode 100644 index 00000000000..a107213f576 --- /dev/null +++ b/qt/python/resources.qrc @@ -0,0 +1,10 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file alias="MantidPlot_Icon_32offset.png">../../images/MantidPlot_Icon_32offset.png</file> + <file alias="data_replace.png">../../images/data_replace.png</file> + <file alias="fileclose.png">../../images/fileclose.png</file> + <file alias="history.png">../../images/history.png</file> + <file alias="replace.png">../../images/replace.png</file> + <file alias="invalid.png">../../images/invalid.png</file> +</qresource> +</RCC> \ No newline at end of file -- GitLab