From fea7b66b5685c29ec2c781e27a1d7ebba2975aef Mon Sep 17 00:00:00 2001 From: ana Date: Wed, 11 Jan 2012 11:48:25 +0000 Subject: [PATCH] Porting GUI_SRC/tools/dlgfactory on win32 platform --- tools/dlgfactory/Makefile.am | 10 ++-- tools/dlgfactory/README.txt | 2 +- tools/dlgfactory/dlgfactory.py | 100 +++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 6 deletions(-) create mode 100755 tools/dlgfactory/dlgfactory.py diff --git a/tools/dlgfactory/Makefile.am b/tools/dlgfactory/Makefile.am index 0bbee5a1e..bff7070a1 100644 --- a/tools/dlgfactory/Makefile.am +++ b/tools/dlgfactory/Makefile.am @@ -58,18 +58,18 @@ GDIALOG_TEMPLATES = __GDIALOG__.ui __GDIALOG__.hxx __GDIALOG__.cxx BUILT_SOURCES = $(UIC_FILES_QDIALOG) $(UIC_FILES_GDIALOG) # extra distributed files -EXTRA_DIST += $(QDIALOG_TEMPLATES) $(GDIALOG_TEMPLATES) GenericDialog.ui README.txt dlgfactory.sh +EXTRA_DIST += $(QDIALOG_TEMPLATES) $(GDIALOG_TEMPLATES) GenericDialog.ui README.txt dlgfactory.py mostlyclean-local: rm @builddir@/QDialogTest* rm @builddir@/GDialogTest* rm -f @builddir@/*_moc.cxx @builddir@/ui_*.hxx -QDialogTest.hxx QDialogTest.cxx QDialogTest.ui: $(QDIALOG_TEMPLATES) dlgfactory.sh - $(srcdir)/dlgfactory.sh -n QDialogTest -t qdialog +QDialogTest.hxx QDialogTest.cxx QDialogTest.ui: $(QDIALOG_TEMPLATES) dlgfactory.py + $(srcdir)/dlgfactory.py -n QDialogTest -t qdialog -GDialogTest.hxx GDialogTest.cxx GDialogTest.ui : $(GDIALOG_TEMPLATES) dlgfactory.sh - $(srcdir)/dlgfactory.sh -n GDialogTest -t gdialog +GDialogTest.hxx GDialogTest.cxx GDialogTest.ui : $(GDIALOG_TEMPLATES) dlgfactory.py + $(srcdir)/dlgfactory.py -n GDialogTest -t gdialog QT_CXXFLAGS=@QT_INCLUDES@ @QT_MT_INCLUDES@ QT_LIBS=@QT_LIBS@ diff --git a/tools/dlgfactory/README.txt b/tools/dlgfactory/README.txt index 1ddca1679..ec1c00559 100644 --- a/tools/dlgfactory/README.txt +++ b/tools/dlgfactory/README.txt @@ -2,7 +2,7 @@ This package provides a simple tool to generates the bootstrap files of a standard Qt dialog. Nothing original neither very smart, but just help to initiate all this stuff the good way. -See the header of the script dlgfactory.sh for details. +See the header of the script dlgfactory.py for details. Some use cases (basic unit test) are given in the files qtester.cxx and gtester.cxx. The build procedure (when you type make) create test diff --git a/tools/dlgfactory/dlgfactory.py b/tools/dlgfactory/dlgfactory.py new file mode 100755 index 000000000..8774a815a --- /dev/null +++ b/tools/dlgfactory/dlgfactory.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python + +import sys, os +from optparse import OptionParser +import shutil, fileinput + +descr_str = """ + This script generates a set of files to initiate a dialog qt window + (i.e. MyDialog.ui, MyDialog.hxx and MyDialog.cxx files). + + The dialog window can be a self-consistent class (i.e. depends only + on Qt classes) or a classe that inherits from the class + GenericDialog whose implementation is provided in this package and + whose design is defined by the GenericDialog.ui file (editable using + the qt designer). + + The -t option let you choose between the two possibilities (specify + "-t qdialog" for the first case, "-t gdialog" otherwise). +""" +msg_str = """ +# +# --------------------------------------------------------- +# Generation rules to create moc files from QObject headers +# and form source files from ui files +# --------------------------------------------------------- + +%_moc.cxx: %.hxx + $(MOC) $< -o $@ + +ui_%.hxx: %.ui + $(UIC) -o $@ $< + + +# --------------------------------------------------------- +# Declaration of form files generated by UIC and MOC files +# as BUILT_SOURCES to be used in the building process. +# --------------------------------------------------------- +# +UIC_FILES = \ + ui___CLASSNAME__.hxx +# +MOC_FILES = \ + __CLASSNAME___moc.cxx + +BUILT_SOURCES = $(UIC_FILES) + +# +# --------------------------------------------------------- +# Declaration of sources files to the building process +# --------------------------------------------------------- +# MOC files and UIC files should be added to the list of undistributed +# source files with something like (where should be +# replaced by the name of the product declared by the directive +# lib_LTLIBRARIES): +# +nodist__la_SOURCES += $(MOC_FILES) $(UIC_FILES) + +dist__la_SOURCES += __CLASSNAME__.cxx +salomeinclude_HEADERS += __CLASSNAME__.hxx + +_la_CPPFLAGS = \\ + $(QT_CXXFLAGS) + +_la_LDFLAGS = \\ + $(QT_LIBS) +""" + +tool_path = os.path.dirname( os.path.abspath(__file__) ) + +parser = OptionParser(description=descr_str) +parser.add_option("-n", action="store", default="TestDialog", + help="specify the name of the class (default is TestDialog)", metavar="className") +parser.add_option("-t", action="store", default="qdialog", + choices=["qdialog", "gdialog"], + help="specify the type of the class (default is qdialog)", metavar="classType") + +(options, args) = parser.parse_args() +className = options.n +classType = options.t + +sep = os.path.sep +for ext in [".cxx", ".hxx", ".ui"]: + file_dest = className + ext + if classType == "qdialog": + file_src = tool_path + sep + "__QDIALOG__" + ext + else: + file_src = tool_path + sep + "__GDIALOG__" + ext + shutil.copyfile(file_src, file_dest) + finput = fileinput.FileInput(file_dest,inplace=1) + for line in finput: + line = line[:-1] + line = line.replace("__CLASSNAME__",className) + print line + +print "Note that the following directives should be present in your Makefile.am (or something like that): \n" +print msg_str.replace("__CLASSNAME__",className) + + + + \ No newline at end of file -- 2.39.2