Commit d7312f30 authored by jcfr's avatar jcfr
Browse files

ENH: SlicerQT - Improve QT Designer launcher:

  - Comment
  - Handle Darwin OS to be able to launch designer
  - Handle Cygwin in order to update OS environment properly

git-svn-id: http://svn.slicer.org/Slicer4/trunk@11550 3bd1e089-480b-0410-8dfb-8563597acbee
parent d3c4b7d4
# Configure Qt Designer launcher
IF(Slicer3_USE_QT)
GET_TARGET_PROPERTY(output_directory ${PROJECT_NAME} LIBRARY_OUTPUT_DIRECTORY)
#MESSAGE(STATUS CMAKE_CONFIGURATION_TYPES:${CMAKE_CONFIGURATION_TYPES})
#MESSAGE(STATUS CMAKE_BUILD_TYPE:${CMAKE_BUILD_TYPE})
IF(CMAKE_CONFIGURATION_TYPES)
FOREACH(config ${CMAKE_CONFIGURATION_TYPES})
SET(LIBRARY_OUTPUT_DIRECTORY ${output_directory}/${config})
SET(designer_launcher "${Slicer3_BINARY_DIR}/Designer-${config}.py")
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/Designer.py.in
${designer_launcher}
IMMEDIATE
)
MESSAGE(STATUS "Configuring Designer launcher:"${designer_launcher})
ENDFOREACH(config)
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(LIBRARY_OUTPUT_DIRECTORY ${output_directory})
SET(designer_launcher "${Slicer3_BINARY_DIR}/Designer.py")
#
# Configure Qt Designer launcher (Designer.py.in) allowing to:
# - update the environment variable QT_PLUGIN_PATH with Slicer QT Plugin path
# - update PATH with Slicer libraries
# - start the designer
#
# --------------------------------------------------------------
SET(designer_launcher_project_name SlicerQT)
SET(designer_launcher_directory ${Slicer3_BINARY_DIR})
# --------------------------------------------------------------
GET_TARGET_PROPERTY(output_directory ${designer_launcher_project_name} LIBRARY_OUTPUT_DIRECTORY)
#MESSAGE(STATUS CMAKE_CONFIGURATION_TYPES:${CMAKE_CONFIGURATION_TYPES})
#MESSAGE(STATUS CMAKE_BUILD_TYPE:${CMAKE_BUILD_TYPE})
#MESSAGE(STATUS output_directory:${output_directory})
# Convert path
FILE(TO_NATIVE_PATH ${LIBRARY_OUTPUT_DIRECTORY} NATIVE_LIBRARY_OUTPUT_DIRECTORY)
FILE(TO_NATIVE_PATH ${QT_BINARY_DIR} NATIVE_QT_BINARY_DIR)
IF(CMAKE_CONFIGURATION_TYPES)
# Loop through all Configuration types
# For further details, see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_CONFIGURATION_TYPES
FOREACH(config ${CMAKE_CONFIGURATION_TYPES})
SET(LIBRARY_OUTPUT_DIRECTORY ${output_directory}/${config})
SET(designer_launcher "${designer_launcher_directory}/Designer-${config}.py")
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/Designer.py.in
${designer_launcher}
IMMEDIATE
)
MESSAGE(STATUS "Configuring Designer launcher:"${designer_launcher})
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(Slicer3_USE_QT)
MESSAGE(STATUS "Configuring Designer launcher: "${designer_launcher})
ENDFOREACH(config)
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(LIBRARY_OUTPUT_DIRECTORY ${output_directory})
SET(designer_launcher "${designer_launcher_directory}/Designer.py")
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/Designer.py.in
${designer_launcher}
IMMEDIATE
)
MESSAGE(STATUS "Configuring Designer launcher: "${designer_launcher})
ENDIF(CMAKE_CONFIGURATION_TYPES)
#! /usr/bin/env python
"""
This module allows to:
- update the environement variable QT_PLUGIN_PATH with Slicer QT Plugin path
After been configured properly using CMAKE,
this module allows to:
- update the environment variable QT_PLUGIN_PATH with Slicer QT Plugin path
- update PATH with Slicer libraries
- start the designer
"""
......@@ -9,26 +10,33 @@ This module allows to:
import os
import sys
def startDesigner(argv):
def startDesigner(open_command, argv):
"Start QT Designer"
addEnvVariable('QT_PLUGIN_PATH', '@LIBRARY_OUTPUT_DIRECTORY@')
addEnvVariable('PATH', '@LIBRARY_OUTPUT_DIRECTORY@')
os.execv('@QT_BINARY_DIR@/'+argv[0], argv)
addEnvVariable('QT_PLUGIN_PATH', '@NATIVE_LIBRARY_OUTPUT_DIRECTORY@')
addEnvVariable('PATH', '@NATIVE_LIBRARY_OUTPUT_DIRECTORY@')
os.execv(open_command+'@NATIVE_QT_BINARY_DIR@'+os.sep+argv[0], argv)
def addEnvVariable(name, value):
"Add variable to environement"
"Add variable to environment"
# If platform is cygwin, force pathseparator to be ':'
pathsep = os.pathsep
if (sys.platform == 'cygwin'):
pathsep = ':'
# Update OS environment
if (name in os.environ):
sep = ''
if (os.environ[name] != ""):
sep = os.pathsep
sep = pathsep
os.environ[name] += (sep + value)
else:
os.environ[name] = value
# Entry point
if __name__ == "__main__":
if (len(sys.argv) > 2):
......@@ -38,6 +46,15 @@ designer.py - Start QT Designer with Slicer plugins
Use: python designer.py [UI file]
"""
else:
# Default executable name
executable_name ='designer'
open_command = ''
# Handle MACOSX case
if sys.platform == 'darwin':
executable_name = 'Designer.app'
open_command = 'open '
# Update first value to match executable name
sys.argv[0] ='designer'
startDesigner(sys.argv);
sys.argv[0] = executable_name
startDesigner(open_command, sys.argv);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment