version 2.0.0_alpha
Important! All QtWraps macros renamed! Qt 6 support Graphic export feature qad_types cross-Qt small changes
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||||
project(qad)
|
project(qad)
|
||||||
set(qad_MAJOR 1)
|
set(qad_MAJOR 2)
|
||||||
set(qad_MINOR 18)
|
set(qad_MINOR 0)
|
||||||
set(qad_REVISION 0)
|
set(qad_REVISION 0)
|
||||||
set(qad_SUFFIX )
|
set(qad_SUFFIX alpha)
|
||||||
set(qad_COMPANY SHS)
|
set(qad_COMPANY SHS)
|
||||||
set(qad_DOMAIN org.SHS)
|
set(qad_DOMAIN org.SHS)
|
||||||
|
|
||||||
@@ -32,17 +32,17 @@ option(UTILS "Build various utils" ${_plugins_default_})
|
|||||||
option(DESIGNER_PLUGINS "Build Qt designer plugins" ${_plugins_default_})
|
option(DESIGNER_PLUGINS "Build Qt designer plugins" ${_plugins_default_})
|
||||||
|
|
||||||
macro(qad_library NAME _MODULES _LIBS)
|
macro(qad_library NAME _MODULES _LIBS)
|
||||||
shstk_qt_project(qad_${NAME} FALSE "qad" "${_MODULES}" "${_LIBS}" ${ARGN})
|
shstk_qad_project(qad_${NAME} FALSE "qad" "${_MODULES}" "${_LIBS}" ${ARGN})
|
||||||
shstk_qt_install("qad" FALSE qad_${NAME} "${out_HDR}" "out_QM")
|
shstk_qad_install("qad" FALSE qad_${NAME} "${out_HDR}" "out_QM")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(qad_application NAME _MODULES _LIBS)
|
macro(qad_application NAME _MODULES _LIBS)
|
||||||
shstk_qt_project(${NAME} TRUE "qad" "${_MODULES}" "${_LIBS}" ${ARGN})
|
shstk_qad_project(${NAME} TRUE "qad" "${_MODULES}" "${_LIBS}" ${ARGN})
|
||||||
shstk_qt_install("qad" TRUE ${NAME} "" "out_QM")
|
shstk_qad_install("qad" TRUE ${NAME} "" "out_QM")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(qad_plugin NAME _MODULES _LIBS)
|
macro(qad_plugin NAME _MODULES _LIBS)
|
||||||
shstk_qt_plugin(qad_${NAME} "${_MODULES}" "qad_${NAME};${_LIBS}")
|
shstk_qad_plugin(qad_${NAME} "${_MODULES}" "qad_${NAME};${_LIBS}")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
shstk_install(qad FALSE "" "${qad_VERSION_FILE}")
|
shstk_install(qad FALSE "" "${qad_VERSION_FILE}")
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ shstk_is_parent_exists(hasParent PARENT_DIRECTORY)
|
|||||||
shstk_set_find_dirs(qad)
|
shstk_set_find_dirs(qad)
|
||||||
set(_SEARCH_DIR ${qad_LIBDIR})
|
set(_SEARCH_DIR ${qad_LIBDIR})
|
||||||
|
|
||||||
find_qt(Core QUIET)
|
qad_find_qt(Core QUIET)
|
||||||
if(NOT SOME_QT_FOUND)
|
if(NOT SOME_QT_FOUND)
|
||||||
message(WARNING "No qt found, please install qt")
|
message(WARNING "No qt found, please install qt")
|
||||||
set(QAD_FOUND OFF CACHE BOOL "")
|
set(QAD_FOUND OFF CACHE BOOL "")
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
#[[
|
#[[
|
||||||
|
|
||||||
find_qt([<Module1> <Module2> ...] [Qt4] [Qt5])
|
qad_find_qt([<Module1> <Module2> ...] [Qt4] [Qt5] [Qt6])
|
||||||
|
|
||||||
Find Qt4 or/and Qt5 packages
|
Find Qt4 or/and Qt5, Qt6 packages
|
||||||
If Qt4/5 found, set
|
If Qt4/5/6 found, set
|
||||||
* Qt<4/5>_ROOT var to Qt root dir
|
* Qt<4/5/6>_ROOT var to Qt root dir
|
||||||
* Qt<4/5>_BIN var to Qt binary dir
|
* Qt<4/5/6>_BIN var to Qt binary dir
|
||||||
* Qt<4/5>_PLUGINS_DIR var to Qt plugins dir
|
* Qt<4/5/6>_PLUGINS_DIR var to Qt plugins dir
|
||||||
* Qt<4/5>_LANG_DIR var to Qt translations dir
|
* Qt<4/5/6>_LANG_DIR var to Qt translations dir
|
||||||
Also set variable SOME_QT_FOUND
|
Also set variable SOME_QT_FOUND
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_sources(<src_out_var> [NO_DEFAULT] [DIR <dir>] [<regexp> ...])
|
qad_sources(<src_out_var> [NO_DEFAULT] [DIR <dir>] [<regexp> ...])
|
||||||
|
|
||||||
Collect all sources, optionally in directory <dir> and
|
Collect all sources, optionally in directory <dir> and
|
||||||
Additional filters <regexp>. By default filter files with regexps
|
Additional filters <regexp>. By default filter files with regexps
|
||||||
@@ -23,34 +23,34 @@ Default filters disabled with option NO_DEFAULT
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_wrap(<file0> <file1> ... [HDRS <hrd_var>] [CPPS <cpp_var>] [QMS <qm_var>])
|
qad_wrap(<file0> <file1> ... [HDRS <hrd_var>] [CPPS <cpp_var>] [QMS <qm_var>])
|
||||||
|
|
||||||
Prepare sources for compile
|
Prepare sources for compile
|
||||||
Store headers to <hrd_var>, all wrapped Qt4 files to <cpp_var>_Qt4 and Qt5 files to <cpp_var>_Qt5
|
Store headers to <hrd_var>, all wrapped Qt4 files to <cpp_var>_Qt4, Qt5 files to <cpp_var>_Qt5 and Qt6 files to <cpp_var>_Qt6
|
||||||
version are automatic detected after find_qt() call
|
version are automatic detected after qad_find_qt() call
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] source1 [source2 ...])
|
qad_add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] source1 [source2 ...])
|
||||||
|
|
||||||
Add executables for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
|
Add executables for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
|
||||||
All needed Qt includes automatic added to corresponding targets
|
All needed Qt includes automatic added to corresponding targets
|
||||||
<source> cant be CPPS variable passed to qt_wrap() or some list or filename
|
<source> cant be CPPS variable passed to qad_wrap() or some list or filename
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] source1 [source2 ...])
|
qad_add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] source1 [source2 ...])
|
||||||
|
|
||||||
Add library for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
|
Add library for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
|
||||||
All needed Qt includes automatic added to corresponding targets
|
All needed Qt includes automatic added to corresponding targets
|
||||||
<source> cant be CPPS variable passed to qt_wrap() or some list or filename
|
<source> cant be CPPS variable passed to qad_wrap() or some list or filename
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_target_link_libraries(<name> ... <item> ...)
|
qad_target_link_libraries(<name> ... <item> ...)
|
||||||
|
|
||||||
Link targets for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
|
Link targets for founded Qt versions, target names is <name><TARGET_SUFFIX_Qt?>
|
||||||
All needed Qt libraries automatic added to corresponding targets
|
All needed Qt libraries automatic added to corresponding targets
|
||||||
@@ -60,7 +60,7 @@ add <MULTILIB_SUFFIX_Qt?> or individual <MULTILIB_>libname<_SUFFIX_Qt?>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_target_compile_definitions(<name> ...)
|
qad_target_compile_definitions(<name> ...)
|
||||||
|
|
||||||
Syntax similar to original "target_compile_definitions()"
|
Syntax similar to original "target_compile_definitions()"
|
||||||
Specify compile definitions to use when compiling a given <name>
|
Specify compile definitions to use when compiling a given <name>
|
||||||
@@ -68,7 +68,7 @@ Specify compile definitions to use when compiling a given <name>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_target_include_directories(<name> ...)
|
qad_target_include_directories(<name> ...)
|
||||||
|
|
||||||
Syntax similar to original "target_include_directories()"
|
Syntax similar to original "target_include_directories()"
|
||||||
Add include directories to a target
|
Add include directories to a target
|
||||||
@@ -76,7 +76,7 @@ Add include directories to a target
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_install(...)
|
qad_install(...)
|
||||||
|
|
||||||
Syntax similar to original "install()"
|
Syntax similar to original "install()"
|
||||||
Install targets for founded Qt versions
|
Install targets for founded Qt versions
|
||||||
@@ -90,12 +90,12 @@ to corresponding Qt plugins directory
|
|||||||
|
|
||||||
Add LANG type for first argument - in this case you should
|
Add LANG type for first argument - in this case you should
|
||||||
specify variable name, not variable value!
|
specify variable name, not variable value!
|
||||||
e.g. "qt_install(LANG my_QM DESTINATION QtLang)"
|
e.g. "qad_install(LANG my_QM DESTINATION QtLang)"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_install_lang(<name> DESTINATION <dir> [PATHS <path0> [<path1>] [...] ])
|
qad_install_lang(<name> DESTINATION <dir> [PATHS <path0> [<path1>] [...] ])
|
||||||
|
|
||||||
Search Qt translations for all <name> dependencies
|
Search Qt translations for all <name> dependencies
|
||||||
in Qt<?>_LANG_DIR for <name>_LANG languages
|
in Qt<?>_LANG_DIR for <name>_LANG languages
|
||||||
@@ -105,23 +105,23 @@ You should use "set_lang()" macro before this action
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_get_target(<name> <var> [Qt4 | Qt5])
|
qad_get_target(<name> <var> [Qt4 | Qt5 | Qt6])
|
||||||
|
|
||||||
Write real <name> Qt target name to <var>
|
Write real <name> Qt target name to <var>
|
||||||
If Qt4 or Qt5 specified, search for this version,
|
If Qt4 or Qt5, Qt6 specified, search for this version,
|
||||||
otherwise returns greatest version
|
otherwise returns greatest version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_get_targets(<name> <var>)
|
qad_get_targets(<name> <var>)
|
||||||
|
|
||||||
Write all real <name> Qt target names to <var>
|
Write all real <name> Qt target names to <var>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qt_generate_export_header(<name> ...)
|
qad_generate_export_header(<name> ...)
|
||||||
|
|
||||||
Call generate_export_header on Qt multitarget
|
Call generate_export_header on Qt multitarget
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ QuickControls2;QuickParticles;QuickShapes;QuickTemplates2;QuickTest;QuickWidgets
|
|||||||
ShaderTools;Sql;Svg;SvgWidgets;Test;Tools;UiPlugin;UiTools;Widgets;Xml")
|
ShaderTools;Sql;Svg;SvgWidgets;Test;Tools;UiPlugin;UiTools;Widgets;Xml")
|
||||||
|
|
||||||
|
|
||||||
set(_QT_VERSIONS_ 4 5)
|
set(_QT_VERSIONS_ 4 5 6)
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (NOT DEFINED TARGET_SUFFIX_Qt${_v})
|
if (NOT DEFINED TARGET_SUFFIX_Qt${_v})
|
||||||
set(TARGET_SUFFIX_Qt${_v} "${_v}")
|
set(TARGET_SUFFIX_Qt${_v} "${_v}")
|
||||||
@@ -176,7 +176,7 @@ endif()
|
|||||||
#set(TARGET_SUFFIX_Qt4 "")
|
#set(TARGET_SUFFIX_Qt4 "")
|
||||||
|
|
||||||
|
|
||||||
macro(find_qt)
|
macro(qad_find_qt)
|
||||||
set(_QCOMP)
|
set(_QCOMP)
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
set(_NEED${_v} 0)
|
set(_NEED${_v} 0)
|
||||||
@@ -307,6 +307,75 @@ macro(find_qt)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if (_NEED6)
|
||||||
|
#set(_MSG 1)
|
||||||
|
#if (Qt6_FOUND)
|
||||||
|
# set(_MSG 0)
|
||||||
|
#endif()
|
||||||
|
set(_QCOMP6 Core LinguistTools UiPlugin Widgets ${_QCOMP})
|
||||||
|
list(REMOVE_DUPLICATES _QCOMP6)
|
||||||
|
find_package(Qt6 COMPONENTS ${_QCOMP6} QUIET)
|
||||||
|
if (DEFINED ANDROID_PLATFORM)
|
||||||
|
set(CMAKE_SHARED_MODULE_SUFFIX_CXX ".so")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".so")
|
||||||
|
set(CMAKE_SHARED_MODULE_SUFFIX_C ".so")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_SUFFIX_C ".so")
|
||||||
|
endif()
|
||||||
|
if (Qt6Core_FOUND)
|
||||||
|
set(LOCAL_FOUND6 1)
|
||||||
|
set(_Qt6Modules)
|
||||||
|
foreach(m ${_QCOMP6})
|
||||||
|
if (m IN_LIST __qt_modules_6)
|
||||||
|
if (${Qt6${m}_FOUND})
|
||||||
|
set(__lib ${Qt6${m}_LIBRARIES})
|
||||||
|
if (DEFINED ANDROID_PLATFORM)
|
||||||
|
if (m IN_LIST __qt_bug_modules)
|
||||||
|
get_target_property(__lib Qt6::${m} LOCATION)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
list(APPEND _Qt6Modules ${m})
|
||||||
|
list(APPEND Qt6_INCLUDES ${Qt6${m}_INCLUDE_DIRS})
|
||||||
|
list(APPEND Qt6_LIBRARIES ${__lib})
|
||||||
|
else()
|
||||||
|
if (NOT "x${_QUIET}" STREQUAL "xQUIET")
|
||||||
|
message(FATAL_ERROR "Qt6${m} NOT FOUND")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
#get_property(_up_dir TARGET Qt6::UiPlugin PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
#message("${_up_dir}")
|
||||||
|
#if (NOT "x${_up_dir}" STREQUAL "x")
|
||||||
|
# list(APPEND Qt6_INCLUDES ${_up_dir})
|
||||||
|
#endif()
|
||||||
|
get_target_property(_Qt6_qmake Qt6::qmake LOCATION)
|
||||||
|
get_filename_component(_Qt6_BIN ${_Qt6_qmake} PATH)
|
||||||
|
foreach(_p ${Qt6Gui_PLUGINS})
|
||||||
|
get_target_property(_l ${_p} LOCATION)
|
||||||
|
get_filename_component(_l ${_l} DIRECTORY)
|
||||||
|
string(FIND "${_l}" "/" _ind REVERSE)
|
||||||
|
string(SUBSTRING "${_l}" 0 ${_ind} _l)
|
||||||
|
#message("Qt6: plugins dir: ${Qt6_PLUGINS_DIR}")
|
||||||
|
break()
|
||||||
|
endforeach()
|
||||||
|
string(FIND "${_Qt6_BIN}" "/" _ind REVERSE)
|
||||||
|
string(SUBSTRING "${_Qt6_BIN}" 0 ${_ind} _Qt6_ROOT)
|
||||||
|
set(Qt6_ROOT "${_Qt6_ROOT}" CACHE STRING "")
|
||||||
|
set(Qt6_BIN "${_Qt6_BIN}" CACHE STRING "")
|
||||||
|
set(Qt6_LANG_DIR ${Qt6_BIN}/../translations CACHE STRING "")
|
||||||
|
if ("x${Qt6_PLUGINS_DIR}" STREQUAL "x")
|
||||||
|
set(Qt6_PLUGINS_DIR "${Qt6_ROOT}/plugins" CACHE STRING "")
|
||||||
|
endif()
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND MOC_INC_Qt6 "-F${Qt6_ROOT}/lib")
|
||||||
|
endif()
|
||||||
|
if (NOT _QT6_MSG)
|
||||||
|
message(STATUS "Found Qt6: ${_Qt6_qmake} (version \"${Qt6_VERSION}\")")
|
||||||
|
set(_QT6_MSG 1 CACHE BOOL "msg_qt6" FORCE)
|
||||||
|
message(STATUS "Found Qt6 modules: ${_Qt6Modules}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
set(SOME_QT_FOUND 1 CACHE BOOL "" FORCE)
|
set(SOME_QT_FOUND 1 CACHE BOOL "" FORCE)
|
||||||
@@ -321,7 +390,7 @@ macro(find_qt)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_sources OUT)
|
macro(qad_sources OUT)
|
||||||
set(${OUT})
|
set(${OUT})
|
||||||
set(_DIR "")
|
set(_DIR "")
|
||||||
set(_IS_DIR 0)
|
set(_IS_DIR 0)
|
||||||
@@ -357,7 +426,7 @@ macro(qt_sources OUT)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_wrap)
|
macro(qad_wrap)
|
||||||
set(HDR_VAR)
|
set(HDR_VAR)
|
||||||
set(CPP_VAR)
|
set(CPP_VAR)
|
||||||
set(QM_VAR)
|
set(QM_VAR)
|
||||||
@@ -471,8 +540,16 @@ macro(qt_wrap)
|
|||||||
set(${QM${_v}_VAR} "")
|
set(${QM${_v}_VAR} "")
|
||||||
qt5_add_translation(${QM${_v}_VAR} ${TS_LIST})
|
qt5_add_translation(${QM${_v}_VAR} ${TS_LIST})
|
||||||
endif()
|
endif()
|
||||||
|
elseif (${_v} EQUAL 6)
|
||||||
|
qt6_wrap_cpp(MOCS${_v} ${H_LIST} OPTIONS -nw ${MOC_INC_Qt6})
|
||||||
|
qt6_wrap_ui(CUIS${_v} ${UI_LIST})
|
||||||
|
qt6_add_resources(CRES${_v} ${RES_LIST})
|
||||||
|
if (WAS_QM_ARG)
|
||||||
|
set(${QM${_v}_VAR} "")
|
||||||
|
qt6_add_translation(${QM${_v}_VAR} ${TS_LIST})
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# Qt6 ...
|
# Qt7 ...
|
||||||
endif()
|
endif()
|
||||||
#message("${${QM${_v}_VAR}}")
|
#message("${${QM${_v}_VAR}}")
|
||||||
list(APPEND ${CPP${_v}_VAR} ${CPP_LIST})
|
list(APPEND ${CPP${_v}_VAR} ${CPP_LIST})
|
||||||
@@ -520,7 +597,8 @@ macro(__qt_set_defines _NAME _T)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_add_executable _NAME)
|
macro(qad_add_executable _NAME)
|
||||||
|
#message("*qad_add_executable: \"${_NAME}\"")
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
_qt_split_add_args(_PREF _ARGS ${ARGN})
|
_qt_split_add_args(_PREF _ARGS ${ARGN})
|
||||||
@@ -537,6 +615,7 @@ macro(qt_add_executable _NAME)
|
|||||||
set(_${_NAME}_is_qt 1)
|
set(_${_NAME}_is_qt 1)
|
||||||
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/qt${_v} ${Qt${_v}_INCLUDES})
|
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/qt${_v} ${Qt${_v}_INCLUDES})
|
||||||
__qt_set_defines(${_NAME} ${_TARGET})
|
__qt_set_defines(${_NAME} ${_TARGET})
|
||||||
|
#message("add exe: \"${_TARGET}\"")
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_INSTALL_NAME_DIR "${_PREV_CIND}")
|
set(CMAKE_INSTALL_NAME_DIR "${_PREV_CIND}")
|
||||||
@@ -559,7 +638,8 @@ macro(qt_add_executable _NAME)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_add_library _NAME)
|
macro(qad_add_library _NAME)
|
||||||
|
#message("*qad_add_library: \"${_NAME}\"")
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
_qt_split_add_args(_PREF _ARGS ${ARGN})
|
_qt_split_add_args(_PREF _ARGS ${ARGN})
|
||||||
@@ -573,6 +653,7 @@ macro(qt_add_library _NAME)
|
|||||||
endif()
|
endif()
|
||||||
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
||||||
add_library(${_TARGET} ${_PREF} ${_ARGS})
|
add_library(${_TARGET} ${_PREF} ${_ARGS})
|
||||||
|
#message("add lib: \"${_TARGET} ${_PREF}\"")
|
||||||
set(_${_NAME}_is_qt 1)
|
set(_${_NAME}_is_qt 1)
|
||||||
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/qt${_v})
|
target_include_directories(${_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/qt${_v})
|
||||||
target_include_directories(${_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${Qt${_v}_INCLUDES})
|
target_include_directories(${_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${Qt${_v}_INCLUDES})
|
||||||
@@ -610,7 +691,7 @@ macro(_qt_multitarget_suffix_ _OUT _IN _v)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_target_link_libraries _NAME)
|
macro(qad_target_link_libraries _NAME)
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
||||||
@@ -633,7 +714,7 @@ macro(qt_target_link_libraries _NAME)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_target_compile_definitions _NAME)
|
macro(qad_target_compile_definitions _NAME)
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
||||||
@@ -643,7 +724,7 @@ macro(qt_target_compile_definitions _NAME)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_target_include_directories _NAME)
|
macro(qad_target_include_directories _NAME)
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
set(_TARGET ${_NAME}${TARGET_SUFFIX_Qt${_v}})
|
||||||
@@ -653,7 +734,7 @@ macro(qt_target_include_directories _NAME)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_install)
|
macro(qad_install)
|
||||||
set(_prev_inst)
|
set(_prev_inst)
|
||||||
set(__add_args)
|
set(__add_args)
|
||||||
#message("command: ${ARGN}")
|
#message("command: ${ARGN}")
|
||||||
@@ -771,7 +852,7 @@ macro(_qt_gather_deps _T _out __p)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_install_lang _NAME)
|
macro(qad_install_lang _NAME)
|
||||||
set(_prev_inst)
|
set(_prev_inst)
|
||||||
#message("command: ${ARGN}")
|
#message("command: ${ARGN}")
|
||||||
set(_PATHS)
|
set(_PATHS)
|
||||||
@@ -849,7 +930,7 @@ macro(qt_install_lang _NAME)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_get_target _NAME _OUT)
|
macro(qad_get_target _NAME _OUT)
|
||||||
set(${_OUT})
|
set(${_OUT})
|
||||||
set(_ver)
|
set(_ver)
|
||||||
foreach(_i ${ARGN})
|
foreach(_i ${ARGN})
|
||||||
@@ -871,7 +952,7 @@ macro(qt_get_target _NAME _OUT)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_get_targets _NAME _OUT)
|
macro(qad_get_targets _NAME _OUT)
|
||||||
set(${_OUT})
|
set(${_OUT})
|
||||||
foreach(_v ${_QT_VERSIONS_})
|
foreach(_v ${_QT_VERSIONS_})
|
||||||
if (LOCAL_FOUND${_v})
|
if (LOCAL_FOUND${_v})
|
||||||
@@ -881,9 +962,9 @@ macro(qt_get_targets _NAME _OUT)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(qt_generate_export_header _NAME)
|
macro(qad_generate_export_header _NAME)
|
||||||
qt_get_target(${_NAME} _some_target)
|
qad_get_target(${_NAME} _some_target)
|
||||||
qt_get_target(${_NAME} _targets)
|
qad_get_target(${_NAME} _targets)
|
||||||
foreach(_t ${_targets})
|
foreach(_t ${_targets})
|
||||||
set_target_properties(${_t} PROPERTIES DEFINE_SYMBOL ${_NAME}_EXPORTS)
|
set_target_properties(${_t} PROPERTIES DEFINE_SYMBOL ${_NAME}_EXPORTS)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|||||||
@@ -94,7 +94,13 @@ bool EMainWindow::eventFilter(QObject * o, QEvent * e) {
|
|||||||
if (tdocks.contains((QDockWidget*)o))
|
if (tdocks.contains((QDockWidget*)o))
|
||||||
popup = popup || ((QDockWidget*)o)->titleBarWidget()->geometry().contains(((QMouseEvent*)e)->pos());
|
popup = popup || ((QDockWidget*)o)->titleBarWidget()->geometry().contains(((QMouseEvent*)e)->pos());
|
||||||
if (popup) {
|
if (popup) {
|
||||||
createPopupMenu()->popup(((QMouseEvent*)e)->globalPos());
|
createPopupMenu()->popup(
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
((QMouseEvent*)e)->globalPos()
|
||||||
|
#else
|
||||||
|
((QMouseEvent*)e)->globalPosition().toPoint()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
@@ -138,7 +137,8 @@ public slots:
|
|||||||
void newFile();
|
void newFile();
|
||||||
void openFile();
|
void openFile();
|
||||||
void openFiles();
|
void openFiles();
|
||||||
bool saveFile(bool ask = false);
|
bool saveFile(bool ask);
|
||||||
|
bool saveFile() {return saveFile(false);}
|
||||||
bool saveAsFile();
|
bool saveAsFile();
|
||||||
void clearRecent();
|
void clearRecent();
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ public slots:
|
|||||||
void setDuplicatesEnabled(bool yes) {duplicates_ = yes;}
|
void setDuplicatesEnabled(bool yes) {duplicates_ = yes;}
|
||||||
void setLimit(int l);
|
void setLimit(int l);
|
||||||
void setHistoryColor(const QColor & c);
|
void setHistoryColor(const QColor & c);
|
||||||
void clear(bool silent = false);
|
void clear(bool silent);
|
||||||
|
void clear() {clear(false);}
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void AlignedTextItem::setFont(const QFont & f) {
|
|||||||
|
|
||||||
QFont AlignedTextItem::sceneFont(const QFont & f) {
|
QFont AlignedTextItem::sceneFont(const QFont & f) {
|
||||||
QFont ret = f;
|
QFont ret = f;
|
||||||
double scl = 16. / QApplication::fontMetrics().size(0, "0").height();
|
double scl = 16. / fontHeight();
|
||||||
ret.setPointSizeF(ret.pointSizeF() * scl);
|
ret.setPointSizeF(ret.pointSizeF() * scl);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -609,9 +609,9 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
|||||||
if (endpoints().contains(selPoint))
|
if (endpoints().contains(selPoint))
|
||||||
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
||||||
}
|
}
|
||||||
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||||
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
|
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||||
if (btncnt > 0) mm_mods = e->modifiers();
|
if (btncnt > 0) mm_mods = e->modifiers();
|
||||||
if (btncnt >= 2 && e->button() == Qt::RightButton) {
|
if (btncnt >= 2 && e->button() == Qt::RightButton) {
|
||||||
//qDebug() << "bus revert";
|
//qDebug() << "bus revert";
|
||||||
@@ -722,9 +722,9 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
|||||||
void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||||
mm_mods = Qt::KeyboardModifiers();
|
mm_mods = Qt::KeyboardModifiers();
|
||||||
int btncnt = 0;
|
int btncnt = 0;
|
||||||
if (e->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||||
if (e->buttons().testFlag(Qt::MidButton)) btncnt++;
|
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||||
if (btncnt == 0) mm_cancel = false;
|
if (btncnt == 0) mm_cancel = false;
|
||||||
if (new_segment) {
|
if (new_segment) {
|
||||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchAccept", Q_ARG(BlockBusItem * , this));
|
QMetaObject::invokeMethod(scene()->views().back(), "newBranchAccept", Q_ARG(BlockBusItem * , this));
|
||||||
|
|||||||
@@ -168,9 +168,10 @@ void BlockItem::clearPins() {
|
|||||||
void BlockItem::clearDecors() {
|
void BlockItem::clearDecors() {
|
||||||
bool pbs = false;
|
bool pbs = false;
|
||||||
if (scene()) pbs = scene()->blockSignals(true);
|
if (scene()) pbs = scene()->blockSignals(true);
|
||||||
if (scene())
|
if (scene()) {
|
||||||
foreach (QGraphicsItem * i, decors_)
|
foreach (QGraphicsItem * i, decors_)
|
||||||
scene()->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
|
scene()->sendEvent(i, new QGraphicsSceneEvent(QEvent::Close));
|
||||||
|
}
|
||||||
qDeleteAll(decors_);
|
qDeleteAll(decors_);
|
||||||
decors_.clear();
|
decors_.clear();
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
|
|||||||
@@ -14,14 +14,6 @@
|
|||||||
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
|
const QString _BlockView_Mime_ = "_BlockView_copypaste_";
|
||||||
|
|
||||||
|
|
||||||
template <typename T> QSet<T> QList2QSet(const QList<T> & l) {
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
||||||
return QSet<T>(l.begin(), l.end());
|
|
||||||
#else
|
|
||||||
return QSet<T>::fromList(l);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockView::BlockView(QWidget * parent): QGraphicsView(parent), tmp_bus(true) {
|
BlockView::BlockView(QWidget * parent): QGraphicsView(parent), tmp_bus(true) {
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
@@ -218,7 +210,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
}
|
}
|
||||||
if (me->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
if (me->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||||
if (me->buttons().testFlag(Qt::MidButton )) btncnt++;
|
if (me->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||||
mm_cancel = btncnt >= 2;
|
mm_cancel = btncnt >= 2;
|
||||||
match_bus = bus_from = 0;
|
match_bus = bus_from = 0;
|
||||||
hpin = 0;
|
hpin = 0;
|
||||||
@@ -266,7 +258,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
mm_drag = moved = false;
|
mm_drag = moved = false;
|
||||||
screen_point = me->screenPos();
|
screen_point = me->screenPos();
|
||||||
scene_point = me->scenePos();
|
scene_point = me->scenePos();
|
||||||
if ((me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
|
if ((me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
|
||||||
thumbShow();
|
thumbShow();
|
||||||
restartTimer(timer_thumb, thumb_hide_delay);
|
restartTimer(timer_thumb, thumb_hide_delay);
|
||||||
return true;
|
return true;
|
||||||
@@ -525,10 +517,10 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
case QEvent::GraphicsSceneMouseRelease:
|
case QEvent::GraphicsSceneMouseRelease:
|
||||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||||
if (me->buttons().testFlag(Qt::MidButton)) btncnt++;
|
if (me->buttons().testFlag(QT_MID_BUTTON)) btncnt++;
|
||||||
cur_bus = 0;
|
cur_bus = 0;
|
||||||
mm_cancel = btncnt > 0;
|
mm_cancel = btncnt > 0;
|
||||||
if (mm_cancel || (me->button() == Qt::MidButton) || (me->button() == Qt::RightButton)) {
|
if (mm_cancel || (me->button() == QT_MID_BUTTON) || (me->button() == Qt::RightButton)) {
|
||||||
mm_ci = 0;
|
mm_ci = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -665,19 +657,19 @@ void BlockView::timerEvent(QTimerEvent * e) {
|
|||||||
void BlockView::wheelEvent(QWheelEvent * e) {
|
void BlockView::wheelEvent(QWheelEvent * e) {
|
||||||
if (!navigation) return;
|
if (!navigation) return;
|
||||||
if (wheel_zoom || e->modifiers().testFlag(Qt::ControlModifier)) {
|
if (wheel_zoom || e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
double scl = 1. - e->angleDelta().y() / 500.;
|
|
||||||
#else
|
|
||||||
double scl = 1. - e->delta() / 500.;
|
double scl = 1. - e->delta() / 500.;
|
||||||
|
#else
|
||||||
|
double scl = 1. - e->angleDelta().y() / 500.;
|
||||||
#endif
|
#endif
|
||||||
if (!is_nav_anim || (nav_anim.state() != QPropertyAnimation::Running))
|
if (!is_nav_anim || (nav_anim.state() != QPropertyAnimation::Running))
|
||||||
nav_target = _nav();
|
nav_target = _nav();
|
||||||
QRectF r = nav_target;
|
QRectF r = nav_target;
|
||||||
double vw = viewport()->width(), vh = viewport()->height();
|
double vw = viewport()->width(), vh = viewport()->height();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
|
|
||||||
#else
|
|
||||||
double cx = double(e->pos().x()) / vw, cy = double(e->pos().y()) / vh;
|
double cx = double(e->pos().x()) / vw, cy = double(e->pos().y()) / vh;
|
||||||
|
#else
|
||||||
|
double cx = double(e->position().x()) / vw, cy = double(e->position().y()) / vh;
|
||||||
#endif
|
#endif
|
||||||
double pw = r.width(), ph = r.height();
|
double pw = r.width(), ph = r.height();
|
||||||
r.setWidth(r.width() * scl);
|
r.setWidth(r.width() * scl);
|
||||||
@@ -692,7 +684,7 @@ void BlockView::wheelEvent(QWheelEvent * e) {
|
|||||||
|
|
||||||
void BlockView::mousePressEvent(QMouseEvent * event) {
|
void BlockView::mousePressEvent(QMouseEvent * event) {
|
||||||
press_point = event->pos();
|
press_point = event->pos();
|
||||||
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
|
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||||
setCursor(Qt::ClosedHandCursor);
|
setCursor(Qt::ClosedHandCursor);
|
||||||
//sel_rect.hide();
|
//sel_rect.hide();
|
||||||
if (sel_rect.scene())
|
if (sel_rect.scene())
|
||||||
@@ -723,7 +715,7 @@ void BlockView::scrolled() {
|
|||||||
void BlockView::mouseMoveEvent(QMouseEvent * event) {
|
void BlockView::mouseMoveEvent(QMouseEvent * event) {
|
||||||
if (!event) return;
|
if (!event) return;
|
||||||
if (navigation) {
|
if (navigation) {
|
||||||
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
|
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||||
QPoint dp = (press_point - event->pos());
|
QPoint dp = (press_point - event->pos());
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + dp.x());
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + dp.x());
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->value() + dp.y());
|
verticalScrollBar()->setValue(verticalScrollBar()->value() + dp.y());
|
||||||
@@ -740,7 +732,7 @@ void BlockView::mouseMoveEvent(QMouseEvent * event) {
|
|||||||
|
|
||||||
|
|
||||||
void BlockView::mouseDoubleClickEvent(QMouseEvent * event) {
|
void BlockView::mouseDoubleClickEvent(QMouseEvent * event) {
|
||||||
if (event->buttons().testFlag(Qt::MidButton) || event->buttons().testFlag(Qt::RightButton)) {
|
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||||
fitInView();
|
fitInView();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,7 +223,8 @@ protected slots:
|
|||||||
void startBusPointMove(int bus_type);
|
void startBusPointMove(int bus_type);
|
||||||
void endBusPointMove();
|
void endBusPointMove();
|
||||||
void pinHoverInOut(BlockItemPin * pin);
|
void pinHoverInOut(BlockItemPin * pin);
|
||||||
void checkPaste(bool queued = false);
|
void checkPaste(bool queued);
|
||||||
|
void checkPaste() {checkPaste(false);}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setGridPen(const QPen & pen) {grid_pen = pen; _updateBack();}
|
void setGridPen(const QPen & pen) {grid_pen = pen; _updateBack();}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ void _DTSizeItem::doubleClick() {
|
|||||||
|
|
||||||
|
|
||||||
void _DTSizeItem::resizeHandles() {
|
void _DTSizeItem::resizeHandles() {
|
||||||
double sz = QApplication::fontMetrics().size(0, "0").height() / 3.;
|
double sz = fontHeight() / 3.;
|
||||||
QRectF r(-sz, -sz, sz*2, sz*2);
|
QRectF r(-sz, -sz, sz*2, sz*2);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
rects[i].setRect(r);
|
rects[i].setRect(r);
|
||||||
@@ -235,7 +235,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
|||||||
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
|
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
|
||||||
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
|
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
|
||||||
widget_props->setEnabled(false);
|
widget_props->setEnabled(false);
|
||||||
int fh = qMax<int>(QApplication::fontMetrics().size(0, "0").height(), 22);
|
int fh = qMax<int>(fontHeight(), 22);
|
||||||
int thick = lineThickness();
|
int thick = lineThickness();
|
||||||
QSize sz(fh * 2.5, fh);
|
QSize sz(fh * 2.5, fh);
|
||||||
ui->comboLineStyle->setIconSize(sz);
|
ui->comboLineStyle->setIconSize(sz);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "markdown.h"
|
#include "markdown.h"
|
||||||
|
#include <QIODevice>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#ifndef NO_MARKDOWN
|
#ifndef NO_MARKDOWN
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
qad_library(graphic "Gui;Widgets;OpenGL" "qad_widgets;${OPENGL_LIBRARIES}")
|
qad_library(graphic "Gui;Widgets;OpenGL;OpenGLWidgets" "qad_widgets;${OPENGL_LIBRARIES}")
|
||||||
|
|||||||
@@ -212,10 +212,20 @@ bool Graphic::eventFilter(QObject * o, QEvent * e) {
|
|||||||
break;
|
break;
|
||||||
case QEvent::TouchUpdate: {
|
case QEvent::TouchUpdate: {
|
||||||
if (!navigation || !gestures) break;
|
if (!navigation || !gestures) break;
|
||||||
QList<QTouchEvent::TouchPoint> tpl = ((QTouchEvent*)e)->touchPoints();
|
QList<QTouchEvent::TouchPoint> tpl =
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
((QTouchEvent*)e)->touchPoints();
|
||||||
|
#else
|
||||||
|
((QTouchEvent*)e)->points();
|
||||||
|
#endif
|
||||||
if (tpl.size() == 2) {
|
if (tpl.size() == 2) {
|
||||||
need_mouse_pan = false;
|
need_mouse_pan = false;
|
||||||
QPointF dp = tpl[0].scenePos() - tpl[1].scenePos();
|
QPointF dp =
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
tpl[0].scenePos() - tpl[1].scenePos();
|
||||||
|
#else
|
||||||
|
tpl[0].scenePosition() - tpl[1].scenePosition();
|
||||||
|
#endif
|
||||||
gesture_angle = rad2deg_qpie * qAtan2(qAbs(dp.y()), qAbs(dp.x()));
|
gesture_angle = rad2deg_qpie * qAtan2(qAbs(dp.y()), qAbs(dp.x()));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -432,7 +442,7 @@ void Graphic::canvasMousePressEvent(QMouseEvent * e) {
|
|||||||
startpos = prevpos;
|
startpos = prevpos;
|
||||||
startpos_r = canvas2real(startpos);
|
startpos_r = canvas2real(startpos);
|
||||||
if (cancel || gestures) return;
|
if (cancel || gestures) return;
|
||||||
if (e->button() == Qt::MidButton) curaction = gaMove;
|
if (e->button() == QT_MID_BUTTON) curaction = gaMove;
|
||||||
if (e->button() == Qt::RightButton) {
|
if (e->button() == Qt::RightButton) {
|
||||||
if (bufferActive) {
|
if (bufferActive) {
|
||||||
curpos = startpos;
|
curpos = startpos;
|
||||||
@@ -700,6 +710,7 @@ void Graphic::setButtons(Graphic::Buttons b) {
|
|||||||
ui->graphic_buttonClear->setVisible(b.testFlag(Clear));
|
ui->graphic_buttonClear->setVisible(b.testFlag(Clear));
|
||||||
ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
|
ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
|
||||||
ui->graphic_buttonSave->setVisible(b.testFlag(Save));
|
ui->graphic_buttonSave->setVisible(b.testFlag(Save));
|
||||||
|
ui->graphic_buttonExport->setVisible(b.testFlag(Export));
|
||||||
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
|
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
|
||||||
ui->graphic_checkPause->setVisible(b.testFlag(Pause));
|
ui->graphic_checkPause->setVisible(b.testFlag(Pause));
|
||||||
if (ui->graphic_buttonAutofit ->isVisible() || ui->graphic_checkGrid ->isVisible() || ui->graphic_checkGuides->isVisible() ||
|
if (ui->graphic_buttonAutofit ->isVisible() || ui->graphic_checkGrid ->isVisible() || ui->graphic_checkGuides->isVisible() ||
|
||||||
@@ -793,10 +804,8 @@ void Graphic::setDefaultRect(const QRectF & rect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Graphic::saveImage() {
|
void Graphic::saveImage(QString filename) {
|
||||||
QString str = QFileDialog::getSaveFileName(this, tr("Save Image"), ppath, "PNG(*.png);;JPEG(*.jpg *.jpeg);;BMP(*.bmp);;TIFF(*.tiff *.tif);;PPM(*.ppm)");
|
ppath = filename;
|
||||||
if (str == "") return;
|
|
||||||
ppath = str;
|
|
||||||
QPixmap im(canvas->size());
|
QPixmap im(canvas->size());
|
||||||
canvas->render(&im);
|
canvas->render(&im);
|
||||||
im.save(ppath);
|
im.save(ppath);
|
||||||
@@ -804,6 +813,50 @@ void Graphic::saveImage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Graphic::exportGraphics(QString filename) {
|
||||||
|
ppath = filename;
|
||||||
|
QFile f(filename);
|
||||||
|
if (!f.open(QIODevice::ReadWrite)) {
|
||||||
|
QMessageBox::critical(this, tr("Export graphics"), tr("Can`t open file \"%1\"!").arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
f.resize(0);
|
||||||
|
QTextStream ts(&f);
|
||||||
|
ts << "#";
|
||||||
|
for (int i = 0; i < graphics.size(); ++i) {
|
||||||
|
GraphicType & g(graphics[i]);
|
||||||
|
if (!g.visible) continue;
|
||||||
|
ts << ";" << (g.name + "_X") << ";" << (g.name + "_Y");
|
||||||
|
}
|
||||||
|
ts << "\n";
|
||||||
|
bool has_data = true;
|
||||||
|
int ind = 0;
|
||||||
|
QString line;
|
||||||
|
while (has_data) {
|
||||||
|
has_data = false;
|
||||||
|
line.clear();
|
||||||
|
line += QString::number(ind + 1);
|
||||||
|
for (int i = 0; i < graphics.size(); ++i) {
|
||||||
|
GraphicType & g(graphics[i]);
|
||||||
|
if (!g.visible) continue;
|
||||||
|
if (ind >= g.polyline.size()) {
|
||||||
|
line += ";;";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
has_data = true;
|
||||||
|
line += ";";
|
||||||
|
line += QString::number(g.polyline[ind].x(), 'g', 9);
|
||||||
|
line += ";";
|
||||||
|
line += QString::number(g.polyline[ind].y(), 'g', 9);
|
||||||
|
}
|
||||||
|
++ind;
|
||||||
|
line += "\n";
|
||||||
|
if (has_data)
|
||||||
|
ts << line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Graphic::setOpenGL(bool on) {
|
void Graphic::setOpenGL(bool on) {
|
||||||
#ifdef HAS_GL
|
#ifdef HAS_GL
|
||||||
isOGL = on;
|
isOGL = on;
|
||||||
@@ -1546,6 +1599,20 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Graphic::on_graphic_buttonSave_clicked() {
|
||||||
|
QString f = QFileDialog::getSaveFileName(this, tr("Save Image"), ppath, "PNG(*.png);;JPEG(*.jpg *.jpeg);;BMP(*.bmp);;TIFF(*.tiff *.tif);;PPM(*.ppm)");
|
||||||
|
if (f.isEmpty()) return;
|
||||||
|
saveImage(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Graphic::on_graphic_buttonExport_clicked() {
|
||||||
|
QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
|
||||||
|
if (f.isEmpty()) return;
|
||||||
|
exportGraphics(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Graphic::on_graphic_checkGuides_toggled(bool checked) {
|
void Graphic::on_graphic_checkGuides_toggled(bool checked) {
|
||||||
guides = checked;
|
guides = checked;
|
||||||
setGuidesCursor();
|
setGuidesCursor();
|
||||||
|
|||||||
@@ -124,19 +124,20 @@ public:
|
|||||||
|
|
||||||
typedef QVector<QVector<QPointF> > GraphicsData;
|
typedef QVector<QVector<QPointF> > GraphicsData;
|
||||||
enum GraphicAction {gaNone, gaZoomInRect, gaZoomRangeX, gaZoomRangeY, gaMove};
|
enum GraphicAction {gaNone, gaZoomInRect, gaZoomRangeX, gaZoomRangeY, gaMove};
|
||||||
enum Button {NoButtons = 0x0,
|
enum Button {NoButtons = 0x0,
|
||||||
AllButtons = 0xFFFFFFFF,
|
AllButtons = 0xFFFFFFFF,
|
||||||
Autofit = 0x01,
|
Autofit = 0x01,
|
||||||
Grid = 0x02,
|
Grid = 0x02,
|
||||||
CursorAxis = 0x04,
|
CursorAxis = 0x04,
|
||||||
Fullscreen = 0x20,
|
Fullscreen = 0x20,
|
||||||
BorderInputs = 0x40,
|
BorderInputs = 0x40,
|
||||||
Legend = 0x80,
|
Legend = 0x80,
|
||||||
Configure = 0x100,
|
Configure = 0x100,
|
||||||
Save = 0x200,
|
Save = 0x200,
|
||||||
Clear = 0x800,
|
Export = 0x400,
|
||||||
Close = 0x1000,
|
Clear = 0x800,
|
||||||
Pause = 0x2000,
|
Close = 0x1000,
|
||||||
|
Pause = 0x2000,
|
||||||
StandartButtons = 0x2FFF
|
StandartButtons = 0x2FFF
|
||||||
};
|
};
|
||||||
enum Alignment {Left, Right};
|
enum Alignment {Left, Right};
|
||||||
@@ -314,9 +315,11 @@ public slots:
|
|||||||
void setVisualRect(const QRectF & rect);
|
void setVisualRect(const QRectF & rect);
|
||||||
void setDefaultRect(const QRectF & rect);
|
void setDefaultRect(const QRectF & rect);
|
||||||
void autofit() {on_graphic_buttonAutofit_clicked();}
|
void autofit() {on_graphic_buttonAutofit_clicked();}
|
||||||
void saveImage();
|
void saveImage(QString filename);
|
||||||
|
void exportGraphics(QString filename);
|
||||||
void clear();
|
void clear();
|
||||||
void update(bool force = false);
|
void update(bool force);
|
||||||
|
void update() {update(false);}
|
||||||
void updateGraphics() {findGraphicsRect(); update();}
|
void updateGraphics() {findGraphicsRect(); update();}
|
||||||
void setCurrentGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curGraphic = arg;}
|
void setCurrentGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curGraphic = arg;}
|
||||||
void setTraceGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curTrace = arg;}
|
void setTraceGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curTrace = arg;}
|
||||||
@@ -421,7 +424,8 @@ protected slots:
|
|||||||
void on_graphic_buttonAutofit_clicked();
|
void on_graphic_buttonAutofit_clicked();
|
||||||
void on_graphic_buttonConfigure_clicked();
|
void on_graphic_buttonConfigure_clicked();
|
||||||
void on_graphic_buttonFullscreen_clicked() {fullscreen();}
|
void on_graphic_buttonFullscreen_clicked() {fullscreen();}
|
||||||
void on_graphic_buttonSave_clicked() {saveImage();}
|
void on_graphic_buttonSave_clicked();
|
||||||
|
void on_graphic_buttonExport_clicked();
|
||||||
void on_graphic_checkGrid_toggled(bool checked) {grid = checked; update();}
|
void on_graphic_checkGrid_toggled(bool checked) {grid = checked; update();}
|
||||||
void on_graphic_checkGuides_toggled(bool checked);
|
void on_graphic_checkGuides_toggled(bool checked);
|
||||||
void on_graphic_actionExpandX_triggered(bool checked);
|
void on_graphic_actionExpandX_triggered(bool checked);
|
||||||
@@ -462,7 +466,9 @@ public:
|
|||||||
__GraphicRegistrator__() {
|
__GraphicRegistrator__() {
|
||||||
qRegisterMetaType<QVector<QPointF> >("QVector<QPointF>");
|
qRegisterMetaType<QVector<QPointF> >("QVector<QPointF>");
|
||||||
qRegisterMetaType<Graphic::GraphicsData>("Graphic::GraphicsData");
|
qRegisterMetaType<Graphic::GraphicsData>("Graphic::GraphicsData");
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
qRegisterMetaTypeStreamOperators<Graphic::GraphicsData>("Graphic::GraphicsData");
|
qRegisterMetaTypeStreamOperators<Graphic::GraphicsData>("Graphic::GraphicsData");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>564</width>
|
<width>575</width>
|
||||||
<height>484</height>
|
<height>440</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@@ -180,6 +180,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="graphic_buttonExport">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Export graphics ...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../blockview/qad_blockview.qrc">
|
||||||
|
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ private:
|
|||||||
if (e->type() != QEvent::Paint) return QWidget::event(e);
|
if (e->type() != QEvent::Paint) return QWidget::event(e);
|
||||||
e->accept();
|
e->accept();
|
||||||
QStyleOption opt;
|
QStyleOption opt;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
opt.init(this);
|
opt.init(this);
|
||||||
|
#else
|
||||||
|
opt.initFrom(this);
|
||||||
|
#endif
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||||
emit paintEvent((QPaintEvent * )e);
|
emit paintEvent((QPaintEvent * )e);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
#include "qvariantedit.h"
|
#include "qvariantedit.h"
|
||||||
#if QT_VERSION >= 0x050200
|
|
||||||
# include <QGeoCoordinate>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el) {
|
const QAD::Enum PI2QADEnum(const PIVariantTypes::Enum & el) {
|
||||||
@@ -60,24 +57,105 @@ const QVariant PI2QVariant(const PIVariant & v) {
|
|||||||
|
|
||||||
|
|
||||||
const PIVariant Q2PIVariant(const QVariant & v) {
|
const PIVariant Q2PIVariant(const QVariant & v) {
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
switch (v.type()) {
|
switch (v.type()) {
|
||||||
case QVariant::Bool: return PIVariant(v.toBool());
|
#else
|
||||||
case QVariant::Int: return PIVariant(v.toInt());
|
switch (v.metaType().id()) {
|
||||||
case QVariant::UInt: return PIVariant(v.toUInt());
|
#endif
|
||||||
case QVariant::LongLong: return PIVariant(v.toLongLong());
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::ULongLong: return PIVariant(v.toULongLong());
|
case QVariant::Bool:
|
||||||
case QVariant::Double: return PIVariant(v.toDouble());
|
#else
|
||||||
case QVariant::ByteArray: return PIVariant(Q2PIByteArray(v.toByteArray()));
|
case QMetaType::Bool:
|
||||||
case QVariant::String: return PIVariant(Q2PIString(v.toString()));
|
#endif
|
||||||
case QVariant::StringList: return PIVariant(Q2PIStringList(v.toStringList()));
|
return PIVariant(v.toBool());
|
||||||
case QVariant::Time: return PIVariant(Q2PITime(v.toTime()));
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Date: return PIVariant(Q2PIDate(v.toDate()));
|
case QVariant::Int:
|
||||||
case QVariant::DateTime: return PIVariant(Q2PIDateTime(v.toDateTime()));
|
#else
|
||||||
case QVariant::Color: return PIVariant(Q2PIColor(v.value<QColor>()));
|
case QMetaType::Int:
|
||||||
|
#endif
|
||||||
|
return PIVariant(v.toInt());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::UInt:
|
||||||
|
#else
|
||||||
|
case QMetaType::UInt:
|
||||||
|
#endif
|
||||||
|
return PIVariant(v.toUInt());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::LongLong:
|
||||||
|
#else
|
||||||
|
case QMetaType::LongLong:
|
||||||
|
#endif
|
||||||
|
return PIVariant(v.toLongLong());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::ULongLong:
|
||||||
|
#else
|
||||||
|
case QMetaType::ULongLong:
|
||||||
|
#endif
|
||||||
|
return PIVariant(v.toULongLong());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Double:
|
||||||
|
#else
|
||||||
|
case QMetaType::Double:
|
||||||
|
#endif
|
||||||
|
return PIVariant(v.toDouble());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::ByteArray:
|
||||||
|
#else
|
||||||
|
case QMetaType::QByteArray:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIByteArray(v.toByteArray()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::String:
|
||||||
|
#else
|
||||||
|
case QMetaType::QString:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIString(v.toString()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::StringList:
|
||||||
|
#else
|
||||||
|
case QMetaType::QStringList:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIStringList(v.toStringList()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Time:
|
||||||
|
#else
|
||||||
|
case QMetaType::QTime:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PITime(v.toTime()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Date:
|
||||||
|
#else
|
||||||
|
case QMetaType::QDate:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIDate(v.toDate()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::DateTime:
|
||||||
|
#else
|
||||||
|
case QMetaType::QDateTime:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIDateTime(v.toDateTime()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Color:
|
||||||
|
#else
|
||||||
|
case QMetaType::QColor:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIColor(v.value<QColor>()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Point:
|
case QVariant::Point:
|
||||||
case QVariant::PointF: return PIVariant(Q2PIPoint(v.toPointF()));
|
case QVariant::PointF:
|
||||||
|
#else
|
||||||
|
case QMetaType::QPoint:
|
||||||
|
case QMetaType::QPointF:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIPoint(v.toPointF()));
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Rect:
|
case QVariant::Rect:
|
||||||
case QVariant::RectF: return PIVariant(Q2PIRect(v.toRectF()));
|
case QVariant::RectF:
|
||||||
|
#else
|
||||||
|
case QMetaType::QRect:
|
||||||
|
case QMetaType::QRectF:
|
||||||
|
#endif
|
||||||
|
return PIVariant(Q2PIRect(v.toRectF()));
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (v.canConvert<float>()) return PIVariant(v.value<float>());
|
if (v.canConvert<float>()) return PIVariant(v.value<float>());
|
||||||
@@ -126,7 +204,7 @@ const PIVariantTypes::Dir QAD2PIDir(const QAD::Dir & v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050200
|
#ifdef PIQT_HAS_GEOPOSITION
|
||||||
const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v) {
|
const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v) {
|
||||||
PIGeoPosition p(v);
|
PIGeoPosition p(v);
|
||||||
p.transformTo(PIGeoPosition::Cartesian);
|
p.transformTo(PIGeoPosition::Cartesian);
|
||||||
|
|||||||
@@ -20,16 +20,28 @@
|
|||||||
#ifndef PIQT_H
|
#ifndef PIQT_H
|
||||||
#define PIQT_H
|
#define PIQT_H
|
||||||
|
|
||||||
#include "pimathmatrix.h"
|
|
||||||
#include "pipropertystorage.h"
|
|
||||||
#include "qad_types.h"
|
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#if QT_VERSION >= 0x050200
|
|
||||||
|
#include "pimathmatrix.h"
|
||||||
|
#include "pipropertystorage.h"
|
||||||
|
#include "qad_types.h"
|
||||||
|
#include "piqt_macros.h"
|
||||||
|
#if QT_VERSION_MAJOR == 5
|
||||||
|
# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||||
|
# define PIQT_HAS_GEOPOSITION
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if QT_VERSION_MAJOR == 6
|
||||||
|
# if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||||
|
# define PIQT_HAS_GEOPOSITION
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifdef PIQT_HAS_GEOPOSITION
|
||||||
|
# include <QGeoCoordinate>
|
||||||
# include "pigeoposition.h"
|
# include "pigeoposition.h"
|
||||||
#endif
|
#endif
|
||||||
#include "piqt_macros.h"
|
|
||||||
#include "qad_piqt_export.h"
|
#include "qad_piqt_export.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -137,7 +149,7 @@ QAD_PIQT_EXPORT const PIVariantTypes::IODevice QAD2PIIODevice(const QAD::IODevic
|
|||||||
|
|
||||||
//inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));}
|
//inline const PIVariant QString2PIVariant(const QString & v) {return PIVariant::readFromString(QString2PIString(v));}
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050200
|
#ifdef PIQT_HAS_GEOPOSITION
|
||||||
QAD_PIQT_EXPORT const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v);
|
QAD_PIQT_EXPORT const QGeoCoordinate PI2QGeoPosition(const PIGeoPosition & v);
|
||||||
QAD_PIQT_EXPORT const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v);
|
QAD_PIQT_EXPORT const PIGeoPosition Q2PIGeoPosition(const QGeoCoordinate & v);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -47,7 +47,14 @@
|
|||||||
namespace PIQt {
|
namespace PIQt {
|
||||||
|
|
||||||
template<typename T> T removePtr(T*) {}
|
template<typename T> T removePtr(T*) {}
|
||||||
template<typename T> QArgument<T> qargument(const T & v) {return QArgument<T>(QMetaType::typeName(qMetaTypeId<T>()), v);}
|
template<typename T> QArgument<T> qargument(const T & v) {
|
||||||
|
return QArgument<T>(
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
QMetaType::typeName(qMetaTypeId<T>())
|
||||||
|
#else
|
||||||
|
QMetaType::fromType<T>().name()
|
||||||
|
#endif
|
||||||
|
, v);}
|
||||||
|
|
||||||
template <typename SR, typename O, typename... ARGS>
|
template <typename SR, typename O, typename... ARGS>
|
||||||
void piqConnect(PIObject * source, const char * event, void(*func)(void*,ARGS...), O * target, SR(O::*slot)(ARGS...)) {
|
void piqConnect(PIObject * source, const char * event, void(*func)(void*,ARGS...), O * target, SR(O::*slot)(ARGS...)) {
|
||||||
|
|||||||
@@ -5,39 +5,38 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter
|
|||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
valueNameFormat.setForeground(QColor(0, 64, 154));
|
valueNameFormat.setForeground(QColor(0, 64, 154));
|
||||||
rule.pattern = QRegExp("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
|
rule.pattern = QRegularExpression("[^=]"); //"\\b[A-Za-z0-9_]+(?=\\()");
|
||||||
rule.format = valueNameFormat;
|
rule.format = valueNameFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
valueFormat.setForeground(QColor(192, 0, 0));
|
valueFormat.setForeground(QColor(192, 0, 0));
|
||||||
rule.pattern = QRegExp("=[^\n]*");
|
rule.pattern = QRegularExpression("=[^\n]*");
|
||||||
rule.format = valueFormat;
|
rule.format = valueFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
equalFormat.setFontWeight(QFont::Bold);
|
equalFormat.setFontWeight(QFont::Bold);
|
||||||
equalFormat.setForeground(QColor(96, 126, 0));
|
equalFormat.setForeground(QColor(96, 126, 0));
|
||||||
rule.pattern = QRegExp("=");
|
rule.pattern = QRegularExpression("=");
|
||||||
rule.format = equalFormat;
|
rule.format = equalFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
sectionFormat.setFontWeight(QFont::Bold);
|
sectionFormat.setFontWeight(QFont::Bold);
|
||||||
sectionFormat.setForeground(QColor(0, 32, 64));
|
sectionFormat.setForeground(QColor(0, 32, 64));
|
||||||
rule.pattern = QRegExp("\\[.*\\]");
|
rule.pattern = QRegularExpression("\\[.*\\]");
|
||||||
rule.format = sectionFormat;
|
rule.format = sectionFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
//substFormat.setFontWeight(QFont::Bold);
|
|
||||||
substFormat.setForeground(QColor(192, 0, 192));
|
substFormat.setForeground(QColor(192, 0, 192));
|
||||||
rule.pattern = QRegExp("\\$\\{.*\\}+");
|
rule.pattern = QRegularExpression("\\$\\{.*\\}+");
|
||||||
rule.pattern.setMinimal(true);
|
//rule.pattern.setMinimal(true);
|
||||||
rule.format = substFormat;
|
rule.format = substFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
rule.pattern = QRegExp("\\$\\{[^\\{]*\\}+");
|
rule.pattern = QRegularExpression("\\$\\{[^\\{]*\\}+");
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
singleLineCommentFormat.setFontItalic(true);
|
singleLineCommentFormat.setFontItalic(true);
|
||||||
singleLineCommentFormat.setForeground(QColor(128, 128, 128));
|
singleLineCommentFormat.setForeground(QColor(128, 128, 128));
|
||||||
rule.pattern = QRegExp("#[^\n]*");
|
rule.pattern = QRegularExpression("#[^\n]*");
|
||||||
rule.format = singleLineCommentFormat;
|
rule.format = singleLineCommentFormat;
|
||||||
highlightingRules.append(rule);
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
@@ -50,21 +49,37 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter
|
|||||||
|
|
||||||
void ConfigHighlighter::highlightBlock(const QString & text) {
|
void ConfigHighlighter::highlightBlock(const QString & text) {
|
||||||
foreach (const HighlightingRule &rule, highlightingRules) {
|
foreach (const HighlightingRule &rule, highlightingRules) {
|
||||||
QRegExp expression(rule.pattern);
|
QRegularExpression expression(rule.pattern);
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
QRegularExpressionMatchIterator i = expression.globalMatch(text);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
QRegularExpressionMatch match = i.next();
|
||||||
|
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
||||||
|
}
|
||||||
|
#else
|
||||||
int index = expression.indexIn(text);
|
int index = expression.indexIn(text);
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
int length = expression.matchedLength();
|
int length = expression.matchedLength();
|
||||||
setFormat(index, length, rule.format);
|
setFormat(index, length, rule.format);
|
||||||
index = expression.indexIn(text, index + length);
|
index = expression.indexIn(text, index + length);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
setCurrentBlockState(0);
|
setCurrentBlockState(0);
|
||||||
|
|
||||||
QRegExp expression = QRegExp("[ |\t]");
|
QRegularExpression expression("[ |\t]");
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
QRegularExpressionMatchIterator i = expression.globalMatch(text);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
QRegularExpressionMatch match = i.next();
|
||||||
|
setFormat(match.capturedStart(), match.capturedLength(), spaceFormat);
|
||||||
|
}
|
||||||
|
#else
|
||||||
int index = expression.indexIn(text);
|
int index = expression.indexIn(text);
|
||||||
while (index >= 0) {
|
while (index >= 0) {
|
||||||
int length = expression.matchedLength();
|
int length = expression.matchedLength();
|
||||||
setFormat(index, length, spaceFormat);
|
setFormat(index, length, spaceFormat);
|
||||||
index = expression.indexIn(text, index + length);
|
index = expression.indexIn(text, index + length);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,12 @@
|
|||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
# include <QRegularExpression>
|
||||||
|
#else
|
||||||
|
# include <QRegExp>
|
||||||
|
typedef QRegExp QRegularExpression;
|
||||||
|
#endif
|
||||||
#include "qad_piqt_utils_export.h"
|
#include "qad_piqt_utils_export.h"
|
||||||
|
|
||||||
class QTextDocument;
|
class QTextDocument;
|
||||||
@@ -39,12 +45,12 @@ private:
|
|||||||
void highlightBlock(const QString &text);
|
void highlightBlock(const QString &text);
|
||||||
|
|
||||||
struct QAD_PIQT_UTILS_EXPORT HighlightingRule {
|
struct QAD_PIQT_UTILS_EXPORT HighlightingRule {
|
||||||
QRegExp pattern;
|
QRegularExpression pattern;
|
||||||
QTextCharFormat format;
|
QTextCharFormat format;
|
||||||
};
|
};
|
||||||
|
|
||||||
QVector<HighlightingRule> highlightingRules;
|
QVector<HighlightingRule> highlightingRules;
|
||||||
QRegExp commentStartExpression, commentEndExpression;
|
QRegularExpression commentStartExpression, commentEndExpression;
|
||||||
QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat;
|
QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
|
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
shstk_qt_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
|
shstk_qad_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
|
||||||
shstk_qt_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")
|
shstk_qad_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")
|
||||||
|
|
||||||
qt_sources(test_SRC DIR "qglview_test")
|
qad_sources(test_SRC DIR "qglview_test")
|
||||||
qt_wrap(${test_SRC} CPPS test_CPP)
|
qad_wrap(${test_SRC} CPPS test_CPP)
|
||||||
qt_add_executable(qglview_test test_CPP)
|
qad_add_executable(qglview_test test_CPP)
|
||||||
qt_target_link_libraries(qglview_test qglview)
|
qad_target_link_libraries(qglview_test qglview)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
shstk_qt_plugin(qglview "Gui;Widgets;OpenGL" "qglview")
|
shstk_qad_plugin(qglview "Gui;Widgets;OpenGL" "qglview")
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QActionGroup>
|
||||||
#include "qpiconfig.h"
|
#include "qpiconfig.h"
|
||||||
#include "qad_sql_table_export.h"
|
#include "qad_sql_table_export.h"
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ PropertyStorage::Property PropertyStorage::parsePropertyLine(QString l) {
|
|||||||
ret.value = QVariant(typeFromLetter(pt));
|
ret.value = QVariant(typeFromLetter(pt));
|
||||||
if (!pv.isEmpty()) {
|
if (!pv.isEmpty()) {
|
||||||
//qDebug() << "set value !" << pv;
|
//qDebug() << "set value !" << pv;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
switch (ret.value.type()) {
|
switch (ret.value.type()) {
|
||||||
case QVariant::Bool: pv = pv.toLower(); ret.value = (pv == "on" || pv == "true" || pv == "enable" || pv == "enabled" || pv.toInt() > 0 ? true : false); break;
|
case QVariant::Bool: pv = pv.toLower(); ret.value = (pv == "on" || pv == "true" || pv == "enable" || pv == "enabled" || pv.toInt() > 0 ? true : false); break;
|
||||||
case QVariant::Int: ret.value = pv.toInt(); break;
|
case QVariant::Int: ret.value = pv.toInt(); break;
|
||||||
@@ -160,6 +161,18 @@ PropertyStorage::Property PropertyStorage::parsePropertyLine(QString l) {
|
|||||||
case QVariant::Color: ret.value = QColor(pv); break;
|
case QVariant::Color: ret.value = QColor(pv); break;
|
||||||
default: ret.value = pv; break;
|
default: ret.value = pv; break;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
switch (ret.value.metaType().id()) {
|
||||||
|
case QMetaType::Bool: pv = pv.toLower(); ret.value = (pv == "on" || pv == "true" || pv == "enable" || pv == "enabled" || pv.toInt() > 0 ? true : false); break;
|
||||||
|
case QMetaType::Int: ret.value = pv.toInt(); break;
|
||||||
|
case QMetaType::UInt: ret.value = pv.toUInt(); break;
|
||||||
|
case QMetaType::LongLong: ret.value = pv.toLongLong(); break;
|
||||||
|
case QMetaType::ULongLong: ret.value = pv.toULongLong(); break;
|
||||||
|
case QMetaType::Double: ret.value = pv.toDouble(); break;
|
||||||
|
case QMetaType::QColor: ret.value = QColor(pv); break;
|
||||||
|
default: ret.value = pv; break;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,9 +115,6 @@ protected:
|
|||||||
|
|
||||||
inline QDebug operator <<(QDebug s, const PropertyStorage::Property & p) {s.nospace() << p.name << " (0x" << QString::number(p.flags, 16) << ") = " << p.value; return s.space();}
|
inline QDebug operator <<(QDebug s, const PropertyStorage::Property & p) {s.nospace() << p.name << " (0x" << QString::number(p.flags, 16) << ") = " << p.value; return s.space();}
|
||||||
|
|
||||||
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage & p) {s << p.properties(); return s;}
|
|
||||||
inline QDataStream & operator >>(QDataStream & s, PropertyStorage & p) {s >> p.properties(); return s;}
|
|
||||||
|
|
||||||
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage::Property & p) {
|
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage::Property & p) {
|
||||||
ChunkStream cs;
|
ChunkStream cs;
|
||||||
cs << cs.chunk(1, p.name) << cs.chunk(2, p.comment) << cs.chunk(3, p.value) << cs.chunk(4, p.flags);
|
cs << cs.chunk(1, p.name) << cs.chunk(2, p.comment) << cs.chunk(3, p.value) << cs.chunk(4, p.flags);
|
||||||
@@ -137,5 +134,8 @@ inline QDataStream & operator >>(QDataStream & s, PropertyStorage::Property & p)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QDataStream & operator <<(QDataStream & s, const PropertyStorage & p) {s << p.properties(); return s;}
|
||||||
|
inline QDataStream & operator >>(QDataStream & s, PropertyStorage & p) {s >> p.properties(); return s;}
|
||||||
|
|
||||||
|
|
||||||
#endif // PROPERTYSTORAGE_H
|
#endif // PROPERTYSTORAGE_H
|
||||||
|
|||||||
@@ -26,25 +26,22 @@ __QADTypesRegistrator__::__QADTypesRegistrator__() {
|
|||||||
_inited = true;
|
_inited = true;
|
||||||
|
|
||||||
qRegisterMetaType<QAD::Enumerator>("QAD::Enumerator");
|
qRegisterMetaType<QAD::Enumerator>("QAD::Enumerator");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::Enumerator>("QAD::Enumerator");
|
|
||||||
|
|
||||||
qRegisterMetaType<QAD::Enum>("QAD::Enum");
|
qRegisterMetaType<QAD::Enum>("QAD::Enum");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::Enum>("QAD::Enum");
|
|
||||||
|
|
||||||
qRegisterMetaType<QAD::File>("QAD::File");
|
qRegisterMetaType<QAD::File>("QAD::File");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::File>("QAD::File");
|
|
||||||
|
|
||||||
qRegisterMetaType<QAD::Dir>("QAD::Dir");
|
qRegisterMetaType<QAD::Dir>("QAD::Dir");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::Dir>("QAD::Dir");
|
|
||||||
|
|
||||||
qRegisterMetaType<QAD::IODevice>("QAD::IODevice");
|
qRegisterMetaType<QAD::IODevice>("QAD::IODevice");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::IODevice>("QAD::IODevice");
|
|
||||||
|
|
||||||
qRegisterMetaType<QAD::MathVector>("QAD::MathVector");
|
qRegisterMetaType<QAD::MathVector>("QAD::MathVector");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::MathVector>("QAD::MathVector");
|
|
||||||
|
|
||||||
qRegisterMetaType<QAD::MathMatrix>("QAD::MathMatrix");
|
qRegisterMetaType<QAD::MathMatrix>("QAD::MathMatrix");
|
||||||
|
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
qRegisterMetaTypeStreamOperators<QAD::Enumerator>("QAD::Enumerator");
|
||||||
|
qRegisterMetaTypeStreamOperators<QAD::Enum>("QAD::Enum");
|
||||||
|
qRegisterMetaTypeStreamOperators<QAD::File>("QAD::File");
|
||||||
|
qRegisterMetaTypeStreamOperators<QAD::Dir>("QAD::Dir");
|
||||||
|
qRegisterMetaTypeStreamOperators<QAD::IODevice>("QAD::IODevice");
|
||||||
|
qRegisterMetaTypeStreamOperators<QAD::MathVector>("QAD::MathVector");
|
||||||
qRegisterMetaTypeStreamOperators<QAD::MathMatrix>("QAD::MathMatrix");
|
qRegisterMetaTypeStreamOperators<QAD::MathMatrix>("QAD::MathMatrix");
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050200
|
#if QT_VERSION >= 0x050200
|
||||||
QMetaType::registerConverter<QAD::Enum, int>(&QAD::Enum::selectedValue);
|
QMetaType::registerConverter<QAD::Enum, int>(&QAD::Enum::selectedValue);
|
||||||
@@ -185,7 +182,13 @@ QString QAD::IODevice::toString() const {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVariant::Type typeFromLetter(const QString & l) {
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
QVariant::Type
|
||||||
|
#else
|
||||||
|
QMetaType
|
||||||
|
#endif
|
||||||
|
typeFromLetter(const QString & l) {
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
if (l.isEmpty()) return QVariant::String;
|
if (l.isEmpty()) return QVariant::String;
|
||||||
QString ft = l.left(1);
|
QString ft = l.left(1);
|
||||||
if (ft == "l") return QVariant::StringList;
|
if (ft == "l") return QVariant::StringList;
|
||||||
@@ -204,6 +207,26 @@ QVariant::Type typeFromLetter(const QString & l) {
|
|||||||
if (ft == "V") return (QVariant::Type)qMetaTypeId<QAD::MathVector>();
|
if (ft == "V") return (QVariant::Type)qMetaTypeId<QAD::MathVector>();
|
||||||
if (ft == "M") return (QVariant::Type)qMetaTypeId<QAD::MathMatrix>();
|
if (ft == "M") return (QVariant::Type)qMetaTypeId<QAD::MathMatrix>();
|
||||||
return QVariant::String;
|
return QVariant::String;
|
||||||
|
#else
|
||||||
|
if (l.isEmpty()) return QMetaType::fromType<QString>();
|
||||||
|
QString ft = l.left(1);
|
||||||
|
if (ft == "l") return QMetaType::fromType<QStringList >();
|
||||||
|
if (ft == "b") return QMetaType::fromType<bool >();
|
||||||
|
if (ft == "n") return QMetaType::fromType<int >();
|
||||||
|
if (ft == "f") return QMetaType::fromType<double >();
|
||||||
|
if (ft == "c") return QMetaType::fromType<QColor >();
|
||||||
|
if (ft == "r") return QMetaType::fromType<QRect >();
|
||||||
|
if (ft == "a") return QMetaType::fromType<QRectF >();
|
||||||
|
if (ft == "p") return QMetaType::fromType<QPoint >();
|
||||||
|
if (ft == "v") return QMetaType::fromType<QPointF >();
|
||||||
|
if (ft == "e") return QMetaType::fromType<QAD::Enum >();
|
||||||
|
if (ft == "F") return QMetaType::fromType<QAD::File >();
|
||||||
|
if (ft == "D") return QMetaType::fromType<QAD::Dir >();
|
||||||
|
if (ft == "d") return QMetaType::fromType<QAD::IODevice >();
|
||||||
|
if (ft == "V") return QMetaType::fromType<QAD::MathVector>();
|
||||||
|
if (ft == "M") return QMetaType::fromType<QAD::MathMatrix>();
|
||||||
|
return QMetaType::fromType<QString>();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -252,7 +275,11 @@ int fontHeight(const QWidget * w) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
return QApplication::fontMetrics().size(0, "0").height();
|
return QApplication::fontMetrics().size(0, "0").height();
|
||||||
|
#else
|
||||||
|
return QFontMetricsF(QApplication::font()).size(0, "0").height();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -276,3 +303,10 @@ QSize preferredIconSize(float x, const QWidget * w) {
|
|||||||
double appScale(const QWidget * w) {
|
double appScale(const QWidget * w) {
|
||||||
return qMax<double>(fontHeight(w) / 15., 1.);
|
return qMax<double>(fontHeight(w) / 15., 1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void enableHighDPI() {
|
||||||
|
#if QT_VERSION_MAJOR == 5
|
||||||
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#ifndef QAD_TYPES_H
|
#ifndef QAD_TYPES_H
|
||||||
#define QAD_TYPES_H
|
#define QAD_TYPES_H
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QApplication>
|
||||||
#include "propertystorage.h"
|
#include "propertystorage.h"
|
||||||
#include "qad_utils_export.h"
|
#include "qad_utils_export.h"
|
||||||
|
|
||||||
@@ -31,6 +31,16 @@
|
|||||||
QCoreApplication::setOrganizationName(__TARGET_COMPANY__); \
|
QCoreApplication::setOrganizationName(__TARGET_COMPANY__); \
|
||||||
QCoreApplication::setApplicationVersion(__TARGET_VERSION__);
|
QCoreApplication::setApplicationVersion(__TARGET_VERSION__);
|
||||||
|
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
# define QT_MID_BUTTON Qt::MidButton
|
||||||
|
# include <QMapIterator>
|
||||||
|
template<typename K, typename T>
|
||||||
|
using QMultiMapIterator = QMapIterator<K,T>;
|
||||||
|
#else
|
||||||
|
# define QT_MID_BUTTON Qt::MiddleButton
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class QMetaEnum;
|
class QMetaEnum;
|
||||||
|
|
||||||
|
|
||||||
@@ -167,13 +177,47 @@ inline QRectF enlargedRect(const QRectF & r, qreal dx, qreal dy, qreal v) {
|
|||||||
return QRectF(r.left() - v + dx, r.top() - v + dy, r.width() + v+v, r.height() + v+v);
|
return QRectF(r.left() - v + dx, r.top() - v + dy, r.width() + v+v, r.height() + v+v);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAD_UTILS_EXPORT QVariant::Type typeFromLetter(const QString & l);
|
template <typename T> QSet<T> QList2QSet(const QList<T> & l) {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
return QSet<T>(l.begin(), l.end());
|
||||||
|
#else
|
||||||
|
return QSet<T>::fromList(l);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename K, typename T>
|
||||||
|
void addToMap(QMap<K, T> & into, const QMap<K, T> & what) {
|
||||||
|
QMapIterator<K, T> it(what);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
if (!into.contains(it.key()))
|
||||||
|
into[it.key()] = it.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename K, typename T>
|
||||||
|
void addToMapOverwrite(QMap<K, T> & into, const QMap<K, T> & what) {
|
||||||
|
QMapIterator<K, T> it(what);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
into[it.key()] = it.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QAD_UTILS_EXPORT
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
QVariant::Type
|
||||||
|
#else
|
||||||
|
QMetaType
|
||||||
|
#endif
|
||||||
|
typeFromLetter(const QString & l);
|
||||||
QAD_UTILS_EXPORT QString uniqueName(QString n, const QStringList & names);
|
QAD_UTILS_EXPORT QString uniqueName(QString n, const QStringList & names);
|
||||||
|
|
||||||
QAD_UTILS_EXPORT int fontHeight(const QWidget * w = 0);
|
QAD_UTILS_EXPORT int fontHeight(const QWidget * w = 0);
|
||||||
QAD_UTILS_EXPORT int lineThickness(const QWidget * w = 0);
|
QAD_UTILS_EXPORT int lineThickness(const QWidget * w = 0);
|
||||||
QAD_UTILS_EXPORT QSize preferredIconSize(float x = 1.f, const QWidget * w = 0);
|
QAD_UTILS_EXPORT QSize preferredIconSize(float x = 1.f, const QWidget * w = 0);
|
||||||
QAD_UTILS_EXPORT double appScale(const QWidget * w = 0);
|
QAD_UTILS_EXPORT double appScale(const QWidget * w = 0);
|
||||||
|
QAD_UTILS_EXPORT void enableHighDPI();
|
||||||
|
|
||||||
|
|
||||||
#endif // QAD_TYPES_H
|
#endif // QAD_TYPES_H
|
||||||
|
|||||||
@@ -303,6 +303,9 @@ QPIConfig::QPIConfig(const QString & path, QStringList dirs) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dev->close();
|
dev->close();
|
||||||
|
#if QT_VERSION_MAJOR > 5
|
||||||
|
stream.setEncoding(QStringConverter::Utf8);
|
||||||
|
#endif
|
||||||
setFileName(cp);
|
setFileName(cp);
|
||||||
open(QIODevice::ReadOnly);
|
open(QIODevice::ReadOnly);
|
||||||
parse();
|
parse();
|
||||||
@@ -347,7 +350,15 @@ void QPIConfig::setString(QString * str) {
|
|||||||
|
|
||||||
void QPIConfig::setCodec(const char * codecName) {
|
void QPIConfig::setCodec(const char * codecName) {
|
||||||
codec = codecName;
|
codec = codecName;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
stream.setCodec(codecName);
|
stream.setCodec(codecName);
|
||||||
|
#else
|
||||||
|
QString cn = QString(codecName).toLower().remove(' ').remove('-').trimmed();
|
||||||
|
QStringConverter::Encoding sc = QStringConverter::System;
|
||||||
|
if (cn == "utf8" ) sc = QStringConverter::Utf8 ;
|
||||||
|
else if (cn == "utf16") sc = QStringConverter::Utf16;
|
||||||
|
stream.setEncoding(sc);
|
||||||
|
#endif
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,8 +781,10 @@ void QPIConfig::parse(QString content) {
|
|||||||
stream.seek(0);
|
stream.seek(0);
|
||||||
other.clear();
|
other.clear();
|
||||||
lines = centry = 0;
|
lines = centry = 0;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
if (!codec.isEmpty())
|
if (!codec.isEmpty())
|
||||||
stream.setCodec(codec.toLatin1().data());
|
stream.setCodec(codec.toLatin1().data());
|
||||||
|
#endif
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
other.push_back(QString());
|
other.push_back(QString());
|
||||||
src = str = parseLine(stream.readLine());
|
src = str = parseLine(stream.readLine());
|
||||||
|
|||||||
@@ -106,7 +106,13 @@ void EComboBox::filterChanged(const QString & text, bool first) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < iv.model()->rowCount(); ++i) {
|
for (int i = 0; i < iv.model()->rowCount(); ++i) {
|
||||||
iv.setRowHidden(i, pi, !iv.model()->index(i, 0, pi).data().toString().contains(QRegExp(text, Qt::CaseInsensitive)));
|
iv.setRowHidden(i, pi, !iv.model()->index(i, 0, pi).data().toString().contains(
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
QRegExp(text, Qt::CaseInsensitive)
|
||||||
|
#else
|
||||||
|
QRegularExpression(text, QRegularExpression::CaseInsensitiveOption)
|
||||||
|
#endif
|
||||||
|
));
|
||||||
iv.model()->setData(iv.model()->index(i, 0), iv.model()->index(i, 0, pi).data().toString(), Qt::ToolTipRole);
|
iv.model()->setData(iv.model()->index(i, 0), iv.model()->index(i, 0, pi).data().toString(), Qt::ToolTipRole);
|
||||||
}
|
}
|
||||||
iv.show();
|
iv.show();
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegExp>
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
# include <QRegExp>
|
||||||
|
#else
|
||||||
|
# include <QRegularExpression>
|
||||||
|
#endif
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
@@ -292,7 +296,13 @@ void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
|
|||||||
|
|
||||||
void EvalSpinBox::wheelEvent(QWheelEvent * event) {
|
void EvalSpinBox::wheelEvent(QWheelEvent * event) {
|
||||||
if (event->modifiers().testFlag(Qt::ShiftModifier))
|
if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||||
stepByDouble(event->delta() > 0 ? 0.1 : -0.1);
|
stepByDouble(
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
event->delta()
|
||||||
|
#else
|
||||||
|
event->angleDelta().y()
|
||||||
|
#endif
|
||||||
|
> 0 ? 0.1 : -0.1);
|
||||||
else
|
else
|
||||||
QAbstractSpinBox::wheelEvent(event);
|
QAbstractSpinBox::wheelEvent(event);
|
||||||
}
|
}
|
||||||
@@ -304,8 +314,8 @@ void EvalSpinBox::stepByDouble(double steps) {
|
|||||||
QString t = text();
|
QString t = text();
|
||||||
if (eval->check(t)) {
|
if (eval->check(t)) {
|
||||||
t = eval->expression();
|
t = eval->expression();
|
||||||
//QRegExp re("(\\-?\\d+)");
|
#if QT_VERSION_MAJOR <= 5
|
||||||
QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
/* QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
if ((pos = re.indexIn(t)) != -1) {
|
if ((pos = re.indexIn(t)) != -1) {
|
||||||
double v = t.mid(pos, re.matchedLength()).toDouble();
|
double v = t.mid(pos, re.matchedLength()).toDouble();
|
||||||
@@ -316,6 +326,10 @@ void EvalSpinBox::stepByDouble(double steps) {
|
|||||||
double v = steps;
|
double v = steps;
|
||||||
t = QString::number(v) + t;
|
t = QString::number(v) + t;
|
||||||
}
|
}
|
||||||
|
#else*/
|
||||||
|
QRegularExpression re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
||||||
|
/// TODO andrey
|
||||||
|
#endif
|
||||||
eval->check(t);
|
eval->check(t);
|
||||||
lineEdit()->setText(eval->expression());
|
lineEdit()->setText(eval->expression());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,7 +482,13 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
break;
|
break;
|
||||||
case QEvent::DragMove:
|
case QEvent::DragMove:
|
||||||
if (!isEnabled()) break;
|
if (!isEnabled()) break;
|
||||||
drag_cursor = ui->textCode->cursorForPosition(((QDragMoveEvent*)e)->pos());
|
drag_cursor = ui->textCode->cursorForPosition(
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
((QDragMoveEvent*)e)->pos()
|
||||||
|
#else
|
||||||
|
((QDragMoveEvent*)e)->position().toPoint()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
repaintCursor();
|
repaintCursor();
|
||||||
break;
|
break;
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
|
|||||||
@@ -226,7 +226,8 @@ public slots:
|
|||||||
void setShowSpaces(bool yes);
|
void setShowSpaces(bool yes);
|
||||||
void setShowLineNumbers(bool yes);
|
void setShowLineNumbers(bool yes);
|
||||||
void search(const QString & t);
|
void search(const QString & t);
|
||||||
void searchNext(bool next = true);
|
void searchNext(bool next);
|
||||||
|
void searchNext() {searchNext(true);}
|
||||||
void searchPrevious();
|
void searchPrevious();
|
||||||
void hideSearch();
|
void hideSearch();
|
||||||
void setWordCompletitionEnabled(bool on) {word_complete = on;}
|
void setWordCompletitionEnabled(bool on) {word_complete = on;}
|
||||||
|
|||||||
@@ -61,7 +61,13 @@ bool QPIConfigWidget::eventFilter(QObject * o, QEvent * e) {
|
|||||||
if (((QMouseEvent * )e)->buttons() == Qt::RightButton) {
|
if (((QMouseEvent * )e)->buttons() == Qt::RightButton) {
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
itemClicked(pi, 1);
|
itemClicked(pi, 1);
|
||||||
popupMenu.popup(((QMouseEvent * )e)->globalPos());
|
popupMenu.popup(
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
((QMouseEvent * )e)->globalPos()
|
||||||
|
#else
|
||||||
|
((QMouseEvent * )e)->globalPosition().toPoint()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,99 +210,167 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_delete();
|
_delete();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
switch (new_value.type()) {
|
switch (new_value.type()) {
|
||||||
|
#else
|
||||||
|
switch (new_value.metaType().id()) {
|
||||||
|
#endif
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Bool:
|
case QVariant::Bool:
|
||||||
|
#else
|
||||||
|
case QMetaType::Bool:
|
||||||
|
#endif
|
||||||
_check = new QCheckBox(this);
|
_check = new QCheckBox(this);
|
||||||
_check->setAutoFillBackground(true);
|
_check->setAutoFillBackground(true);
|
||||||
_cur_edit = _check;
|
_cur_edit = _check;
|
||||||
connect(_check, SIGNAL(toggled(bool)), this, SLOT(_changed()));
|
connect(_check, SIGNAL(toggled(bool)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Int:
|
case QVariant::Int:
|
||||||
|
#else
|
||||||
|
case QMetaType::Int:
|
||||||
|
#endif
|
||||||
_spin = new QDoubleSpinBox(this);
|
_spin = new QDoubleSpinBox(this);
|
||||||
_spin->setDecimals(0);
|
_spin->setDecimals(0);
|
||||||
_spin->setRange(-0x7FFFFFFF, 0x7FFFFFFF);
|
_spin->setRange(-0x7FFFFFFF, 0x7FFFFFFF);
|
||||||
_cur_edit = _spin;
|
_cur_edit = _spin;
|
||||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::UInt:
|
case QVariant::UInt:
|
||||||
|
#else
|
||||||
|
case QMetaType::UInt:
|
||||||
|
#endif
|
||||||
_spin = new QDoubleSpinBox(this);
|
_spin = new QDoubleSpinBox(this);
|
||||||
_spin->setDecimals(0);
|
_spin->setDecimals(0);
|
||||||
_spin->setRange(0, 0xFFFFFFFF);
|
_spin->setRange(0, 0xFFFFFFFF);
|
||||||
_cur_edit = _spin;
|
_cur_edit = _spin;
|
||||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::LongLong:
|
case QVariant::LongLong:
|
||||||
|
#else
|
||||||
|
case QMetaType::LongLong:
|
||||||
|
#endif
|
||||||
_spin = new QDoubleSpinBox(this);
|
_spin = new QDoubleSpinBox(this);
|
||||||
_spin->setDecimals(0);
|
_spin->setDecimals(0);
|
||||||
_spin->setRange(-0x7FFFFFFFFFFFFFFFL, 0x7FFFFFFFFFFFFFFFL);
|
_spin->setRange(-0x7FFFFFFFFFFFFFFFL, 0x7FFFFFFFFFFFFFFFL);
|
||||||
_cur_edit = _spin;
|
_cur_edit = _spin;
|
||||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::ULongLong:
|
case QVariant::ULongLong:
|
||||||
|
#else
|
||||||
|
case QMetaType::ULongLong:
|
||||||
|
#endif
|
||||||
_spin = new QDoubleSpinBox(this);
|
_spin = new QDoubleSpinBox(this);
|
||||||
_spin->setDecimals(0);
|
_spin->setDecimals(0);
|
||||||
_spin->setRange(0L, 0x7FFFFFFFFFFFFFFFL);
|
_spin->setRange(0L, 0x7FFFFFFFFFFFFFFFL);
|
||||||
_cur_edit = _spin;
|
_cur_edit = _spin;
|
||||||
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_spin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
|
#else
|
||||||
|
case QMetaType::Double:
|
||||||
|
#endif
|
||||||
_espin = new EvalSpinBox(this);
|
_espin = new EvalSpinBox(this);
|
||||||
//_spin->setDecimals(5);
|
//_spin->setDecimals(5);
|
||||||
//_spin->setRange(-1E+199, 1E+199);
|
//_spin->setRange(-1E+199, 1E+199);
|
||||||
_cur_edit = _espin;
|
_cur_edit = _espin;
|
||||||
connect(_espin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
connect(_espin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Color:
|
case QVariant::Color:
|
||||||
|
#else
|
||||||
|
case QMetaType::QColor:
|
||||||
|
#endif
|
||||||
_color = new ColorButton(this);
|
_color = new ColorButton(this);
|
||||||
_color->setUseAlphaChannel(true);
|
_color->setUseAlphaChannel(true);
|
||||||
_cur_edit = _color;
|
_cur_edit = _color;
|
||||||
connect(_color, SIGNAL(colorChanged(QColor)), this, SLOT(_changed()));
|
connect(_color, SIGNAL(colorChanged(QColor)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::String:
|
case QVariant::String:
|
||||||
|
#else
|
||||||
|
case QMetaType::QString:
|
||||||
|
#endif
|
||||||
_line = new CLineEdit(this);
|
_line = new CLineEdit(this);
|
||||||
_cur_edit = _line;
|
_cur_edit = _line;
|
||||||
connect(_line, SIGNAL(textChanged(QString)), this, SLOT(_changed()));
|
connect(_line, SIGNAL(textChanged(QString)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::StringList:
|
case QVariant::StringList:
|
||||||
|
#else
|
||||||
|
case QMetaType::QStringList:
|
||||||
|
#endif
|
||||||
_list = new StringListEdit(this);
|
_list = new StringListEdit(this);
|
||||||
_cur_edit = _list;
|
_cur_edit = _list;
|
||||||
connect(_list, SIGNAL(valueChanged()), this, SLOT(_changed()));
|
connect(_list, SIGNAL(valueChanged()), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Rect:
|
case QVariant::Rect:
|
||||||
|
#else
|
||||||
|
case QMetaType::QRect:
|
||||||
|
#endif
|
||||||
_rect = new QRectEdit(this);
|
_rect = new QRectEdit(this);
|
||||||
_rect->setDecimals(0);
|
_rect->setDecimals(0);
|
||||||
_cur_edit = _rect;
|
_cur_edit = _rect;
|
||||||
connect(_rect, SIGNAL(valueChanged(QRectF)), this, SLOT(_changed()));
|
connect(_rect, SIGNAL(valueChanged(QRectF)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::RectF:
|
case QVariant::RectF:
|
||||||
|
#else
|
||||||
|
case QMetaType::QRectF:
|
||||||
|
#endif
|
||||||
_rect = new QRectEdit(this);
|
_rect = new QRectEdit(this);
|
||||||
_rect->setDecimals(3);
|
_rect->setDecimals(3);
|
||||||
_cur_edit = _rect;
|
_cur_edit = _rect;
|
||||||
connect(_rect, SIGNAL(valueChanged(QRectF)), this, SLOT(_changed()));
|
connect(_rect, SIGNAL(valueChanged(QRectF)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Point:
|
case QVariant::Point:
|
||||||
|
#else
|
||||||
|
case QMetaType::QPoint:
|
||||||
|
#endif
|
||||||
_point = new QPointEdit(this);
|
_point = new QPointEdit(this);
|
||||||
_point->setDecimals(0);
|
_point->setDecimals(0);
|
||||||
_cur_edit = _point;
|
_cur_edit = _point;
|
||||||
connect(_point, SIGNAL(valueChanged(QPointF)), this, SLOT(_changed()));
|
connect(_point, SIGNAL(valueChanged(QPointF)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::PointF:
|
case QVariant::PointF:
|
||||||
|
#else
|
||||||
|
case QMetaType::QPointF:
|
||||||
|
#endif
|
||||||
_point = new QPointEdit(this);
|
_point = new QPointEdit(this);
|
||||||
_point->setDecimals(3);
|
_point->setDecimals(3);
|
||||||
_cur_edit = _point;
|
_cur_edit = _point;
|
||||||
connect(_point, SIGNAL(valueChanged(QPointF)), this, SLOT(_changed()));
|
connect(_point, SIGNAL(valueChanged(QPointF)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Date:
|
case QVariant::Date:
|
||||||
|
#else
|
||||||
|
case QMetaType::QDate:
|
||||||
|
#endif
|
||||||
_date = new QDateEdit(this);
|
_date = new QDateEdit(this);
|
||||||
_cur_edit = _date;
|
_cur_edit = _date;
|
||||||
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::Time:
|
case QVariant::Time:
|
||||||
|
#else
|
||||||
|
case QMetaType::QTime:
|
||||||
|
#endif
|
||||||
_date = new QTimeEdit(this);
|
_date = new QTimeEdit(this);
|
||||||
_cur_edit = _date;
|
_cur_edit = _date;
|
||||||
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
||||||
break;
|
break;
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::DateTime:
|
case QVariant::DateTime:
|
||||||
|
#else
|
||||||
|
case QMetaType::QDateTime:
|
||||||
|
#endif
|
||||||
_date = new QDateTimeEdit(this);
|
_date = new QDateTimeEdit(this);
|
||||||
_cur_edit = _date;
|
_cur_edit = _date;
|
||||||
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
connect(_date, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(_changed()));
|
||||||
@@ -351,23 +419,107 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
|
|||||||
|
|
||||||
|
|
||||||
QVariant QVariantEdit::value() const {
|
QVariant QVariantEdit::value() const {
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
switch (_value.type()) {
|
switch (_value.type()) {
|
||||||
case QVariant::Bool: return _check->isChecked();
|
#else
|
||||||
case QVariant::Int: return int(_spin->value());
|
switch (_value.metaType().id()) {
|
||||||
case QVariant::UInt: return (unsigned int)(_spin->value());
|
#endif
|
||||||
case QVariant::LongLong: return qlonglong(_spin->value());
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::ULongLong: return qulonglong(_spin->value());
|
case QVariant::Bool:
|
||||||
case QVariant::Double: return _espin->value();
|
#else
|
||||||
case QVariant::Color: return _color->color();
|
case QMetaType::Bool:
|
||||||
case QVariant::String: return _line->text();
|
#endif
|
||||||
case QVariant::StringList: return _list->value();
|
return _check->isChecked();
|
||||||
case QVariant::Rect: return _rect->value().toRect();
|
#if QT_VERSION_MAJOR <= 5
|
||||||
case QVariant::RectF: return _rect->value();
|
case QVariant::Int:
|
||||||
case QVariant::Point: return _point->value().toPoint();
|
#else
|
||||||
case QVariant::PointF: return _point->value();
|
case QMetaType::Int:
|
||||||
case QVariant::Date: return _date->date();
|
#endif
|
||||||
case QVariant::Time: return _date->time();
|
return int(_spin->value());
|
||||||
case QVariant::DateTime: return _date->dateTime();
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::UInt:
|
||||||
|
#else
|
||||||
|
case QMetaType::UInt:
|
||||||
|
#endif
|
||||||
|
return (unsigned int)(_spin->value());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::LongLong:
|
||||||
|
#else
|
||||||
|
case QMetaType::LongLong:
|
||||||
|
#endif
|
||||||
|
return qlonglong(_spin->value());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::ULongLong:
|
||||||
|
#else
|
||||||
|
case QMetaType::ULongLong:
|
||||||
|
#endif
|
||||||
|
return qulonglong(_spin->value());
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Double:
|
||||||
|
#else
|
||||||
|
case QMetaType::Double:
|
||||||
|
#endif
|
||||||
|
return _espin->value();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Color:
|
||||||
|
#else
|
||||||
|
case QMetaType::QColor:
|
||||||
|
#endif
|
||||||
|
return _color->color();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::String:
|
||||||
|
#else
|
||||||
|
case QMetaType::QString:
|
||||||
|
#endif
|
||||||
|
return _line->text();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::StringList:
|
||||||
|
#else
|
||||||
|
case QMetaType::QStringList:
|
||||||
|
#endif
|
||||||
|
return _list->value();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Rect:
|
||||||
|
#else
|
||||||
|
case QMetaType::QRect:
|
||||||
|
#endif
|
||||||
|
return _rect->value().toRect();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::RectF:
|
||||||
|
#else
|
||||||
|
case QMetaType::QRectF:
|
||||||
|
#endif
|
||||||
|
return _rect->value();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Point:
|
||||||
|
#else
|
||||||
|
case QMetaType::QPoint:
|
||||||
|
#endif
|
||||||
|
return _point->value().toPoint();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::PointF:
|
||||||
|
#else
|
||||||
|
case QMetaType::QPointF:
|
||||||
|
#endif
|
||||||
|
return _point->value();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Date:
|
||||||
|
#else
|
||||||
|
case QMetaType::QDate:
|
||||||
|
#endif
|
||||||
|
return _date->date();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::Time:
|
||||||
|
#else
|
||||||
|
case QMetaType::QTime:
|
||||||
|
#endif
|
||||||
|
return _date->time();
|
||||||
|
#if QT_VERSION_MAJOR <= 5
|
||||||
|
case QVariant::DateTime:
|
||||||
|
#else
|
||||||
|
case QMetaType::QDateTime:
|
||||||
|
#endif
|
||||||
|
return _date->dateTime();
|
||||||
default:
|
default:
|
||||||
if (_value.canConvert<QAD::Enum>() && _enum) {
|
if (_value.canConvert<QAD::Enum>() && _enum) {
|
||||||
QAD::Enum ret;
|
QAD::Enum ret;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
#include "qad_locations.h"
|
#include "qad_locations.h"
|
||||||
|
#include "qad_types.h"
|
||||||
|
|
||||||
|
|
||||||
SessionManager::SessionManager(QString file) {
|
SessionManager::SessionManager(QString file) {
|
||||||
@@ -107,7 +108,7 @@ void SessionManager::save() {
|
|||||||
sr.setValue(floats[i].first, *floats[i].second, false);
|
sr.setValue(floats[i].first, *floats[i].second, false);
|
||||||
QSet<QObject*> all_list;
|
QSet<QObject*> all_list;
|
||||||
foreach (QObject * c, tsc) {
|
foreach (QObject * c, tsc) {
|
||||||
all_list |= QSet<QObject*>::fromList(c->findChildren<QObject*>());
|
all_list |= QList2QSet(c->findChildren<QObject*>());
|
||||||
}
|
}
|
||||||
QMap<const QMetaObject*, QByteArray> funcs = metaFunctions(all_list, "sessionSave");
|
QMap<const QMetaObject*, QByteArray> funcs = metaFunctions(all_list, "sessionSave");
|
||||||
//qDebug() << "check for save" << all_list.size();
|
//qDebug() << "check for save" << all_list.size();
|
||||||
@@ -231,7 +232,7 @@ void SessionManager::load(bool onlyMainwindow) {
|
|||||||
*floats[i].second = sr.getValue(floats[i].first, *floats[i].second).toFloat();
|
*floats[i].second = sr.getValue(floats[i].first, *floats[i].second).toFloat();
|
||||||
QSet<QObject*> all_list;
|
QSet<QObject*> all_list;
|
||||||
foreach (QObject * c, tsc) {
|
foreach (QObject * c, tsc) {
|
||||||
all_list |= QSet<QObject*>::fromList(c->findChildren<QObject*>());
|
all_list |= QList2QSet(c->findChildren<QObject*>());
|
||||||
}
|
}
|
||||||
QMap<const QMetaObject*, QByteArray> funcs = metaFunctions(all_list, "sessionLoad");
|
QMap<const QMetaObject*, QByteArray> funcs = metaFunctions(all_list, "sessionLoad");
|
||||||
//qDebug() << "check for load" << all_list.size();
|
//qDebug() << "check for load" << all_list.size();
|
||||||
|
|||||||
@@ -117,8 +117,10 @@ private:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void save();
|
void save();
|
||||||
void load(bool onlyMainwindow = false);
|
void load(bool onlyMainwindow);
|
||||||
void clear(bool with_filename = true);
|
void load() {load(false);}
|
||||||
|
void clear(bool with_filename);
|
||||||
|
void clear() {clear(true);}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loading(QPIConfig & );
|
void loading(QPIConfig & );
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
#if QT_VERSION >= 0x050000
|
enableHighDPI();
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
#endif
|
|
||||||
a.setWindowIcon(QIcon(":/icons/blockview.png"));
|
a.setWindowIcon(QIcon(":/icons/blockview.png"));
|
||||||
BlockEditor w;
|
BlockEditor w;
|
||||||
if (a.arguments().size() > 1)
|
if (a.arguments().size() > 1)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "piqt_connection_edit.h"
|
#include "piqt_connection_edit.h"
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <qpiconfig.h>
|
#include <qpiconfig.h>
|
||||||
|
#include <qad_types.h>
|
||||||
#include <evalspinbox.h>
|
#include <evalspinbox.h>
|
||||||
#include <piintrospection_server.h>
|
#include <piintrospection_server.h>
|
||||||
|
|
||||||
@@ -9,9 +10,7 @@
|
|||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
PIINTROSPECTION_START
|
PIINTROSPECTION_START
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
#if QT_VERSION >= 0x050000
|
enableHighDPI();
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
#endif
|
|
||||||
ConnectionEdit w;
|
ConnectionEdit w;
|
||||||
if (a.arguments().size() > 1) {
|
if (a.arguments().size() > 1) {
|
||||||
QPIConfig cfg(a.arguments()[1]);
|
QPIConfig cfg(a.arguments()[1]);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "ui_pidumper.h"
|
#include "ui_pidumper.h"
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
#if QT_VERSION >= 0x050000
|
enableHighDPI();
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
#endif
|
|
||||||
PIDumper w;
|
PIDumper w;
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "ui_piintrospector.h"
|
#include "ui_piintrospector.h"
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <emainwindow.h>
|
#include <emainwindow.h>
|
||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
|
|||||||
@@ -1,13 +1,35 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
#include "piintrospector.h"
|
#include "piintrospector.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "qcodeedit.h"
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
#if QT_VERSION >= 0x050000
|
enableHighDPI();
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
#endif
|
|
||||||
QPIIntrospector w;
|
QPIIntrospector w;
|
||||||
|
/*QCodeEdit w;
|
||||||
|
w.setEditorFont(QFont("dejavu sans mono", 10));
|
||||||
|
w.setText(
|
||||||
|
"Telegram.addCommand(\"Поискать 💰\", \"find_money\");\n"
|
||||||
|
"Telegram.addCommand(\"🔍Исследования\", \"research\");\n"
|
||||||
|
"Telegram.addCommand(\"📖Инфо/🌍Планета\", \"planet_info\");\n"
|
||||||
|
"Telegram.addCommand(\"📖Инфо/💻Дерево исследований\", \"research_map\");\n"
|
||||||
|
"Telegram.addCommand(\"📖Инфо/🌌Сканер планет\", \"map_info\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/📖Инфо\", \"planet_info\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/⛏Шахта\", \"info_plant\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/⛏Шахта/📖Инфо\", \"info_plant\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/⛏Шахта/🛠Cтроить ⛏Шахту\", \"build_plant\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/⚡️Электростанция\", \"info_solar\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/⚡️Электростанция/📖Инфо\", \"info_solar\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/⚡️Электростанция/🛠Cтроить ⚡️Электростанцию\", \"build_solar\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/🔋Аккумулятор\", \"info_accum\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/🔋Аккумулятор/📖Инфо\", \"info_accum\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/🔋Аккумулятор/🛠Cтроить 🔋Аккумулятор\", \"build_accum\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/📦Хранилище\", \"info_storage\");\n"
|
||||||
|
"Telegram.addCommand(\"🛠Строительство/📦Хранилище/📖Инфо\", \"info_storage\");\n"
|
||||||
|
);
|
||||||
|
//w.textEdit()->setCursorWidth(1);*/
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include "qad_types.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
#if QT_VERSION >= 0x050000
|
enableHighDPI();
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
|
||||||
#endif
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|||||||
Reference in New Issue
Block a user