From ed553c6ace94aa4b0e8a8e32126ad53e3134d66b Mon Sep 17 00:00:00 2001 From: David Cattermole Date: Tue, 28 Jan 2020 00:15:47 +0000 Subject: [PATCH] Adding Qt Resources for Tree View icons. CMake build system compiles Qt .rcc files to be loaded at runtime for icons. Issue #29 and #30. --- CMakeLists.txt | 16 +++++++-- icons/CMakeLists.txt | 33 ++++++++++++++++++ icons/resources.qrc | 12 +++++++ icons/ui/mmSolver_attr.png | Bin 0 -> 130 bytes icons/ui/mmSolver_bundle.png | Bin 0 -> 117 bytes icons/ui/mmSolver_camera.png | Bin 0 -> 118 bytes icons/ui/mmSolver_marker.png | Bin 0 -> 118 bytes icons/ui/mmSolver_node.png | Bin 0 -> 125 bytes icons/ui/mmSolver_object.png | Bin 0 -> 118 bytes icons/ui/mmSolver_plug.png | Bin 0 -> 130 bytes icons/ui/mmSolver_solverStep.png | Bin 0 -> 112 bytes modules/mayaMatchMoveSolver_windows.mod | 1 + .../mmSolver/tools/solver/ui/solver_window.py | 24 +++++++++++++ 13 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 icons/CMakeLists.txt create mode 100644 icons/resources.qrc create mode 100644 icons/ui/mmSolver_attr.png create mode 100644 icons/ui/mmSolver_bundle.png create mode 100644 icons/ui/mmSolver_camera.png create mode 100644 icons/ui/mmSolver_marker.png create mode 100644 icons/ui/mmSolver_node.png create mode 100644 icons/ui/mmSolver_object.png create mode 100644 icons/ui/mmSolver_plug.png create mode 100644 icons/ui/mmSolver_solverStep.png diff --git a/CMakeLists.txt b/CMakeLists.txt index 24958b5e5..dd2614292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,16 +483,24 @@ endif () # Install Icons. if (BUILD_ICONS) + install(DIRECTORY "icons/" + DESTINATION "${MODULE_FULL_NAME}/resources" + FILES_MATCHING PATTERN "*.rcc" + PATTERN "icons/edit" EXCLUDE + PATTERN "icons/library" EXCLUDE + PATTERN "icons/ui" EXCLUDE) install(DIRECTORY "icons/" DESTINATION "${MODULE_FULL_NAME}/icons" FILES_MATCHING PATTERN "*.png" PATTERN "icons/edit" EXCLUDE - PATTERN "icons/library" EXCLUDE) + PATTERN "icons/library" EXCLUDE + PATTERN "icons/ui" EXCLUDE) install(DIRECTORY "icons/" DESTINATION "${MODULE_FULL_NAME}/icons" FILES_MATCHING PATTERN "*.svg" PATTERN "icons/edit" EXCLUDE - PATTERN "icons/library" EXCLUDE) + PATTERN "icons/library" EXCLUDE + PATTERN "icons/ui" EXCLUDE) endif () @@ -550,6 +558,10 @@ if (BUILD_DOCS) add_subdirectory(docs) endif () +if (BUILD_ICONS) + add_subdirectory(icons) +endif () + if (BUILD_TESTS) enable_testing() add_subdirectory(tests) diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt new file mode 100644 index 000000000..28f099c4a --- /dev/null +++ b/icons/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (C) 2020 David Cattermole. +# +# This file is part of mmSolver. +# +# mmSolver is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# mmSolver is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with mmSolver. If not, see . +# --------------------------------------------------------------------- +# +# Build Icons (using Qt Resource Compiler) + +set(input_file ${CMAKE_SOURCE_DIR}/icons/resources.qrc) +set(output_file ${CMAKE_SOURCE_DIR}/icons/resources.rcc) +add_custom_command( + OUTPUT ${output_file} + COMMAND rcc -binary resources.qrc -o resources.rcc + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/icons + DEPENDS ${input_file} +) +add_custom_target( + build_icons ALL + DEPENDS ${output_file} + COMMENT "Building Icons (with Qt Resource Compiler) (${input_file})..." +) diff --git a/icons/resources.qrc b/icons/resources.qrc new file mode 100644 index 000000000..efa0ba324 --- /dev/null +++ b/icons/resources.qrc @@ -0,0 +1,12 @@ + + + ui/mmSolver_attr.png + ui/mmSolver_node.png + ui/mmSolver_plug.png + ui/mmSolver_bundle.png + ui/mmSolver_marker.png + ui/mmSolver_object.png + ui/mmSolver_camera.png + ui/mmSolver_solverStep.png + + diff --git a/icons/ui/mmSolver_attr.png b/icons/ui/mmSolver_attr.png new file mode 100644 index 0000000000000000000000000000000000000000..1c45f55e1ad9cb05ada4a70123c60a0f9896924c GIT binary patch literal 130 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1SGw4HSYi^#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=AqSK$x*9nNw!ubJYD@<);T3K0RYs%9_9c5 literal 0 HcmV?d00001 diff --git a/icons/ui/mmSolver_bundle.png b/icons/ui/mmSolver_bundle.png new file mode 100644 index 0000000000000000000000000000000000000000..8e33c60da2201f02e9893f33cfe3bf79f5c52169 GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1SGw4HSYi^mUKs7M+SzC{oH>NS%G}c0*}aI z1_qTEAk5g5%qjyE6!&y-43P*=-tyhza09P_VNS%G}c0*}aI z1_qTEAk5g5%qjyEl<;(M43P*={!>4xpHVuY>5@c(ftP^+14D5SNS%G}c0*}aI z1_qTEAk5g5%qjyEl<;(M43P*=j(M}Qg;6@8>5@c(ftP^+1A|Q&!lvI6;>1s;*b3=AqSK$x*9nNNS%G}c0*}aI z1_qTEAk5g5%qjyEl<;(M43P*=PKo%^#3-H6bV(w?z{|jZfx+xG!lvI6;>1s;*b3=AqSK$x*9nNxdvVX$4njr2~`OR2H#%B Vt&OjRp97UJc)I$ztaD0e0szd99`gVI literal 0 HcmV?d00001 diff --git a/icons/ui/mmSolver_solverStep.png b/icons/ui/mmSolver_solverStep.png new file mode 100644 index 0000000000000000000000000000000000000000..9f5632dcf1e7c337fd32a716d1987b69f0eade7f GIT binary patch literal 112 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1SGw4HSYi^mUKs7M+SzC{oH>NS%G}c0*}aI z1_qTEAk5g5%qjyE6!LU&43P*=4!HHAS(I0^v)7K{-(B~EyDS4X0A(3GUHx3vIVCg! E0NN@WN&o-= literal 0 HcmV?d00001 diff --git a/modules/mayaMatchMoveSolver_windows.mod b/modules/mayaMatchMoveSolver_windows.mod index 4651d4cb7..986f08e52 100644 --- a/modules/mayaMatchMoveSolver_windows.mod +++ b/modules/mayaMatchMoveSolver_windows.mod @@ -2,6 +2,7 @@ MMSOLVER_LOCATION := MMSOLVER_CONFIG_PATH +:= config MMSOLVER_CONFIG_PATH += ${APPDATA}/mmSolver +MMSOLVER_RESOURCE_PATH := resources MMSOLVER_LOAD_AT_STARTUP = 1 MMSOLVER_CREATE_MENU = 1 MMSOLVER_CREATE_SHELF = 1 diff --git a/python/mmSolver/tools/solver/ui/solver_window.py b/python/mmSolver/tools/solver/ui/solver_window.py index d5e3f1c7e..ffc7fa3f1 100644 --- a/python/mmSolver/tools/solver/ui/solver_window.py +++ b/python/mmSolver/tools/solver/ui/solver_window.py @@ -19,6 +19,7 @@ The main window for the 'Solver' tool. """ +import os import datetime import uuid from functools import partial @@ -629,6 +630,28 @@ def help(self): return +def loadAllResources(): + base_install_location = os.environ.get('MMSOLVER_LOCATION', None) + assert base_install_location is not None + fallback = os.path.join(base_install_location, 'resources') + resource_paths = os.environ.get('MMSOLVER_RESOURCE_PATH', fallback) + assert isinstance(resource_paths, basestring) + resource_paths = resource_paths.split(os.pathsep) + for directory_path in resource_paths: + if not os.path.isdir(directory_path): + continue + file_names = os.listdir(directory_path) + for file_name in file_names: + file_path = os.path.join(directory_path, file_name) + if os.path.isfile(file_path): + is_registered = QtCore.QResource.registerResource(file_path) + if is_registered: + LOG.info("Resource registered: %r", file_path) + else: + LOG.warn("Resource failed to register: %r", file_path) + return + + def main(show=True, auto_raise=True, delete=False): """ Open the Solver UI window. @@ -650,6 +673,7 @@ def main(show=True, auto_raise=True, delete=False): # Force the Plug-in to load. If the plug-in cannot load, the UI # will not open and an error will be given. lib_maya_utils.ensure_plugin_loaded() + loadAllResources() win = SolverWindow.open_window( show=show,