diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml
index a8ff73315c7..5722143c046 100644
--- a/.github/workflows/build_cmake.yml
+++ b/.github/workflows/build_cmake.yml
@@ -168,6 +168,47 @@ jobs:
string(REPLACE "licheck_mac" "" qtconfig "${qtconfig}")
file(WRITE "qt5/${qt_dir_prefix}/mkspecs/qconfig.pri" "${qtconfig}")
+ - name: Download OpenSSL
+ shell: cmake -P {0}
+ run: |
+ if ("${{ runner.os }}" STREQUAL "Windows")
+ set(url_os "windows_x86")
+ set(openssl_localdir "Tools/OpenSSL/Win_x64/bin")
+ set(openssl_dest_dir "instdir/bin")
+ set(shared_suffix ".dll")
+ elseif ("${{ runner.os }}" STREQUAL "Linux")
+ set(url_os "linux_x64")
+ set(openssl_localdir "Tools/OpenSSL/binary/lib")
+ set(openssl_dest_dir "instdir/lib/Qt/lib")
+ set(shared_suffix ".so*")
+ elseif ("${{ runner.os }}" STREQUAL "macOS")
+ # Not needed on macOS
+ return()
+ endif()
+
+ set(openssl_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/tools_openssl_x64")
+ file(DOWNLOAD "${openssl_base_url}/Updates.xml" ./Updates.xml SHOW_PROGRESS)
+
+ file(READ ./Updates.xml updates_xml)
+ string(REGEX MATCH
+ "(qt.tools.openssl.*).*([0-9+-.]+).*(.*)" updates_xml_output "${updates_xml}")
+
+ set(openssl_directory ${CMAKE_MATCH_1})
+ set(openssl_version ${CMAKE_MATCH_2})
+ set(openssl_archive ${CMAKE_MATCH_3})
+
+ set(url "${openssl_base_url}/${openssl_directory}/${openssl_version}${openssl_archive}")
+
+ file(MAKE_DIRECTORY openssl)
+ file(MAKE_DIRECTORY ${openssl_dest_dir})
+
+ message("Downloading ${url}")
+ file(DOWNLOAD "${url}" ./openssl.7z SHOW_PROGRESS)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ../openssl.7z WORKING_DIRECTORY openssl)
+
+ file(GLOB openssl_shared_objects "openssl/${openssl_localdir}/*${shared_suffix}")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy ${openssl_shared_objects} ${openssl_dest_dir})
- name: Download libclang
id: libclang
@@ -358,13 +399,18 @@ jobs:
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest -j ${N}
WORKING_DIRECTORY build
RESULT_VARIABLE result
+ OUTPUT_VARIABLE stdout
+ ERROR_VARIABLE stdout
)
- # Do not fail on ctest failure
- #if (NOT result EQUAL 0)
- # message(FATAL_ERROR "Running tests failed!")
- #endif()
+ message("${stdout}")
+ if (NOT result EQUAL 0)
+ string(REGEX MATCH "[0-9]+% tests.*[0-9.]+ sec" pass_rate "${stdout}")
+
+ # Do not fail on ctest failure
+ message("::warning::${pass_rate}")
+ endif()
- name: Install Strip
run: |
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 5904b8bd307..47c8c696f0d 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -54,10 +54,23 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP ON)
include(InstallRequiredsystemLibraries)
+ # For Qt Creator
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION ${IDE_APP_PATH}
COMPONENT Dependencies
EXCLUDE_FROM_ALL
)
+
+ # For qtcreatorcdbext
+ set(ArchSuffix 32)
+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ArchSuffix 64)
+ endif()
+
+ install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
+ DESTINATION lib/qtcreatorcdbext${ArchSuffix}
+ COMPONENT Dependencies
+ EXCLUDE_FROM_ALL
+ )
endif()
endif()
diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake
index 1e0829dd675..bbfb0a214be 100644
--- a/cmake/QtCreatorAPI.cmake
+++ b/cmake/QtCreatorAPI.cmake
@@ -433,7 +433,7 @@ endfunction()
#
function(add_qtc_library name)
- cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS"
+ cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS;UNVERSIONED"
"DESTINATION;COMPONENT"
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN}
)
@@ -536,6 +536,7 @@ function(add_qtc_library name)
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
VERSION "${IDE_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
+ CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
BUILD_RPATH "${_LIB_RPATH}"
@@ -547,7 +548,7 @@ function(add_qtc_library name)
)
enable_pch(${name})
- if (WIN32 AND library_type STREQUAL "SHARED")
+ if (WIN32 AND library_type STREQUAL "SHARED" AND NOT _arg_UNVERSIONED)
# Match qmake naming scheme e.g. Library4.dll
set_target_properties(${name} PROPERTIES
SUFFIX "${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}"
@@ -781,6 +782,7 @@ function(add_qtc_plugin target_name)
qtc_output_binary_dir(_output_binary_dir)
set_target_properties(${target_name} PROPERTIES
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
+ CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
_arg_DEPENDS "${_arg_PLUGIN_DEPENDS}"
@@ -991,6 +993,7 @@ function(add_qtc_executable name)
INSTALL_RPATH "${install_rpath}"
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
QT_SKIP_TRANSLATION "${skip_translation}"
+ CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
${_arg_PROPERTIES}
@@ -1121,3 +1124,16 @@ function(finalize_qtc_gtest test_name)
finalize_test_setup(${test})
endforeach()
endfunction()
+
+# This is the CMake equivalent of "RESOURCES = $$files()" from qmake
+function(qtc_glob_resources)
+ cmake_parse_arguments(_arg "" "QRC_FILE;ROOT;GLOB" "" ${ARGN})
+
+ file(GLOB_RECURSE fileList RELATIVE "${_arg_ROOT}" "${_arg_ROOT}/${_arg_GLOB}")
+ set(qrcData "\n")
+ foreach(file IN LISTS fileList)
+ string(APPEND qrcData " ${_arg_ROOT}/${file}\n")
+ endforeach()
+ string(APPEND qrcData "")
+ file(WRITE "${_arg_QRC_FILE}" "${qrcData}")
+endfunction()
diff --git a/dist/installer/mac/entitlements.plist b/dist/installer/mac/entitlements.plist
new file mode 100644
index 00000000000..0aae7ab39d9
--- /dev/null
+++ b/dist/installer/mac/entitlements.plist
@@ -0,0 +1,10 @@
+
+
+
+
+ com.apple.security.cs.debugger
+
+ com.apple.security.cs.disable-library-validation
+
+
+
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index c8876613bc0..80f2b4cf66c 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -10,6 +10,33 @@ add_feature_info("Build online documentation" WITH_ONLINE_DOCS "")
option(BUILD_DEVELOPER_DOCS "Include developer documentation" OFF)
add_feature_info("Include developer documentation" BUILD_DEVELOPER_DOCS "")
+function(_find_all_includes _ret_includes _ret_framework_paths)
+ set(_all_includes "${PROJECT_SOURCE_DIR}/src/plugins;${PROJECT_SOURCE_DIR}/src/libs")
+ foreach(_target ${__QTC_PLUGINS} ${__QTC_LIBRARIES})
+ if (NOT TARGET ${_target})
+ continue()
+ endif()
+ get_target_property(_includes ${_target} INCLUDE_DIRECTORIES)
+ foreach(_include ${_includes})
+ string(FIND "${_include}" "/src/plugins/" _in_plugins)
+ string(FIND "${_include}" "/src/libs/" _in_libs)
+ string(FIND "${_include}" "${CMAKE_BINARY_DIR}" _in_build)
+ if(_in_plugins LESS 0 AND _in_libs LESS 0 AND _in_build LESS 0)
+ list(APPEND _all_includes ${_include})
+ endif()
+ endforeach()
+ endforeach()
+ list(APPEND _all_includes ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
+ list(REMOVE_DUPLICATES _all_includes)
+ set("${_ret_includes}" "${_all_includes}" PARENT_SCOPE)
+
+ # framework path
+ if (APPLE)
+ get_target_property(_qt_target Qt5::Core LOCATION) # /QtCore.framework/QtCore
+ get_filename_component(_qt_loc "${_qt_target}" DIRECTORY)
+ set("${_ret_framework_paths}" "${_qt_loc}/.." PARENT_SCOPE)
+ endif()
+endfunction()
# Find programs:
function(_doc_find_program result_var)
@@ -51,7 +78,7 @@ endfunction()
function(_setup_qdoc_targets _qdocconf_file _retval)
cmake_parse_arguments(_arg "" "HTML_DIR;INSTALL_DIR;POSTFIX"
- "INDEXES;ENVIRONMENT_EXPORTS" ${ARGN})
+ "INDEXES;INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;ENVIRONMENT_EXPORTS" ${ARGN})
foreach(_index ${_arg_INDEXES})
list(APPEND _qdoc_index_args "-indexdir;${_index}")
@@ -79,9 +106,30 @@ function(_setup_qdoc_targets _qdocconf_file _retval)
set(_html_outputdir "${_arg_HTML_DIR}/${_target}${_arg_POSTFIX}")
file(MAKE_DIRECTORY "${_html_outputdir}")
+ set(_qdoc_include_args "")
+ if (_arg_INCLUDE_DIRECTORIES OR _arg_FRAMEWORK_PATHS)
+ # pass include directories to qdoc via hidden @ option, since we need to generate a file
+ # to be able to resolve the generators inside the include paths
+ set(_qdoc_includes "${CMAKE_CURRENT_BINARY_DIR}/cmake/qdoc_${_target}.inc")
+ set(_qdoc_include_args "@${_qdoc_includes}")
+ set(_includes "")
+ if (_arg_INCLUDE_DIRECTORIES)
+ set(_includes "-I$\n")
+ endif()
+ set(_frameworks "")
+ if (_arg_FRAMEWORK_PATHS)
+ set(_frameworks "-F$\n")
+ endif()
+ file(GENERATE
+ OUTPUT "${_qdoc_includes}"
+ CONTENT "${_includes}${_frameworks}"
+ )
+ endif()
+
set(_html_target "html_docs_${_target}")
add_custom_target("${_html_target}"
- ${_full_qdoc_command} "-outputdir" "${_html_outputdir}" "${_qdocconf_file}" ${_qdoc_index_args}
+ ${_full_qdoc_command} -outputdir "${_html_outputdir}" "${_qdocconf_file}"
+ ${_qdoc_index_args} ${_qdoc_include_args}
COMMENT "Build HTML documentation from ${_qdocconf_file}"
DEPENDS "${_qdocconf_file}"
SOURCES "${_qdocconf_file}"
@@ -176,7 +224,7 @@ function(qdoc_build_qdocconf_file _qdocconf_file)
endif()
cmake_parse_arguments(_arg "QCH" "HTML_DIR;QCH_DIR;INSTALL_DIR;POSTFIX"
- "INDEXES;ENVIRONMENT_EXPORTS" ${ARGN})
+ "INDEXES;INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;ENVIRONMENT_EXPORTS" ${ARGN})
if (_arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "qdoc_build_qdocconf_file has unknown arguments: ${_arg_UNPARSED_ARGUMENTS}.")
endif()
@@ -188,7 +236,10 @@ function(qdoc_build_qdocconf_file _qdocconf_file)
_setup_qdoc_targets("${_qdocconf_file}" _html_outputdir
HTML_DIR "${_arg_HTML_DIR}" INSTALL_DIR "${_arg_INSTALL_DIR}"
INDEXES ${_arg_INDEXES} ENVIRONMENT_EXPORTS ${_arg_ENVIRONMENT_EXPORTS}
- POSTFIX "${_arg_POSTFIX}")
+ POSTFIX "${_arg_POSTFIX}"
+ INCLUDE_DIRECTORIES ${_arg_INCLUDE_DIRECTORIES}
+ FRAMEWORK_PATHS ${_arg_FRAMEWORK_PATHS}
+ )
if (_arg_QCH)
_setup_qhelpgenerator_targets("${_qdocconf_file}" "${_html_outputdir}"
@@ -231,13 +282,21 @@ if (WITH_ONLINE_DOCS OR WITH_DOCS)
if (WITH_DOCS)
qdoc_build_qdocconf_file("qtcreator/qtcreator.qdocconf" ${_qch_params} ${_qdoc_params})
if (BUILD_DEVELOPER_DOCS)
- qdoc_build_qdocconf_file("qtcreatordev/qtcreator-dev.qdocconf" ${_qch_params} ${_qdoc_params})
+ _find_all_includes(_all_includes _framework_paths)
+ qdoc_build_qdocconf_file("qtcreatordev/qtcreator-dev.qdocconf" ${_qch_params} ${_qdoc_params}
+ INCLUDE_DIRECTORIES ${_all_includes}
+ FRAMEWORK_PATHS ${_framework_paths}
+ )
endif()
endif()
if(WITH_ONLINE_DOCS)
qdoc_build_qdocconf_file("qtcreator/qtcreator-online.qdocconf" ${_qdoc_params})
if (BUILD_DEVELOPER_DOCS)
- qdoc_build_qdocconf_file("qtcreatordev/qtcreator-dev-online.qdocconf" ${_qdoc_params})
+ _find_all_includes(_all_includes _framework_paths)
+ qdoc_build_qdocconf_file("qtcreatordev/qtcreator-dev-online.qdocconf" ${_qdoc_params}
+ INCLUDE_DIRECTORIES ${_all_includes}
+ FRAMEWORK_PATHS ${_framework_paths}
+ )
endif()
endif()
endif()
diff --git a/doc/doc.pri b/doc/doc.pri
index 28c6be8520b..4f4c315c3cb 100644
--- a/doc/doc.pri
+++ b/doc/doc.pri
@@ -1,7 +1,7 @@
build_online_docs: \
- DOC_FILES += $$PWD/qtcreator/qtcreator-online.qdocconf $$PWD/qtcreatordev/qtcreator-dev-online.qdocconf
+ DOC_FILES += $$IDE_DOC_FILES_ONLINE
else: \
- DOC_FILES += $$PWD/qtcreator/qtcreator.qdocconf $$PWD/qtcreatordev/qtcreator-dev.qdocconf
+ DOC_FILES += $$IDE_DOC_FILES
include(../docs.pri)
diff --git a/doc/qtcreator/images/qtcreator-workspace-manager.png b/doc/qtcreator/images/qtcreator-workspace-manager.png
new file mode 100644
index 00000000000..3a42f3e536f
Binary files /dev/null and b/doc/qtcreator/images/qtcreator-workspace-manager.png differ
diff --git a/doc/qtcreator/src/howto/creator-sidebars.qdoc b/doc/qtcreator/src/howto/creator-sidebars.qdoc
new file mode 100644
index 00000000000..6cc9feebc4f
--- /dev/null
+++ b/doc/qtcreator/src/howto/creator-sidebars.qdoc
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Creator documentation.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+**
+****************************************************************************/
+
+/*!
+ \contentspage index.html
+ \page creator-sidebars.html
+ \previouspage creator-views.html
+ \nextpage creator-project-managing-workspaces.html
+
+ \title Working with Sidebars
+
+ In the \uicontrol Edit mode, you can use a left and right sidebar to
+ organize different views into project contents. Only views that are
+ relevant to the \l{Selecting Modes}{mode} you are working in are
+ available in it.
+
+ You can select views in the sidebar menu (1):
+
+ \image qtcreator-sidebar.png
+
+ You can change the view of the sidebars in the following ways:
+
+ \list
+ \li To toggle the left sidebar, click \inlineimage leftsidebaricon.png
+ (\uicontrol {Hide Left Sidebar/Show Left Sidebar}) or press
+ \key Alt+0 (\key Cmd+0 on \macos). To toggle the right
+ sidebar, click \inlineimage rightsidebaricon.png
+ (\uicontrol {Hide Right Sidebar/Show Right Sidebar}) or press
+ \key Alt+Shift+0 (\key Cmd+Shift+0 on \macos).
+ \li To split a sidebar, click \inlineimage splitbutton_horizontal.png
+ (\uicontrol {Split}). Select new content to view in the split view.
+ \li To close a sidebar view, click \inlineimage splitbutton_closetop.png
+ (\uicontrol {Close}).
+ \endlist
+*/
diff --git a/doc/qtcreator/src/howto/creator-ui.qdoc b/doc/qtcreator/src/howto/creator-ui.qdoc
index 8e6a23b317f..787633e5ecf 100644
--- a/doc/qtcreator/src/howto/creator-ui.qdoc
+++ b/doc/qtcreator/src/howto/creator-ui.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
@@ -87,11 +87,13 @@
\endif
- The following sections describe some of these controls in more detail:
+ The following sections describe some \QC controls in more detail:
\list
\li \l{Selecting Modes}{Mode selector}
- \li \l{Browsing Project Contents}{Sidebars}
+ \li \l{Browsing Project Contents}{Views}
+ \li \l{Working with Sidebars}{Sidebars}
+ \li \l{Managing Workspaces}{Workspaces}
\li \l{Viewing Output}{Output panes}
\endlist
@@ -253,7 +255,7 @@
\contentspage index.html
\page creator-modes.html
\previouspage creator-quick-tour.html
- \nextpage creator-sidebar-views.html
+ \nextpage creator-views.html
\title Selecting Modes
@@ -327,7 +329,7 @@
/*!
\contentspage index.html
\page creator-output-panes.html
- \previouspage creator-sidebar-views.html
+ \previouspage creator-project-managing-workspaces.html
\if defined(qtdesignstudio)
\nextpage creator-using-qt-quick-designer.html
\else
diff --git a/doc/qtcreator/src/howto/creator-sidebar-views.qdoc b/doc/qtcreator/src/howto/creator-views.qdoc
similarity index 90%
rename from doc/qtcreator/src/howto/creator-sidebar-views.qdoc
rename to doc/qtcreator/src/howto/creator-views.qdoc
index 19662247758..1ae508d3401 100644
--- a/doc/qtcreator/src/howto/creator-sidebar-views.qdoc
+++ b/doc/qtcreator/src/howto/creator-views.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
@@ -25,22 +25,18 @@
/*!
\contentspage index.html
- \page creator-sidebar-views.html
+ \page creator-views.html
\previouspage creator-modes.html
- \nextpage creator-output-panes.html
+ \nextpage creator-sidebars.html
\title Browsing Project Contents
- A left and right sidebar are available in most \QC \l{Selecting Modes}
- {modes}. The availability of the sidebars and their contents depend on
- the mode.
+ You can organize \QC views in \l {Working with Sidebars}{sidebars} or as
+ \l {Managing Workspaces}{workspaces}, depending on the \l{Selecting Modes}
+ {mode} you are working in. Only views that are relevant to a mode are
+ available in it.
- In the \uicontrol Edit and \uicontrol Design mode, you can use the sidebars
- to browse the project contents.
-
- \image qtcreator-sidebar.png
-
- You can select the contents of the sidebars in the sidebar menu (1):
+ The following views are related to managing projects and files:
\list
\li \uicontrol Projects shows a list of projects open in the current
@@ -72,28 +68,8 @@
\endlist
\endif
- For more information about the sidebar views that are only
- available when editing QML files in the Design mode, see
- \l{Editing QML Files in Design Mode}.
-
- You can change the view of the sidebars in the following ways:
-
- \list
-
- \li To toggle the left sidebar, click \inlineimage leftsidebaricon.png
- (\uicontrol {Hide Left Sidebar/Show Left Sidebar}) or press
- \key Alt+0 (\key Cmd+0 on \macos). To toggle the right
- sidebar, click \inlineimage rightsidebaricon.png
- (\uicontrol {Hide Right Sidebar/Show Right Sidebar}) or press
- \key Alt+Shift+0 (\key Cmd+Shift+0 on \macos).
-
- \li To split a sidebar, click \inlineimage splitbutton_horizontal.png
- (\uicontrol {Split}). Select new content to view in the split view.
-
- \li To close a sidebar view, click \inlineimage splitbutton_closetop.png
- (\uicontrol {Close}).
-
- \endlist
+ For more information about views that are only available when editing QML
+ files in the Design mode, see \l{Editing QML Files in Design Mode}.
The additional options in each view are described in the following
sections.
@@ -103,7 +79,8 @@
\section1 Viewing Project Files
- The sidebar displays projects in a project tree. The project tree contains
+ The \uicontrol Projects view displays projects in a project tree. The
+ project tree contains
a list of all projects open in the current session. For each project, the
tree visualizes the build system structure of the project and lists all
files that are part of the project.
diff --git a/doc/qtcreator/src/howto/creator-workspaces.qdoc b/doc/qtcreator/src/howto/creator-workspaces.qdoc
new file mode 100644
index 00000000000..c297c4dc929
--- /dev/null
+++ b/doc/qtcreator/src/howto/creator-workspaces.qdoc
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Creator documentation.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+**
+****************************************************************************/
+
+/*!
+ \contentspage index.html
+ \previouspage creator-sidebars.html
+ \page creator-project-managing-workspaces.html
+ \nextpage creator-output-panes.html
+
+ \title Managing Workspaces
+
+ In the Design and Debug modes, you can arrange a set of \QC
+ views as a \e workspace on the screen. For a list of views,
+ select \uicontrol Window > \uicontrol Views.
+
+ In \QMLD, you can select the \uicontrol {Restore last workspace on startup}
+ check box to save the current workspace as a \e default workspace when you
+ exit \QC and to restore it the next time you start \QC.
+
+ To manage workspaces, select \uicontrol Window > \uicontrol Workspaces >
+ \uicontrol Manage.
+
+ \image qtcreator-workspace-manager.png "Workspace Manager"
+
+ To save a workspace under a new name, select \uicontrol Clone.
+
+ To delete the selected workspace, select \uicontrol Delete.
+
+ To switch between workspaces, select \uicontrol {Switch To}.
+
+ To create a new workspace:
+
+ \list 1
+ \li Select \uicontrol New.
+ \li In the \uicontrol {Enter the name of the workspace} field,
+ enter a name for the workspace.
+ \li Select \uicontrol Create to create a new empty workspace or
+ \uicontrol {Create and Open} to create a workspace and to
+ switch to it.
+ \endlist
+
+*/
diff --git a/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc b/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc
index d6a91039ed9..51b50d93ef2 100644
--- a/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc
+++ b/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
@@ -31,7 +31,7 @@
/*!
\contentspage index.html
- \previouspage creator-quick-tour.html
+ \previouspage creator-output-panes.html
\page creator-configuring.html
\nextpage creator-build-example-application.html
diff --git a/doc/qtcreator/src/qtcreator-toc.qdoc b/doc/qtcreator/src/qtcreator-toc.qdoc
index a01ad1cd34f..8a8cae0ddb5 100644
--- a/doc/qtcreator/src/qtcreator-toc.qdoc
+++ b/doc/qtcreator/src/qtcreator-toc.qdoc
@@ -38,6 +38,8 @@
\list
\li \l{Selecting Modes}
\li \l{Browsing Project Contents}
+ \li \l{Working with Sidebars}
+ \li \l{Managing Workspaces}
\li \l{Viewing Output}
\endlist
\li \l{Configuring Qt Creator}
diff --git a/doc/qtcreator/src/qtquick/creator-only/qtquick-iso-icon-browser.qdoc b/doc/qtcreator/src/qtquick/creator-only/qtquick-iso-icon-browser.qdoc
index c84529b2982..0dbfc06b9fb 100644
--- a/doc/qtcreator/src/qtquick/creator-only/qtquick-iso-icon-browser.qdoc
+++ b/doc/qtcreator/src/qtquick/creator-only/qtquick-iso-icon-browser.qdoc
@@ -48,7 +48,7 @@
\li Open the Qt Quick UI form in the \uicontrol Design mode.
- \li In the \uicontrol Library, select \uicontrol Imports >
+ \li In the \uicontrol Library, select \uicontrol {QML Imports} >
\uicontrol {Add Import} > \uicontrol {QtQuick.Extras} to import the
\l {Qt Quick Extras} module.
diff --git a/doc/qtcreator/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc b/doc/qtcreator/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc
index 0354299713a..709cadb3a81 100644
--- a/doc/qtcreator/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc
+++ b/doc/qtcreator/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc
@@ -76,7 +76,7 @@
\endlist
- Your module should now appear in the \uicontrol Imports tab in the
+ Your module should now appear in the \uicontrol {QML Imports} tab in the
\uicontrol Library in the Design mode. Your components should appear in the
\uicontrol {QML Types} tab if a valid \c .metainfo file is in place.
diff --git a/doc/qtcreator/src/qtquick/qtquick-components.qdoc b/doc/qtcreator/src/qtquick/qtquick-components.qdoc
index 475a8928b53..fac448c820a 100644
--- a/doc/qtcreator/src/qtquick/qtquick-components.qdoc
+++ b/doc/qtcreator/src/qtquick/qtquick-components.qdoc
@@ -48,7 +48,7 @@
applications.
The \uicontrol {Library} pane lists the available QML types, UI
- components, assets, and imports.
+ components, assets, and QML imports.
\image qmldesigner-qml-components.png "QML Components"
@@ -60,11 +60,11 @@
Quick Controls, Dialogs, and Layouts are available for creating user
interfaces using Qt Quick 2. The components and controls are based on
standard QML types. To view the components and controls in the
- \uicontrol {Library}, import the component sets in \uicontrol Imports.
+ \uicontrol {Library}, import the component sets in \uicontrol {QML Imports}.
The \uicontrol {Qt Quick Application} wizards for a particular platform add
the import statements automatically. You can remove import statements in
- \uicontrol Imports
+ \uicontrol {QML Imports}
\uicontrol {Assets} displays the images and other files that you copy
to the project folder (to the same subfolder as the QML files).
diff --git a/doc/qtcreatordev/config/qtcreator-developer.qdocconf b/doc/qtcreatordev/config/qtcreator-developer.qdocconf
index 72fd0efb2cd..f6a4b9a25cd 100644
--- a/doc/qtcreatordev/config/qtcreator-developer.qdocconf
+++ b/doc/qtcreatordev/config/qtcreator-developer.qdocconf
@@ -6,12 +6,15 @@ language = Cpp
headerdirs = . \
../src \
../../../src/libs/aggregation \
- ../../../src/libs/extensionsystem
+ ../../../src/libs/extensionsystem \
+ ../../../src/plugins/coreplugin
sourcedirs = . \
../src \
../../../src/libs/aggregation \
- ../../../src/libs/extensionsystem
+ ../../../src/libs/extensionsystem \
+ ../../../src/plugins/coreplugin
+
excludedirs = ../../../src/libs/aggregation/examples
diff --git a/doc/qtcreatordev/src/common-extension-tasks.qdoc b/doc/qtcreatordev/src/common-extension-tasks.qdoc
index 36f88967818..807c84e1bde 100644
--- a/doc/qtcreatordev/src/common-extension-tasks.qdoc
+++ b/doc/qtcreatordev/src/common-extension-tasks.qdoc
@@ -60,11 +60,16 @@
\row
\li Add a new wizard.
- \li You can extend the wizards in File > New File or Project with
- your own file and project templates.
- \li \l{Core::IWizard}, \l{Core::StandardFileWizard},
- \l{Core::BaseFileWizard}, \l{Core::BaseFileWizardParameters}
+ \li You can extend the wizards in \uicontrol File >
+ \uicontrol {New File or Project} with your own file
+ and project templates. We recommend that you create
+ JSON-based wizards instead of implementing new
+ wizards in C++ code.
+ \li \l{https://doc.qt.io/qtcreator/creator-project-wizards.html}
+ {Adding New Custom Wizards}
+ \l{Core::IWizardFactory}, \l{Core::BaseFileWizardFactory},
+ \l{Core::BaseFileWizard}, \l{Core::WizardDialogParameters}
\row
\li Add support for a new version control system.
\li Version control systems integrated in \QC are Bazaar, CVS, Git,
diff --git a/doc/qtcreatordev/src/qtcreator-module.qdoc b/doc/qtcreatordev/src/qtcreator-module.qdoc
index 4d57ca4a57c..2a4ec2d03de 100644
--- a/doc/qtcreatordev/src/qtcreator-module.qdoc
+++ b/doc/qtcreatordev/src/qtcreator-module.qdoc
@@ -77,8 +77,10 @@
\row
\li \l{qtcreatorcdbext}
\li Windows CDB debugger extension
+ \endomit
\endtable
+
\section1 Plugins
As already mentioned, \QC is basically only a plugin loader framework
@@ -98,9 +100,10 @@
most important ones.
This plugin also contains classes necessary to hook into the
- \l{Locator} as well as support for searching text in arbitrary
- widgets.
+ \l{Core::ILocatorFilter}{Locator} as well as support for
+ searching text in arbitrary widgets.
+ \omit
\row
\li \l{ProjectExplorer}
\li The project explorer plugin. Provides base classes for project
diff --git a/doc/qtdesignstudio/src/qtbridge/qtbridge-sketch-using.qdoc b/doc/qtdesignstudio/src/qtbridge/qtbridge-sketch-using.qdoc
index 2e76d6c59e0..412c20fca2e 100644
--- a/doc/qtdesignstudio/src/qtbridge/qtbridge-sketch-using.qdoc
+++ b/doc/qtdesignstudio/src/qtbridge/qtbridge-sketch-using.qdoc
@@ -168,8 +168,8 @@
example, if you drew a rectangle, you can export it as a
\l Rectangle component.
You can provide the import statement of the module where the QML
- type is defined in the \uicontrol Imports field.
- \li In the \uicontrol Imports field, enter
+ type is defined in the \uicontrol {QML Imports} field.
+ \li In the \uicontrol {QML Imports} field, enter
additional import statements to have them added to the generated QML
file. For example, to use Qt Quick Controls 2.3, you need the
import statement \c {QtQuick.Controls 2.3} and to use Qt Quick
diff --git a/qtcreator_ide_branding.pri b/qtcreator_ide_branding.pri
index 4f7aa7c39ca..cc802f0cc18 100644
--- a/qtcreator_ide_branding.pri
+++ b/qtcreator_ide_branding.pri
@@ -10,3 +10,8 @@ IDE_CASED_ID = QtCreator
PRODUCT_BUNDLE_ORGANIZATION = org.qt-project
PROJECT_USER_FILE_EXTENSION = .user
+
+IDE_DOC_FILES_ONLINE = $$PWD/doc/qtcreator/qtcreator-online.qdocconf \
+ $$PWD/doc/qtcreatordev/qtcreator-dev-online.qdocconf
+IDE_DOC_FILES = $$PWD/doc/qtcreator/qtcreator.qdocconf \
+ $$PWD/doc/qtcreatordev/qtcreator-dev.qdocconf
diff --git a/scripts/build.py b/scripts/build.py
new file mode 100755
index 00000000000..4724ece02a7
--- /dev/null
+++ b/scripts/build.py
@@ -0,0 +1,244 @@
+#!/usr/bin/env python
+#############################################################################
+##
+## Copyright (C) 2020 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the release tools of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+# import the print function which is used in python 3.x
+from __future__ import print_function
+
+import argparse
+import collections
+import glob
+import os
+
+import common
+
+def existing_path(path):
+ return path if os.path.exists(path) else None
+
+def default_python3():
+ path_system = os.path.join('/usr', 'bin') if not common.is_windows_platform() else None
+ path = os.environ.get('PYTHON3_PATH') or path_system
+ postfix = '.exe' if common.is_windows_platform() else ''
+ return existing_path(os.path.join(path, 'python3' + postfix)) or existing_path(os.path.join(path, 'python' + postfix))
+
+def get_arguments():
+ parser = argparse.ArgumentParser(description='Build Qt Creator for packaging')
+ parser.add_argument('--src', help='path to sources', required=True)
+ parser.add_argument('--build', help='path that should be used for building', required=True)
+ parser.add_argument('--qt-path', help='Path to Qt', required=True)
+
+ parser.add_argument('--debug', help='Enable debug builds', action='store_true', default=False)
+
+ # clang codemodel
+ parser.add_argument('--llvm-path', help='Path to LLVM installation for Clang code model',
+ default=os.environ.get('LLVM_INSTALL_DIR'))
+
+ # perfparser
+ parser.add_argument('--elfutils-path',
+ help='Path to elfutils installation for use by perfprofiler (Windows, Linux)')
+
+ # signing
+ parser.add_argument('--keychain-unlock-script',
+ help='Path to script for unlocking the keychain used for signing (macOS)')
+
+ # cdbextension
+ parser.add_argument('--python-path',
+ help='Path to python libraries for use by cdbextension (Windows)')
+
+ parser.add_argument('--app-target', help='File name of the executable / app bundle',
+ default=('Qt Creator.app' if common.is_mac_platform()
+ else 'qtcreator'))
+ parser.add_argument('--python3', help='File path to python3 executable for generating translations',
+ default=default_python3())
+
+ parser.add_argument('--no-cdb',
+ help='Skip cdbextension and the python dependency packaging step (Windows)',
+ action='store_true', default=(not common.is_windows_platform()))
+ parser.add_argument('--no-docs', help='Skip documentation generation',
+ action='store_true', default=False)
+ return parser.parse_args()
+
+def build_qtcreator(args, paths):
+ if not os.path.exists(paths.build):
+ os.makedirs(paths.build)
+ prefix_paths = [paths.qt]
+ if args.llvm_path:
+ prefix_paths += [args.llvm_path]
+ if args.elfutils_path:
+ prefix_paths += [args.elfutils_path]
+ build_type = 'Debug' if args.debug else 'Release'
+ with_docs_str = 'OFF' if args.no_docs else 'ON'
+ cmake_args = ['cmake',
+ '-DCMAKE_PREFIX_PATH=' + ';'.join(prefix_paths),
+ '-DCMAKE_BUILD_TYPE=' + build_type,
+ '-DWITH_DOCS=' + with_docs_str,
+ '-DBUILD_DEVELOPER_DOCS=' + with_docs_str,
+ '-DBUILD_EXECUTABLE_SDKTOOL=OFF',
+ '-DCMAKE_INSTALL_PREFIX=' + paths.install,
+ '-DWITH_TESTS=OFF',
+ '-G', 'Ninja']
+
+ if args.python3:
+ cmake_args += ['-DPYTHON_EXECUTABLE=' + args.python3]
+
+ # force MSVC on Windows, because it looks for GCC in the PATH first,
+ # even if MSVC is first mentioned in the PATH...
+ # TODO would be nicer if we only did this if cl.exe is indeed first in the PATH
+ if common.is_windows_platform():
+ cmake_args += ['-DCMAKE_C_COMPILER=cl',
+ '-DCMAKE_CXX_COMPILER=cl',
+ '-DBUILD_EXECUTABLE_WIN32INTERRUPT=OFF',
+ '-DBUILD_EXECUTABLE_WIN64INTERRUPT=OFF',
+ '-DBUILD_LIBRARY_QTCREATORCDBEXT=OFF']
+ if args.python_path:
+ python_library = glob.glob(os.path.join(args.python_path, 'libs', 'python??.lib'))
+ if python_library:
+ cmake_args += ['-DPYTHON_LIBRARY=' + python_library[0],
+ '-DPYTHON_INCLUDE_DIR=' + os.path.join(args.python_path, 'include')]
+
+ # TODO this works around a CMake bug https://gitlab.kitware.com/cmake/cmake/issues/20119
+ if common.is_linux_platform():
+ cmake_args += ['-DBUILD_WITH_PCH=OFF']
+
+ ide_revision = common.get_commit_SHA(paths.src)
+ if ide_revision:
+ cmake_args += ['-DIDE_REVISION=ON',
+ '-DIDE_REVISION_STR=' + ide_revision,
+ '-DIDE_REVISION_URL_STR=https://code.qt.io/cgit/qt-creator/qt-creator.git/log/?id=' + ide_revision]
+
+ common.check_print_call(cmake_args + [paths.src], paths.build)
+ common.check_print_call(['cmake', '--build', '.'], paths.build)
+ if not args.no_docs:
+ common.check_print_call(['cmake', '--build', '.', '--target', 'docs'], paths.build)
+
+ common.check_print_call(['cmake', '--install', '.', '--prefix', paths.install, '--strip'],
+ paths.build)
+ common.check_print_call(['cmake', '--install', '.', '--prefix', paths.dev_install,
+ '--component', 'Devel'],
+ paths.build)
+
+def build_wininterrupt(args, paths):
+ if not common.is_windows_platform():
+ return
+ # assumes existing Qt Creator build
+ cmake_args = ['-DBUILD_EXECUTABLE_WIN32INTERRUPT=ON',
+ '-DBUILD_EXECUTABLE_WIN64INTERRUPT=ON',
+ '-DBUILD_LIBRARY_QTCREATORCDBEXT=OFF']
+ common.check_print_call(['cmake'] + cmake_args + [paths.src], paths.build)
+ common.check_print_call(['cmake', '--build', '.'], paths.build)
+ common.check_print_call(['cmake', '--install', '.', '--prefix', paths.wininterrupt_install,
+ '--component', 'wininterrupt'],
+ paths.build)
+
+def build_qtcreatorcdbext(args, paths):
+ if args.no_cdb:
+ return
+ # assumes existing Qt Creator build
+ cmake_args = ['-DBUILD_EXECUTABLE_WIN32INTERRUPT=OFF',
+ '-DBUILD_EXECUTABLE_WIN64INTERRUPT=OFF',
+ '-DBUILD_LIBRARY_QTCREATORCDBEXT=ON']
+ common.check_print_call(['cmake'] + cmake_args + [paths.src], paths.build)
+ common.check_print_call(['cmake', '--build', '.'], paths.build)
+ common.check_print_call(['cmake', '--install', '.', '--prefix', paths.qtcreatorcdbext_install,
+ '--component', 'qtcreatorcdbext'],
+ paths.build)
+
+def deploy_qt(args, paths):
+ if common.is_mac_platform():
+ script = os.path.join(paths.src, 'scripts', 'deployqtHelper_mac.sh')
+ app = os.path.join(paths.install, args.app_target)
+ # TODO this is wrong if Qt is set up non-standard
+ # TODO integrate deployqtHelper_mac.sh into deployqt.py, finally
+ qt_bins = os.path.join(paths.qt, 'bin')
+ qt_translations = os.path.join(paths.qt, 'translations')
+ qt_plugins = os.path.join(paths.qt, 'plugins')
+ qt_imports = os.path.join(paths.qt, 'imports')
+ qt_qml = os.path.join(paths.qt, 'qml')
+ common.check_print_call([script, app, qt_bins, qt_translations, qt_plugins,
+ qt_imports, qt_qml],
+ paths.build)
+ else:
+ exe = os.path.join(paths.install, 'bin', args.app_target)
+ common.check_print_call(['python', '-u', os.path.join(paths.src, 'scripts', 'deployqt.py'),
+ '-i', exe, os.path.join(paths.qt, 'bin', 'qmake')],
+ paths.build)
+
+def package_qtcreator(args, paths):
+ common.check_print_call(['7z', 'a', '-mmt2', os.path.join(paths.result, 'qtcreator.7z'), '*'],
+ paths.install)
+ common.check_print_call(['7z', 'a', '-mmt2',
+ os.path.join(paths.result, 'qtcreator_dev.7z'), '*'],
+ paths.dev_install)
+ if common.is_windows_platform():
+ common.check_print_call(['7z', 'a', '-mmt2',
+ os.path.join(paths.result, 'wininterrupt.7z'), '*'],
+ paths.wininterrupt_install)
+ if not args.no_cdb:
+ common.check_print_call(['7z', 'a', '-mmt2',
+ os.path.join(paths.result, 'qtcreatorcdbext.7z'), '*'],
+ paths.qtcreatorcdbext_install)
+
+ if common.is_mac_platform():
+ if args.keychain_unlock_script:
+ common.check_print_call([args.keychain_unlock_script], paths.install)
+ common.check_print_call(['python', '-u',
+ os.path.join(paths.src, 'scripts', 'makedmg.py'),
+ 'qt-creator.dmg',
+ 'Qt Creator',
+ paths.src,
+ paths.install],
+ paths.result)
+
+def get_paths(args):
+ Paths = collections.namedtuple('Paths',
+ ['qt', 'src', 'build',
+ 'install', 'dev_install', 'wininterrupt_install',
+ 'qtcreatorcdbext_install', 'result'])
+ build_path = os.path.abspath(args.build)
+ install_path = os.path.join(build_path, 'install')
+ return Paths(qt=os.path.abspath(args.qt_path),
+ src=os.path.abspath(args.src),
+ build=os.path.join(build_path, 'build'),
+ install=os.path.join(install_path, 'qt-creator'),
+ dev_install=os.path.join(install_path, 'qt-creator-dev'),
+ wininterrupt_install=os.path.join(install_path, 'wininterrupt'),
+ qtcreatorcdbext_install=os.path.join(install_path, 'qtcreatorcdbext'),
+ result=build_path)
+
+def main():
+ args = get_arguments()
+ paths = get_paths(args)
+
+ build_qtcreator(args, paths)
+ build_wininterrupt(args, paths)
+ build_qtcreatorcdbext(args, paths)
+ deploy_qt(args, paths)
+ package_qtcreator(args, paths)
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/common.py b/scripts/common.py
index db97ea35616..61923803fb9 100644
--- a/scripts/common.py
+++ b/scripts/common.py
@@ -40,6 +40,33 @@ def is_linux_platform():
def is_mac_platform():
return sys.platform.startswith('darwin')
+def check_print_call(command, workdir):
+ print('------------------------------------------')
+ print('COMMAND:')
+ print(' '.join(['"' + c.replace('"', '\\"') + '"' for c in command]))
+ print('PWD: "' + workdir + '"')
+ print('------------------------------------------')
+ subprocess.check_call(command, cwd=workdir)
+
+
+def get_git_SHA(path):
+ try:
+ return subprocess.check_output(['git', 'rev-list', '-n1', 'HEAD'], cwd=path).strip()
+ except subprocess.CalledProcessError:
+ return None
+ return None
+
+
+# get commit SHA either directly from git, or from a .tag file in the source directory
+def get_commit_SHA(path):
+ git_sha = get_git_SHA(path)
+ if not git_sha:
+ tagfile = os.path.join(path, '.tag')
+ if os.path.exists(tagfile):
+ with open(tagfile, 'r') as f:
+ git_sha = f.read().strip()
+ return git_sha
+
# copy of shutil.copytree that does not bail out if the target directory already exists
# and that does not create empty directories
def copytree(src, dst, symlinks=False, ignore=None):
@@ -211,5 +238,7 @@ def codesign(app_path):
lambda ff: ff.endswith('.dylib'))
codesign = codesign_call()
if is_mac_platform() and codesign:
+ entitlements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'dist',
+ 'installer', 'mac', 'entitlements.plist')
# sign the whole bundle
- subprocess.check_call(codesign + ['--deep', app_path])
+ subprocess.check_call(codesign + ['--deep', app_path, '--entitlements', entitlements_path])
diff --git a/share/qtcreator/debugger/boosttypes.py b/share/qtcreator/debugger/boosttypes.py
index e61d1e4bb8f..215ccc6922e 100644
--- a/share/qtcreator/debugger/boosttypes.py
+++ b/share/qtcreator/debugger/boosttypes.py
@@ -23,7 +23,7 @@
#
############################################################################
-from dumper import *
+from dumper import Children
def qdump__boost__bimaps__bimap(d, value):
#leftType = value.type[0]
diff --git a/share/qtcreator/debugger/cdbbridge.py b/share/qtcreator/debugger/cdbbridge.py
index 097494cc90a..ad63a19b388 100644
--- a/share/qtcreator/debugger/cdbbridge.py
+++ b/share/qtcreator/debugger/cdbbridge.py
@@ -28,10 +28,12 @@ import os
import sys
import cdbext
import re
+import threading
+from utils import TypeCode
sys.path.insert(1, os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
-from dumper import *
+from dumper import DumperBase, SubItem
class FakeVoidType(cdbext.Type):
def __init__(self, name , dumper):
@@ -47,19 +49,19 @@ class FakeVoidType(cdbext.Type):
def code(self):
if self.typeName.endswith('*'):
- return TypeCodePointer
+ return TypeCode.TypeCodePointer
if self.typeName.endswith(']'):
- return TypeCodeArray
- return TypeCodeVoid
+ return TypeCode.TypeCodeArray
+ return TypeCode.TypeCodeVoid
def unqualified(self):
return self
def target(self):
code = self.code()
- if code == TypeCodePointer:
+ if code == TypeCode.TypeCodePointer:
return FakeVoidType(self.typeName[:-1], self.dumper)
- if code == TypeCodeVoid:
+ if code == TypeCode.TypeCodeVoid:
return self
try:
return FakeVoidType(self.typeName[:self.typeName.rindex('[')], self.dumper)
@@ -105,7 +107,7 @@ class Dumper(DumperBase):
val.type = self.fromNativeType(nativeValue.type())
# There is no cdb api for the size of bitfields.
# Workaround this issue by parsing the native debugger text for integral types.
- if val.type.code == TypeCodeIntegral:
+ if val.type.code == TypeCode.TypeCodeIntegral:
integerString = nativeValue.nativeDebuggerValue()
if integerString == 'true':
val.ldata = int(1).to_bytes(1, byteorder='little')
@@ -128,7 +130,7 @@ class Dumper(DumperBase):
except:
# read raw memory in case the integerString can not be interpreted
pass
- if val.type.code == TypeCodeEnum:
+ if val.type.code == TypeCode.TypeCodeEnum:
val.ldisplay = self.enumValue(nativeValue)
val.isBaseClass = val.name == val.type.name
val.nativeValue = nativeValue
@@ -159,21 +161,21 @@ class Dumper(DumperBase):
nativeType = FakeVoidType(nativeType.name(), self)
code = nativeType.code()
- if code == TypeCodePointer:
+ if code == TypeCode.TypeCodePointer:
if not nativeType.name().startswith(''):
targetType = self.lookupType(nativeType.targetName(), nativeType.moduleId())
if targetType is not None:
return self.createPointerType(targetType)
- code = TypeCodeFunction
+ code = TypeCode.TypeCodeFunction
- if code == TypeCodeArray:
+ if code == TypeCode.TypeCodeArray:
# cdb reports virtual function tables as arrays those ar handled separetly by
# the DumperBase. Declare those types as structs prevents a lookup to a none existing type
if not nativeType.name().startswith('__fptr()') and not nativeType.name().startswith(' align else align
diff --git a/share/qtcreator/debugger/creatortypes.py b/share/qtcreator/debugger/creatortypes.py
index cfdd248b232..346b53ae7da 100644
--- a/share/qtcreator/debugger/creatortypes.py
+++ b/share/qtcreator/debugger/creatortypes.py
@@ -23,8 +23,6 @@
#
############################################################################
-from dumper import *
-
def typeTarget(type):
target = type.target()
if target:
@@ -234,7 +232,7 @@ def qdump__CPlusPlus__Internal__PPToken(d, value):
data, size, alloc = d.byteArrayData(value["m_src"])
length = value["f"]["utf16chars"].integer()
offset = value["utf16charOffset"].integer()
- #warn("size: %s, alloc: %s, offset: %s, length: %s, data: %s"
+ #DumperBase.warn("size: %s, alloc: %s, offset: %s, length: %s, data: %s"
# % (size, alloc, offset, length, data))
d.putValue(d.readMemory(data + offset, min(100, length)), "latin1")
d.putPlainChildren(value)
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py
index 8ce967d3a55..6b0416c563d 100644
--- a/share/qtcreator/debugger/dumper.py
+++ b/share/qtcreator/debugger/dumper.py
@@ -34,15 +34,19 @@ import re
import time
import inspect
import threading
+from utils import DisplayFormat, TypeCode
try:
# That's only used in native combined debugging right now, so
# we do not need to hard fail in cases of partial python installation
# that will never use this.
import json
-except:
+except ModuleNotFoundError:
+ DumperBase.warn("Python module json not found. "
+ "Native combined debugging might not work.")
pass
+
if sys.version_info[0] >= 3:
xrange = range
toInteger = int
@@ -50,98 +54,6 @@ else:
toInteger = long
-# Debugger start modes. Keep in sync with DebuggerStartMode in debuggerconstants.h
-NoStartMode, \
-StartInternal, \
-StartExternal, \
-AttachExternal, \
-AttachCrashedExternal, \
-AttachCore, \
-AttachToRemoteServer, \
-AttachToRemoteProcess, \
-StartRemoteProcess, \
- = range(0, 9)
-
-
-# Known special formats. Keep in sync with DisplayFormat in debuggerprotocol.h
-AutomaticFormat, \
-RawFormat, \
-SimpleFormat, \
-EnhancedFormat, \
-SeparateFormat, \
-Latin1StringFormat, \
-SeparateLatin1StringFormat, \
-Utf8StringFormat, \
-SeparateUtf8StringFormat, \
-Local8BitStringFormat, \
-Utf16StringFormat, \
-Ucs4StringFormat, \
-Array10Format, \
-Array100Format, \
-Array1000Format, \
-Array10000Format, \
-ArrayPlotFormat, \
-CompactMapFormat, \
-DirectQListStorageFormat, \
-IndirectQListStorageFormat, \
- = range(0, 20)
-
-# Breakpoints. Keep synchronized with BreakpointType in breakpoint.h
-UnknownType, \
-BreakpointByFileAndLine, \
-BreakpointByFunction, \
-BreakpointByAddress, \
-BreakpointAtThrow, \
-BreakpointAtCatch, \
-BreakpointAtMain, \
-BreakpointAtFork, \
-BreakpointAtExec, \
-BreakpointAtSysCall, \
-WatchpointAtAddress, \
-WatchpointAtExpression, \
-BreakpointOnQmlSignalEmit, \
-BreakpointAtJavaScriptThrow, \
- = range(0, 14)
-
-
-# Internal codes for types keep in sync with cdbextensions pytype.cpp
-TypeCodeTypedef, \
-TypeCodeStruct, \
-TypeCodeVoid, \
-TypeCodeIntegral, \
-TypeCodeFloat, \
-TypeCodeEnum, \
-TypeCodePointer, \
-TypeCodeArray, \
-TypeCodeComplex, \
-TypeCodeReference, \
-TypeCodeFunction, \
-TypeCodeMemberPointer, \
-TypeCodeFortranString, \
-TypeCodeUnresolvable, \
-TypeCodeBitfield, \
-TypeCodeRValueReference, \
- = range(0, 16)
-
-def isIntegralTypeName(name):
- return name in ('int', 'unsigned int', 'signed int',
- 'short', 'unsigned short',
- 'long', 'unsigned long',
- 'long long', 'unsigned long long',
- 'char', 'signed char', 'unsigned char',
- 'bool')
-
-def isFloatingPointTypeName(name):
- return name in ('float', 'double', 'long double')
-
-
-def arrayForms():
- return [ArrayPlotFormat]
-
-def mapForms():
- return [CompactMapFormat]
-
-
class ReportItem:
"""
Helper structure to keep temporary 'best' information about a value
@@ -159,21 +71,6 @@ class ReportItem:
% (self.value, self.encoding, self.priority, self.elided)
-def warn(message):
- DumperBase.warn(message)
-
-def xwarn(message):
- warn(message)
- import traceback
- traceback.print_stack()
-
-def error(message):
- raise RuntimeError(message)
-
-def showException(msg, exType, exValue, exTraceback):
- DumperBase.showException(msg, exType, exValue, exTraceback)
-
-
class Timer:
def __init__(self, d, desc):
self.d = d
@@ -220,7 +117,7 @@ class Children:
def __exit__(self, exType, exValue, exTraceBack):
if exType is not None:
if self.d.passExceptions:
- showException('CHILDREN', exType, exValue, exTraceBack)
+ self.d.showException('CHILDREN', exType, exValue, exTraceBack)
self.d.putSpecialValue('notaccessible')
self.d.putNumChild(0)
if self.d.currentMaxNumChild is not None:
@@ -267,11 +164,11 @@ class DumperBase:
@staticmethod
def showException(msg, exType, exValue, exTraceback):
- warn('**** CAUGHT EXCEPTION: %s ****' % msg)
+ DumperBase.warn('**** CAUGHT EXCEPTION: %s ****' % msg)
try:
import traceback
for line in traceback.format_exception(exType, exValue, exTraceback):
- warn('%s' % line)
+ DumperBase.warn('%s' % line)
except:
pass
@@ -353,9 +250,9 @@ class DumperBase:
self.uninitialized = list(map(lambda x: self.hexdecode(x), self.uninitialized))
self.partialUpdate = int(args.get('partial', '0'))
self.fallbackQtVersion = 0x50200
- #warn('NAMESPACE: "%s"' % self.qtNamespace())
- #warn('EXPANDED INAMES: %s' % self.expandedINames)
- #warn('WATCHERS: %s' % self.watchers)
+ #DumperBase.warn('NAMESPACE: "%s"' % self.qtNamespace())
+ #DumperBase.warn('EXPANDED INAMES: %s' % self.expandedINames)
+ #DumperBase.warn('WATCHERS: %s' % self.watchers)
def resetPerStepCaches(self):
self.perStepCache = {}
@@ -363,7 +260,7 @@ class DumperBase:
def resetCaches(self):
# This is a cache mapping from 'type name' to 'display alternatives'.
- self.qqFormats = { 'QVariant (QVariantMap)' : mapForms() }
+ self.qqFormats = { 'QVariant (QVariantMap)' : [DisplayFormat.CompactMapFormat] }
# This is a cache of all known dumpers.
self.qqDumpers = {} # Direct type match
@@ -434,11 +331,11 @@ class DumperBase:
self.currentType = ReportItem();
def exitSubItem(self, item, exType, exValue, exTraceBack):
- #warn('CURRENT VALUE: %s: %s %s' %
+ #DumperBase.warn('CURRENT VALUE: %s: %s %s' %
# (self.currentIName, self.currentValue, self.currentType))
if not exType is None:
if self.passExceptions:
- showException('SUBITEM', exType, exValue, exTraceBack)
+ self.showException('SUBITEM', exType, exValue, exTraceBack)
self.putSpecialValue('notaccessible')
self.putNumChild(0)
if not self.isCli:
@@ -493,7 +390,7 @@ class DumperBase:
def stripForFormat(self, typeName):
if not isinstance(typeName, str):
- error('Expected string in stripForFormat(), got %s' % type(typeName))
+ raise RuntimeError('Expected string in stripForFormat(), got %s' % type(typeName))
if typeName in self.cachedFormats:
return self.cachedFormats[typeName]
stripped = ''
@@ -541,7 +438,7 @@ class DumperBase:
tdata.name = typeId
tdata.typeId = typeId
tdata.lbitsize = 16
- tdata.code = TypeCodeIntegral
+ tdata.code = TypeCode.TypeCodeIntegral
self.registerType(typeId, tdata)
typeId = 'QChar'
@@ -549,7 +446,7 @@ class DumperBase:
tdata.name = typeId
tdata.typeId = typeId
tdata.lbitsize = 16
- tdata.code = TypeCodeStruct
+ tdata.code = TypeCode.TypeCodeStruct
tdata.lfields = [self.Field(dumper=self, name='ucs', type='unsigned short', bitsize=16, bitpos=0)]
tdata.lalignment = 2
tdata.templateArguments = []
@@ -576,14 +473,14 @@ class DumperBase:
inner = inner[6:].strip()
if inner.endswith(' const'):
inner = inner[:-6].strip()
- #warn("FOUND: %s" % inner)
+ #DumperBase.warn("FOUND: %s" % inner)
targs.append(inner)
- #warn("SPLITTING %s" % typename)
+ #DumperBase.warn("SPLITTING %s" % typename)
level = 0
inner = ''
for c in typename[::-1]: # Reversed...
- #warn("C: %s" % c)
+ #DumperBase.warn("C: %s" % c)
if c == '>':
if level > 0:
inner += c
@@ -597,7 +494,7 @@ class DumperBase:
inner = ''
break
elif c == ',':
- #warn('c: %s level: %s' % (c, level))
+ #DumperBase.warn('c: %s level: %s' % (c, level))
if level == 1:
push(inner)
inner = ''
@@ -606,7 +503,7 @@ class DumperBase:
else:
inner += c
- #warn("TARGS: %s %s" % (typename, targs))
+ #DumperBase.warn("TARGS: %s %s" % (typename, targs))
res = []
for item in targs[::-1]:
if len(item) == 0:
@@ -626,7 +523,7 @@ class DumperBase:
res.append(val)
else:
res.append(self.Type(self, item))
- #warn("RES: %s %s" % (typename, [(None if t is None else t.name) for t in res]))
+ #DumperBase.warn("RES: %s %s" % (typename, [(None if t is None else t.name) for t in res]))
return res
# Hex decoding operating on str, return str.
@@ -729,12 +626,12 @@ class DumperBase:
return elided, self.readMemory(data, shown)
def putCharArrayValue(self, data, size, charSize,
- displayFormat = AutomaticFormat):
+ displayFormat = DisplayFormat.AutomaticFormat):
bytelen = size * charSize
elided, shown = self.computeLimit(bytelen, self.displayStringLimit)
mem = self.readMemory(data, shown)
if charSize == 1:
- if displayFormat in (Latin1StringFormat, SeparateLatin1StringFormat):
+ if displayFormat in (DisplayFormat.Latin1StringFormat, DisplayFormat.SeparateLatin1StringFormat):
encodingType = 'latin1'
else:
encodingType = 'utf8'
@@ -748,12 +645,12 @@ class DumperBase:
self.putValue(mem, encodingType, elided=elided)
- if displayFormat in (SeparateLatin1StringFormat, SeparateUtf8StringFormat, SeparateFormat):
+ if displayFormat in (DisplayFormat.SeparateLatin1StringFormat, DisplayFormat.SeparateUtf8StringFormat, DisplayFormat.SeparateFormat):
elided, shown = self.computeLimit(bytelen, 100000)
self.putDisplay(encodingType + ':separate', self.readMemory(data, shown))
def putCharArrayHelper(self, data, size, charType,
- displayFormat = AutomaticFormat,
+ displayFormat = DisplayFormat.AutomaticFormat,
makeExpandable = True):
charSize = charType.size()
self.putCharArrayValue(data, size, charSize, displayFormat = displayFormat)
@@ -976,7 +873,7 @@ class DumperBase:
def check(self, exp):
if not exp:
- error('Check failed: %s' % exp)
+ raise RuntimeError('Check failed: %s' % exp)
def checkRef(self, ref):
# Assume there aren't a million references to any object.
@@ -985,7 +882,7 @@ class DumperBase:
def checkIntType(self, thing):
if not self.isInt(thing):
- error('Expected an integral value, got %s' % type(thing))
+ raise RuntimeError('Expected an integral value, got %s' % type(thing))
def readToFirstZero(self, base, tsize, maximum):
self.checkIntType(base)
@@ -1001,9 +898,9 @@ class DumperBase:
break
except:
maximum = int(maximum / 2)
- warn('REDUCING READING MAXIMUM TO %s' % maximum)
+ self.warn('REDUCING READING MAXIMUM TO %s' % maximum)
- #warn('BASE: 0x%x TSIZE: %s MAX: %s' % (base, tsize, maximum))
+ #DumperBase.warn('BASE: 0x%x TSIZE: %s MAX: %s' % (base, tsize, maximum))
for i in xrange(0, maximum, tsize):
t = struct.unpack_from(code, blob, i)[0]
if t == 0:
@@ -1179,7 +1076,7 @@ class DumperBase:
self.putItem(value)
def isExpanded(self):
- #warn('IS EXPANDED: %s in %s: %s' % (self.currentIName,
+ #DumperBase.warn('IS EXPANDED: %s in %s: %s' % (self.currentIName,
# self.expandedINames, self.currentIName in self.expandedINames))
return self.currentIName in self.expandedINames
@@ -1213,7 +1110,7 @@ class DumperBase:
n = arrayByteSize // innerType.size()
p = value.address()
- if displayFormat != RawFormat and p:
+ if displayFormat != DisplayFormat.RawFormat and p:
if innerType.name in ('char', 'wchar_t', 'unsigned char', 'signed char', 'CHAR', 'WCHAR'):
self.putCharArrayHelper(p, n, innerType, self.currentItemFormat(),
makeExpandable = False)
@@ -1236,7 +1133,7 @@ class DumperBase:
ns = self.qtNamespace()
if len(ns) > 0 and typeName.startswith(ns):
typeName = typeName[len(ns):]
- # warn( 'stripping %s' % typeName )
+ # DumperBase.warn( 'stripping %s' % typeName )
lvl = 0
pos = None
stripChunks = []
@@ -1251,24 +1148,24 @@ class DumperBase:
elif s == '>':
lvl -= 1
if lvl < 0 :
- error("Unbalanced '<' in type, @index %d" % index)
+ raise RuntimeError("Unbalanced '<' in type, @index %d" % index)
if lvl == 0:
stripChunks.append((pos, index+1))
if lvl != 0:
- error("unbalanced at end of type name")
+ raise RuntimeError("unbalanced at end of type name")
for (f, l) in reversed(stripChunks):
typeName = typeName[:f] + typeName[l:]
return typeName
def tryPutPrettyItem(self, typeName, value):
value.check()
- if self.useFancy and self.currentItemFormat() != RawFormat:
+ if self.useFancy and self.currentItemFormat() != DisplayFormat.RawFormat:
self.putType(typeName)
nsStrippedType = self.stripNamespaceFromType(typeName)\
.replace('::', '__')
- #warn('STRIPPED: %s' % nsStrippedType)
+ #DumperBase.warn('STRIPPED: %s' % nsStrippedType)
# The following block is only needed for D.
if nsStrippedType.startswith('_A'):
# DMD v2.058 encodes string[] as _Array_uns long long.
@@ -1281,7 +1178,7 @@ class DumperBase:
return True
dumper = self.qqDumpers.get(nsStrippedType)
- #warn('DUMPER: %s' % dumper)
+ #DumperBase.warn('DUMPER: %s' % dumper)
if dumper is not None:
dumper(self, value)
return True
@@ -1308,7 +1205,7 @@ class DumperBase:
# This is shared by pointer and array formatting.
def tryPutSimpleFormattedPointer(self, ptr, typeName, innerType, displayFormat, limit):
- if displayFormat == AutomaticFormat:
+ if displayFormat == DisplayFormat.AutomaticFormat:
if innerType.name in ('char', 'signed char', 'unsigned char', 'CHAR'):
# Use UTF-8 as default for char *.
self.putType(typeName)
@@ -1328,45 +1225,45 @@ class DumperBase:
self.putValue(data, 'ucs4', elided=elided)
return True
- if displayFormat == Latin1StringFormat:
+ if displayFormat == DisplayFormat.Latin1StringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 1, limit)
self.putValue(data, 'latin1', elided=elided)
return True
- if displayFormat == SeparateLatin1StringFormat:
+ if displayFormat == DisplayFormat.SeparateLatin1StringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 1, limit)
self.putValue(data, 'latin1', elided=elided)
self.putDisplay('latin1:separate', data)
return True
- if displayFormat == Utf8StringFormat:
+ if displayFormat == DisplayFormat.Utf8StringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 1, limit)
self.putValue(data, 'utf8', elided=elided)
return True
- if displayFormat == SeparateUtf8StringFormat:
+ if displayFormat == DisplayFormat.SeparateUtf8StringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 1, limit)
self.putValue(data, 'utf8', elided=elided)
self.putDisplay('utf8:separate', data)
return True
- if displayFormat == Local8BitStringFormat:
+ if displayFormat == DisplayFormat.Local8BitStringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 1, limit)
self.putValue(data, 'local8bit', elided=elided)
return True
- if displayFormat == Utf16StringFormat:
+ if displayFormat == DisplayFormat.Utf16StringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 2, limit)
self.putValue(data, 'utf16', elided=elided)
return True
- if displayFormat == Ucs4StringFormat:
+ if displayFormat == DisplayFormat.Ucs4StringFormat:
self.putType(typeName)
(elided, data) = self.encodeCArray(ptr, 4, limit)
self.putValue(data, 'ucs4', elided=elided)
@@ -1390,12 +1287,12 @@ class DumperBase:
def putFormattedPointerX(self, value):
self.putOriginalAddress(value.address())
- #warn("PUT FORMATTED: %s" % value)
+ #DumperBase.warn("PUT FORMATTED: %s" % value)
pointer = value.pointer()
self.putAddress(pointer)
- #warn('POINTER: 0x%x' % pointer)
+ #DumperBase.warn('POINTER: 0x%x' % pointer)
if pointer == 0:
- #warn('NULL POINTER')
+ #DumperBase.warn('NULL POINTER')
self.putType(value.type)
self.putValue('0x0')
self.putNumChild(0)
@@ -1408,7 +1305,7 @@ class DumperBase:
except:
# Failure to dereference a pointer should at least
# show the value of a pointer.
- #warn('BAD POINTER: %s' % value)
+ #DumperBase.warn('BAD POINTER: %s' % value)
self.putValue('0x%x' % pointer)
self.putType(typeName)
self.putNumChild(0)
@@ -1422,15 +1319,15 @@ class DumperBase:
innerType = value.type.target() #.unqualified()
if innerType.name == 'void':
- #warn('VOID POINTER: %s' % displayFormat)
+ #DumperBase.warn('VOID POINTER: %s' % displayFormat)
self.putType(typeName)
self.putSymbolValue(pointer)
self.putNumChild(0)
return
- if displayFormat == RawFormat:
+ if displayFormat == DisplayFormat.RawFormat:
# Explicitly requested bald pointer.
- #warn('RAW')
+ #DumperBase.warn('RAW')
self.putType(typeName)
self.putValue('0x%x' % pointer)
self.putNumChild(1)
@@ -1441,38 +1338,38 @@ class DumperBase:
return
limit = self.displayStringLimit
- if displayFormat in (SeparateLatin1StringFormat, SeparateUtf8StringFormat):
+ if displayFormat in (DisplayFormat.SeparateLatin1StringFormat, DisplayFormat.SeparateUtf8StringFormat):
limit = 1000000
if self.tryPutSimpleFormattedPointer(pointer, typeName,
innerType, displayFormat, limit):
self.putNumChild(1)
return
- if Array10Format <= displayFormat and displayFormat <= Array1000Format:
- n = (10, 100, 1000, 10000)[displayFormat - Array10Format]
+ if DisplayFormat.Array10Format <= displayFormat and displayFormat <= DisplayFormat.Array1000Format:
+ n = (10, 100, 1000, 10000)[displayFormat - DisplayFormat.Array10Format]
self.putType(typeName)
self.putItemCount(n)
self.putArrayData(value.pointer(), n, innerType)
return
- if innerType.code == TypeCodeFunction:
+ if innerType.code == TypeCode.TypeCodeFunction:
# A function pointer.
self.putSymbolValue(pointer)
self.putType(typeName)
self.putNumChild(0)
return
- #warn('AUTODEREF: %s' % self.autoDerefPointers)
- #warn('INAME: %s' % self.currentIName)
- #warn('INNER: %s' % innerType.name)
+ #DumperBase.warn('AUTODEREF: %s' % self.autoDerefPointers)
+ #DumperBase.warn('INAME: %s' % self.currentIName)
+ #DumperBase.warn('INNER: %s' % innerType.name)
if self.autoDerefPointers:
# Generic pointer type with AutomaticFormat, but never dereference char types:
if innerType.name not in ('char', 'signed char', 'unsigned char', 'wchar_t', 'CHAR', 'WCHAR'):
self.putDerefedPointer(value)
return
- #warn('GENERIC PLAIN POINTER: %s' % value.type)
- #warn('ADDR PLAIN POINTER: 0x%x' % value.laddress)
+ #DumperBase.warn('GENERIC PLAIN POINTER: %s' % value.type)
+ #DumperBase.warn('ADDR PLAIN POINTER: 0x%x' % value.laddress)
self.putType(typeName)
self.putSymbolValue(pointer)
self.putNumChild(1)
@@ -1631,14 +1528,14 @@ class DumperBase:
# metaObjectFunc = self.extractPointer(vtablePtr)
# cmd = '((void*(*)(void*))0x%x)((void*)0x%x)' % (metaObjectFunc, objectPtr)
# try:
-# #warn('MO CMD: %s' % cmd)
+# #DumperBase.warn('MO CMD: %s' % cmd)
# res = self.parseAndEvaluate(cmd)
-# #warn('MO RES: %s' % res)
+# #DumperBase.warn('MO RES: %s' % res)
# self.bump('successfulMetaObjectCall')
# return res.pointer()
# except:
# self.bump('failedMetaObjectCall')
-# #warn('COULD NOT EXECUTE: %s' % cmd)
+# #DumperBase.warn('COULD NOT EXECUTE: %s' % cmd)
# return 0
def extractMetaObjectPtr(self, objectPtr, typeobj):
@@ -1659,14 +1556,14 @@ class DumperBase:
metaObjectFunc = self.extractPointer(vtablePtr)
cmd = '((void*(*)(void*))0x%x)((void*)0x%x)' % (metaObjectFunc, objectPtr)
try:
- #warn('MO CMD: %s' % cmd)
+ #DumperBase.warn('MO CMD: %s' % cmd)
res = self.parseAndEvaluate(cmd)
- #warn('MO RES: %s' % res)
+ #DumperBase.warn('MO RES: %s' % res)
self.bump('successfulMetaObjectCall')
return res.pointer()
except:
self.bump('failedMetaObjectCall')
- #warn('COULD NOT EXECUTE: %s' % cmd)
+ #DumperBase.warn('COULD NOT EXECUTE: %s' % cmd)
return 0
def extractStaticMetaObjectFromTypeHelper(someTypeObj):
@@ -1729,12 +1626,12 @@ class DumperBase:
result = self.knownStaticMetaObjects.get(typeName, None)
if result is not None: # Is 0 or the static metaobject.
self.bump('typecached')
- #warn('CACHED RESULT: %s %s 0x%x' % (self.currentIName, typeName, result))
+ #DumperBase.warn('CACHED RESULT: %s %s 0x%x' % (self.currentIName, typeName, result))
return result
if not self.couldBeQObjectPointer(objectPtr):
self.bump('cannotBeQObject')
- #warn('DOES NOT LOOK LIKE A QOBJECT: %s' % self.currentIName)
+ #DumperBase.warn('DOES NOT LOOK LIKE A QOBJECT: %s' % self.currentIName)
return 0
metaObjectPtr = 0
@@ -1761,7 +1658,7 @@ class DumperBase:
val = self.Value(self)
val.laddress = value
return val.split(pattern)
- error('CANNOT EXTRACT STRUCT FROM %s' % type(value))
+ raise RuntimeError('CANNOT EXTRACT STRUCT FROM %s' % type(value))
def extractCString(self, addr):
result = bytearray()
@@ -1878,9 +1775,9 @@ class DumperBase:
isQMetaObject = origType == 'QMetaObject'
isQObject = origType == 'QObject'
- #warn('OBJECT GUTS: %s 0x%x ' % (self.currentIName, metaObjectPtr))
+ #DumperBase.warn('OBJECT GUTS: %s 0x%x ' % (self.currentIName, metaObjectPtr))
dataPtr = extractDataPtr(metaObjectPtr)
- #warn('DATA PTRS: %s 0x%x ' % (self.currentIName, dataPtr))
+ #DumperBase.warn('DATA PTRS: %s 0x%x ' % (self.currentIName, dataPtr))
(revision, classname,
classinfo, classinfo2,
methodCount, methods,
@@ -2048,18 +1945,18 @@ class DumperBase:
# LLDB doesn't like calling it on a derived class, possibly
# due to type information living in a different shared object.
#base = self.createValue(qobjectPtr, '@QObject')
- #warn("CALL FUNC: 0x%x" % self.qtPropertyFunc)
+ #DumperBase.warn("CALL FUNC: 0x%x" % self.qtPropertyFunc)
cmd = '((QVariant(*)(void*,char*))0x%x)((void*)0x%x,"%s")' \
% (self.qtPropertyFunc, qobjectPtr, name)
try:
- #warn('PROP CMD: %s' % cmd)
+ #DumperBase.warn('PROP CMD: %s' % cmd)
res = self.parseAndEvaluate(cmd)
- #warn('PROP RES: %s' % res)
+ #DumperBase.warn('PROP RES: %s' % res)
except:
self.bump('failedMetaObjectCall')
putt(name, ' ')
continue
- #warn('COULD NOT EXECUTE: %s' % cmd)
+ #DumperBase.warn('COULD NOT EXECUTE: %s' % cmd)
#self.putCallItem(name, '@QVariant', base, 'property', '"' + name + '"')
if res is None:
self.bump('failedMetaObjectCall2')
@@ -2205,19 +2102,19 @@ class DumperBase:
break
def currentItemFormat(self, typeName = None):
- displayFormat = self.formats.get(self.currentIName, AutomaticFormat)
- if displayFormat == AutomaticFormat:
+ displayFormat = self.formats.get(self.currentIName, DisplayFormat.AutomaticFormat)
+ if displayFormat == DisplayFormat.AutomaticFormat:
if typeName is None:
typeName = self.currentType.value
needle = None if typeName is None else self.stripForFormat(typeName)
- displayFormat = self.typeformats.get(needle, AutomaticFormat)
+ displayFormat = self.typeformats.get(needle, DisplayFormat.AutomaticFormat)
return displayFormat
def putSubItem(self, component, value): # -> ReportItem
if not isinstance(value, self.Value):
- error('WRONG VALUE TYPE IN putSubItem: %s' % type(value))
+ raise RuntimeError('WRONG VALUE TYPE IN putSubItem: %s' % type(value))
if not isinstance(value.type, self.Type):
- error('WRONG TYPE TYPE IN putSubItem: %s' % type(value.type))
+ raise RuntimeError('WRONG TYPE TYPE IN putSubItem: %s' % type(value.type))
res = None
with SubItem(self, component):
self.putItem(value)
@@ -2230,7 +2127,7 @@ class DumperBase:
addrBase = base
innerSize = innerType.size()
self.putNumChild(n)
- #warn('ADDRESS: 0x%x INNERSIZE: %s INNERTYPE: %s' % (addrBase, innerSize, innerType))
+ #DumperBase.warn('ADDRESS: 0x%x INNERSIZE: %s INNERTYPE: %s' % (addrBase, innerSize, innerType))
enc = innerType.simpleEncoding()
if enc:
self.put('childtype="%s",' % innerType.name)
@@ -2262,7 +2159,7 @@ class DumperBase:
if n > maxNumChild:
self.putField('plotelided', n) # FIXME: Act on that in frontend
n = maxNumChild
- if self.currentItemFormat() == ArrayPlotFormat and innerType.isSimpleType():
+ if self.currentItemFormat() == DisplayFormat.ArrayPlotFormat and innerType.isSimpleType():
enc = innerType.simpleEncoding()
if enc:
self.putField('editencoding', enc)
@@ -2302,7 +2199,7 @@ class DumperBase:
def extractPointer(self, value):
try:
- if value.type.code == TypeCodeArray:
+ if value.type.code == TypeCode.TypeCodeArray:
return value.address()
except:
pass
@@ -2337,7 +2234,7 @@ class DumperBase:
return val.extractSomething(pattern, bitsize)
if isinstance(value, self.Value):
return value.extractSomething(pattern, bitsize)
- error('CANT EXTRACT FROM %s' % type(value))
+ raise RuntimeError('CANT EXTRACT FROM %s' % type(value))
# Parses a..b and a.(s).b
def parseRange(self, exp):
@@ -2394,13 +2291,13 @@ class DumperBase:
self.putField('numchild', numchild)
def handleLocals(self, variables):
- #warn('VARIABLES: %s' % variables)
+ #DumperBase.warn('VARIABLES: %s' % variables)
#with self.timer('locals'):
shadowed = {}
for value in variables:
if value.name == 'argv':
- if value.type.code == TypeCodePointer:
- if value.type.ltarget.code == TypeCodePointer:
+ if value.type.code == TypeCode.TypeCodePointer:
+ if value.type.ltarget.code == TypeCode.TypeCodePointer:
if value.type.ltarget.ltarget.name == 'char':
self.putSpecialArgv(value)
continue
@@ -2430,7 +2327,7 @@ class DumperBase:
def handleWatch(self, origexp, exp, iname):
exp = str(exp).strip()
escapedExp = self.hexencode(exp)
- #warn('HANDLING WATCH %s -> %s, INAME: "%s"' % (origexp, exp, iname))
+ #DumperBase.warn('HANDLING WATCH %s -> %s, INAME: "%s"' % (origexp, exp, iname))
# Grouped items separated by semicolon.
if exp.find(';') >= 0:
@@ -2450,7 +2347,7 @@ class DumperBase:
# Special array index: e.g a[1..199] or a[1.(3).199] for stride 3.
isRange, begin, step, end, template = self.parseRange(exp)
if isRange:
- #warn('RANGE: %s %s %s in %s' % (begin, step, end, template))
+ #DumperBase.warn('RANGE: %s %s %s in %s' % (begin, step, end, template))
r = range(begin, end, step)
n = len(r)
with TopLevelItem(self, iname):
@@ -2632,7 +2529,7 @@ class DumperBase:
resdict = json.loads(payload)
continue
except:
- warn('Cannot parse native payload: %s' % payload)
+ self.warn('Cannot parse native payload: %s' % payload)
else:
print('interpreteralien=%s'
% {'service': service, 'payload': self.hexencode(payload)})
@@ -2640,7 +2537,7 @@ class DumperBase:
expr = 'qt_qmlDebugClearBuffer()'
res = self.parseAndEvaluate(expr)
except RuntimeError as error:
- warn('Cleaning buffer failed: %s: %s' % (expr, error))
+ self.warn('Cleaning buffer failed: %s: %s' % (expr, error))
return resdict
@@ -2651,14 +2548,14 @@ class DumperBase:
try:
res = self.parseAndEvaluate(expr)
except RuntimeError as error:
- warn('Interpreter command failed: %s: %s' % (encoded, error))
+ self.warn('Interpreter command failed: %s: %s' % (encoded, error))
return {}
except AttributeError as error:
# Happens with LLDB and 'None' current thread.
- warn('Interpreter command failed: %s: %s' % (encoded, error))
+ self.warn('Interpreter command failed: %s: %s' % (encoded, error))
return {}
if not res:
- warn('Interpreter command failed: %s ' % encoded)
+ self.warn('Interpreter command failed: %s ' % encoded)
return {}
return self.fetchInterpreterResult()
@@ -2683,7 +2580,7 @@ class DumperBase:
self.doContinue()
def doInsertInterpreterBreakpoint(self, args, wasPending):
- #warn('DO INSERT INTERPRETER BREAKPOINT, WAS PENDING: %s' % wasPending)
+ #DumperBase.warn('DO INSERT INTERPRETER BREAKPOINT, WAS PENDING: %s' % wasPending)
# Will fail if the service is not yet up and running.
response = self.sendInterpreterRequest('setbreakpoint', args)
bp = None if response is None else response.get('breakpoint', None)
@@ -2738,7 +2635,7 @@ class DumperBase:
self.putItemX(value)
def putItemX(self, value):
- #warn('PUT ITEM: %s' % value.stringify())
+ #DumperBase.warn('PUT ITEM: %s' % value.stringify())
typeobj = value.type #unqualified()
typeName = typeobj.name
@@ -2753,23 +2650,23 @@ class DumperBase:
return
if not isinstance(value, self.Value):
- error('WRONG TYPE IN putItem: %s' % type(self.Value))
+ raise RuntimeError('WRONG TYPE IN putItem: %s' % type(self.Value))
# Try on possibly typedefed type first.
if self.tryPutPrettyItem(typeName, value):
- if typeobj.code == TypeCodePointer:
+ if typeobj.code == TypeCode.TypeCodePointer:
self.putOriginalAddress(value.address())
else:
self.putAddress(value.address())
return
- if typeobj.code == TypeCodeTypedef:
- #warn('TYPEDEF VALUE: %s' % value.stringify())
+ if typeobj.code == TypeCode.TypeCodeTypedef:
+ #DumperBase.warn('TYPEDEF VALUE: %s' % value.stringify())
self.putItem(value.detypedef())
self.putBetterType(typeName)
return
- if typeobj.code == TypeCodePointer:
+ if typeobj.code == TypeCode.TypeCodePointer:
self.putFormattedPointer(value)
if value.summary and self.useFancy:
self.putValue(self.hexencode(value.summary), 'utf8:1:0')
@@ -2777,50 +2674,50 @@ class DumperBase:
self.putAddress(value.address())
- if typeobj.code == TypeCodeFunction:
- #warn('FUNCTION VALUE: %s' % value)
+ if typeobj.code == TypeCode.TypeCodeFunction:
+ #DumperBase.warn('FUNCTION VALUE: %s' % value)
self.putType(typeobj)
self.putSymbolValue(value.pointer())
self.putNumChild(0)
return
- if typeobj.code == TypeCodeEnum:
- #warn('ENUM VALUE: %s' % value.stringify())
+ if typeobj.code == TypeCode.TypeCodeEnum:
+ #DumperBase.warn('ENUM VALUE: %s' % value.stringify())
self.putType(typeobj.name)
self.putValue(value.display())
self.putNumChild(0)
return
- if typeobj.code == TypeCodeArray:
- #warn('ARRAY VALUE: %s' % value)
+ if typeobj.code == TypeCode.TypeCodeArray:
+ #DumperBase.warn('ARRAY VALUE: %s' % value)
self.putCStyleArray(value)
return
- if typeobj.code == TypeCodeBitfield:
- #warn('BITFIELD VALUE: %s %d %s' % (value.name, value.lvalue, typeName))
+ if typeobj.code == TypeCode.TypeCodeBitfield:
+ #DumperBase.warn('BITFIELD VALUE: %s %d %s' % (value.name, value.lvalue, typeName))
self.putNumChild(0)
dd = typeobj.ltarget.typeData().enumDisplay
self.putValue(str(value.lvalue) if dd is None else dd(value.lvalue, value.laddress, '%d'))
self.putType(typeName)
return
- if typeobj.code == TypeCodeIntegral:
- #warn('INTEGER: %s %s' % (value.name, value))
+ if typeobj.code == TypeCode.TypeCodeIntegral:
+ #DumperBase.warn('INTEGER: %s %s' % (value.name, value))
val = value.value()
self.putNumChild(0)
self.putValue(val)
self.putType(typeName)
return
- if typeobj.code == TypeCodeFloat:
- #warn('FLOAT VALUE: %s' % value)
+ if typeobj.code == TypeCode.TypeCodeFloat:
+ #DumperBase.warn('FLOAT VALUE: %s' % value)
self.putValue(value.value())
self.putNumChild(0)
self.putType(typeobj.name)
return
- if typeobj.code in (TypeCodeReference, TypeCodeRValueReference):
- #warn('REFERENCE VALUE: %s' % value)
+ if typeobj.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference):
+ #DumperBase.warn('REFERENCE VALUE: %s' % value)
val = value.dereference()
if val.laddress != 0:
self.putItem(val)
@@ -2829,13 +2726,13 @@ class DumperBase:
self.putBetterType(typeName)
return
- if typeobj.code == TypeCodeComplex:
+ if typeobj.code == TypeCode.TypeCodeComplex:
self.putType(typeobj)
self.putValue(value.display())
self.putNumChild(0)
return
- if typeobj.code == TypeCodeFortranString:
+ if typeobj.code == TypeCode.TypeCodeFortranString:
self.putValue(self.hexencode(value.data()), 'latin1')
self.putNumChild(0)
self.putType(typeobj)
@@ -2850,12 +2747,12 @@ class DumperBase:
self.putArrayData(base.pointer(), n, base.type.target())
return
- #warn('SOME VALUE: %s' % value)
- #warn('HAS CHILDREN VALUE: %s' % value.hasChildren())
- #warn('GENERIC STRUCT: %s' % typeobj)
- #warn('INAME: %s ' % self.currentIName)
- #warn('INAMES: %s ' % self.expandedINames)
- #warn('EXPANDED: %s ' % (self.currentIName in self.expandedINames))
+ #DumperBase.warn('SOME VALUE: %s' % value)
+ #DumperBase.warn('HAS CHILDREN VALUE: %s' % value.hasChildren())
+ #DumperBase.warn('GENERIC STRUCT: %s' % typeobj)
+ #DumperBase.warn('INAME: %s ' % self.currentIName)
+ #DumperBase.warn('INAMES: %s ' % self.expandedINames)
+ #DumperBase.warn('EXPANDED: %s ' % (self.currentIName in self.expandedINames))
self.putType(typeName)
if value.summary is not None and self.useFancy:
@@ -2865,7 +2762,7 @@ class DumperBase:
self.putNumChild(1)
self.putEmptyValue()
- #warn('STRUCT GUTS: %s ADDRESS: 0x%x ' % (value.name, value.address()))
+ #DumperBase.warn('STRUCT GUTS: %s ADDRESS: 0x%x ' % (value.name, value.address()))
if self.showQObjectNames:
#with self.timer(self.currentIName):
self.putQObjectNameValue(value)
@@ -2888,7 +2785,7 @@ class DumperBase:
if addr:
# Only available with Qt 5.3+
(hookVersion, x, x, x, x, x, tiVersion) = self.split('ppppppp', addr)
- #warn('HOOK: %s TI: %s' % (hookVersion, tiVersion))
+ #DumperBase.warn('HOOK: %s TI: %s' % (hookVersion, tiVersion))
if hookVersion >= 3:
self.qtTypeInfoVersion = lambda: tiVersion
return tiVersion
@@ -2948,12 +2845,12 @@ class DumperBase:
def check(self):
if self.laddress is not None and not self.dumper.isInt(self.laddress):
- error('INCONSISTENT ADDRESS: %s' % type(self.laddress))
+ raise RuntimeError('INCONSISTENT ADDRESS: %s' % type(self.laddress))
if self.type is not None and not isinstance(self.type, self.dumper.Type):
- error('INCONSISTENT TYPE: %s' % type(self.type))
+ raise RuntimeError('INCONSISTENT TYPE: %s' % type(self.type))
def __str__(self):
- #error('Not implemented')
+ #raise RuntimeError('Not implemented')
return self.stringify()
def __int__(self):
@@ -2987,14 +2884,14 @@ class DumperBase:
return ''
def pointer(self):
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.detypedef().pointer()
return self.extractInteger(self.dumper.ptrSize() * 8, True)
def integer(self, bitsize=None):
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.detypedef().integer()
- elif self.type.code == TypeCodeBitfield:
+ elif self.type.code == TypeCode.TypeCodeBitfield:
return self.lvalue
# Could be something like 'short unsigned int'
unsigned = self.type.name == 'unsigned' \
@@ -3007,7 +2904,7 @@ class DumperBase:
def floatingPoint(self):
if self.nativeValue is not None and not self.dumper.isCdb:
return str(self.nativeValue)
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.detypedef().floatingPoint()
if self.type.size() == 8:
return self.extractSomething('d', 64)
@@ -3022,7 +2919,7 @@ class DumperBase:
exp = (h & 0x7fff)
fraction = l
bit63 = (l >> 63) & 1
- #warn("SIGN: %s EXP: %s H: 0x%x L: 0x%x" % (sign, exp, h, l))
+ #DumperBase.warn("SIGN: %s EXP: %s H: 0x%x L: 0x%x" % (sign, exp, h, l))
if exp == 0:
if bit63 == 0:
if l == 0:
@@ -3039,7 +2936,7 @@ class DumperBase:
sign = h >> 63
exp = (h >> 48) & 0x7fff
fraction = h & (2**48 - 1)
- #warn("SIGN: %s EXP: %s FRAC: %s H: 0x%x L: 0x%x" % (sign, exp, fraction, h, l))
+ #DumperBase.warn("SIGN: %s EXP: %s FRAC: %s H: 0x%x L: 0x%x" % (sign, exp, fraction, h, l))
if exp == 0:
if fraction == 0:
res = -0.0 if sign else 0.0
@@ -3053,17 +2950,17 @@ class DumperBase:
def value(self):
if self.type is not None:
- if self.type.code == TypeCodeEnum:
+ if self.type.code == TypeCode.TypeCodeEnum:
return self.displayEnum()
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.detypedef().value()
- if self.type.code == TypeCodeIntegral:
+ if self.type.code == TypeCode.TypeCodeIntegral:
return self.integer()
- if self.type.code == TypeCodeBitfield:
+ if self.type.code == TypeCode.TypeCodeBitfield:
return self.integer()
- if self.type.code == TypeCodeFloat:
+ if self.type.code == TypeCode.TypeCodeFloat:
return self.floatingPoint()
- if self.type.code == TypeCodePointer:
+ if self.type.code == TypeCode.TypeCodePointer:
return self.pointer()
return None
@@ -3072,42 +2969,42 @@ class DumperBase:
def findMemberByName(self, name):
self.check()
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.findMemberByName(self.detypedef())
- if self.type.code in (TypeCodePointer, TypeCodeReference, TypeCodeRValueReference):
+ if self.type.code in (TypeCode.TypeCodePointer, TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference):
res = self.dereference().findMemberByName(name)
if res is not None:
return res
- if self.type.code == TypeCodeStruct:
- #warn('SEARCHING FOR MEMBER: %s IN %s' % (name, self.type.name))
+ if self.type.code == TypeCode.TypeCodeStruct:
+ #DumperBase.warn('SEARCHING FOR MEMBER: %s IN %s' % (name, self.type.name))
members = self.members(True)
- #warn('MEMBERS: %s' % members)
+ #DumperBase.warn('MEMBERS: %s' % members)
for member in members:
- #warn('CHECKING FIELD %s' % member.name)
- if member.type.code == TypeCodeTypedef:
+ #DumperBase.warn('CHECKING FIELD %s' % member.name)
+ if member.type.code == TypeCode.TypeCodeTypedef:
member = member.detypedef()
if member.name == name:
return member
for member in members:
- if member.type.code == TypeCodeTypedef:
+ if member.type.code == TypeCode.TypeCodeTypedef:
member = member.detypedef()
if member.name == name: # Could be base class.
return member
- if member.type.code == TypeCodeStruct:
+ if member.type.code == TypeCode.TypeCodeStruct:
res = member.findMemberByName(name)
if res is not None:
return res
return None
def __getitem__(self, index):
- #warn('GET ITEM %s %s' % (self, index))
+ #DumperBase.warn('GET ITEM %s %s' % (self, index))
self.check()
- if self.type.code == TypeCodeTypedef:
- #warn('GET ITEM STRIP TYPEDEFS TO %s' % self.type.ltarget)
+ if self.type.code == TypeCode.TypeCodeTypedef:
+ #DumperBase.warn('GET ITEM STRIP TYPEDEFS TO %s' % self.type.ltarget)
return self.cast(self.type.ltarget).__getitem__(index)
if isinstance(index, str):
- if self.type.code == TypeCodePointer:
- #warn('GET ITEM %s DEREFERENCE TO %s' % (self, self.dereference()))
+ if self.type.code == TypeCode.TypeCodePointer:
+ #DumperBase.warn('GET ITEM %s DEREFERENCE TO %s' % (self, self.dereference()))
return self.dereference().__getitem__(index)
res = self.findMemberByName(index)
if res is None:
@@ -3117,40 +3014,40 @@ class DumperBase:
elif isinstance(index, self.dumper.Field):
field = index
elif self.dumper.isInt(index):
- if self.type.code == TypeCodeArray:
+ if self.type.code == TypeCode.TypeCodeArray:
addr = self.laddress + int(index) * self.type.ltarget.size()
return self.dumper.createValue(addr, self.type.ltarget)
- if self.type.code == TypeCodePointer:
+ if self.type.code == TypeCode.TypeCodePointer:
addr = self.pointer() + int(index) * self.type.ltarget.size()
return self.dumper.createValue(addr, self.type.ltarget)
return self.members(False)[index]
else:
- error('BAD INDEX TYPE %s' % type(index))
+ raise RuntimeError('BAD INDEX TYPE %s' % type(index))
field.check()
- #warn('EXTRACT FIELD: %s, BASE 0x%x' % (field, self.address()))
- if self.type.code == TypeCodePointer:
- #warn('IS TYPEDEFED POINTER!')
+ #DumperBase.warn('EXTRACT FIELD: %s, BASE 0x%x' % (field, self.address()))
+ if self.type.code == TypeCode.TypeCodePointer:
+ #DumperBase.warn('IS TYPEDEFED POINTER!')
res = self.dereference()
- #warn('WAS POINTER: %s' % res)
+ #DumperBase.warn('WAS POINTER: %s' % res)
return field.extract(self)
def extractField(self, field):
if not isinstance(field, self.dumper.Field):
- error('BAD INDEX TYPE %s' % type(field))
+ raise RuntimeError('BAD INDEX TYPE %s' % type(field))
if field.extractor is not None:
val = field.extractor(self)
if val is not None:
- #warn('EXTRACTOR SUCCEEDED: %s ' % val)
+ #DumperBase.warn('EXTRACTOR SUCCEEDED: %s ' % val)
return val
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.cast(self.type.ltarget).extractField(field)
- if self.type.code in (TypeCodeReference, TypeCodeRValueReference):
+ if self.type.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference):
return self.dereference().extractField(field)
- #warn('FIELD: %s ' % field)
+ #DumperBase.warn('FIELD: %s ' % field)
val = self.dumper.Value(self.dumper)
val.name = field.name
val.isBaseClass = field.isBase
@@ -3169,7 +3066,7 @@ class DumperBase:
fieldOffset = fieldBitpos // 8
fieldType = field.fieldType()
- if fieldType.code == TypeCodeBitfield:
+ if fieldType.code == TypeCode.TypeCodeBitfield:
fieldBitpos -= fieldOffset * 8
ldata = self.data()
data = 0
@@ -3193,12 +3090,12 @@ class DumperBase:
else:
self.dumper.check(False)
- if fieldType.code in (TypeCodeReference, TypeCodeRValueReference):
+ if fieldType.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference):
if val.laddress is not None:
val = self.dumper.createReferenceValue(val.laddress, fieldType.ltarget)
val.name = field.name
- #warn('GOT VAL %s FOR FIELD %s' % (val, field))
+ #DumperBase.warn('GOT VAL %s FOR FIELD %s' % (val, field))
val.lbitsize = fieldBitsize
val.check()
return val
@@ -3207,8 +3104,8 @@ class DumperBase:
# The native backends replace it in their fromNativeValue()
# implementations.
def members(self, includeBases):
- #warn("LISTING MEMBERS OF %s" % self)
- if self.type.code == TypeCodeTypedef:
+ #DumperBase.warn("LISTING MEMBERS OF %s" % self)
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.detypedef().members(includeBases)
tdata = self.type.typeData()
@@ -3222,47 +3119,47 @@ class DumperBase:
else:
fields = list(tdata.lfields(self))
- #warn("FIELDS: %s" % fields)
+ #DumperBase.warn("FIELDS: %s" % fields)
res = []
for field in fields:
if isinstance(field, self.dumper.Value):
- #warn("USING VALUE DIRECTLY %s" % field.name)
+ #DumperBase.warn("USING VALUE DIRECTLY %s" % field.name)
res.append(field)
continue
if field.isBase and not includeBases:
- #warn("DROPPING BASE %s" % field.name)
+ #DumperBase.warn("DROPPING BASE %s" % field.name)
continue
res.append(self.extractField(field))
- #warn("GOT MEMBERS: %s" % res)
+ #DumperBase.warn("GOT MEMBERS: %s" % res)
return res
def __add__(self, other):
self.check()
if self.dumper.isInt(other):
stripped = self.type.stripTypedefs()
- if stripped.code == TypeCodePointer:
+ if stripped.code == TypeCode.TypeCodePointer:
address = self.pointer() + stripped.dereference().size() * other
val = self.dumper.Value(self.dumper)
val.laddress = None
val.ldata = bytes(struct.pack(self.dumper.packCode + 'Q', address))
val.type = self.type
return val
- error('BAD DATA TO ADD TO: %s %s' % (self.type, other))
+ raise RuntimeError('BAD DATA TO ADD TO: %s %s' % (self.type, other))
def __sub__(self, other):
self.check()
if self.type.name == other.type.name:
stripped = self.type.stripTypedefs()
- if stripped.code == TypeCodePointer:
+ if stripped.code == TypeCode.TypeCodePointer:
return (self.pointer() - other.pointer()) // stripped.dereference().size()
- error('BAD DATA TO SUB TO: %s %s' % (self.type, other))
+ raise RuntimeError('BAD DATA TO SUB TO: %s %s' % (self.type, other))
def dereference(self):
self.check()
- if self.type.code == TypeCodeTypedef:
+ if self.type.code == TypeCode.TypeCodeTypedef:
return self.detypedef().dereference()
val = self.dumper.Value(self.dumper)
- if self.type.code in (TypeCodeReference, TypeCodeRValueReference):
+ if self.type.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference):
val.summary = self.summary
if self.nativeValue is None:
val.laddress = self.pointer()
@@ -3271,16 +3168,16 @@ class DumperBase:
val.type = self.dumper.nativeDynamicType(val.laddress, self.type.dereference())
else:
val = self.dumper.nativeValueDereferenceReference(self)
- elif self.type.code == TypeCodePointer:
+ elif self.type.code == TypeCode.TypeCodePointer:
if self.nativeValue is None:
val.laddress = self.pointer()
val.type = self.dumper.nativeDynamicType(val.laddress, self.type.dereference())
else:
val = self.dumper.nativeValueDereferencePointer(self)
else:
- error("WRONG: %s" % self.type.code)
- #warn("DEREFERENCING FROM: %s" % self)
- #warn("DEREFERENCING TO: %s" % val)
+ raise RuntimeError("WRONG: %s" % self.type.code)
+ #DumperBase.warn("DEREFERENCING FROM: %s" % self)
+ #DumperBase.warn("DEREFERENCING TO: %s" % val)
#dynTypeName = val.type.dynamicTypeName(val.laddress)
#if dynTypeName is not None:
# val.type = self.dumper.createType(dynTypeName)
@@ -3288,12 +3185,12 @@ class DumperBase:
def detypedef(self):
self.check()
- if self.type.code != TypeCodeTypedef:
- error("WRONG")
+ if self.type.code != TypeCode.TypeCodeTypedef:
+ raise RuntimeError("WRONG")
val = self.copy()
val.type = self.type.ltarget
- #warn("DETYPEDEF FROM: %s" % self)
- #warn("DETYPEDEF TO: %s" % val)
+ #DumperBase.warn("DETYPEDEF FROM: %s" % self)
+ #DumperBase.warn("DETYPEDEF TO: %s" % val)
return val
def extend(self, size):
@@ -3304,7 +3201,7 @@ class DumperBase:
return val
if self.type.size() == size:
return self
- error('NOT IMPLEMENTED')
+ raise RuntimeError('NOT IMPLEMENTED')
def zeroExtend(self, data, size):
ext = '\0' * (size - len(data))
@@ -3337,7 +3234,7 @@ class DumperBase:
return self.ldata
if size < len(self.ldata):
return self.ldata[:size]
- #error('ZERO-EXTENDING DATA TO %s BYTES: %s' % (size, self))
+ #raise RuntimeError('ZERO-EXTENDING DATA TO %s BYTES: %s' % (size, self))
return self.zeroExtend(self.ldata, size)
if self.laddress is not None:
if size is None:
@@ -3345,8 +3242,8 @@ class DumperBase:
res = self.dumper.readRawMemory(self.laddress, size)
if len(res) > 0:
return res
- error('CANNOT CONVERT ADDRESS TO BYTES: %s' % self)
- error('CANNOT CONVERT TO BYTES: %s' % self)
+ raise RuntimeError('CANNOT CONVERT ADDRESS TO BYTES: %s' % self)
+ raise RuntimeError('CANNOT CONVERT TO BYTES: %s' % self)
def extractInteger(self, bitsize, unsigned):
#with self.dumper.timer('extractInt'):
@@ -3365,7 +3262,7 @@ class DumperBase:
code = 'B' if unsigned else 'b'
rawBytes = self.data(size)
res = struct.unpack_from(self.dumper.packCode + code, rawBytes, 0)[0]
- #warn('Extract: Code: %s Bytes: %s Bitsize: %s Size: %s'
+ #DumperBase.warn('Extract: Code: %s Bytes: %s Bitsize: %s Size: %s'
# % (self.dumper.packCode + code, self.dumper.hexencode(rawBytes), bitsize, size))
return res
@@ -3382,25 +3279,25 @@ class DumperBase:
def split(self, pattern):
#with self.dumper.timer('split'):
- #warn('EXTRACT STRUCT FROM: %s' % self.type)
+ #DumperBase.warn('EXTRACT STRUCT FROM: %s' % self.type)
(pp, size, fields) = self.dumper.describeStruct(pattern)
- #warn('SIZE: %s ' % size)
+ #DumperBase.warn('SIZE: %s ' % size)
result = struct.unpack_from(self.dumper.packCode + pp, self.data(size))
def structFixer(field, thing):
- #warn('STRUCT MEMBER: %s' % type(thing))
+ #DumperBase.warn('STRUCT MEMBER: %s' % type(thing))
if field.isStruct:
#if field.type != field.fieldType():
- # error('DO NOT SIMPLIFY')
- #warn('FIELD POS: %s' % field.type.stringify())
- #warn('FIELD TYE: %s' % field.fieldType().stringify())
+ # raise RuntimeError('DO NOT SIMPLIFY')
+ #DumperBase.warn('FIELD POS: %s' % field.type.stringify())
+ #DumperBase.warn('FIELD TYE: %s' % field.fieldType().stringify())
res = self.dumper.createValue(thing, field.fieldType())
- #warn('RES TYPE: %s' % res.type)
+ #DumperBase.warn('RES TYPE: %s' % res.type)
if self.laddress is not None:
res.laddress = self.laddress + field.offset()
return res
return thing
if len(fields) != len(result):
- error('STRUCT ERROR: %s %s' % (fields, result))
+ raise RuntimeError('STRUCT ERROR: %s %s' % (fields, result))
return tuple(map(structFixer, fields, result))
def checkPointer(self, p, align = 1):
@@ -3424,14 +3321,14 @@ class DumperBase:
return (type_name[0:pos1].strip(), type_name[pos2+1:].strip(), int(item_count))
def registerType(self, typeId, tdata):
- #warn('REGISTER TYPE: %s' % typeId)
+ #DumperBase.warn('REGISTER TYPE: %s' % typeId)
self.typeData[typeId] = tdata
#typeId = typeId.replace(' ', '')
#self.typeData[typeId] = tdata
- #warn('REGISTERED: %s' % self.typeData)
+ #DumperBase.warn('REGISTERED: %s' % self.typeData)
def registerTypeAlias(self, existingTypeId, aliasId):
- #warn('REGISTER ALIAS %s FOR %s' % (aliasId, existingTypeId))
+ #DumperBase.warn('REGISTER ALIAS %s FOR %s' % (aliasId, existingTypeId))
self.typeData[aliasId] = self.typeData[existingTypeId]
class TypeData:
@@ -3475,13 +3372,13 @@ class DumperBase:
def typeData(self):
tdata = self.dumper.typeData.get(self.typeId, None)
if tdata is not None:
- #warn('USING : %s' % self.typeId)
+ #DumperBase.warn('USING : %s' % self.typeId)
return tdata
typeId = self.typeId.replace(' ', '')
if tdata is not None:
- #warn('USING FALLBACK : %s' % self.typeId)
+ #DumperBase.warn('USING FALLBACK : %s' % self.typeId)
return tdata
- #warn('EXPANDING LAZILY: %s' % self.typeId)
+ #DumperBase.warn('EXPANDING LAZILY: %s' % self.typeId)
self.dumper.lookupType(self.typeId)
return self.dumper.typeData.get(self.typeId)
@@ -3522,19 +3419,19 @@ class DumperBase:
def __getitem__(self, index):
if self.dumper.isInt(index):
return self.templateArgument(index)
- error('CANNOT INDEX TYPE')
+ raise RuntimeError('CANNOT INDEX TYPE')
def dynamicTypeName(self, address):
tdata = self.typeData()
if tdata is None:
return None
- if tdata.code != TypeCodeStruct:
+ if tdata.code != TypeCode.TypeCodeStruct:
return None
try:
vtbl = self.dumper.extractPointer(address)
except:
return None
- #warn('VTBL: 0x%x' % vtbl)
+ #DumperBase.warn('VTBL: 0x%x' % vtbl)
if not self.dumper.couldBePointer(vtbl):
return None
return self.dumper.nativeDynamicTypeName(address, self)
@@ -3552,12 +3449,12 @@ class DumperBase:
def check(self):
tdata = self.typeData()
if tdata is None:
- error('TYPE WITHOUT DATA: %s ALL: %s' % (self.typeId, self.dumper.typeData.keys()))
+ raise RuntimeError('TYPE WITHOUT DATA: %s ALL: %s' % (self.typeId, self.dumper.typeData.keys()))
if tdata.name is None:
- error('TYPE WITHOUT NAME: %s' % self.typeId)
+ raise RuntimeError('TYPE WITHOUT NAME: %s' % self.typeId)
def dereference(self):
- if self.code == TypeCodeTypedef:
+ if self.code == TypeCode.TypeCodeTypedef:
return self.ltarget.dereference()
self.check()
return self.ltarget
@@ -3573,18 +3470,18 @@ class DumperBase:
def templateArgument(self, position):
tdata = self.typeData()
- #warn('TDATA: %s' % tdata)
- #warn('ID: %s' % self.typeId)
+ #DumperBase.warn('TDATA: %s' % tdata)
+ #DumperBase.warn('ID: %s' % self.typeId)
if tdata is None:
# Native lookups didn't help. Happens for 'wrong' placement of 'const'
# etc. with LLDB. But not all is lost:
ta = self.dumper.listTemplateParameters(self.typeId)
- #warn('MANUAL: %s' % ta)
+ #DumperBase.warn('MANUAL: %s' % ta)
res = ta[position]
- #warn('RES: %s' % res.typeId)
+ #DumperBase.warn('RES: %s' % res.typeId)
return res
- #warn('TA: %s %s' % (position, self.typeId))
- #warn('ARGS: %s' % tdata.templateArguments)
+ #DumperBase.warn('TA: %s %s' % (position, self.typeId))
+ #DumperBase.warn('ARGS: %s' % tdata.templateArguments)
return tdata.templateArguments[position]
def simpleEncoding(self):
@@ -3605,18 +3502,18 @@ class DumperBase:
return res
def isSimpleType(self):
- return self.code in (TypeCodeIntegral, TypeCodeFloat, TypeCodeEnum)
+ return self.code in (TypeCode.TypeCodeIntegral, TypeCode.TypeCodeFloat, TypeCode.TypeCodeEnum)
def alignment(self):
tdata = self.typeData()
- if tdata.code == TypeCodeTypedef:
+ if tdata.code == TypeCode.TypeCodeTypedef:
return tdata.ltarget.alignment()
- if tdata.code in (TypeCodeIntegral, TypeCodeFloat, TypeCodeEnum):
+ if tdata.code in (TypeCode.TypeCodeIntegral, TypeCode.TypeCodeFloat, TypeCode.TypeCodeEnum):
if tdata.name in ('double', 'long long', 'unsigned long long'):
# Crude approximation.
return 8 if self.dumper.isWindowsTarget() else self.dumper.ptrSize()
return self.size()
- if tdata.code in (TypeCodePointer, TypeCodeReference, TypeCodeRValueReference):
+ if tdata.code in (TypeCode.TypeCodePointer, TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference):
return self.dumper.ptrSize()
if tdata.lalignment is not None:
#if isinstance(tdata.lalignment, function): # Does not work that way.
@@ -3632,24 +3529,24 @@ class DumperBase:
return self.typeData().ltarget
def stripTypedefs(self):
- if isinstance(self, self.dumper.Type) and self.code != TypeCodeTypedef:
- #warn('NO TYPEDEF: %s' % self)
+ if isinstance(self, self.dumper.Type) and self.code != TypeCode.TypeCodeTypedef:
+ #DumperBase.warn('NO TYPEDEF: %s' % self)
return self
return self.ltarget
def size(self):
bs = self.bitsize()
if bs % 8 != 0:
- warn('ODD SIZE: %s' % self)
+ DumperBase.warn('ODD SIZE: %s' % self)
return (7 + bs) >> 3
def bitsize(self):
if self.lbitsize is not None:
return self.lbitsize
- error('DONT KNOW SIZE: %s' % self)
+ raise RuntimeError('DONT KNOW SIZE: %s' % self)
def isMovableType(self):
- if self.code in (TypeCodePointer, TypeCodeIntegral, TypeCodeFloat):
+ if self.code in (TypeCode.TypeCodePointer, TypeCode.TypeCodeIntegral, TypeCode.TypeCodeFloat):
return True
strippedName = self.dumper.stripNamespaceFromType(self.name)
if strippedName in (
@@ -3704,7 +3601,7 @@ class DumperBase:
def fieldType(self):
if self.type is not None:
return self.type
- error('CANT GET FIELD TYPE FOR %s' % self)
+ raise RuntimeError('CANT GET FIELD TYPE FOR %s' % self)
return None
def ptrCode(self):
@@ -3712,7 +3609,7 @@ class DumperBase:
def toPointerData(self, address):
if not self.isInt(address):
- error('wrong')
+ raise RuntimeError('wrong')
return bytes(struct.pack(self.packCode + self.ptrCode(), address))
def fromPointerData(self, bytes_value):
@@ -3720,10 +3617,10 @@ class DumperBase:
def createPointerValue(self, targetAddress, targetTypish):
if not isinstance(targetTypish, self.Type) and not isinstance(targetTypish, str):
- error('Expected type in createPointerValue(), got %s'
+ raise RuntimeError('Expected type in createPointerValue(), got %s'
% type(targetTypish))
if not self.isInt(targetAddress):
- error('Expected integral address value in createPointerValue(), got %s'
+ raise RuntimeError('Expected integral address value in createPointerValue(), got %s'
% type(targetTypish))
val = self.Value(self)
val.ldata = self.toPointerData(targetAddress)
@@ -3733,10 +3630,10 @@ class DumperBase:
def createReferenceValue(self, targetAddress, targetType):
if not isinstance(targetType, self.Type):
- error('Expected type in createReferenceValue(), got %s'
+ raise RuntimeError('Expected type in createReferenceValue(), got %s'
% type(targetType))
if not self.isInt(targetAddress):
- error('Expected integral address value in createReferenceValue(), got %s'
+ raise RuntimeError('Expected integral address value in createReferenceValue(), got %s'
% type(targetType))
val = self.Value(self)
val.ldata = self.toPointerData(targetAddress)
@@ -3746,27 +3643,27 @@ class DumperBase:
def createPointerType(self, targetType):
if not isinstance(targetType, self.Type):
- error('Expected type in createPointerType(), got %s'
+ raise RuntimeError('Expected type in createPointerType(), got %s'
% type(targetType))
typeId = targetType.typeId + ' *'
tdata = self.TypeData(self)
tdata.name = targetType.name + '*'
tdata.typeId = typeId
tdata.lbitsize = 8 * self.ptrSize()
- tdata.code = TypeCodePointer
+ tdata.code = TypeCode.TypeCodePointer
tdata.ltarget = targetType
self.registerType(typeId, tdata)
return self.Type(self, typeId)
def createReferenceType(self, targetType):
if not isinstance(targetType, self.Type):
- error('Expected type in createReferenceType(), got %s'
+ raise RuntimeError('Expected type in createReferenceType(), got %s'
% type(targetType))
typeId = targetType.typeId + ' &'
tdata = self.TypeData(self)
tdata.name = targetType.name + ' &'
tdata.typeId = typeId
- tdata.code = TypeCodeReference
+ tdata.code = TypeCode.TypeCodeReference
tdata.ltarget = targetType
tdata.lbitsize = 8 * self.ptrSize() # Needed for Gdb13393 test.
#tdata.lbitsize = None
@@ -3775,13 +3672,13 @@ class DumperBase:
def createRValueReferenceType(self, targetType):
if not isinstance(targetType, self.Type):
- error('Expected type in createRValueReferenceType(), got %s'
+ raise RuntimeError('Expected type in createRValueReferenceType(), got %s'
% type(targetType))
typeId = targetType.typeId + ' &&'
tdata = self.TypeData(self)
tdata.name = targetType.name + ' &&'
tdata.typeId = typeId
- tdata.code = TypeCodeRValueReference
+ tdata.code = TypeCode.TypeCodeRValueReference
tdata.ltarget = targetType
tdata.lbitsize = None
self.registerType(typeId, tdata)
@@ -3789,7 +3686,7 @@ class DumperBase:
def createArrayType(self, targetType, count):
if not isinstance(targetType, self.Type):
- error('Expected type in createArrayType(), got %s'
+ raise RuntimeError('Expected type in createArrayType(), got %s'
% type(targetType))
targetTypeId = targetType.typeId
@@ -3804,7 +3701,7 @@ class DumperBase:
tdata = self.TypeData(self)
tdata.name = type_name
tdata.typeId = type_id
- tdata.code = TypeCodeArray
+ tdata.code = TypeCode.TypeCodeArray
tdata.ltarget = targetType
tdata.lbitsize = targetType.lbitsize * count
self.registerType(type_id, tdata)
@@ -3812,13 +3709,13 @@ class DumperBase:
def createBitfieldType(self, targetType, bitsize):
if not isinstance(targetType, self.Type):
- error('Expected type in createBitfieldType(), got %s'
+ raise RuntimeError('Expected type in createBitfieldType(), got %s'
% type(targetType))
typeId = '%s:%d' % (targetType.typeId, bitsize)
tdata = self.TypeData(self)
tdata.name = '%s : %d' % (targetType.typeId, bitsize)
tdata.typeId = typeId
- tdata.code = TypeCodeBitfield
+ tdata.code = TypeCode.TypeCodeBitfield
tdata.ltarget = targetType
tdata.lbitsize = bitsize
self.registerType(typeId, tdata)
@@ -3828,7 +3725,7 @@ class DumperBase:
if typeId is None:
typeId = typeName
if not isinstance(targetType, self.Type):
- error('Expected type in createTypedefType(), got %s'
+ raise RuntimeError('Expected type in createTypedefType(), got %s'
% type(targetType))
# Happens for C-style struct in GDB: typedef { int x; } struct S1;
if targetType.typeId == typeId:
@@ -3836,7 +3733,7 @@ class DumperBase:
tdata = self.TypeData(self)
tdata.name = typeName
tdata.typeId = typeId
- tdata.code = TypeCodeTypedef
+ tdata.code = TypeCode.TypeCodeTypedef
tdata.ltarget = targetType
tdata.lbitsize = targetType.lbitsize
#tdata.lfields = targetType.lfields
@@ -3889,12 +3786,12 @@ class DumperBase:
return self.Type(self, typish)
knownType = self.lookupType(typish)
- #warn('KNOWN: %s' % knownType)
+ #DumperBase.warn('KNOWN: %s' % knownType)
if knownType is not None:
- #warn('USE FROM NATIVE')
+ #DumperBase.warn('USE FROM NATIVE')
return knownType
- #warn('FAKING: %s SIZE: %s' % (typish, size))
+ #DumperBase.warn('FAKING: %s SIZE: %s' % (typish, size))
tdata = self.TypeData(self)
tdata.name = typish
tdata.typeId = typish
@@ -3903,25 +3800,25 @@ class DumperBase:
tdata.lbitsize = 8 * size
self.registerType(typish, tdata)
typeobj = self.Type(self, typish)
- #warn('CREATE TYPE: %s' % typeobj.stringify())
+ #DumperBase.warn('CREATE TYPE: %s' % typeobj.stringify())
typeobj.check()
return typeobj
- error('NEED TYPE, NOT %s' % type(typish))
+ raise RuntimeError('NEED TYPE, NOT %s' % type(typish))
def createValue(self, datish, typish):
val = self.Value(self)
val.type = self.createType(typish)
if self.isInt(datish): # Used as address.
- #warn('CREATING %s AT 0x%x' % (val.type.name, datish))
+ #DumperBase.warn('CREATING %s AT 0x%x' % (val.type.name, datish))
val.laddress = datish
val.type = val.type.dynamicType(datish)
return val
if isinstance(datish, bytes):
- #warn('CREATING %s WITH DATA %s' % (val.type.name, self.hexencode(datish)))
+ #DumperBase.warn('CREATING %s WITH DATA %s' % (val.type.name, self.hexencode(datish)))
val.ldata = datish
val.check()
return val
- error('EXPECTING ADDRESS OR BYTES, GOT %s' % type(datish))
+ raise RuntimeError('EXPECTING ADDRESS OR BYTES, GOT %s' % type(datish))
def createContainerItem(self, data, innerTypish, container):
innerType = self.createType(innerTypish)
@@ -3966,7 +3863,7 @@ class DumperBase:
if self.autoPadNext:
self.currentBitsize = 8 * ((self.currentBitsize + 7) >> 3) # Fill up byte.
padding = (fieldAlign - (self.currentBitsize >> 3)) % fieldAlign
- #warn('AUTO PADDING AT %s BITS BY %s BYTES' % (self.currentBitsize, padding))
+ #DumperBase.warn('AUTO PADDING AT %s BITS BY %s BYTES' % (self.currentBitsize, padding))
field = self.dumper.Field(self.dumper, bitpos=self.currentBitsize,
bitsize=padding*8)
self.pattern += '%ds' % padding
@@ -3976,7 +3873,7 @@ class DumperBase:
if fieldAlign > self.maxAlign:
self.maxAlign = fieldAlign
- #warn("MAX ALIGN: %s" % self.maxAlign)
+ #DumperBase.warn("MAX ALIGN: %s" % self.maxAlign)
field = self.dumper.Field(dumper=self.dumper, name=fieldName, type=fieldType,
isStruct=fieldIsStruct, bitpos=self.currentBitsize,
@@ -4046,7 +3943,7 @@ class DumperBase:
builder.fields.append(field)
n = None
else:
- error('UNKNOWN STRUCT CODE: %s' % c)
+ raise RuntimeError('UNKNOWN STRUCT CODE: %s' % c)
pp = builder.pattern
size = (builder.currentBitsize + 7) >> 3
fields = builder.fields
diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py
index 6a912ea388d..c50ba14281c 100644
--- a/share/qtcreator/debugger/gdbbridge.py
+++ b/share/qtcreator/debugger/gdbbridge.py
@@ -37,8 +37,8 @@ import struct
import tempfile
import types
-from dumper import *
-
+from dumper import DumperBase, Children, toInteger, TopLevelItem
+from utils import TypeCode
#######################################################################
#
@@ -168,7 +168,7 @@ def importPlainDumpers(args):
gdb.execute('disable pretty-printer .* .*')
except:
# Might occur in non-ASCII directories
- warn('COULD NOT DISABLE PRETTY PRINTERS')
+ DumperBase.warn('COULD NOT DISABLE PRETTY PRINTERS')
else:
theDumper.importPlainDumpers()
@@ -186,7 +186,7 @@ class OutputSaver:
def __exit__(self, exType, exValue, exTraceBack):
if self.d.passExceptions and not exType is None:
- showException('OUTPUTSAVER', exType, exValue, exTraceBack)
+ self.d.showException('OUTPUTSAVER', exType, exValue, exTraceBack)
self.d.output = self.savedOutput
else:
self.savedOutput += self.d.output
@@ -217,7 +217,7 @@ class Dumper(DumperBase):
self.setVariableFetchingOptions(args)
def fromFrameValue(self, nativeValue):
- #warn('FROM FRAME VALUE: %s' % nativeValue.address)
+ #DumperBase.warn('FROM FRAME VALUE: %s' % nativeValue.address)
val = nativeValue
try:
val = nativeValue.cast(nativeValue.dynamic_type)
@@ -226,7 +226,7 @@ class Dumper(DumperBase):
return self.fromNativeValue(val)
def fromNativeValue(self, nativeValue):
- #warn('FROM NATIVE VALUE: %s' % nativeValue)
+ #DumperBase.warn('FROM NATIVE VALUE: %s' % nativeValue)
self.check(isinstance(nativeValue, gdb.Value))
nativeType = nativeValue.type
code = nativeType.code
@@ -234,7 +234,7 @@ class Dumper(DumperBase):
targetType = self.fromNativeType(nativeType.target().unqualified())
val = self.createReferenceValue(toInteger(nativeValue.address), targetType)
val.nativeValue = nativeValue
- #warn('CREATED REF: %s' % val)
+ #DumperBase.warn('CREATED REF: %s' % val)
return val
if code == gdb.TYPE_CODE_PTR:
try:
@@ -248,14 +248,14 @@ class Dumper(DumperBase):
# later which
# is surprisingly expensive.
val.nativeValue = nativeValue
- #warn('CREATED PTR 1: %s' % val)
+ #DumperBase.warn('CREATED PTR 1: %s' % val)
if not nativeValue.address is None:
val.laddress = toInteger(nativeValue.address)
- #warn('CREATED PTR 2: %s' % val)
+ #DumperBase.warn('CREATED PTR 2: %s' % val)
return val
if code == gdb.TYPE_CODE_TYPEDEF:
targetType = nativeType.strip_typedefs().unqualified()
- #warn('TARGET TYPE: %s' % targetType)
+ #DumperBase.warn('TARGET TYPE: %s' % targetType)
if targetType.code == gdb.TYPE_CODE_ARRAY:
val = self.Value(self)
else:
@@ -267,7 +267,7 @@ class Dumper(DumperBase):
val = self.fromNativeValue(nativeValue.cast(targetType))
except:
val = self.Value(self)
- #warn('CREATED TYPEDEF: %s' % val)
+ #DumperBase.warn('CREATED TYPEDEF: %s' % val)
else:
val = self.Value(self)
@@ -308,34 +308,34 @@ class Dumper(DumperBase):
def fromNativeType(self, nativeType):
self.check(isinstance(nativeType, gdb.Type))
code = nativeType.code
- #warn('FROM NATIVE TYPE: %s' % nativeType)
+ #DumperBase.warn('FROM NATIVE TYPE: %s' % nativeType)
nativeType = nativeType.unqualified()
if code == gdb.TYPE_CODE_PTR:
- #warn('PTR')
+ #DumperBase.warn('PTR')
targetType = self.fromNativeType(nativeType.target().unqualified())
return self.createPointerType(targetType)
if code == gdb.TYPE_CODE_REF:
- #warn('REF')
+ #DumperBase.warn('REF')
targetType = self.fromNativeType(nativeType.target().unqualified())
return self.createReferenceType(targetType)
if hasattr(gdb, "TYPE_CODE_RVALUE_REF"):
if code == gdb.TYPE_CODE_RVALUE_REF:
- #warn('RVALUEREF')
+ #DumperBase.warn('RVALUEREF')
targetType = self.fromNativeType(nativeType.target())
return self.createRValueReferenceType(targetType)
if code == gdb.TYPE_CODE_ARRAY:
- #warn('ARRAY')
+ #DumperBase.warn('ARRAY')
nativeTargetType = nativeType.target().unqualified()
targetType = self.fromNativeType(nativeTargetType)
count = nativeType.sizeof // nativeTargetType.sizeof
return self.createArrayType(targetType, count)
if code == gdb.TYPE_CODE_TYPEDEF:
- #warn('TYPEDEF')
+ #DumperBase.warn('TYPEDEF')
nativeTargetType = nativeType.unqualified()
while nativeTargetType.code == gdb.TYPE_CODE_TYPEDEF:
nativeTargetType = nativeTargetType.strip_typedefs().unqualified()
@@ -344,7 +344,7 @@ class Dumper(DumperBase):
self.nativeTypeId(nativeType))
if code == gdb.TYPE_CODE_ERROR:
- warn('Type error: %s' % nativeType)
+ self.warn('Type error: %s' % nativeType)
return self.Type(self, '')
typeId = self.nativeTypeId(nativeType)
@@ -356,28 +356,28 @@ class Dumper(DumperBase):
tdata.lbitsize = nativeType.sizeof * 8
tdata.code = {
#gdb.TYPE_CODE_TYPEDEF : TypeCodeTypedef, # Handled above.
- gdb.TYPE_CODE_METHOD : TypeCodeFunction,
- gdb.TYPE_CODE_VOID : TypeCodeVoid,
- gdb.TYPE_CODE_FUNC : TypeCodeFunction,
- gdb.TYPE_CODE_METHODPTR : TypeCodeFunction,
- gdb.TYPE_CODE_MEMBERPTR : TypeCodeFunction,
- #gdb.TYPE_CODE_PTR : TypeCodePointer, # Handled above.
- #gdb.TYPE_CODE_REF : TypeCodeReference, # Handled above.
- gdb.TYPE_CODE_BOOL : TypeCodeIntegral,
- gdb.TYPE_CODE_CHAR : TypeCodeIntegral,
- gdb.TYPE_CODE_INT : TypeCodeIntegral,
- gdb.TYPE_CODE_FLT : TypeCodeFloat,
- gdb.TYPE_CODE_ENUM : TypeCodeEnum,
- #gdb.TYPE_CODE_ARRAY : TypeCodeArray,
- gdb.TYPE_CODE_STRUCT : TypeCodeStruct,
- gdb.TYPE_CODE_UNION : TypeCodeStruct,
- gdb.TYPE_CODE_COMPLEX : TypeCodeComplex,
- gdb.TYPE_CODE_STRING : TypeCodeFortranString,
+ gdb.TYPE_CODE_METHOD : TypeCode.TypeCodeFunction,
+ gdb.TYPE_CODE_VOID : TypeCode.TypeCodeVoid,
+ gdb.TYPE_CODE_FUNC : TypeCode.TypeCodeFunction,
+ gdb.TYPE_CODE_METHODPTR : TypeCode.TypeCodeFunction,
+ gdb.TYPE_CODE_MEMBERPTR : TypeCode.TypeCodeFunction,
+ #gdb.TYPE_CODE_PTR : TypeCode.TypeCodePointer, # Handled above.
+ #gdb.TYPE_CODE_REF : TypeCode.TypeCodeReference, # Handled above.
+ gdb.TYPE_CODE_BOOL : TypeCode.TypeCodeIntegral,
+ gdb.TYPE_CODE_CHAR : TypeCode.TypeCodeIntegral,
+ gdb.TYPE_CODE_INT : TypeCode.TypeCodeIntegral,
+ gdb.TYPE_CODE_FLT : TypeCode.TypeCodeFloat,
+ gdb.TYPE_CODE_ENUM : TypeCode.TypeCodeEnum,
+ #gdb.TYPE_CODE_ARRAY : TypeCode.TypeCodeArray,
+ gdb.TYPE_CODE_STRUCT : TypeCode.TypeCodeStruct,
+ gdb.TYPE_CODE_UNION : TypeCode.TypeCodeStruct,
+ gdb.TYPE_CODE_COMPLEX : TypeCode.TypeCodeComplex,
+ gdb.TYPE_CODE_STRING : TypeCode.TypeCodeFortranString,
}[code]
- if tdata.code == TypeCodeEnum:
+ if tdata.code == TypeCode.TypeCodeEnum:
tdata.enumDisplay = lambda intval, addr, form : \
self.nativeTypeEnumDisplay(nativeType, intval, form)
- if tdata.code == TypeCodeStruct:
+ if tdata.code == TypeCode.TypeCodeStruct:
tdata.lalignment = lambda : \
self.nativeStructAlignment(nativeType)
tdata.lfields = lambda value : \
@@ -402,7 +402,7 @@ class Dumper(DumperBase):
elif isinstance(targ, gdb.Value):
targs.append(self.fromNativeValue(targ).value())
else:
- error('UNKNOWN TEMPLATE PARAMETER')
+ raise RuntimeError('UNKNOWN TEMPLATE PARAMETER')
pos += 1
targs2 = self.listTemplateParametersManually(str(nativeType))
return targs if len(targs) >= len(targs2) else targs2
@@ -451,7 +451,7 @@ class Dumper(DumperBase):
return typeId
def nativeStructAlignment(self, nativeType):
- #warn('NATIVE ALIGN FOR %s' % nativeType.name)
+ #DumperBase.warn('NATIVE ALIGN FOR %s' % nativeType.name)
def handleItem(nativeFieldType, align):
a = self.fromNativeType(nativeFieldType).alignment()
return a if a > align else align
@@ -507,7 +507,7 @@ class Dumper(DumperBase):
anonNumber = 0
- #warn('LISTING FIELDS FOR %s' % nativeType)
+ #DumperBase.warn('LISTING FIELDS FOR %s' % nativeType)
for nativeField in nativeType.fields():
fieldName = nativeField.name
# Something without a name.
@@ -521,7 +521,7 @@ class Dumper(DumperBase):
# multiple anonymous unions in the struct.
anonNumber += 1
fieldName = '#%s' % anonNumber
- #warn('FIELD: %s' % fieldName)
+ #DumperBase.warn('FIELD: %s' % fieldName)
# hasattr(nativeField, 'bitpos') == False indicates a static field,
# but if we have access to a nativeValue .fromNativeField will
# also succeed. We essentially skip only static members from
@@ -531,8 +531,8 @@ class Dumper(DumperBase):
def fromNativeField(self, nativeField, nativeValue, fieldName):
nativeFieldType = nativeField.type.unqualified()
- #warn(' TYPE: %s' % nativeFieldType)
- #warn(' TYPEID: %s' % self.nativeTypeId(nativeFieldType))
+ #DumperBase.warn(' TYPE: %s' % nativeFieldType)
+ #DumperBase.warn(' TYPEID: %s' % self.nativeTypeId(nativeFieldType))
if hasattr(nativeField, 'bitpos'):
bitpos = nativeField.bitpos
@@ -562,7 +562,7 @@ class Dumper(DumperBase):
capturedFieldName,
value)
- #warn("FOUND NATIVE FIELD: %s bitpos: %s" % (fieldName, bitpos))
+ #DumperBase.warn("FOUND NATIVE FIELD: %s bitpos: %s" % (fieldName, bitpos))
return self.Field(dumper=self, name=fieldName, isBase=nativeField.is_base_class,
bitsize=bitsize, bitpos=bitpos, type=fieldType,
extractor=extractor)
@@ -574,19 +574,19 @@ class Dumper(DumperBase):
try:
block = frame.block()
- #warn('BLOCK: %s ' % block)
+ #DumperBase.warn('BLOCK: %s ' % block)
except RuntimeError as error:
- #warn('BLOCK IN FRAME NOT ACCESSIBLE: %s' % error)
+ #DumperBase.warn('BLOCK IN FRAME NOT ACCESSIBLE: %s' % error)
return []
except:
- warn('BLOCK NOT ACCESSIBLE FOR UNKNOWN REASONS')
+ self.warn('BLOCK NOT ACCESSIBLE FOR UNKNOWN REASONS')
return []
items = []
shadowed = {}
while True:
if block is None:
- warn("UNEXPECTED 'None' BLOCK")
+ self.warn("UNEXPECTED 'None' BLOCK")
break
for symbol in block:
@@ -602,12 +602,12 @@ class Dumper(DumperBase):
# 'NotImplementedError: Symbol type not yet supported in
# Python scripts.'
- #warn('SYMBOL %s (%s, %s)): ' % (symbol, name, symbol.name))
+ #DumperBase.warn('SYMBOL %s (%s, %s)): ' % (symbol, name, symbol.name))
if self.passExceptions and not self.isTesting:
nativeValue = frame.read_var(name, block)
value = self.fromFrameValue(nativeValue)
value.name = name
- #warn('READ 0: %s' % value.stringify())
+ #DumperBase.warn('READ 0: %s' % value.stringify())
items.append(value)
continue
@@ -616,14 +616,14 @@ class Dumper(DumperBase):
nativeValue = frame.read_var(name, block)
value = self.fromFrameValue(nativeValue)
value.name = name
- #warn('READ 1: %s' % value.stringify())
+ #DumperBase.warn('READ 1: %s' % value.stringify())
items.append(value)
continue
except:
pass
try:
- #warn('READ 2: %s' % item.value)
+ #DumperBase.warn('READ 2: %s' % item.value)
value = self.fromFrameValue(frame.read_var(name))
value.name = name
items.append(value)
@@ -637,8 +637,8 @@ class Dumper(DumperBase):
pass
try:
- #warn('READ 3: %s %s' % (name, item.value))
- #warn('ITEM 3: %s' % item.value)
+ #DumperBase.warn('READ 3: %s %s' % (name, item.value))
+ #DumperBase.warn('ITEM 3: %s' % item.value)
value = self.fromFrameValue(gdb.parse_and_eval(name))
value.name = name
items.append(value)
@@ -685,7 +685,7 @@ class Dumper(DumperBase):
partialName = partialVar.split('.')[1].split('@')[0] if isPartial else None
variables = self.listLocals(partialName)
- #warn('VARIABLES: %s' % variables)
+ #DumperBase.warn('VARIABLES: %s' % variables)
# Take care of the return value of the last function call.
if len(self.resultVarName) > 0:
@@ -728,13 +728,13 @@ class Dumper(DumperBase):
return None if val is None else self.fromNativeValue(val)
def nativeParseAndEvaluate(self, exp):
- #warn('EVALUATE "%s"' % exp)
+ #DumperBase.warn('EVALUATE "%s"' % exp)
try:
val = gdb.parse_and_eval(exp)
return val
except RuntimeError as error:
if self.passExceptions:
- warn("Cannot evaluate '%s': %s" % (exp, error))
+ self.warn("Cannot evaluate '%s': %s" % (exp, error))
return None
def callHelper(self, rettype, value, function, args):
@@ -749,7 +749,7 @@ class Dumper(DumperBase):
else:
arg += a
- #warn('CALL: %s -> %s(%s)' % (value, function, arg))
+ #DumperBase.warn('CALL: %s -> %s(%s)' % (value, function, arg))
typeName = value.type.name
if typeName.find(':') >= 0:
typeName = "'" + typeName + "'"
@@ -758,11 +758,11 @@ class Dumper(DumperBase):
addr = value.address()
if addr is None:
addr = self.pokeValue(value)
- #warn('PTR: %s -> %s(%s)' % (value, function, addr))
+ #DumperBase.warn('PTR: %s -> %s(%s)' % (value, function, addr))
exp = '((%s*)0x%x)->%s(%s)' % (typeName, addr, function, arg)
- #warn('CALL: %s' % exp)
+ #DumperBase.warn('CALL: %s' % exp)
result = gdb.parse_and_eval(exp)
- #warn(' -> %s' % result)
+ #DumperBase.warn(' -> %s' % result)
res = self.fromNativeValue(result)
if value.address() is None:
self.releaseValue(addr)
@@ -770,9 +770,9 @@ class Dumper(DumperBase):
def makeExpression(self, value):
typename = '::' + value.type.name
- #warn(' TYPE: %s' % typename)
+ #DumperBase.warn(' TYPE: %s' % typename)
exp = '(*(%s*)(0x%x))' % (typename, value.address())
- #warn(' EXP: %s' % exp)
+ #DumperBase.warn(' EXP: %s' % exp)
return exp
def makeStdString(init):
@@ -790,13 +790,13 @@ class Dumper(DumperBase):
size = value.type.size()
data = value.data()
h = self.hexencode(data)
- #warn('DATA: %s' % h)
+ #DumperBase.warn('DATA: %s' % h)
string = ''.join('\\x' + h[2*i:2*i+2] for i in range(size))
exp = '(%s*)memcpy(calloc(%d, 1), "%s", %d)' \
% (value.type.name, size, string, size)
- #warn('EXP: %s' % exp)
+ #DumperBase.warn('EXP: %s' % exp)
res = gdb.parse_and_eval(exp)
- #warn('RES: %s' % res)
+ #DumperBase.warn('RES: %s' % res)
return toInteger(res)
def releaseValue(self, address):
@@ -824,7 +824,7 @@ class Dumper(DumperBase):
return self.cachedInferior
def readRawMemory(self, address, size):
- #warn('READ: %s FROM 0x%x' % (size, address))
+ #DumperBase.warn('READ: %s FROM 0x%x' % (size, address))
if address == 0 or size == 0:
return bytes()
res = self.selectedInferior().read_memory(address, size)
@@ -1185,7 +1185,7 @@ class Dumper(DumperBase):
def lookupNativeTypeHelper(self, typeName):
typeobj = self.typeCache.get(typeName)
- #warn('LOOKUP 1: %s -> %s' % (typeName, typeobj))
+ #DumperBase.warn('LOOKUP 1: %s -> %s' % (typeName, typeobj))
if not typeobj is None:
return typeobj
@@ -1217,7 +1217,7 @@ class Dumper(DumperBase):
self.typesToReport[typeName] = typeobj
return typeobj
- #warn(" RESULT FOR 7.2: '%s': %s" % (typeName, typeobj))
+ #DumperBase.warn(" RESULT FOR 7.2: '%s': %s" % (typeName, typeobj))
# This part should only trigger for
# gdb 7.1 for types with namespace separators.
@@ -1255,24 +1255,24 @@ class Dumper(DumperBase):
return typeobj
try:
- #warn("LOOKING UP 1 '%s'" % ts)
+ #DumperBase.warn("LOOKING UP 1 '%s'" % ts)
typeobj = gdb.lookup_type(ts)
except RuntimeError as error:
- #warn("LOOKING UP 2 '%s' ERROR %s" % (ts, error))
+ #DumperBase.warn("LOOKING UP 2 '%s' ERROR %s" % (ts, error))
# See http://sourceware.org/bugzilla/show_bug.cgi?id=11912
exp = "(class '%s'*)0" % ts
try:
typeobj = self.parse_and_eval(exp).type.target()
- #warn("LOOKING UP 3 '%s'" % typeobj)
+ #DumperBase.warn("LOOKING UP 3 '%s'" % typeobj)
except:
# Can throw 'RuntimeError: No type named class Foo.'
pass
except:
- #warn("LOOKING UP '%s' FAILED" % ts)
+ #DumperBase.warn("LOOKING UP '%s' FAILED" % ts)
pass
if not typeobj is None:
- #warn('CACHING: %s' % typeobj)
+ #DumperBase.warn('CACHING: %s' % typeobj)
self.typeCache[typeName] = typeobj
self.typesToReport[typeName] = typeobj
diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py
index 7d84bccdae8..3617d398a6a 100644
--- a/share/qtcreator/debugger/lldbbridge.py
+++ b/share/qtcreator/debugger/lldbbridge.py
@@ -31,6 +31,8 @@ import sys
import threading
import time
import lldb
+import utils
+from utils import DebuggerStartMode, BreakpointType, TypeCode
from contextlib import contextmanager
@@ -40,7 +42,7 @@ sys.path.insert(1, os.path.dirname(os.path.abspath(inspect.getfile(inspect.curre
if 'dumper' in sys.modules:
reload(sys.modules['dumper'])
-from dumper import *
+from dumper import DumperBase, SubItem, Children, TopLevelItem
#######################################################################
#
@@ -154,23 +156,23 @@ class Dumper(DumperBase):
targetType = self.fromNativeType(nativeTargetType)
val = self.createReferenceValue(nativeValue.GetValueAsUnsigned(), targetType)
val.laddress = nativeValue.AddressOf().GetValueAsUnsigned()
- #warn('CREATED REF: %s' % val)
+ #DumperBase.warn('CREATED REF: %s' % val)
elif code == lldb.eTypeClassPointer:
nativeTargetType = nativeType.GetPointeeType()
if not nativeTargetType.IsPointerType():
nativeTargetType = nativeTargetType.GetUnqualifiedType()
targetType = self.fromNativeType(nativeTargetType)
val = self.createPointerValue(nativeValue.GetValueAsUnsigned(), targetType)
- #warn('CREATED PTR 1: %s' % val)
+ #DumperBase.warn('CREATED PTR 1: %s' % val)
val.laddress = nativeValue.AddressOf().GetValueAsUnsigned()
- #warn('CREATED PTR 2: %s' % val)
+ #DumperBase.warn('CREATED PTR 2: %s' % val)
elif code == lldb.eTypeClassTypedef:
nativeTargetType = nativeType.GetUnqualifiedType()
if hasattr(nativeTargetType, 'GetCanonicalType'):
nativeTargetType = nativeTargetType.GetCanonicalType()
val = self.fromNativeValue(nativeValue.Cast(nativeTargetType))
val.type = self.fromNativeType(nativeType)
- #warn('CREATED TYPEDEF: %s' % val)
+ #DumperBase.warn('CREATED TYPEDEF: %s' % val)
else:
val = self.Value(self)
address = nativeValue.GetLoadAddress()
@@ -233,7 +235,7 @@ class Dumper(DumperBase):
return align
def listMembers(self, value, nativeType):
- #warn("ADDR: 0x%x" % self.fakeAddress)
+ #DumperBase.warn("ADDR: 0x%x" % self.fakeAddress)
fakeAddress = self.fakeAddress if value.laddress is None else value.laddress
sbaddr = lldb.SBAddress(fakeAddress, self.target)
fakeValue = self.target.CreateValueFromAddress('x', sbaddr, nativeType)
@@ -359,8 +361,8 @@ class Dumper(DumperBase):
# // Define a mask that can be used for any type when finding types
# eTypeClassAny = (0xffffffffu)
- #warn('CURRENT: %s' % self.typeData.keys())
- #warn('FROM NATIVE TYPE: %s' % nativeType.GetName())
+ #DumperBase.warn('CURRENT: %s' % self.typeData.keys())
+ #DumperBase.warn('FROM NATIVE TYPE: %s' % nativeType.GetName())
if code == lldb.eTypeClassInvalid:
return None
@@ -368,23 +370,23 @@ class Dumper(DumperBase):
nativeType = nativeType.GetUnqualifiedType()
if code == lldb.eTypeClassPointer:
- #warn('PTR')
+ #DumperBase.warn('PTR')
nativeTargetType = nativeType.GetPointeeType()
if not nativeTargetType.IsPointerType():
nativeTargetType = nativeTargetType.GetUnqualifiedType()
- #warn('PTR: %s' % nativeTargetType.name)
+ #DumperBase.warn('PTR: %s' % nativeTargetType.name)
return self.createPointerType(self.fromNativeType(nativeTargetType))
if code == lldb.eTypeClassReference:
- #warn('REF')
+ #DumperBase.warn('REF')
nativeTargetType = nativeType.GetDereferencedType()
if not nativeTargetType.IsPointerType():
nativeTargetType = nativeTargetType.GetUnqualifiedType()
- #warn('REF: %s' % nativeTargetType.name)
+ #DumperBase.warn('REF: %s' % nativeTargetType.name)
return self.createReferenceType(self.fromNativeType(nativeTargetType))
if code == lldb.eTypeClassTypedef:
- #warn('TYPEDEF')
+ #DumperBase.warn('TYPEDEF')
nativeTargetType = nativeType.GetUnqualifiedType()
if hasattr(nativeTargetType, 'GetCanonicalType'):
nativeTargetType = nativeTargetType.GetCanonicalType()
@@ -395,12 +397,12 @@ class Dumper(DumperBase):
typeName = self.typeName(nativeType)
if code in (lldb.eTypeClassArray, lldb.eTypeClassVector):
- #warn('ARRAY: %s' % nativeType.GetName())
+ #DumperBase.warn('ARRAY: %s' % nativeType.GetName())
if hasattr(nativeType, 'GetArrayElementType'): # New in 3.8(?) / 350.x
nativeTargetType = nativeType.GetArrayElementType()
if not nativeTargetType.IsValid():
if hasattr(nativeType, 'GetVectorElementType'): # New in 3.8(?) / 350.x
- #warn('BAD: %s ' % nativeTargetType.get_fields_array())
+ #DumperBase.warn('BAD: %s ' % nativeTargetType.get_fields_array())
nativeTargetType = nativeType.GetVectorElementType()
count = nativeType.GetByteSize() // nativeTargetType.GetByteSize()
targetTypeName = nativeTargetType.GetName()
@@ -408,7 +410,7 @@ class Dumper(DumperBase):
typeName = nativeType.GetName()
pos1 = typeName.rfind('[')
targetTypeName = typeName[0:pos1].strip()
- #warn("TARGET TYPENAME: %s" % targetTypeName)
+ #DumperBase.warn("TARGET TYPENAME: %s" % targetTypeName)
targetType = self.fromNativeType(nativeTargetType)
tdata = targetType.typeData().copy()
tdata.name = targetTypeName
@@ -431,33 +433,33 @@ class Dumper(DumperBase):
tdata.name = typeName
tdata.lbitsize = nativeType.GetByteSize() * 8
if code == lldb.eTypeClassBuiltin:
- if isFloatingPointTypeName(typeName):
- tdata.code = TypeCodeFloat
- elif isIntegralTypeName(typeName):
- tdata.code = TypeCodeIntegral
+ if utils.isFloatingPointTypeName(typeName):
+ tdata.code = TypeCode.TypeCodeFloat
+ elif utils.isIntegralTypeName(typeName):
+ tdata.code = TypeCode.TypeCodeIntegral
elif typeName in ('__int128', 'unsigned __int128'):
- tdata.code = TypeCodeIntegral
+ tdata.code = TypeCode.TypeCodeIntegral
elif typeName == 'void':
- tdata.code = TypeCodeVoid
+ tdata.code = TypeCode.TypeCodeVoid
else:
- warn('UNKNOWN TYPE KEY: %s: %s' % (typeName, code))
+ self.warn('UNKNOWN TYPE KEY: %s: %s' % (typeName, code))
elif code == lldb.eTypeClassEnumeration:
- tdata.code = TypeCodeEnum
+ tdata.code = TypeCode.TypeCodeEnum
tdata.enumDisplay = lambda intval, addr, form : \
self.nativeTypeEnumDisplay(nativeType, intval, form)
elif code in (lldb.eTypeClassComplexInteger, lldb.eTypeClassComplexFloat):
- tdata.code = TypeCodeComplex
+ tdata.code = TypeCode.TypeCodeComplex
elif code in (lldb.eTypeClassClass, lldb.eTypeClassStruct, lldb.eTypeClassUnion):
- tdata.code = TypeCodeStruct
+ tdata.code = TypeCode.TypeCodeStruct
tdata.lalignment = lambda : \
self.nativeStructAlignment(nativeType)
tdata.lfields = lambda value : \
self.listMembers(value, nativeType)
tdata.templateArguments = self.listTemplateParametersHelper(nativeType)
elif code == lldb.eTypeClassFunction:
- tdata.code = TypeCodeFunction
+ tdata.code = TypeCode.TypeCodeFunction
elif code == lldb.eTypeClassMemberPointer:
- tdata.code = TypeCodeMemberPointer
+ tdata.code = TypeCode.TypeCodeMemberPointer
self.registerType(typeId, tdata) # Fix up fields and template args
# warn('CREATE TYPE: %s' % typeId)
@@ -491,12 +493,12 @@ class Dumper(DumperBase):
targs.append(self.fromNativeType(innerType))
#elif kind == lldb.eTemplateArgumentKindIntegral:
# innerType = nativeType.GetTemplateArgumentType(i).GetUnqualifiedType().GetCanonicalType()
- # #warn('INNER TYP: %s' % innerType)
+ # #DumperBase.warn('INNER TYP: %s' % innerType)
# basicType = innerType.GetBasicType()
- # #warn('IBASIC TYP: %s' % basicType)
+ # #DumperBase.warn('IBASIC TYP: %s' % basicType)
# inner = self.extractTemplateArgument(nativeType.GetName(), i)
# exp = '(%s)%s' % (innerType.GetName(), inner)
- # #warn('EXP : %s' % exp)
+ # #DumperBase.warn('EXP : %s' % exp)
# val = self.nativeParseAndEvaluate('(%s)%s' % (innerType.GetName(), inner))
# # Clang writes 'int' and '0xfffffff' into the debug info
# # LLDB manages to read a value of 0xfffffff...
@@ -504,12 +506,12 @@ class Dumper(DumperBase):
# value = val.GetValueAsUnsigned()
# if value >= 0x8000000:
# value -= 0x100000000
- # #warn('KIND: %s' % kind)
+ # #DumperBase.warn('KIND: %s' % kind)
# targs.append(value)
else:
- #warn('UNHANDLED TEMPLATE TYPE : %s' % kind)
+ #DumperBase.warn('UNHANDLED TEMPLATE TYPE : %s' % kind)
targs.append(stringArgs[i]) # Best we can do.
- #warn('TARGS: %s %s' % (nativeType.GetName(), [str(x) for x in targs]))
+ #DumperBase.warn('TARGS: %s %s' % (nativeType.GetName(), [str(x) for x in targs]))
return targs
def typeName(self, nativeType):
@@ -529,7 +531,7 @@ class Dumper(DumperBase):
return name
fields = nativeType.get_fields_array()
typeId = c + ''.join(['{%s:%s}' % (f.name, self.nativeTypeId(f.GetType())) for f in fields])
- #warn('NATIVE TYPE ID FOR %s IS %s' % (name, typeId))
+ #DumperBase.warn('NATIVE TYPE ID FOR %s IS %s' % (name, typeId))
return typeId
def nativeTypeEnumDisplay(self, nativeType, intval, form):
@@ -614,12 +616,12 @@ class Dumper(DumperBase):
def callHelper(self, rettype, value, func, args):
# args is a tuple.
arg = ','.join(args)
- #warn('PRECALL: %s -> %s(%s)' % (value.address(), func, arg))
+ #DumperBase.warn('PRECALL: %s -> %s(%s)' % (value.address(), func, arg))
typename = value.type.name
exp = '((%s*)0x%x)->%s(%s)' % (typename, value.address(), func, arg)
- #warn('CALL: %s' % exp)
+ #DumperBase.warn('CALL: %s' % exp)
result = self.currentContextValue.CreateValueFromExpression('', exp)
- #warn(' -> %s' % result)
+ #DumperBase.warn(' -> %s' % result)
return self.fromNativeValue(result)
def pokeValue(self, typeName, *args):
@@ -627,9 +629,9 @@ class Dumper(DumperBase):
frame = thread.GetFrameAtIndex(0)
inner = ','.join(args)
value = frame.EvaluateExpression(typeName + '{' + inner + '}')
- #self.warn(' TYPE: %s' % value.type)
- #self.warn(' ADDR: 0x%x' % value.address)
- #self.warn(' VALUE: %s' % value)
+ #DumperBase.warn(' TYPE: %s' % value.type)
+ #DumperBase.warn(' ADDR: 0x%x' % value.address)
+ #DumperBase.warn(' VALUE: %s' % value)
return value
def nativeParseAndEvaluate(self, exp):
@@ -640,10 +642,10 @@ class Dumper(DumperBase):
#val = self.target.EvaluateExpression(exp, options)
err = val.GetError()
if err.Fail():
- #warn('FAILING TO EVAL: %s' % exp)
+ #DumperBase.warn('FAILING TO EVAL: %s' % exp)
return None
- #warn('NO ERROR.')
- #warn('EVAL: %s -> %s' % (exp, val.IsValid()))
+ #DumperBase.warn('NO ERROR.')
+ #DumperBase.warn('EVAL: %s -> %s' % (exp, val.IsValid()))
return val
def parseAndEvaluate(self, exp):
@@ -749,14 +751,14 @@ class Dumper(DumperBase):
return re.sub('^(struct|class|union|enum|typedef) ', '', name)
def lookupNativeType(self, name):
- #warn('LOOKUP TYPE NAME: %s' % name)
+ #DumperBase.warn('LOOKUP TYPE NAME: %s' % name)
typeobj = self.typeCache.get(name)
if not typeobj is None:
- #warn('CACHED: %s' % name)
+ #DumperBase.warn('CACHED: %s' % name)
return typeobj
typeobj = self.target.FindFirstType(name)
if typeobj.IsValid():
- #warn('VALID FIRST : %s' % typeobj)
+ #DumperBase.warn('VALID FIRST : %s' % typeobj)
self.typeCache[name] = typeobj
return typeobj
@@ -773,16 +775,16 @@ class Dumper(DumperBase):
for typeobj in typeobjlist:
n = self.canonicalTypeName(self.removeTypePrefix(typeobj.GetDisplayTypeName()))
if n == nonPrefixedName:
- #warn('FOUND TYPE USING FindTypes : %s' % typeobj)
+ #DumperBase.warn('FOUND TYPE USING FindTypes : %s' % typeobj)
self.typeCache[name] = typeobj
return typeobj
if name.endswith('*'):
- #warn('RECURSE PTR')
+ #DumperBase.warn('RECURSE PTR')
typeobj = self.lookupNativeType(name[:-1].strip())
if typeobj is not None:
- #warn('RECURSE RESULT X: %s' % typeobj)
+ #DumperBase.warn('RECURSE RESULT X: %s' % typeobj)
self.fromNativeType(typeobj.GetPointerType())
- #warn('RECURSE RESULT: %s' % typeobj.GetPointerType())
+ #DumperBase.warn('RECURSE RESULT: %s' % typeobj.GetPointerType())
return typeobj.GetPointerType()
#typeobj = self.target.FindFirstType(name[:-1].strip())
@@ -791,13 +793,13 @@ class Dumper(DumperBase):
# return typeobj.GetPointerType()
if name.endswith(' const'):
- #warn('LOOKUP END CONST')
+ #DumperBase.warn('LOOKUP END CONST')
typeobj = self.lookupNativeType(name[:-6])
if typeobj is not None:
return typeobj
if name.startswith('const '):
- #warn('LOOKUP START CONST')
+ #DumperBase.warn('LOOKUP START CONST')
typeobj = self.lookupNativeType(name[6:])
if typeobj is not None:
return typeobj
@@ -806,17 +808,17 @@ class Dumper(DumperBase):
def lookupNativeTypeInAllModules(self, name):
needle = self.canonicalTypeName(name)
- #warn('NEEDLE: %s ' % needle)
- warn('Searching for type %s across all target modules, this could be very slow' % name)
+ #DumperBase.warn('NEEDLE: %s ' % needle)
+ self.warn('Searching for type %s across all target modules, this could be very slow' % name)
for i in xrange(self.target.GetNumModules()):
module = self.target.GetModuleAtIndex(i)
# SBModule.GetType is new somewhere after early 300.x
# So this may fail.
for t in module.GetTypes():
n = self.canonicalTypeName(t.GetName())
- #warn('N: %s' % n)
+ #DumperBase.warn('N: %s' % n)
if n == needle:
- #warn('FOUND TYPE DIRECT 2: %s ' % t)
+ #DumperBase.warn('FOUND TYPE DIRECT 2: %s ' % t)
self.typeCache[name] = t
return t
if n == needle + '*':
@@ -824,16 +826,16 @@ class Dumper(DumperBase):
self.typeCache[name] = res
x = self.fromNativeType(res) # Register under both names
self.registerTypeAlias(x.typeId, name)
- #warn('FOUND TYPE BY POINTER: %s ' % res.name)
+ #DumperBase.warn('FOUND TYPE BY POINTER: %s ' % res.name)
return res
if n == needle + '&':
res = t.GetDereferencedType().GetUnqualifiedType()
self.typeCache[name] = res
x = self.fromNativeType(res) # Register under both names
self.registerTypeAlias(x.typeId, name)
- #warn('FOUND TYPE BY REFERENCE: %s ' % res.name)
+ #DumperBase.warn('FOUND TYPE BY REFERENCE: %s ' % res.name)
return res
- #warn('NOT FOUND: %s ' % needle)
+ #DumperBase.warn('NOT FOUND: %s ' % needle)
return None
def setupInferior(self, args):
@@ -861,7 +863,7 @@ class Dumper(DumperBase):
self.ignoreStops = 0
if platform.system() == 'Linux':
- if self.startMode_ == AttachCore:
+ if self.startMode_ == DebuggerStartMode.AttachCore:
pass
else:
if self.useTerminal_:
@@ -911,7 +913,8 @@ class Dumper(DumperBase):
self.reportState('enginerunandinferiorstopok')
else:
self.reportState('enginerunandinferiorrunok')
- elif self.startMode_ == AttachToRemoteServer or self.startMode_ == AttachToRemoteProcess:
+ elif (self.startMode_ == DebuggerStartMode.AttachToRemoteServer
+ or self.startMode_ == DebuggerStartMode.AttachToRemoteProcess):
self.process = self.target.ConnectRemote(
self.debugger.GetListener(),
self.remoteChannel_, None, error)
@@ -923,7 +926,7 @@ class Dumper(DumperBase):
# and later detects that it did stop after all, so it is be
# better to mirror that and wait for the spontaneous stop.
self.reportState('enginerunandinferiorrunok')
- elif self.startMode_ == AttachCore:
+ elif self.startMode_ == DebuggerStartMode.AttachCore:
coreFile = args.get('coreFile', '');
self.process = self.target.LoadCore(coreFile)
if self.process.IsValid():
@@ -1124,7 +1127,7 @@ class Dumper(DumperBase):
if size == 0:
return bytes()
error = lldb.SBError()
- #warn("READ: %s %s" % (address, size))
+ #DumperBase.warn("READ: %s %s" % (address, size))
res = self.process.ReadMemory(address, size, error)
if res is None or len(res) != size:
# Using code in e.g. readToFirstZero relies on exceptions.
@@ -1307,12 +1310,12 @@ class Dumper(DumperBase):
self.handleBreakpointEvent(event)
return
if not lldb.SBProcess.EventIsProcessEvent(event):
- warn("UNEXPECTED event (%s)" % event.GetType())
+ self.warn("UNEXPECTED event (%s)" % event.GetType())
return
out = lldb.SBStream()
event.GetDescription(out)
- #warn("EVENT: %s" % event)
+ #DumperBase.warn("EVENT: %s" % event)
eventType = event.GetType()
msg = lldb.SBEvent.GetCStringFromEvent(event)
flavor = event.GetDataFlavor()
@@ -1430,7 +1433,7 @@ class Dumper(DumperBase):
def insertBreakpoint(self, args):
bpType = args['type']
- if bpType == BreakpointByFileAndLine:
+ if bpType == BreakpointType.BreakpointByFileAndLine:
fileName = args['file']
if fileName.endswith('.js') or fileName.endswith('.qml'):
self.insertInterpreterBreakpoint(args)
@@ -1438,28 +1441,28 @@ class Dumper(DumperBase):
extra = ''
more = True
- if bpType == BreakpointByFileAndLine:
+ if bpType == BreakpointType.BreakpointByFileAndLine:
bp = self.target.BreakpointCreateByLocation(
str(args['file']), int(args['line']))
- elif bpType == BreakpointByFunction:
+ elif bpType == BreakpointType.BreakpointByFunction:
bp = self.target.BreakpointCreateByName(args['function'])
- elif bpType == BreakpointByAddress:
+ elif bpType == BreakpointType.BreakpointByAddress:
bp = self.target.BreakpointCreateByAddress(args['address'])
- elif bpType == BreakpointAtMain:
+ elif bpType == BreakpointType.BreakpointAtMain:
bp = self.createBreakpointAtMain()
- elif bpType == BreakpointAtThrow:
+ elif bpType == BreakpointType.BreakpointAtThrow:
bp = self.target.BreakpointCreateForException(
lldb.eLanguageTypeC_plus_plus, False, True)
- elif bpType == BreakpointAtCatch:
+ elif bpType == BreakpointType.BreakpointAtCatch:
bp = self.target.BreakpointCreateForException(
lldb.eLanguageTypeC_plus_plus, True, False)
- elif bpType == WatchpointAtAddress:
+ elif bpType == BreakpointType.WatchpointAtAddress:
error = lldb.SBError()
# This might yield bp.IsValid() == False and
# error.desc == 'process is not alive'.
bp = self.target.WatchAddress(args['address'], 4, False, True, error)
extra = self.describeError(error)
- elif bpType == WatchpointAtExpression:
+ elif bpType == BreakpointType.WatchpointAtExpression:
# FIXME: Top level-only for now.
try:
frame = self.currentFrame()
@@ -1702,7 +1705,7 @@ class Dumper(DumperBase):
else:
base = args.get('address', 0)
if int(base) == 0xffffffffffffffff:
- warn('INVALID DISASSEMBLER BASE')
+ self.warn('INVALID DISASSEMBLER BASE')
return
addr = lldb.SBAddress(base, self.target)
instructions = self.target.ReadInstructions(addr, 100)
@@ -1736,7 +1739,7 @@ class Dumper(DumperBase):
# With lldb-3.8 files like /data/dev/creator-3.6/tests/
# auto/debugger/qt_tst_dumpers_StdVector_bfNWZa/main.cpp
# with non-existent directories appear.
- warn('FILE: %s ERROR: %s' % (fileName, error))
+ self.warn('FILE: %s ERROR: %s' % (fileName, error))
source = ''
result += '{line="%s"' % lineNumber
result += ',file="%s"' % fileName
@@ -1836,7 +1839,7 @@ class Tester(Dumper):
self.target = self.debugger.CreateTarget(binary, None, None, True, error)
if error.GetType():
- warn('ERROR: %s' % error)
+ self.warn('ERROR: %s' % error)
return
s = threading.Thread(target=self.testLoop, args=(args,))
@@ -1856,14 +1859,14 @@ class Tester(Dumper):
self.process = self.target.Launch(launchInfo, error)
if error.GetType():
- warn('ERROR: %s' % error)
+ self.warn('ERROR: %s' % error)
event = lldb.SBEvent()
listener = self.debugger.GetListener()
while True:
state = self.process.GetState()
if listener.WaitForEvent(100, event):
- #warn('EVENT: %s' % event)
+ #DumperBase.warn('EVENT: %s' % event)
state = lldb.SBProcess.GetStateFromEvent(event)
if state == lldb.eStateExited: # 10
break
@@ -1872,7 +1875,7 @@ class Tester(Dumper):
for i in xrange(0, self.process.GetNumThreads()):
thread = self.process.GetThreadAtIndex(i)
reason = thread.GetStopReason()
- #warn('THREAD: %s REASON: %s' % (thread, reason))
+ #DumperBase.warn('THREAD: %s REASON: %s' % (thread, reason))
if (reason == lldb.eStopReasonBreakpoint or
reason == lldb.eStopReasonException or
reason == lldb.eStopReasonSignal):
@@ -1894,8 +1897,8 @@ class Tester(Dumper):
break
else:
- warn('TIMEOUT')
- warn('Cannot determined stopped thread')
+ self.warn('TIMEOUT')
+ self.warn('Cannot determined stopped thread')
lldb.SBDebugger.Destroy(self.debugger)
@@ -1981,7 +1984,7 @@ class SummaryDumper(Dumper, LogMixin):
return # Don't mess up lldb output
def lookupNativeTypeInAllModules(self, name):
- warn('Failed to resolve type %s' % name)
+ self.warn('Failed to resolve type %s' % name)
return None
def dump_summary(self, valobj, expanded = False):
diff --git a/share/qtcreator/debugger/misctypes.py b/share/qtcreator/debugger/misctypes.py
index 72e42e45101..a1343eb9dc8 100644
--- a/share/qtcreator/debugger/misctypes.py
+++ b/share/qtcreator/debugger/misctypes.py
@@ -23,7 +23,8 @@
#
############################################################################
-from dumper import *
+from dumper import Children, SubItem
+from utils import TypeCode, DisplayFormat
import re
#######################################################################
@@ -100,7 +101,7 @@ def qdump____m512i(d, value):
#######################################################################
def qform__std__array():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__gsl__span(d, value):
size, pointer = value.split('pp')
@@ -186,7 +187,7 @@ def qdump__NimStringDesc(d, value):
def qdump__NimGenericSequence__(d, value, regex = '^TY[\d]+$'):
code = value.type.stripTypedefs().code
- if code == TypeCodeStruct:
+ if code == TypeCode.TypeCodeStruct:
size, reserved = d.split('pp', value)
data = value.address() + 2 * d.ptrSize()
typeobj = value['data'].type.dereference()
@@ -322,7 +323,7 @@ def qdump__KDSoapValue1(d, value):
d.putPlainChildren(inner)
def qdump__KDSoapValue(d, value):
- p = (value.cast(lookupType('char*')) + 4).dereference().cast(lookupType('QString'))
+ p = (value.cast(d.lookupType('char*')) + 4).dereference().cast(d.lookupType('QString'))
d.putStringValue(p)
d.putPlainChildren(value['d']['d'].dereference())
diff --git a/share/qtcreator/debugger/opencvtypes.py b/share/qtcreator/debugger/opencvtypes.py
index 2e58637b383..7a62af7041f 100644
--- a/share/qtcreator/debugger/opencvtypes.py
+++ b/share/qtcreator/debugger/opencvtypes.py
@@ -23,14 +23,15 @@
#
############################################################################
-from dumper import *
+from dumper import Children, SubItem
+from utils import TypeCode, DisplayFormat
def qdump__cv__Size_(d, value):
d.putValue('(%s, %s)' % (value[0].display(), value[1].display()))
d.putPlainChildren(value)
def qform__cv__Mat():
- return [SeparateFormat]
+ return [DisplayFormat.SeparateFormat]
def qdump__cv__Mat(d, value):
(flag, dims, rows, cols, data, refcount, datastart, dataend,
@@ -43,7 +44,7 @@ def qdump__cv__Mat(d, value):
d.putPlainChildren(value)
return
- if d.currentItemFormat() == SeparateFormat:
+ if d.currentItemFormat() == DisplayFormat.SeparateFormat:
rs = steps[0] * innerSize
cs = cols * innerSize
dform = 'arraydata:separate:int:%d::2:%d:%d' % (innerSize, cols, rows)
@@ -53,7 +54,7 @@ def qdump__cv__Mat(d, value):
d.putValue('(%s x %s)' % (rows, cols))
if d.isExpanded():
with Children(d):
- innerType = d.createType(TypeCodeIntegral, innerSize)
+ innerType = d.createType(TypeCode.TypeCodeIntegral, innerSize)
for i in range(rows):
for j in range(cols):
with SubItem(d, None):
diff --git a/share/qtcreator/debugger/pdbbridge.py b/share/qtcreator/debugger/pdbbridge.py
index 4f3a0fcd3bf..4c77d41ce5b 100644
--- a/share/qtcreator/debugger/pdbbridge.py
+++ b/share/qtcreator/debugger/pdbbridge.py
@@ -1552,10 +1552,10 @@ class QtcInternalDumper:
self.put('name="%s",' % name)
def isExpanded(self, iname):
- # self.warn('IS EXPANDED: %s in %s' % (iname, self.expandedINames))
+ # DumperBase.warn('IS EXPANDED: %s in %s' % (iname, self.expandedINames))
if iname.startswith('None'):
raise "Illegal iname '%s'" % iname
- # self.warn(' --> %s' % (iname in self.expandedINames))
+ # DumperBase.warn(' --> %s' % (iname in self.expandedINames))
return iname in self.expandedINames
def isExpandedIName(self, iname):
diff --git a/share/qtcreator/debugger/personaltypes.py b/share/qtcreator/debugger/personaltypes.py
index b4d34db10c8..7f82cc57dfb 100644
--- a/share/qtcreator/debugger/personaltypes.py
+++ b/share/qtcreator/debugger/personaltypes.py
@@ -56,6 +56,6 @@
# for more details or look at qttypes.py, stdtypes.py, boosttypes.py
# for more complex examples.
-from dumper import *
+import dumper
######################## Your code below #######################
diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py
index 65b0828cdb9..705a0051c22 100644
--- a/share/qtcreator/debugger/qttypes.py
+++ b/share/qtcreator/debugger/qttypes.py
@@ -25,8 +25,8 @@
import platform
import re
-from dumper import *
-
+from dumper import Children, SubItem, UnnamedSubItem, toInteger
+from utils import DisplayFormat
def qdump__QAtomicInt(d, value):
d.putValue(value.integer())
@@ -44,8 +44,8 @@ def qdump__QAtomicPointer(d, value):
def qform__QByteArray():
- return [Latin1StringFormat, SeparateLatin1StringFormat,
- Utf8StringFormat, SeparateUtf8StringFormat ]
+ return [DisplayFormat.Latin1StringFormat, DisplayFormat.SeparateLatin1StringFormat,
+ DisplayFormat.Utf8StringFormat, DisplayFormat.SeparateUtf8StringFormat ]
def qedit__QByteArray(d, value, data):
d.call('void', value, 'resize', str(len(data)))
@@ -58,14 +58,14 @@ def qdump__QByteArray(d, value):
d.putNumChild(size)
elided, p = d.encodeByteArrayHelper(d.extractPointer(value), d.displayStringLimit)
displayFormat = d.currentItemFormat()
- if displayFormat == AutomaticFormat or displayFormat == Latin1StringFormat:
+ if displayFormat == DisplayFormat.AutomaticFormat or displayFormat == DisplayFormat.Latin1StringFormat:
d.putValue(p, 'latin1', elided=elided)
- elif displayFormat == SeparateLatin1StringFormat:
+ elif displayFormat == DisplayFormat.SeparateLatin1StringFormat:
d.putValue(p, 'latin1', elided=elided)
d.putDisplay('latin1:separate', d.encodeByteArray(value, limit=100000))
- elif displayFormat == Utf8StringFormat:
+ elif displayFormat == DisplayFormat.Utf8StringFormat:
d.putValue(p, 'utf8', elided=elided)
- elif displayFormat == SeparateUtf8StringFormat:
+ elif displayFormat == DisplayFormat.SeparateUtf8StringFormat:
d.putValue(p, 'utf8', elided=elided)
d.putDisplay('utf8:separate', d.encodeByteArray(value, limit=100000))
if d.isExpanded():
@@ -103,11 +103,11 @@ def qdump__QChar(d, value):
def qform_X_QAbstractItemModel():
- return [SimpleFormat, EnhancedFormat]
+ return [DisplayFormat.SimpleFormat, DisplayFormat.EnhancedFormat]
def qdump_X_QAbstractItemModel(d, value):
displayFormat = d.currentItemFormat()
- if displayFormat == SimpleFormat:
+ if displayFormat == DisplayFormat.SimpleFormat:
d.putPlainChildren(value)
return
#displayFormat == EnhancedFormat:
@@ -137,11 +137,11 @@ def qdump_X_QAbstractItemModel(d, value):
#gdb.execute('call free($ri)')
def qform_X_QModelIndex():
- return [SimpleFormat, EnhancedFormat]
+ return [DisplayFormat.SimpleFormat, DisplayFormat.EnhancedFormat]
def qdump_X_QModelIndex(d, value):
displayFormat = d.currentItemFormat()
- if displayFormat == SimpleFormat:
+ if displayFormat == DisplayFormat.SimpleFormat:
d.putPlainChildren(value)
return
r = value['r']
@@ -306,12 +306,12 @@ def qdump__QDateTime(d, value):
is32bit = d.ptrSize() == 4
if qtVersion >= 0x050200:
tiVersion = d.qtTypeInfoVersion()
- #warn('TI VERSION: %s' % tiVersion)
+ #DumperBase.warn('TI VERSION: %s' % tiVersion)
if tiVersion is None:
tiVersion = 4
if tiVersion > 10:
status = d.extractByte(value)
- #warn('STATUS: %s' % status)
+ #DumperBase.warn('STATUS: %s' % status)
if status & 0x01:
# Short data
msecs = d.extractUInt64(value) >> 8
@@ -757,7 +757,7 @@ def qdump__QFixed(d, value):
def qform__QFiniteStack():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__QFiniteStack(d, value):
array, alloc, size = value.split('pii')
@@ -775,7 +775,7 @@ def qdump__QFlags(d, value):
def qform__QHash():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__QHash(d, value):
qdumpHelper_QHash(d, value, value.type[0], value.type[1])
@@ -835,7 +835,7 @@ def qdumpHelper_QHash(d, value, keyType, valueType):
def qform__QHashNode():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__QHashNode(d, value):
d.putPairItem(None, value)
@@ -872,7 +872,7 @@ def qdump__QHostAddress(d, value):
dd = d.extractPointer(value)
qtVersion = d.qtVersion()
tiVersion = d.qtTypeInfoVersion()
- #warn('QT: %x, TI: %s' % (qtVersion, tiVersion))
+ #DumperBase.warn('QT: %x, TI: %s' % (qtVersion, tiVersion))
mayNeedParse = True
if tiVersion is not None:
if tiVersion >= 16:
@@ -942,7 +942,7 @@ def qdump__QIPv6Address(d, value):
d.putArrayData(value.address(), 16, d.lookupType('unsigned char'))
def qform__QList():
- return [DirectQListStorageFormat, IndirectQListStorageFormat]
+ return [DisplayFormat.DirectQListStorageFormat, DisplayFormat.IndirectQListStorageFormat]
def qdump__QList(d, value):
return qdumpHelper_QList(d, value, value.type[0])
@@ -972,9 +972,9 @@ def qdumpHelper_QList(d, value, innerType):
# in the frontend.
# So as first approximation only do the 'isLarge' check:
displayFormat = d.currentItemFormat()
- if displayFormat == DirectQListStorageFormat:
+ if displayFormat == DisplayFormat.DirectQListStorageFormat:
isInternal = True
- elif displayFormat == IndirectQListStorageFormat:
+ elif displayFormat == DisplayFormat.IndirectQListStorageFormat:
isInternal = False
else:
isInternal = innerSize <= stepSize and innerType.isMovableType()
@@ -995,7 +995,7 @@ def qdumpHelper_QList(d, value, innerType):
d.putSubItem(i, x)
def qform__QImage():
- return [SimpleFormat, SeparateFormat]
+ return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat]
def qdump__QImage(d, value):
if d.qtVersion() < 0x050000:
@@ -1024,7 +1024,7 @@ def qdump__QImage(d, value):
d.putType('void *')
displayFormat = d.currentItemFormat()
- if displayFormat == SeparateFormat:
+ if displayFormat == DisplayFormat.SeparateFormat:
d.putDisplay('imagedata:separate', '%08x%08x%08x%08x' % (width, height, nbytes, iformat)
+ d.readMemory(bits, nbytes))
@@ -1167,7 +1167,7 @@ def qdumpHelper_Qt5_QMap(d, value, keyType, valueType):
def qform__QMap():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__QMap(d, value):
qdumpHelper_QMap(d, value, value.type[0], value.type[1])
@@ -1179,13 +1179,13 @@ def qdumpHelper_QMap(d, value, keyType, valueType):
qdumpHelper_Qt5_QMap(d, value, keyType, valueType)
def qform__QMultiMap():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__QMultiMap(d, value):
qdump__QMap(d, value)
def qform__QVariantMap():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__QVariantMap(d, value):
qdumpHelper_QMap(d, value, d.createType('QString'), d.createType('QVariant'))
@@ -1458,7 +1458,7 @@ def qdump__QSizePolicy(d, value):
def qform__QStack():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__QStack(d, value):
qdump__QVector(d, value)
@@ -1492,14 +1492,14 @@ def qedit__QString(d, value, data):
d.setValues(base, 'short', [ord(c) for c in data])
def qform__QString():
- return [SimpleFormat, SeparateFormat]
+ return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat]
def qdump__QString(d, value):
d.putStringValue(value)
(data, size, alloc) = d.stringData(value)
d.putNumChild(size)
displayFormat = d.currentItemFormat()
- if displayFormat == SeparateFormat:
+ if displayFormat == DisplayFormat.SeparateFormat:
d.putDisplay('utf16:separate', d.encodeString(value, limit=100000))
if d.isExpanded():
d.putArrayData(data, size, d.createType('QChar'))
@@ -1596,7 +1596,7 @@ def qdump__QTextDocument(d, value):
def qform__QUrl():
- return [SimpleFormat, SeparateFormat]
+ return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat]
def qdump__QUrl(d, value):
privAddress = d.extractPointer(value)
@@ -1637,7 +1637,7 @@ def qdump__QUrl(d, value):
d.putValue(url, 'utf16')
displayFormat = d.currentItemFormat()
- if displayFormat == SeparateFormat:
+ if displayFormat == DisplayFormat.SeparateFormat:
d.putDisplay('utf16:separate', url)
d.putNumChild(1)
@@ -1851,7 +1851,7 @@ def qdump__QVariant(d, value):
d.putNumChild(0)
return None
- #warn('TYPE: %s' % variantType)
+ #DumperBase.warn('TYPE: %s' % variantType)
if variantType <= 86:
# Known Core or Gui type.
@@ -1867,15 +1867,15 @@ def qdump__QVariant(d, value):
#data = value['d']['data']
innerType = d.qtNamespace() + innert
- #warn('SHARED: %s' % isShared)
+ #DumperBase.warn('SHARED: %s' % isShared)
if isShared:
base1 = d.extractPointer(value)
- #warn('BASE 1: %s %s' % (base1, innert))
+ #DumperBase.warn('BASE 1: %s %s' % (base1, innert))
base = d.extractPointer(base1)
- #warn('SIZE 1: %s' % size)
+ #DumperBase.warn('SIZE 1: %s' % size)
val = d.createValue(base, innerType)
else:
- #warn('DIRECT ITEM 1: %s' % innerType)
+ #DumperBase.warn('DIRECT ITEM 1: %s' % innerType)
val = d.createValue(data, innerType)
val.laddress = value.laddress
@@ -1939,7 +1939,7 @@ def qedit__QVector(d, value, data):
def qform__QVector():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__QVector(d, value):
@@ -2053,17 +2053,17 @@ def qdump__QXmlStreamAttribute(d, value):
#######################################################################
def extractQmlData(d, value):
- #if value.type.code == TypeCodePointer:
+ #if value.type.code == TypeCode.TypeCodePointer:
# value = value.dereference()
base = value.split('p')[0]
#mmdata = d.split('Q', base)[0]
#PointerMask = 0xfffffffffffffffd
#vtable = mmdata & PointerMask
- #warn('QML DATA: %s' % value.stringify())
+ #DumperBase.warn('QML DATA: %s' % value.stringify())
#data = value['data']
#return #data.cast(d.lookupType(value.type.name.replace('QV4::', 'QV4::Heap::')))
typeName = value.type.name.replace('QV4::', 'QV4::Heap::')
- #warn('TYOE DATA: %s' % typeName)
+ #DumperBase.warn('TYOE DATA: %s' % typeName)
return d.createValue(base, typeName)
def qdump__QV4__Heap__Base(d, value):
@@ -2236,7 +2236,7 @@ def QV4_valueForData(d, jsval): # (Dumper, QJSValue *jsval) -> QV4::Value *
v = QV4_getValue(d, jsval)
if v:
return v
- warn('Not implemented: VARIANT')
+ d.warn('Not implemented: VARIANT')
return 0
def QV4_putObjectValue(d, objectPtr):
@@ -2424,7 +2424,7 @@ def qdump_64__QV4__Value(d, value):
d.putBetterType('%sQV4::Value (object)' % ns)
#QV4_putObjectValue(d, d.extractPointer(value) + 2 * d.ptrSize())
arrayVTable = d.symbolAddress(ns + 'QV4::ArrayObject::static_vtbl')
- #warn('ARRAY VTABLE: 0x%x' % arrayVTable)
+ #DumperBase.warn('ARRAY VTABLE: 0x%x' % arrayVTable)
d.putNumChild(1)
d.putItem(d.createValue(d.extractPointer(value) + 2 * d.ptrSize(), ns + 'QV4::Object'))
return
@@ -2630,7 +2630,7 @@ def qdump__QScriptValue(d, value):
payload = x['asBits']['payload']
#isValid = int(x['asBits']['tag']) != -6 # Empty
#isCell = int(x['asBits']['tag']) == -2
- #warn('IS CELL: %s ' % isCell)
+ #DumperBase.warn('IS CELL: %s ' % isCell)
#isObject = False
#className = 'UNKNOWN NAME'
#if isCell:
@@ -2648,7 +2648,7 @@ def qdump__QScriptValue(d, value):
# type = cell['m_structure']['m_typeInfo']['m_type']
# isObject = int(type) == 7 # ObjectType;
# className = 'UNKNOWN NAME'
- #warn('IS OBJECT: %s ' % isObject)
+ #DumperBase.warn('IS OBJECT: %s ' % isObject)
#inline bool JSCell::inherits(const ClassInfo* info) const
#for (const ClassInfo* ci = classInfo(); ci; ci = ci->parentClass) {
diff --git a/share/qtcreator/debugger/stdtypes.py b/share/qtcreator/debugger/stdtypes.py
index 56890487b11..83201e42e83 100644
--- a/share/qtcreator/debugger/stdtypes.py
+++ b/share/qtcreator/debugger/stdtypes.py
@@ -23,10 +23,11 @@
#
############################################################################
-from dumper import *
+from utils import DisplayFormat
+from dumper import Children, SubItem
def qform__std__array():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__std__array(d, value):
size = value.type[1]
@@ -36,7 +37,7 @@ def qdump__std__array(d, value):
def qform__std____1__array():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__std____1__array(d, value):
qdump__std__array(d, value)
@@ -260,7 +261,7 @@ def qdump__std____1__list(d, value):
d.putSubItem(i, val)
def qform__std__map():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__std__map(d, value):
if d.isQnxTarget() or d.isMsvcTarget():
@@ -334,7 +335,7 @@ def qdump__std____cxx1998__map(d, value):
qdump__std__map(d, value)
def qform__std__multimap():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__std__multimap(d, value):
return qdump__std__map(d, value)
@@ -537,7 +538,7 @@ def qdump__std____1__multiset(d, value):
qdump__std____1__set(d, value)
def qform__std____1__map():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__std____1__map(d, value):
try:
@@ -574,7 +575,7 @@ def qdump__std____1__map(d, value):
d.putPairItem(i, pair, 'key', 'value')
def qform__std____1__multimap():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__std____1__multimap(d, value):
qdump__std____1__map(d, value)
@@ -620,8 +621,8 @@ def qdump__std____1__stack(d, value):
d.putBetterType(value.type)
def qform__std__string():
- return [Latin1StringFormat, SeparateLatin1StringFormat,
- Utf8StringFormat, SeparateUtf8StringFormat ]
+ return [DisplayFormat.Latin1StringFormat, DisplayFormat.SeparateLatin1StringFormat,
+ DisplayFormat.Utf8StringFormat, DisplayFormat.SeparateUtf8StringFormat ]
def qdump__std__string(d, value):
qdumpHelper_std__string(d, value, d.createType("char"), d.currentItemFormat())
@@ -760,10 +761,10 @@ def qdump__std__pair(d, value):
d.putValue(value.value, value.encoding)
def qform__std__unordered_map():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qform__std____debug__unordered_map():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__std__unordered_map(d, value):
if d.isQnxTarget() or d.isMsvcTarget():
@@ -861,7 +862,7 @@ def qdump__std__unordered_set(d, value):
p = d.extractPointer(p + offset)
def qform__std____1__unordered_map():
- return mapForms()
+ return [DisplayFormat.CompactMapFormat]
def qdump__std____1__unordered_map(d, value):
(size, _) = value["__table_"]["__p2_"].split("pp")
@@ -916,7 +917,7 @@ def qdump__std____debug__unordered_multiset(d, value):
def qform__std__valarray():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__std__valarray(d, value):
if d.isMsvcTarget():
@@ -928,7 +929,7 @@ def qdump__std__valarray(d, value):
def qform__std____1__valarray():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__std____1__valarray(d, value):
innerType = value.type[0]
@@ -939,7 +940,7 @@ def qdump__std____1__valarray(d, value):
def qform__std__vector():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qedit__std__vector(d, value, data):
import gdb
@@ -1036,13 +1037,13 @@ def qdumpHelper__std__vector__QNX(d, value):
d.putPlotData(start, size, innerType)
def qform__std____1__vector():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__std____1__vector(d, value):
qdumpHelper__std__vector(d, value, True)
def qform__std____debug__vector():
- return arrayForms()
+ return [DisplayFormat.ArrayPlotFormat]
def qdump__std____debug__vector(d, value):
qdump__std__vector(d, value)
@@ -1088,7 +1089,7 @@ def qdump__string(d, value):
qdump__std__string(d, value)
def qform__std__wstring():
- return [SimpleFormat, SeparateFormat]
+ return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat]
def qdump__std__wstring(d, value):
qdumpHelper_std__string(d, value, d.createType('wchar_t'), d.currentItemFormat())
@@ -1131,7 +1132,7 @@ def qdump__std____1__basic_string(d, value):
elif innerType == "wchar_t":
qdump__std____1__wstring(d, value)
else:
- warn("UNKNOWN INNER TYPE %s" % innerType)
+ d.warn("UNKNOWN INNER TYPE %s" % innerType)
def qdump__wstring(d, value):
qdump__std__wstring(d, value)
@@ -1183,7 +1184,7 @@ def qdump__std__byte(d, value):
def qdump__std__optional(d, value):
innerType = value.type[0]
- (initialized, pad, payload) = d.split('b@{%s}' % innerType.name, value)
+ (payload, pad, initialized) = d.split('{%s}@b' % innerType.name, value)
if initialized:
d.putItem(payload)
d.putBetterType(value.type)
diff --git a/share/qtcreator/debugger/utils.py b/share/qtcreator/debugger/utils.py
new file mode 100644
index 00000000000..f67b9311199
--- /dev/null
+++ b/share/qtcreator/debugger/utils.py
@@ -0,0 +1,130 @@
+############################################################################
+#
+# Copyright (C) 2016 The Qt Company Ltd.
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of Qt Creator.
+#
+# Commercial License Usage
+# Licensees holding valid commercial Qt licenses may use this file in
+# accordance with the commercial license agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and The Qt Company. For licensing terms
+# and conditions see https://www.qt.io/terms-conditions. For further
+# information use the contact form at https://www.qt.io/contact-us.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 3 as published by the Free Software
+# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+# included in the packaging of this file. Please review the following
+# information to ensure the GNU General Public License requirements will
+# be met: https://www.gnu.org/licenses/gpl-3.0.html.
+#
+############################################################################
+
+# Debugger start modes. Keep in sync with DebuggerStartMode in debuggerconstants.h
+
+
+class DebuggerStartMode:
+ (
+ NoStartMode,
+ StartInternal,
+ StartExternal,
+ AttachExternal,
+ AttachCrashedExternal,
+ AttachCore,
+ AttachToRemoteServer,
+ AttachToRemoteProcess,
+ StartRemoteProcess,
+ ) = range(0, 9)
+
+
+# Known special formats. Keep in sync with DisplayFormat in debuggerprotocol.h
+class DisplayFormat:
+ (
+ AutomaticFormat,
+ RawFormat,
+ SimpleFormat,
+ EnhancedFormat,
+ SeparateFormat,
+ Latin1StringFormat,
+ SeparateLatin1StringFormat,
+ Utf8StringFormat,
+ SeparateUtf8StringFormat,
+ Local8BitStringFormat,
+ Utf16StringFormat,
+ Ucs4StringFormat,
+ Array10Format,
+ Array100Format,
+ Array1000Format,
+ Array10000Format,
+ ArrayPlotFormat,
+ CompactMapFormat,
+ DirectQListStorageFormat,
+ IndirectQListStorageFormat,
+ ) = range(0, 20)
+
+
+# Breakpoints. Keep synchronized with BreakpointType in breakpoint.h
+class BreakpointType:
+ (
+ UnknownType,
+ BreakpointByFileAndLine,
+ BreakpointByFunction,
+ BreakpointByAddress,
+ BreakpointAtThrow,
+ BreakpointAtCatch,
+ BreakpointAtMain,
+ BreakpointAtFork,
+ BreakpointAtExec,
+ BreakpointAtSysCall,
+ WatchpointAtAddress,
+ WatchpointAtExpression,
+ BreakpointOnQmlSignalEmit,
+ BreakpointAtJavaScriptThrow,
+ ) = range(0, 14)
+
+
+# Internal codes for types keep in sync with cdbextensions pytype.cpp
+class TypeCode:
+ (
+ TypeCodeTypedef,
+ TypeCodeStruct,
+ TypeCodeVoid,
+ TypeCodeIntegral,
+ TypeCodeFloat,
+ TypeCodeEnum,
+ TypeCodePointer,
+ TypeCodeArray,
+ TypeCodeComplex,
+ TypeCodeReference,
+ TypeCodeFunction,
+ TypeCodeMemberPointer,
+ TypeCodeFortranString,
+ TypeCodeUnresolvable,
+ TypeCodeBitfield,
+ TypeCodeRValueReference,
+ ) = range(0, 16)
+
+
+def isIntegralTypeName(name):
+ return name in (
+ "int",
+ "unsigned int",
+ "signed int",
+ "short",
+ "unsigned short",
+ "long",
+ "unsigned long",
+ "long long",
+ "unsigned long long",
+ "char",
+ "signed char",
+ "unsigned char",
+ "bool",
+ )
+
+
+def isFloatingPointTypeName(name):
+ return name in ("float", "double", "long double")
diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri
index 7bc595154b3..deee4c34e1c 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri
+++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri
@@ -29,9 +29,10 @@ HEADERS += $$PWD/puppetalivecommand.h
HEADERS += $$PWD/changeselectioncommand.h
HEADERS += $$PWD/drop3dlibraryitemcommand.h
HEADERS += $$PWD/update3dviewstatecommand.h
-HEADERS += $$PWD/enable3dviewcommand.h
HEADERS += $$PWD/view3dclosedcommand.h
HEADERS += $$PWD/puppettocreatorcommand.h
+HEADERS += $$PWD/inputeventcommand.h
+HEADERS += $$PWD/view3dactioncommand.h
SOURCES += $$PWD/synchronizecommand.cpp
SOURCES += $$PWD/debugoutputcommand.cpp
@@ -62,6 +63,7 @@ SOURCES += $$PWD/puppetalivecommand.cpp
SOURCES += $$PWD/changeselectioncommand.cpp
SOURCES += $$PWD/drop3dlibraryitemcommand.cpp
SOURCES += $$PWD/update3dviewstatecommand.cpp
-SOURCES += $$PWD/enable3dviewcommand.cpp
SOURCES += $$PWD/view3dclosedcommand.cpp
SOURCES += $$PWD/puppettocreatorcommand.cpp
+SOURCES += $$PWD/inputeventcommand.cpp
+SOURCES += $$PWD/view3dactioncommand.cpp
diff --git a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.cpp
new file mode 100644
index 00000000000..73a68b06207
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "inputeventcommand.h"
+
+#include
+#include
+
+namespace QmlDesigner {
+
+InputEventCommand::InputEventCommand() = default;
+
+InputEventCommand::InputEventCommand(QInputEvent *e)
+ : m_type(e->type()),
+ m_modifiers(e->modifiers())
+{
+ if (m_type == QEvent::Wheel) {
+ auto we = static_cast(e);
+#if QT_VERSION <= QT_VERSION_CHECK(5, 15, 0)
+ m_pos = we->pos();
+#else
+ m_pos = we->position().toPoint();
+#endif
+ m_buttons = we->buttons();
+ m_angleDelta = we->angleDelta().y();
+ } else {
+ auto me = static_cast(e);
+ m_pos = me->pos();
+ m_button = me->button();
+ m_buttons = me->buttons();
+ }
+}
+
+QDataStream &operator<<(QDataStream &out, const InputEventCommand &command)
+{
+ out << command.type();
+ out << command.pos();
+ out << command.button();
+ out << command.buttons();
+ out << command.modifiers();
+ out << command.angleDelta();
+
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, InputEventCommand &command)
+{
+ int type;
+ int button;
+ in >> type;
+ command.m_type = (QEvent::Type)type;
+ in >> command.m_pos;
+ in >> button;
+ command.m_button = (Qt::MouseButton)button;
+ in >> command.m_buttons;
+ in >> command.m_modifiers;
+ in >> command.m_angleDelta;
+
+ return in;
+}
+
+QDebug operator <<(QDebug debug, const InputEventCommand &command)
+{
+ return debug.nospace() << "InputEventCommand("
+ << "type: " << command.type() << ", "
+ << "pos: " << command.pos() << ", "
+ << "button: " << command.button() << ", "
+ << "buttons: " << command.buttons() << ", "
+ << "modifiers: " << command.modifiers() << ", "
+ << "angleDelta: " << command.angleDelta() << ")";
+
+}
+
+} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h
new file mode 100644
index 00000000000..2d77cab6dd5
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+
+#include "instancecontainer.h"
+
+namespace QmlDesigner {
+
+class InputEventCommand
+{
+ friend QDataStream &operator>>(QDataStream &in, InputEventCommand &command);
+ friend QDebug operator <<(QDebug debug, const InputEventCommand &command);
+
+public:
+ InputEventCommand();
+ explicit InputEventCommand(QInputEvent *e);
+
+ QEvent::Type type() const { return m_type; }
+ QPoint pos() const { return m_pos; }
+ Qt::MouseButton button() const { return m_button; }
+ Qt::MouseButtons buttons() const { return m_buttons; }
+ Qt::KeyboardModifiers modifiers() const { return m_modifiers; }
+ int angleDelta() const { return m_angleDelta; }
+
+private:
+ QEvent::Type m_type;
+ QPoint m_pos;
+ Qt::MouseButton m_button = Qt::NoButton;
+ Qt::MouseButtons m_buttons = Qt::NoButton;
+ Qt::KeyboardModifiers m_modifiers = Qt::NoModifier;
+ int m_angleDelta = 0;
+};
+
+QDataStream &operator<<(QDataStream &out, const InputEventCommand &command);
+QDataStream &operator>>(QDataStream &in, InputEventCommand &command);
+
+QDebug operator <<(QDebug debug, const InputEventCommand &command);
+
+} // namespace QmlDesigner
+
+Q_DECLARE_METATYPE(QmlDesigner::InputEventCommand)
diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h
index 3ac17ee0c5b..91c2877f4b3 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h
+++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h
@@ -34,7 +34,7 @@ namespace QmlDesigner {
class PuppetToCreatorCommand
{
public:
- enum Type { KeyPressed, Edit3DToolState, None };
+ enum Type { KeyPressed, Edit3DToolState, Render3DView, ActiveSceneChanged, None };
PuppetToCreatorCommand(Type type, const QVariant &data);
PuppetToCreatorCommand() = default;
diff --git a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp
index b387cf09f3d..584e041c7ab 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp
+++ b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp
@@ -45,6 +45,12 @@ Update3dViewStateCommand::Update3dViewStateCommand(bool active, bool hasPopup)
{
}
+Update3dViewStateCommand::Update3dViewStateCommand(const QSize &size)
+ : m_size(size)
+ , m_type(Update3dViewStateCommand::SizeChange)
+{
+}
+
Qt::WindowStates Update3dViewStateCommand::previousStates() const
{
return m_previousStates;
@@ -65,6 +71,11 @@ bool Update3dViewStateCommand::hasPopup() const
return m_hasPopup;
}
+QSize Update3dViewStateCommand::size() const
+{
+ return m_size;
+}
+
Update3dViewStateCommand::Type Update3dViewStateCommand::type() const
{
return m_type;
@@ -77,6 +88,7 @@ QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &comman
out << qint32(command.isActive());
out << qint32(command.hasPopup());
out << qint32(command.type());
+ out << command.size();
return out;
}
@@ -94,13 +106,16 @@ QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command)
command.m_active = active;
command.m_hasPopup = hasPopup;
command.m_type = Update3dViewStateCommand::Type(type);
+ in >> command.m_size;
return in;
}
QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command)
{
- return debug.nospace() << "Update3dViewStateCommand(type: " << command.m_type << ")";
+ return debug.nospace() << "Update3dViewStateCommand(type: "
+ << command.m_type << ","
+ << command.m_size << ")";
}
} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h
index de8511255d5..a38ca4bb543 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h
+++ b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h
@@ -26,6 +26,7 @@
#pragma once
#include
+#include
namespace QmlDesigner {
@@ -35,10 +36,11 @@ class Update3dViewStateCommand
friend QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command);
public:
- enum Type { StateChange, ActiveChange, Empty };
+ enum Type { StateChange, ActiveChange, SizeChange, Empty };
explicit Update3dViewStateCommand(Qt::WindowStates previousStates, Qt::WindowStates currentStates);
explicit Update3dViewStateCommand(bool active, bool hasPopup);
+ explicit Update3dViewStateCommand(const QSize &size);
Update3dViewStateCommand() = default;
Qt::WindowStates previousStates() const;
@@ -46,6 +48,7 @@ public:
bool isActive() const;
bool hasPopup() const;
+ QSize size() const;
Type type() const;
@@ -55,6 +58,7 @@ private:
bool m_active = false;
bool m_hasPopup = false;
+ QSize m_size;
Type m_type = Empty;
};
diff --git a/share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.cpp
similarity index 58%
rename from share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.cpp
rename to share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.cpp
index 7fd3b3f350a..ae94ed79812 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.cpp
+++ b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
@@ -23,43 +23,54 @@
**
****************************************************************************/
-#include "enable3dviewcommand.h"
+#include "view3dactioncommand.h"
#include
#include
namespace QmlDesigner {
-// open / close edit view 3D command
-Enable3DViewCommand::Enable3DViewCommand(bool enable)
- : m_enable(enable)
+View3DActionCommand::View3DActionCommand(Type type, bool enable)
+ : m_type(type)
+ , m_enabled(enable)
{
}
-bool Enable3DViewCommand::isEnable() const
+bool View3DActionCommand::isEnabled() const
{
- return m_enable;
+ return m_enabled;
}
-QDataStream &operator<<(QDataStream &out, const Enable3DViewCommand &command)
+View3DActionCommand::Type View3DActionCommand::type() const
{
- out << qint32(command.isEnable());
+ return m_type;
+}
+
+QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command)
+{
+ out << qint32(command.isEnabled());
+ out << qint32(command.type());
return out;
}
-QDataStream &operator>>(QDataStream &in, Enable3DViewCommand &command)
+QDataStream &operator>>(QDataStream &in, View3DActionCommand &command)
{
- qint32 enable;
- in >> enable;
- command.m_enable = enable;
+ qint32 enabled;
+ qint32 type;
+ in >> enabled;
+ in >> type;
+ command.m_enabled = bool(enabled);
+ command.m_type = View3DActionCommand::Type(type);
return in;
}
-QDebug operator<<(QDebug debug, const Enable3DViewCommand &command)
+QDebug operator<<(QDebug debug, const View3DActionCommand &command)
{
- return debug.nospace() << "Enable3DViewCommand(enable: " << command.m_enable << ")";
+ return debug.nospace() << "View3DActionCommand(type: "
+ << command.m_type << ","
+ << command.m_enabled << ")";
}
} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h
new file mode 100644
index 00000000000..9f25e2abb4b
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include
+
+namespace QmlDesigner {
+
+class View3DActionCommand
+{
+ friend QDataStream &operator>>(QDataStream &in, View3DActionCommand &command);
+ friend QDebug operator<<(QDebug debug, const View3DActionCommand &command);
+
+public:
+ enum Type { Empty,
+ MoveTool,
+ ScaleTool,
+ RotateTool,
+ FitToView,
+ SelectionModeToggle,
+ CameraToggle,
+ OrientationToggle,
+ EditLightToggle
+ };
+
+ explicit View3DActionCommand(Type type, bool enable);
+ View3DActionCommand() = default;
+
+ bool isEnabled() const;
+ Type type() const;
+
+private:
+ Type m_type = Empty;
+ bool m_enabled = false;
+};
+
+QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command);
+QDataStream &operator>>(QDataStream &in, View3DActionCommand &command);
+
+QDebug operator<<(QDebug debug, const View3DActionCommand &command);
+
+} // namespace QmlDesigner
+
+Q_DECLARE_METATYPE(QmlDesigner::View3DActionCommand)
diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp
index 4ca4f0fb385..e42c8bb3a2a 100644
--- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp
+++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp
@@ -42,7 +42,6 @@
#include "createinstancescommand.h"
#include "createscenecommand.h"
#include "update3dviewstatecommand.h"
-#include "enable3dviewcommand.h"
#include "changevaluescommand.h"
#include "changebindingscommand.h"
#include "changeauxiliarycommand.h"
@@ -57,6 +56,8 @@
#include "synchronizecommand.h"
#include "removesharedmemorycommand.h"
#include "tokencommand.h"
+#include "inputeventcommand.h"
+#include "view3dactioncommand.h"
#include "informationchangedcommand.h"
#include "pixmapchangedcommand.h"
@@ -76,6 +77,13 @@
namespace QmlDesigner {
+constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError)
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+ = &QLocalSocket::error;
+#else
+ = &QLocalSocket::errorOccurred;
+#endif
+
NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
: QObject(parent),
m_inputIoDevice(nullptr),
@@ -93,7 +101,7 @@ void NodeInstanceClientProxy::initializeSocket()
{
QLocalSocket *localSocket = new QLocalSocket(this);
connect(localSocket, &QIODevice::readyRead, this, &NodeInstanceClientProxy::readDataStream);
- connect(localSocket, QOverload::of(&QLocalSocket::error),
+ connect(localSocket, LocalSocketErrorFunction,
QCoreApplication::instance(), &QCoreApplication::quit);
connect(localSocket, &QLocalSocket::disconnected, QCoreApplication::instance(), &QCoreApplication::quit);
localSocket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered);
@@ -321,6 +329,16 @@ QVariant NodeInstanceClientProxy::readCommandFromIOStream(QIODevice *ioDevice, q
return command;
}
+void NodeInstanceClientProxy::inputEvent(const InputEventCommand &command)
+{
+ nodeInstanceServer()->inputEvent(command);
+}
+
+void NodeInstanceClientProxy::view3DAction(const View3DActionCommand &command)
+{
+ nodeInstanceServer()->view3DAction(command);
+}
+
void NodeInstanceClientProxy::readDataStream()
{
QList commandList;
@@ -379,11 +397,6 @@ void NodeInstanceClientProxy::update3DViewState(const Update3dViewStateCommand &
nodeInstanceServer()->update3DViewState(command);
}
-void NodeInstanceClientProxy::enable3DView(const Enable3DViewCommand &command)
-{
- nodeInstanceServer()->enable3DView(command);
-}
-
void NodeInstanceClientProxy::clearScene(const ClearSceneCommand &command)
{
nodeInstanceServer()->clearScene(command);
@@ -472,7 +485,6 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
{
static const int createInstancesCommandType = QMetaType::type("CreateInstancesCommand");
static const int update3dViewStateCommand = QMetaType::type("Update3dViewStateCommand");
- static const int enable3DViewCommandType = QMetaType::type("Enable3DViewCommand");
static const int changeFileUrlCommandType = QMetaType::type("ChangeFileUrlCommand");
static const int createSceneCommandType = QMetaType::type("CreateSceneCommand");
static const int clearSceneCommandType = QMetaType::type("ClearSceneCommand");
@@ -491,15 +503,17 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
static const int tokenCommandType = QMetaType::type("TokenCommand");
static const int endPuppetCommandType = QMetaType::type("EndPuppetCommand");
static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand");
+ static const int inputEventCommandType = QMetaType::type("InputEventCommand");
+ static const int view3DActionCommandType = QMetaType::type("View3DActionCommand");
const int commandType = command.userType();
- if (commandType == createInstancesCommandType)
+ if (commandType == inputEventCommandType)
+ inputEvent(command.value());
+ else if (commandType == createInstancesCommandType)
createInstances(command.value());
else if (commandType == update3dViewStateCommand)
update3DViewState(command.value());
- else if (commandType == enable3DViewCommandType)
- enable3DView(command.value());
else if (commandType == changeFileUrlCommandType)
changeFileUrl(command.value());
else if (commandType == createSceneCommandType)
@@ -532,6 +546,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
redirectToken(command.value());
else if (commandType == endPuppetCommandType)
redirectToken(command.value());
+ else if (commandType == view3DActionCommandType)
+ view3DAction(command.value());
else if (commandType == synchronizeCommandType) {
SynchronizeCommand synchronizeCommand = command.value();
m_synchronizeId = synchronizeCommand.synchronizeId();
diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h
index 6a114bbe3e1..6cafd282af4 100644
--- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h
+++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h
@@ -46,7 +46,6 @@ class CreateInstancesCommand;
class ClearSceneCommand;
class ReparentInstancesCommand;
class Update3dViewStateCommand;
-class Enable3DViewCommand;
class ChangeFileUrlCommand;
class ChangeValuesCommand;
class ChangeAuxiliaryCommand;
@@ -62,6 +61,8 @@ class ChangeSelectionCommand;
class Drop3DLibraryItemCommand;
class PuppetToCreatorCommand;
class View3DClosedCommand;
+class InputEventCommand;
+class View3DActionCommand;
class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface
{
@@ -102,7 +103,6 @@ protected:
void createScene(const CreateSceneCommand &command);
void clearScene(const ClearSceneCommand &command);
void update3DViewState(const Update3dViewStateCommand &command);
- void enable3DView(const Enable3DViewCommand &command);
void removeInstances(const RemoveInstancesCommand &command);
void removeProperties(const RemovePropertiesCommand &command);
void changePropertyBindings(const ChangeBindingsCommand &command);
@@ -118,6 +118,8 @@ protected:
void redirectToken(const EndPuppetCommand &command);
void changeSelection(const ChangeSelectionCommand &command);
static QVariant readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize);
+ void inputEvent(const InputEventCommand &command);
+ void view3DAction(const View3DActionCommand &command);
protected slots:
void readDataStream();
diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
index 5c7c9d2953a..b2703f7f320 100644
--- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
+++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
@@ -33,7 +33,6 @@
#include "createinstancescommand.h"
#include "createscenecommand.h"
#include "update3dviewstatecommand.h"
-#include "enable3dviewcommand.h"
#include "changevaluescommand.h"
#include "changebindingscommand.h"
#include "changeauxiliarycommand.h"
@@ -49,6 +48,8 @@
#include "changenodesourcecommand.h"
#include "changeselectioncommand.h"
#include "drop3dlibraryitemcommand.h"
+#include "inputeventcommand.h"
+#include "view3dactioncommand.h"
#include "informationchangedcommand.h"
#include "pixmapchangedcommand.h"
@@ -97,9 +98,6 @@ void NodeInstanceServerInterface::registerCommands()
qRegisterMetaType("Update3dViewStateCommand");
qRegisterMetaTypeStreamOperators("Update3dViewStateCommand");
- qRegisterMetaType("Enable3DViewCommand");
- qRegisterMetaTypeStreamOperators("Enable3DViewCommand");
-
qRegisterMetaType("ChangeBindingsCommand");
qRegisterMetaTypeStreamOperators("ChangeBindingsCommand");
@@ -214,6 +212,12 @@ void NodeInstanceServerInterface::registerCommands()
qRegisterMetaType("PuppetToCreatorCommand");
qRegisterMetaTypeStreamOperators("PuppetToCreatorCommand");
+ qRegisterMetaType("InputEventCommand");
+ qRegisterMetaTypeStreamOperators("InputEventCommand");
+
+ qRegisterMetaType("View3DActionCommand");
+ qRegisterMetaTypeStreamOperators("View3DActionCommand");
+
qRegisterMetaType>("QPairIntInt");
qRegisterMetaTypeStreamOperators>("QPairIntInt");
}
diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h
index e60d99b1e19..0c6009e4778 100644
--- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h
+++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h
@@ -34,7 +34,6 @@ class PropertyBindingContainer;
class PropertyValueContainer;
class Update3dViewStateCommand;
-class Enable3DViewCommand;
class ChangeFileUrlCommand;
class ChangeValuesCommand;
class ChangeBindingsCommand;
@@ -52,6 +51,8 @@ class ChangeNodeSourceCommand;
class TokenCommand;
class RemoveSharedMemoryCommand;
class ChangeSelectionCommand;
+class InputEventCommand;
+class View3DActionCommand;
class NodeInstanceServerInterface : public QObject
{
@@ -69,7 +70,6 @@ public:
virtual void createScene(const CreateSceneCommand &command) = 0;
virtual void clearScene(const ClearSceneCommand &command) = 0;
virtual void update3DViewState(const Update3dViewStateCommand &command) = 0;
- virtual void enable3DView(const Enable3DViewCommand &command) = 0;
virtual void removeInstances(const RemoveInstancesCommand &command) = 0;
virtual void removeProperties(const RemovePropertiesCommand &command) = 0;
virtual void changePropertyBindings(const ChangeBindingsCommand &command) = 0;
@@ -83,6 +83,8 @@ public:
virtual void token(const TokenCommand &command) = 0;
virtual void removeSharedMemory(const RemoveSharedMemoryCommand &command) = 0;
virtual void changeSelection(const ChangeSelectionCommand &command) = 0;
+ virtual void inputEvent(const InputEventCommand &command) = 0;
+ virtual void view3DAction(const View3DActionCommand &command) = 0;
virtual void benchmark(const QString &)
{}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
index 4b90659e6e6..9ee23e48a4e 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
@@ -30,16 +30,11 @@ import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import MouseArea3D 1.0
-Window {
- id: viewWindow
+Item {
+ id: viewRoot
width: 1024
height: 768
- minimumHeight: 200
- minimumWidth: 200
visible: true
- title: qsTr("3D Edit View [") + sceneId + qsTr("]")
- // need all those flags otherwise the title bar disappears after setting WindowStaysOnTopHint flag later
- flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint
property Node activeScene: null
property View3D editView: null
@@ -48,6 +43,7 @@ Window {
property alias showEditLight: btnEditViewLight.toggled
property alias usePerspective: btnPerspective.toggled
property alias globalOrientation: btnLocalGlobal.toggled
+ property alias contentItem: contentItem
property Node selectedNode: null // This is non-null only in single selection case
property var selectedNodes: [] // All selected nodes
@@ -57,6 +53,8 @@ Window {
property var selectionBoxes: []
property rect viewPortRect: Qt.rect(0, 0, 1000, 1000)
+ property bool showButtons: false
+
signal selectionChanged(var selectedNodes)
signal commitObjectProperty(var object, var propName)
signal changeObjectProperty(var object, var propName)
@@ -86,7 +84,7 @@ Window {
editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;});
selectionBoxes.length = 0;
- updateToolStates();
+ updateToolStates(_generalHelper.getToolStates(sceneId), true);
}
}
}
@@ -99,54 +97,62 @@ Window {
_generalHelper.enableItemUpdate(editView, (scene && scene === activeScene));
}
-
- function restoreWindowState()
+ function fitToView()
{
- // It is expected that tool states have been initialized before calling this
- _generalHelper.restoreWindowState(viewWindow);
+ if (editView) {
+ var targetNode = selectedNodes.length > 0
+ ? selectionBoxes[0].model : null;
+ cameraControl.focusObject(targetNode, editView.camera.rotation, true);
+ }
}
- function updateToolStates()
+ // If resetToDefault is true, tool states not specifically set to anything will be reset to
+ // their default state.
+ function updateToolStates(toolStates, resetToDefault)
{
- var toolStates = _generalHelper.getToolStates(sceneId);
if ("showEditLight" in toolStates)
showEditLight = toolStates.showEditLight;
- else
+ else if (resetToDefault)
showEditLight = false;
if ("usePerspective" in toolStates)
usePerspective = toolStates.usePerspective;
- else
+ else if (resetToDefault)
usePerspective = false;
if ("globalOrientation" in toolStates)
globalOrientation = toolStates.globalOrientation;
- else
+ else if (resetToDefault)
globalOrientation = false;
var groupIndex;
var group;
var i;
- btnSelectItem.selected = false;
- btnSelectGroup.selected = true;
+
if ("groupSelect" in toolStates) {
groupIndex = toolStates.groupSelect;
group = toolbarButtons.buttonGroups["groupSelect"];
for (i = 0; i < group.length; ++i)
group[i].selected = (i === groupIndex);
+ _generalHelper.storeToolState(sceneId, "groupSelect", groupIndex)
+ } else if (resetToDefault) {
+ btnSelectItem.selected = true;
+ btnSelectGroup.selected = false;
}
- btnRotate.selected = false;
- btnScale.selected = false;
- btnMove.selected = true;
if ("groupTransform" in toolStates) {
groupIndex = toolStates.groupTransform;
group = toolbarButtons.buttonGroups["groupTransform"];
for (i = 0; i < group.length; ++i)
group[i].selected = (i === groupIndex);
+ _generalHelper.storeToolState(sceneId, "groupTransform", groupIndex)
+ } else if (resetToDefault) {
+ btnRotate.selected = false;
+ btnScale.selected = false;
+ btnMove.selected = true;
}
if ("editCamState" in toolStates)
cameraControl.restoreCameraState(toolStates.editCamState);
- else
+ else if (resetToDefault)
cameraControl.restoreDefaultState();
}
@@ -324,37 +330,27 @@ Window {
_generalHelper.requestOverlayUpdate();
}
- onWidthChanged: {
- _generalHelper.requestOverlayUpdate();
- _generalHelper.storeWindowState(viewWindow);
- }
- onHeightChanged: {
- _generalHelper.requestOverlayUpdate();
- _generalHelper.storeWindowState(viewWindow);
-
- }
- onXChanged: _generalHelper.storeWindowState(viewWindow);
- onYChanged: _generalHelper.storeWindowState(viewWindow);
- onWindowStateChanged: _generalHelper.storeWindowState(viewWindow);
+ onWidthChanged: _generalHelper.requestOverlayUpdate()
+ onHeightChanged: _generalHelper.requestOverlayUpdate()
Node {
id: overlayScene
PerspectiveCamera {
id: overlayPerspectiveCamera
- clipFar: viewWindow.editView ? viewWindow.editView.perpectiveCamera.clipFar : 1000
- clipNear: viewWindow.editView ? viewWindow.editView.perpectiveCamera.clipNear : 1
- position: viewWindow.editView ? viewWindow.editView.perpectiveCamera.position : Qt.vector3d(0, 0, 0)
- rotation: viewWindow.editView ? viewWindow.editView.perpectiveCamera.rotation : Qt.vector3d(0, 0, 0)
+ clipFar: viewRoot.editView ? viewRoot.editView.perpectiveCamera.clipFar : 1000
+ clipNear: viewRoot.editView ? viewRoot.editView.perpectiveCamera.clipNear : 1
+ position: viewRoot.editView ? viewRoot.editView.perpectiveCamera.position : Qt.vector3d(0, 0, 0)
+ rotation: viewRoot.editView ? viewRoot.editView.perpectiveCamera.rotation : Qt.vector3d(0, 0, 0)
}
OrthographicCamera {
id: overlayOrthoCamera
- clipFar: viewWindow.editView ? viewWindow.editView.orthoCamera.clipFar : 1000
- clipNear: viewWindow.editView ? viewWindow.editView.orthoCamera.clipNear : 1
- position: viewWindow.editView ? viewWindow.editView.orthoCamera.position : Qt.vector3d(0, 0, 0)
- rotation: viewWindow.editView ? viewWindow.editView.orthoCamera.rotation : Qt.vector3d(0, 0, 0)
- scale: viewWindow.editView ? viewWindow.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0)
+ clipFar: viewRoot.editView ? viewRoot.editView.orthoCamera.clipFar : 1000
+ clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1
+ position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0)
+ rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.vector3d(0, 0, 0)
+ scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0)
}
MouseArea3D {
@@ -366,41 +362,41 @@ Window {
id: moveGizmo
scale: autoScale.getScale(Qt.vector3d(5, 5, 5))
highlightOnHover: true
- targetNode: viewWindow.selectedNode
- globalOrientation: viewWindow.globalOrientation
- visible: viewWindow.selectedNode && btnMove.selected
+ targetNode: viewRoot.selectedNode
+ globalOrientation: viewRoot.globalOrientation
+ visible: viewRoot.selectedNode && btnMove.selected
view3D: overlayView
dragHelper: gizmoDragHelper
- onPositionCommit: viewWindow.commitObjectProperty(viewWindow.selectedNode, "position")
- onPositionMove: viewWindow.changeObjectProperty(viewWindow.selectedNode, "position")
+ onPositionCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "position")
+ onPositionMove: viewRoot.changeObjectProperty(viewRoot.selectedNode, "position")
}
ScaleGizmo {
id: scaleGizmo
scale: autoScale.getScale(Qt.vector3d(5, 5, 5))
highlightOnHover: true
- targetNode: viewWindow.selectedNode
- visible: viewWindow.selectedNode && btnScale.selected
+ targetNode: viewRoot.selectedNode
+ visible: viewRoot.selectedNode && btnScale.selected
view3D: overlayView
dragHelper: gizmoDragHelper
- onScaleCommit: viewWindow.commitObjectProperty(viewWindow.selectedNode, "scale")
- onScaleChange: viewWindow.changeObjectProperty(viewWindow.selectedNode, "scale")
+ onScaleCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "scale")
+ onScaleChange: viewRoot.changeObjectProperty(viewRoot.selectedNode, "scale")
}
RotateGizmo {
id: rotateGizmo
scale: autoScale.getScale(Qt.vector3d(7, 7, 7))
highlightOnHover: true
- targetNode: viewWindow.selectedNode
- globalOrientation: viewWindow.globalOrientation
- visible: viewWindow.selectedNode && btnRotate.selected
+ targetNode: viewRoot.selectedNode
+ globalOrientation: viewRoot.globalOrientation
+ visible: viewRoot.selectedNode && btnRotate.selected
view3D: overlayView
dragHelper: gizmoDragHelper
- onRotateCommit: viewWindow.commitObjectProperty(viewWindow.selectedNode, "rotation")
- onRotateChange: viewWindow.changeObjectProperty(viewWindow.selectedNode, "rotation")
+ onRotateCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "rotation")
+ onRotateChange: viewRoot.changeObjectProperty(viewRoot.selectedNode, "rotation")
}
AutoScaleHelper {
@@ -412,31 +408,31 @@ Window {
Line3D {
id: pivotLine
- visible: viewWindow.selectedNode
+ visible: viewRoot.selectedNode
name: "3D Edit View Pivot Line"
color: "#ddd600"
function flipIfNeeded(vec) {
- if (!viewWindow.selectedNode || viewWindow.selectedNode.orientation === Node.LeftHanded)
+ if (!viewRoot.selectedNode || viewRoot.selectedNode.orientation === Node.LeftHanded)
return vec;
else
return Qt.vector3d(vec.x, vec.y, -vec.z);
}
- startPos: viewWindow.selectedNode ? flipIfNeeded(viewWindow.selectedNode.scenePosition)
+ startPos: viewRoot.selectedNode ? flipIfNeeded(viewRoot.selectedNode.scenePosition)
: Qt.vector3d(0, 0, 0)
Connections {
- target: viewWindow
+ target: viewRoot
onSelectedNodeChanged: {
pivotLine.endPos = pivotLine.flipIfNeeded(gizmoDragHelper.pivotScenePosition(
- viewWindow.selectedNode));
+ viewRoot.selectedNode));
}
}
Connections {
- target: viewWindow.selectedNode
+ target: viewRoot.selectedNode
onSceneTransformChanged: {
pivotLine.endPos = pivotLine.flipIfNeeded(gizmoDragHelper.pivotScenePosition(
- viewWindow.selectedNode));
+ viewRoot.selectedNode));
}
}
@@ -457,243 +453,235 @@ Window {
}
}
- Rectangle {
- id: viewRect
+ Item {
+ id: contentItem
anchors.fill: parent
- focus: true
- gradient: Gradient {
- GradientStop { position: 1.0; color: "#222222" }
- GradientStop { position: 0.0; color: "#999999" }
- }
-
- MouseArea {
+ Rectangle {
+ id: viewRect
anchors.fill: parent
- acceptedButtons: Qt.LeftButton
- onClicked: {
- if (viewWindow.editView) {
- var pickResult = viewWindow.editView.pick(mouse.x, mouse.y);
- handleObjectClicked(_generalHelper.resolvePick(pickResult.objectHit),
- mouse.modifiers & Qt.ControlModifier);
- if (!pickResult.objectHit)
- mouse.accepted = false;
+ focus: true
+
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#222222" }
+ GradientStop { position: 0.0; color: "#999999" }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton
+ onClicked: {
+ if (viewRoot.editView) {
+ var pickResult = viewRoot.editView.pick(mouse.x, mouse.y);
+ handleObjectClicked(_generalHelper.resolvePick(pickResult.objectHit),
+ mouse.modifiers & Qt.ControlModifier);
+ if (!pickResult.objectHit)
+ mouse.accepted = false;
+ }
}
}
- }
- DropArea {
- anchors.fill: parent
- }
+ DropArea {
+ anchors.fill: parent
+ }
- View3D {
- id: overlayView
- anchors.fill: parent
- camera: usePerspective ? overlayPerspectiveCamera : overlayOrthoCamera
- importScene: overlayScene
- z: 2
- }
+ View3D {
+ id: overlayView
+ anchors.fill: parent
+ camera: usePerspective ? overlayPerspectiveCamera : overlayOrthoCamera
+ importScene: overlayScene
+ z: 2
+ }
- Overlay2D {
- id: gizmoLabel
- targetNode: moveGizmo.visible ? moveGizmo : scaleGizmo
- targetView: overlayView
- visible: targetNode.dragging
- z: 3
+ Overlay2D {
+ id: gizmoLabel
+ targetNode: moveGizmo.visible ? moveGizmo : scaleGizmo
+ targetView: overlayView
+ visible: targetNode.dragging
+ z: 3
- Rectangle {
- color: "white"
- x: -width / 2
- y: -height - 8
- width: gizmoLabelText.width + 4
- height: gizmoLabelText.height + 4
- border.width: 1
- Text {
- id: gizmoLabelText
- text: {
- var l = Qt.locale();
- var targetProperty;
- if (viewWindow.selectedNode) {
- if (gizmoLabel.targetNode === moveGizmo)
- targetProperty = viewWindow.selectedNode.position;
- else
- targetProperty = viewWindow.selectedNode.scale;
- return qsTr("x:") + Number(targetProperty.x).toLocaleString(l, 'f', 1)
- + qsTr(" y:") + Number(targetProperty.y).toLocaleString(l, 'f', 1)
- + qsTr(" z:") + Number(targetProperty.z).toLocaleString(l, 'f', 1);
- } else {
- return "";
+ Rectangle {
+ color: "white"
+ x: -width / 2
+ y: -height - 8
+ width: gizmoLabelText.width + 4
+ height: gizmoLabelText.height + 4
+ border.width: 1
+ Text {
+ id: gizmoLabelText
+ text: {
+ var l = Qt.locale();
+ var targetProperty;
+ if (viewRoot.selectedNode) {
+ if (gizmoLabel.targetNode === moveGizmo)
+ targetProperty = viewRoot.selectedNode.position;
+ else
+ targetProperty = viewRoot.selectedNode.scale;
+ return qsTr("x:") + Number(targetProperty.x).toLocaleString(l, 'f', 1)
+ + qsTr(" y:") + Number(targetProperty.y).toLocaleString(l, 'f', 1)
+ + qsTr(" z:") + Number(targetProperty.z).toLocaleString(l, 'f', 1);
+ } else {
+ return "";
+ }
}
+ anchors.centerIn: parent
}
- anchors.centerIn: parent
}
}
+
+ EditCameraController {
+ id: cameraControl
+ camera: viewRoot.editView ? viewRoot.editView.camera : null
+ anchors.fill: parent
+ view3d: viewRoot.editView
+ sceneId: viewRoot.sceneId
+ }
}
- EditCameraController {
- id: cameraControl
- camera: viewWindow.editView ? viewWindow.editView.camera : null
- anchors.fill: parent
- view3d: viewWindow.editView
- sceneId: viewWindow.sceneId
- }
- }
+ Rectangle { // toolbar
+ id: toolbar
+ color: "#9F000000"
+ width: 35
+ height: toolbarButtons.height
+ visible: viewRoot.showButtons
- Rectangle { // toolbar
- id: toolbar
- color: "#9F000000"
- width: 35
- height: toolbarButtons.height
-
- Column {
- id: toolbarButtons
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 5
- padding: 5
-
- // Button groups must be defined in parent object of buttons
- property var buttonGroups: {
- "groupSelect": [btnSelectGroup, btnSelectItem],
- "groupTransform": [btnMove, btnRotate, btnScale]
- }
-
- ToolBarButton {
- id: btnSelectItem
- selected: true
- tooltip: qsTr("Select Item")
- shortcut: "Q"
- currentShortcut: selected ? "" : shortcut
- tool: "item_selection"
- buttonGroup: "groupSelect"
- sceneId: viewWindow.sceneId
- }
-
- ToolBarButton {
- id: btnSelectGroup
- tooltip: qsTr("Select Group")
- shortcut: "Q"
- currentShortcut: btnSelectItem.currentShortcut === shortcut ? "" : shortcut
- tool: "group_selection"
- buttonGroup: "groupSelect"
- sceneId: viewWindow.sceneId
- }
-
- Rectangle { // separator
- width: 25
- height: 1
- color: "#f1f1f1"
+ Column {
+ id: toolbarButtons
anchors.horizontalCenter: parent.horizontalCenter
- }
+ spacing: 5
+ padding: 5
- ToolBarButton {
- id: btnMove
- selected: true
- tooltip: qsTr("Move current selection")
- shortcut: "W"
- currentShortcut: shortcut
- tool: "move"
- buttonGroup: "groupTransform"
- sceneId: viewWindow.sceneId
- }
+ // Button groups must be defined in parent object of buttons
+ property var buttonGroups: {
+ "groupSelect": [btnSelectGroup, btnSelectItem],
+ "groupTransform": [btnMove, btnRotate, btnScale]
+ }
- ToolBarButton {
- id: btnRotate
- tooltip: qsTr("Rotate current selection")
- shortcut: "E"
- currentShortcut: shortcut
- tool: "rotate"
- buttonGroup: "groupTransform"
- sceneId: viewWindow.sceneId
- }
+ ToolBarButton {
+ id: btnSelectItem
+ selected: true
+ tooltip: qsTr("Select Item")
+ shortcut: "Q"
+ currentShortcut: selected ? "" : shortcut
+ tool: "item_selection"
+ buttonGroup: "groupSelect"
+ sceneId: viewRoot.sceneId
+ }
- ToolBarButton {
- id: btnScale
- tooltip: qsTr("Scale current selection")
- shortcut: "R"
- currentShortcut: shortcut
- tool: "scale"
- buttonGroup: "groupTransform"
- sceneId: viewWindow.sceneId
- }
+ ToolBarButton {
+ id: btnSelectGroup
+ tooltip: qsTr("Select Group")
+ shortcut: "Q"
+ currentShortcut: btnSelectItem.currentShortcut === shortcut ? "" : shortcut
+ tool: "group_selection"
+ buttonGroup: "groupSelect"
+ sceneId: viewRoot.sceneId
+ }
- Rectangle { // separator
- width: 25
- height: 1
- color: "#f1f1f1"
- anchors.horizontalCenter: parent.horizontalCenter
- }
+ Rectangle { // separator
+ width: 25
+ height: 1
+ color: "#f1f1f1"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
- ToolBarButton {
- id: btnFit
- tooltip: qsTr("Fit camera to current selection")
- shortcut: "F"
- currentShortcut: shortcut
- tool: "fit"
- togglable: false
+ ToolBarButton {
+ id: btnMove
+ selected: true
+ tooltip: qsTr("Move current selection")
+ shortcut: "W"
+ currentShortcut: shortcut
+ tool: "move"
+ buttonGroup: "groupTransform"
+ sceneId: viewRoot.sceneId
+ }
- onSelectedChanged: {
- if (viewWindow.editView && selected) {
- var targetNode = viewWindow.selectedNodes.length > 0
- ? selectionBoxes[0].model : null;
- cameraControl.focusObject(targetNode, viewWindow.editView.camera.rotation, true);
+ ToolBarButton {
+ id: btnRotate
+ tooltip: qsTr("Rotate current selection")
+ shortcut: "E"
+ currentShortcut: shortcut
+ tool: "rotate"
+ buttonGroup: "groupTransform"
+ sceneId: viewRoot.sceneId
+ }
+
+ ToolBarButton {
+ id: btnScale
+ tooltip: qsTr("Scale current selection")
+ shortcut: "R"
+ currentShortcut: shortcut
+ tool: "scale"
+ buttonGroup: "groupTransform"
+ sceneId: viewRoot.sceneId
+ }
+
+ Rectangle { // separator
+ width: 25
+ height: 1
+ color: "#f1f1f1"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ ToolBarButton {
+ id: btnFit
+ tooltip: qsTr("Fit camera to current selection")
+ shortcut: "F"
+ currentShortcut: shortcut
+ tool: "fit"
+ togglable: false
+
+ onSelectedChanged: {
+ if (selected)
+ viewRoot.fitToView();
}
}
}
}
- }
- AxisHelper {
- anchors.right: parent.right
- anchors.top: parent.top
- width: 100
- height: width
- editCameraCtrl: cameraControl
- selectedNode : viewWindow.selectedNodes.length ? selectionBoxes[0].model : null
- }
-
- Rectangle { // top controls bar
- color: "#aa000000"
- width: 290
- height: btnPerspective.height + 10
- anchors.top: parent.top
- anchors.right: parent.right
- anchors.rightMargin: 100
-
- Row {
- padding: 5
- anchors.fill: parent
- ToggleButton {
- id: btnPerspective
- width: 105
- tooltip: qsTr("Toggle Perspective / Orthographic Projection")
- states: [{iconId: "ortho", text: qsTr("Orthographic")}, {iconId: "persp", text: qsTr("Perspective")}]
- }
-
- ToggleButton {
- id: btnLocalGlobal
- width: 65
- tooltip: qsTr("Toggle Global / Local Orientation")
- states: [{iconId: "local", text: qsTr("Local")}, {iconId: "global", text: qsTr("Global")}]
- }
-
- ToggleButton {
- id: btnEditViewLight
- width: 110
- toggleBackground: true
- tooltip: qsTr("Toggle Edit Light")
- states: [{iconId: "edit_light_off", text: qsTr("Edit Light Off")}, {iconId: "edit_light_on", text: qsTr("Edit Light On")}]
- }
+ AxisHelper {
+ anchors.right: parent.right
+ anchors.top: parent.top
+ width: 100
+ height: width
+ editCameraCtrl: cameraControl
+ selectedNode : viewRoot.selectedNodes.length ? selectionBoxes[0].model : null
}
- }
+ Rectangle { // top controls bar
+ color: "#aa000000"
+ width: 290
+ height: btnPerspective.height + 10
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.rightMargin: 100
+ visible: viewRoot.showButtons
- Text {
- id: helpText
+ Row {
+ padding: 5
+ anchors.fill: parent
+ ToggleButton {
+ id: btnPerspective
+ width: 105
+ tooltip: qsTr("Toggle Perspective / Orthographic Projection")
+ states: [{iconId: "ortho", text: qsTr("Orthographic")}, {iconId: "persp", text: qsTr("Perspective")}]
+ }
- property string modKey: _generalHelper.isMacOS ? qsTr("Option") : qsTr("Alt")
+ ToggleButton {
+ id: btnLocalGlobal
+ width: 65
+ tooltip: qsTr("Toggle Global / Local Orientation")
+ states: [{iconId: "local", text: qsTr("Local")}, {iconId: "global", text: qsTr("Global")}]
+ }
- color: "white"
- text: qsTr("Camera controls: ") + modKey
- + qsTr(" + mouse press and drag. Left: Rotate, Middle: Pan, Right/Wheel: Zoom.")
- anchors.bottom: parent.bottom
+ ToggleButton {
+ id: btnEditViewLight
+ width: 110
+ toggleBackground: true
+ tooltip: qsTr("Toggle Edit Light")
+ states: [{iconId: "edit_light_off", text: qsTr("Edit Light Off")}, {iconId: "edit_light_on", text: qsTr("Edit Light On")}]
+ }
+ }
+ }
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditWindow3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditWindow3D.qml
new file mode 100644
index 00000000000..4ec92e63c35
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditWindow3D.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.12
+
+Window {
+ id: viewWindow
+ width: 1024
+ height: 768
+ visible: true
+ title: qsTr("3D Edit View [") + sceneId + qsTr("]")
+ // need all those flags otherwise the title bar disappears after setting WindowStaysOnTopHint flag later
+ flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint
+
+ property alias editViewRoot: windowContentItem
+
+ onWidthChanged: _generalHelper.storeWindowState();
+ onHeightChanged: _generalHelper.storeWindowState();
+ onXChanged: _generalHelper.storeWindowState();
+ onYChanged: _generalHelper.storeWindowState();
+ onWindowStateChanged: _generalHelper.storeWindowState();
+
+ EditView3D {
+ id: windowContentItem
+ anchors.fill: parent
+ }
+}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml
index a198cae04bc..77f3a54a055 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml
@@ -45,7 +45,7 @@ Node {
}
property alias iconSource: iconImage.source
- property alias overlayColor: colorOverlay.color
+ //property alias overlayColor: colorOverlay.color
signal positionCommit()
signal clicked(Node node, bool multi)
@@ -94,15 +94,15 @@ Node {
acceptedButtons: Qt.LeftButton
}
}
- ColorOverlay {
- id: colorOverlay
- anchors.fill: parent
- cached: true
- source: iconImage
- color: "transparent"
- opacity: 0.6
- }
-
+// ColorOverlay doesn't work correctly with hidden windows so commenting it out for now
+// ColorOverlay {
+// id: colorOverlay
+// anchors.fill: parent
+// cached: true
+// source: iconImage
+// color: "#00000000"
+// opacity: 0.6
+// }
}
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml
index 6e321f8398a..7c9953e9bb5 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml
@@ -37,5 +37,6 @@ IconGizmo {
: "qrc:///qtquickplugin/mockfiles/images/point_light_gradient.png"
: "qrc:///qtquickplugin/mockfiles/images/point_light_gradient.png"
- overlayColor: targetNode ? targetNode.color : "transparent"
+ // ColorOverlay doesn't work correctly with hidden windows so commenting it out for now
+ //overlayColor: targetNode ? targetNode.color : "transparent"
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
index 7c33ab2b8e4..c123a68d47d 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
@@ -48,7 +48,7 @@
namespace QmlDesigner {
namespace Internal {
-const QString globalStateId = QStringLiteral("@GTS"); // global tool state
+const QString _globalStateId = QStringLiteral("@GTS"); // global tool state
GeneralHelper::GeneralHelper()
: QObject()
@@ -260,37 +260,42 @@ void GeneralHelper::initToolStates(const QString &sceneId, const QVariantMap &to
m_toolStates[sceneId] = toolStates;
}
-void GeneralHelper::storeWindowState(QQuickWindow *w)
+void GeneralHelper::storeWindowState()
{
+ if (!m_edit3DWindow)
+ return;
+
QVariantMap windowState;
- const QRect geometry = w->geometry();
- const bool maximized = w->windowState() == Qt::WindowMaximized;
+ const QRect geometry = m_edit3DWindow->geometry();
+ const bool maximized = m_edit3DWindow->windowState() == Qt::WindowMaximized;
windowState.insert("maximized", maximized);
windowState.insert("geometry", geometry);
- storeToolState(globalStateId, "windowState", windowState, 500);
+ storeToolState(globalStateId(), "windowState", windowState, 500);
}
-void GeneralHelper::restoreWindowState(QQuickWindow *w)
+void GeneralHelper::restoreWindowState()
{
- if (m_toolStates.contains(globalStateId)) {
- const QVariantMap &globalStateMap = m_toolStates[globalStateId];
+ if (!m_edit3DWindow)
+ return;
+
+ if (m_toolStates.contains(globalStateId())) {
+ const QVariantMap &globalStateMap = m_toolStates[globalStateId()];
const QString stateKey = QStringLiteral("windowState");
if (globalStateMap.contains(stateKey)) {
QVariantMap windowState = globalStateMap[stateKey].value();
- doRestoreWindowState(w, windowState);
+ doRestoreWindowState(windowState);
// If the mouse cursor at puppet launch time is in a different screen than the one where the
// view geometry was saved on, the initial position and size can be incorrect, but if
// we reset the geometry again asynchronously, it should end up with correct geometry.
- QTimer::singleShot(0, [this, w, windowState]() {
- doRestoreWindowState(w, windowState);
-
- QTimer::singleShot(0, [w]() {
+ QTimer::singleShot(0, [this, windowState]() {
+ doRestoreWindowState(windowState);
+ QTimer::singleShot(0, [this]() {
// Make sure that the window is at least partially visible on the screen
- QRect geo = w->geometry();
- QRect sRect = w->screen()->geometry();
+ QRect geo = m_edit3DWindow->geometry();
+ QRect sRect = m_edit3DWindow->screen()->geometry();
if (geo.left() > sRect.right() - 150)
geo.moveRight(sRect.right());
if (geo.right() < sRect.left() + 150)
@@ -303,7 +308,7 @@ void GeneralHelper::restoreWindowState(QQuickWindow *w)
geo.setWidth(sRect.width());
if (geo.height() > sRect.height())
geo.setHeight(sRect.height());
- w->setGeometry(geo);
+ m_edit3DWindow->setGeometry(geo);
});
});
}
@@ -324,7 +329,17 @@ QVariantMap GeneralHelper::getToolStates(const QString &sceneId)
return {};
}
-void GeneralHelper::doRestoreWindowState(QQuickWindow *w, const QVariantMap &windowState)
+void GeneralHelper::setEdit3DWindow(QQuickWindow *w)
+{
+ m_edit3DWindow = w;
+}
+
+QString GeneralHelper::globalStateId() const
+{
+ return _globalStateId;
+}
+
+void GeneralHelper::doRestoreWindowState(const QVariantMap &windowState)
{
const QString geoKey = QStringLiteral("geometry");
if (windowState.contains(geoKey)) {
@@ -335,9 +350,9 @@ void GeneralHelper::doRestoreWindowState(QQuickWindow *w, const QVariantMap &win
QRect rect = windowState[geoKey].value();
- w->setGeometry(rect);
+ m_edit3DWindow->setGeometry(rect);
if (maximized)
- w->showMaximized();
+ m_edit3DWindow->showMaximized();
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
index a6b66907488..f36e7458173 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
#include
@@ -74,10 +75,12 @@ public:
Q_INVOKABLE void storeToolState(const QString &sceneId, const QString &tool,
const QVariant &state, int delayEmit = 0);
void initToolStates(const QString &sceneId, const QVariantMap &toolStates);
- Q_INVOKABLE void storeWindowState(QQuickWindow *w);
- void restoreWindowState(QQuickWindow *w);
+ Q_INVOKABLE void storeWindowState();
+ void restoreWindowState();
Q_INVOKABLE void enableItemUpdate(QQuickItem *item, bool enable);
Q_INVOKABLE QVariantMap getToolStates(const QString &sceneId);
+ void setEdit3DWindow(QQuickWindow *w);
+ QString globalStateId() const;
bool isMacOS() const;
@@ -86,7 +89,7 @@ signals:
void toolStateChanged(const QString &sceneId, const QString &tool, const QVariant &toolState);
private slots:
- void doRestoreWindowState(QQuickWindow *w, const QVariantMap &windowState);
+ void doRestoreWindowState(const QVariantMap &windowState);
private:
void handlePendingToolStateUpdate();
@@ -95,6 +98,7 @@ private:
QTimer m_toolStateUpdateTimer;
QHash m_toolStates;
QHash m_toolStatesPending;
+ QPointer m_edit3DWindow;
};
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp
index d772844b3c6..2b5f805f174 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp
@@ -68,6 +68,8 @@
#include
#include
#include
+#include
+#include
#include
#include
@@ -336,10 +338,6 @@ void NodeInstanceServer::update3DViewState(const Update3dViewStateCommand &/*com
{
}
-void NodeInstanceServer::enable3DView(const Enable3DViewCommand &/*command*/)
-{
-}
-
void NodeInstanceServer::changeSelection(const ChangeSelectionCommand & /*command*/)
{
}
@@ -1395,6 +1393,16 @@ QStringList NodeInstanceServer::dummyDataDirectories(const QString& directoryPat
}
}
+void NodeInstanceServer::inputEvent(const InputEventCommand &command)
+{
+ Q_UNUSED(command)
+}
+
+void NodeInstanceServer::view3DAction(const View3DActionCommand &command)
+{
+ Q_UNUSED(command)
+}
+
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h
index 1c3ee59791c..e2a5528bcf1 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h
@@ -102,7 +102,6 @@ public:
void createScene(const CreateSceneCommand &command) override;
void clearScene(const ClearSceneCommand &command) override;
void update3DViewState(const Update3dViewStateCommand &command) override;
- void enable3DView(const Enable3DViewCommand &command) override;
void removeInstances(const RemoveInstancesCommand &command) override;
void removeProperties(const RemovePropertiesCommand &command) override;
void reparentInstances(const ReparentInstancesCommand &command) override;
@@ -112,6 +111,8 @@ public:
void token(const TokenCommand &command) override;
void removeSharedMemory(const RemoveSharedMemoryCommand &command) override;
void changeSelection(const ChangeSelectionCommand &command) override;
+ void inputEvent(const InputEventCommand &command) override;
+ void view3DAction(const View3DActionCommand &command) override;
ServerNodeInstance instanceForId(qint32 id) const;
bool hasInstanceForId(qint32 id) const;
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
index a30f972025e..3b8cb04a909 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -41,7 +41,6 @@
#include "clearscenecommand.h"
#include "reparentinstancescommand.h"
#include "update3dviewstatecommand.h"
-#include "enable3dviewcommand.h"
#include "changevaluescommand.h"
#include "changebindingscommand.h"
#include "changeidscommand.h"
@@ -63,6 +62,8 @@
#include "drop3dlibraryitemcommand.h"
#include "puppettocreatorcommand.h"
#include "view3dclosedcommand.h"
+#include "inputeventcommand.h"
+#include "view3dactioncommand.h"
#include "dummycontextobject.h"
#include "../editor3d/generalhelper.h"
@@ -73,6 +74,7 @@
#include "../editor3d/linegeometry.h"
#include
+#include
#include
#include
@@ -80,6 +82,8 @@
#include
#include
#include
+#include
+#include
#ifdef QUICK3D_MODULE
#include
@@ -165,53 +169,72 @@ bool Qt5InformationNodeInstanceServer::dropAcceptable(QDragMoveEvent *event) con
return canBeDropped == "true" || canBeDropped == "True";
}
-QObject *Qt5InformationNodeInstanceServer::createEditView3D(QQmlEngine *engine)
+void Qt5InformationNodeInstanceServer::createEditView3D()
{
#ifdef QUICK3D_MODULE
- auto helper = new QmlDesigner::Internal::GeneralHelper();
- QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged,
- this, &Qt5InformationNodeInstanceServer::handleToolStateChanged);
- engine->rootContext()->setContextProperty("_generalHelper", helper);
- m_3dHelper = helper;
+ static bool showEditView = qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW");
+
qmlRegisterType("MouseArea3D", 1, 0, "MouseArea3D");
qmlRegisterType("CameraGeometry", 1, 0, "CameraGeometry");
qmlRegisterType("GridGeometry", 1, 0, "GridGeometry");
qmlRegisterType("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
qmlRegisterType("LineGeometry", 1, 0, "LineGeometry");
-#endif
- QQmlComponent component(engine, QUrl("qrc:/qtquickplugin/mockfiles/EditView3D.qml"));
+ auto helper = new QmlDesigner::Internal::GeneralHelper();
+ QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged,
+ this, &Qt5InformationNodeInstanceServer::handleToolStateChanged);
+ engine()->rootContext()->setContextProperty("_generalHelper", helper);
+ m_3dHelper = helper;
- QWindow *window = qobject_cast(component.create());
+ QQmlComponent component(engine());
+ if (showEditView) {
+ component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/EditWindow3D.qml"));
+ m_editWindow3D = qobject_cast(component.create());
+ m_editView3DRootItem = QQmlProperty::read(m_editWindow3D, "editViewRoot").value();
- if (!window) {
- qWarning() << "Could not create edit view 3D: " << component.errors();
- return nullptr;
+ //For macOS we have to use the 4.1 core profile
+ QSurfaceFormat surfaceFormat = m_editWindow3D->requestedFormat();
+ surfaceFormat.setVersion(4, 1);
+ surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
+ m_editWindow3D->setFormat(surfaceFormat);
+ } else {
+ m_editView3D = new QQuickView(quickView()->engine(), quickView());
+ m_editView3D->setFormat(quickView()->format());
+ DesignerSupport::createOpenGLContext(m_editView3D.data());
+ component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/EditView3D.qml"));
+ m_editView3DRootItem = qobject_cast(component.create());
}
- window->installEventFilter(this);
- QObject::connect(window, SIGNAL(selectionChanged(QVariant)),
+ if (!m_editView3DRootItem) {
+ qWarning() << "Could not create edit view 3D: " << component.errors();
+ return;
+ }
+
+ if (!showEditView) {
+ DesignerSupport::setRootItem(m_editView3D, m_editView3DRootItem);
+ } else {
+ m_editView3DRootItem->installEventFilter(this);
+ QQmlProperty showButtonsProperty(m_editView3DRootItem, "showButtons", context());
+ showButtonsProperty.write(QVariant(true));
+ }
+
+ QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)),
this, SLOT(handleSelectionChanged(QVariant)));
- QObject::connect(window, SIGNAL(commitObjectProperty(QVariant, QVariant)),
+ QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)),
this, SLOT(handleObjectPropertyCommit(QVariant, QVariant)));
- QObject::connect(window, SIGNAL(changeObjectProperty(QVariant, QVariant)),
+ QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)),
this, SLOT(handleObjectPropertyChange(QVariant, QVariant)));
QObject::connect(&m_propertyChangeTimer, &QTimer::timeout,
this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout);
QObject::connect(&m_selectionChangeTimer, &QTimer::timeout,
this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout);
+ QObject::connect(&m_renderTimer, &QTimer::timeout,
+ this, &Qt5InformationNodeInstanceServer::doRender3DEditView);
- //For macOS we have to use the 4.1 core profile
- QSurfaceFormat surfaceFormat = window->requestedFormat();
- surfaceFormat.setVersion(4, 1);
- surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
- window->setFormat(surfaceFormat);
-
-#ifdef QUICK3D_MODULE
- helper->setParent(window);
+ helper->setParent(m_editView3DRootItem);
+ if (showEditView)
+ helper->setEdit3DWindow(m_editWindow3D);
#endif
-
- return window;
}
// The selection has changed in the edit view 3D. Empty list indicates selection is cleared.
@@ -357,10 +380,10 @@ void Qt5InformationNodeInstanceServer::handleNode3DDestroyed(QObject *obj)
{
#ifdef QUICK3D_MODULE
if (qobject_cast(obj)) {
- QMetaObject::invokeMethod(m_editView3D, "releaseCameraGizmo",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "releaseCameraGizmo",
Q_ARG(QVariant, objectToVariant(obj)));
} else if (qobject_cast(obj)) {
- QMetaObject::invokeMethod(m_editView3D, "releaseLightGizmo",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "releaseLightGizmo",
Q_ARG(QVariant, objectToVariant(obj)));
}
removeNode3D(obj);
@@ -376,29 +399,41 @@ void Qt5InformationNodeInstanceServer::updateView3DRect(QObject *view3D)
viewPortrect = QRectF(0., 0., view3D->property("width").toDouble(),
view3D->property("height").toDouble());
}
- QQmlProperty viewPortProperty(m_editView3D, "viewPortRect", context());
+ QQmlProperty viewPortProperty(m_editView3DRootItem, "viewPortRect", context());
viewPortProperty.write(viewPortrect);
}
void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D()
{
+#ifdef QUICK3D_MODULE
// Active scene change handling on qml side is async, so a deleted importScene would crash
// editView when it updates next. Disable/enable edit view update synchronously to avoid this.
QVariant activeSceneVar = objectToVariant(m_active3DScene);
- QMetaObject::invokeMethod(m_editView3D, "enableEditViewUpdate",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "enableEditViewUpdate",
Q_ARG(QVariant, activeSceneVar));
ServerNodeInstance sceneInstance = active3DSceneInstance();
- QVariant sceneInstanceVar;
- QQmlProperty sceneIdProperty(m_editView3D, "sceneId", context());
+ QVariant sceneIdVar;
+ QQmlProperty sceneIdProperty(m_editView3DRootItem, "sceneId", context());
+ const QString sceneId = sceneInstance.id();
if (sceneInstance.isValid())
- sceneInstanceVar = QVariant::fromValue(sceneInstance.id());
- sceneIdProperty.write(sceneInstanceVar);
+ sceneIdVar = QVariant::fromValue(sceneId);
+ sceneIdProperty.write(sceneIdVar);
- QQmlProperty sceneProperty(m_editView3D, "activeScene", context());
+ QQmlProperty sceneProperty(m_editView3DRootItem, "activeScene", context());
sceneProperty.write(activeSceneVar);
+ auto helper = qobject_cast(m_3dHelper);
+ QVariantMap toolStates;
+ if (helper)
+ toolStates = helper->getToolStates(sceneId);
+ toolStates.insert("sceneInstanceId", QVariant::fromValue(sceneInstance.instanceId()));
+
+ nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::ActiveSceneChanged,
+ toolStates});
+
updateView3DRect(m_active3DView);
+#endif
}
void Qt5InformationNodeInstanceServer::removeNode3D(QObject *node)
@@ -439,11 +474,11 @@ void Qt5InformationNodeInstanceServer::resolveSceneRoots()
if (newRoot != oldRoot) {
if (qobject_cast(node)) {
- QMetaObject::invokeMethod(m_editView3D, "updateCameraGizmoScene",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "updateCameraGizmoScene",
Q_ARG(QVariant, objectToVariant(newRoot)),
Q_ARG(QVariant, objectToVariant(node)));
} else if (qobject_cast(node)) {
- QMetaObject::invokeMethod(m_editView3D, "updateLightGizmoScene",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "updateLightGizmoScene",
Q_ARG(QVariant, objectToVariant(newRoot)),
Q_ARG(QVariant, objectToVariant(node)));
}
@@ -467,11 +502,65 @@ ServerNodeInstance Qt5InformationNodeInstanceServer::active3DSceneInstance() con
return sceneInstance;
}
+void Qt5InformationNodeInstanceServer::render3DEditView()
+{
+ m_needRender = true;
+ if (!m_renderTimer.isActive())
+ m_renderTimer.start(0);
+}
+
+// render the 3D edit view and send the result to creator process
+void Qt5InformationNodeInstanceServer::doRender3DEditView()
+{
+ static bool showEditView = qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW");
+ if (m_editView3DRootItem && !showEditView) {
+ auto t = std::chrono::steady_clock::now();
+ if (!m_editView3DContentItem) {
+ m_editView3DContentItem = QQmlProperty::read(m_editView3DRootItem, "contentItem").value();
+ if (m_editView3DContentItem) {
+ designerSupport()->refFromEffectItem(m_editView3DContentItem, false);
+ QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(m_editView3DContentItem);
+ }
+ }
+
+ std::function updateNodesRecursive;
+ updateNodesRecursive = [&updateNodesRecursive](QQuickItem *item) {
+ for (QQuickItem *childItem : item->childItems())
+ updateNodesRecursive(childItem);
+ DesignerSupport::updateDirtyNode(item);
+ };
+ updateNodesRecursive(m_editView3DContentItem);
+
+ QSizeF size = qobject_cast(m_editView3DContentItem)->size();
+ QRectF renderRect(QPointF(0., 0.), size);
+ QImage renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem,
+ renderRect, size.toSize());
+
+ // There's no instance related to image, so instance id is -1.
+ // Key number is selected so that it is unlikely to conflict other ImageContainer use.
+ const qint32 edit3DKey = 2100000000;
+ auto imgContainer = ImageContainer(-1, renderImage, edit3DKey);
+
+ // send the rendered image to creator process
+ nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::Render3DView,
+ QVariant::fromValue(imgContainer)});
+ qDebug() << "\x1b[42m \x1b[1m" << __FUNCTION__
+ << ", t=" << std::chrono::duration_cast(std::chrono::steady_clock::now()-t).count()
+ << "\x1b[m";
+
+ if (m_needRender) {
+ m_renderTimer.start(0);
+ m_needRender = false;
+ }
+ }
+}
+
Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
Qt5NodeInstanceServer(nodeInstanceClient)
{
m_propertyChangeTimer.setInterval(100);
m_selectionChangeTimer.setSingleShot(true);
+ m_renderTimer.setSingleShot(true);
}
void Qt5InformationNodeInstanceServer::sendTokenBack()
@@ -523,7 +612,6 @@ bool Qt5InformationNodeInstanceServer::isDirtyRecursiveForParentInstances(QQuick
return false;
return isDirtyRecursiveForParentInstances(parentItem);
-
}
return false;
@@ -549,12 +637,14 @@ QList Qt5InformationNodeInstanceServer::createInstances(
{
const auto createdInstances = NodeInstanceServer::createInstances(container);
- if (m_editView3D) {
+ if (m_editView3DRootItem) {
add3DViewPorts(createdInstances);
add3DScenes(createdInstances);
createCameraAndLightGizmos(createdInstances);
}
+ render3DEditView();
+
return createdInstances;
}
@@ -586,7 +676,7 @@ void Qt5InformationNodeInstanceServer::createCameraAndLightGizmos(
while (cameraIt != cameras.constEnd()) {
const auto cameraObjs = cameraIt.value();
for (auto &obj : cameraObjs) {
- QMetaObject::invokeMethod(m_editView3D, "addCameraGizmo",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "addCameraGizmo",
Q_ARG(QVariant, objectToVariant(cameraIt.key())),
Q_ARG(QVariant, objectToVariant(obj)));
}
@@ -596,7 +686,7 @@ void Qt5InformationNodeInstanceServer::createCameraAndLightGizmos(
while (lightIt != lights.constEnd()) {
const auto lightObjs = lightIt.value();
for (auto &obj : lightObjs) {
- QMetaObject::invokeMethod(m_editView3D, "addLightGizmo",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "addLightGizmo",
Q_ARG(QVariant, objectToVariant(lightIt.key())),
Q_ARG(QVariant, objectToVariant(obj)));
}
@@ -791,8 +881,8 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QListinitToolStates(it.key(), it.value());
++it;
}
- helper->restoreWindowState(qobject_cast(m_editView3D));
+ helper->restoreWindowState();
+ if (toolStates.contains(helper->globalStateId())
+ && toolStates[helper->globalStateId()].contains("rootSize")) {
+ m_editView3DRootItem->setSize(toolStates[helper->globalStateId()]["rootSize"].value());
+ }
}
updateActiveSceneToEditView3D();
@@ -900,7 +994,7 @@ void Qt5InformationNodeInstanceServer::reparentInstances(const ReparentInstances
Qt5NodeInstanceServer::reparentInstances(command);
- if (m_editView3D)
+ if (m_editView3DRootItem)
resolveSceneRoots();
}
@@ -991,7 +1085,7 @@ void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const Qml
void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command)
{
- if (!m_editView3D)
+ if (!m_editView3DRootItem)
return;
if (m_selectionChangeTimer.isActive()) {
@@ -1033,16 +1127,18 @@ void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionComm
// Ensure the UI has enough selection box items. If it doesn't yet have them, which can be the
// case when the first selection processed is a multiselection, we wait a bit as
// using the new boxes immediately leads to visual glitches.
- int boxCount = m_editView3D->property("selectionBoxes").value().size();
+ int boxCount = m_editView3DRootItem->property("selectionBoxes").value().size();
if (boxCount < selectedObjs.size()) {
- QMetaObject::invokeMethod(m_editView3D, "ensureSelectionBoxes",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "ensureSelectionBoxes",
Q_ARG(QVariant, QVariant::fromValue(selectedObjs.size())));
m_pendingSelectionChangeCommand = command;
m_selectionChangeTimer.start(100);
} else {
- QMetaObject::invokeMethod(m_editView3D, "selectObjects",
+ QMetaObject::invokeMethod(m_editView3DRootItem, "selectObjects",
Q_ARG(QVariant, QVariant::fromValue(selectedObjs)));
}
+
+ render3DEditView();
}
void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command)
@@ -1060,6 +1156,8 @@ void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCo
refreshBindings();
startRenderTimer();
+
+ render3DEditView();
}
void Qt5InformationNodeInstanceServer::removeInstances(const RemoveInstancesCommand &command)
@@ -1074,45 +1172,118 @@ void Qt5InformationNodeInstanceServer::removeInstances(const RemoveInstancesComm
resolveSceneRoots();
}
- if (m_editView3D && (!m_active3DScene || !m_active3DView)) {
+ if (m_editView3DRootItem && (!m_active3DScene || !m_active3DView)) {
if (!m_active3DScene && !m_3DSceneMap.isEmpty())
m_active3DScene = m_3DSceneMap.begin().key();
m_active3DView = findView3DForSceneRoot(m_active3DScene);
updateActiveSceneToEditView3D();
}
+ render3DEditView();
+}
+
+void Qt5InformationNodeInstanceServer::inputEvent(const InputEventCommand &command)
+{
+ if (m_editView3D) {
+ if (command.type() == QEvent::Wheel) {
+ QWheelEvent *we
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
+ = new QWheelEvent(command.pos(), command.pos(), {0, 0}, {0, command.angleDelta()},
+ command.buttons(), command.modifiers(), Qt::NoScrollPhase,
+ false);
+#else
+ = new QWheelEvent(command.pos(), command.pos(), {0, 0}, {0, command.angleDelta()},
+ 0, Qt::Horizontal, command.buttons(), command.modifiers(),
+ Qt::NoScrollPhase, Qt::MouseEventNotSynthesized);
+#endif
+
+ QGuiApplication::postEvent(m_editView3D, we);
+ } else {
+ auto me = new QMouseEvent(command.type(), command.pos(), command.button(),
+ command.buttons(), command.modifiers());
+ QGuiApplication::postEvent(m_editView3D, me);
+ }
+
+ render3DEditView();
+ }
+}
+
+void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &command)
+{
+ QVariantMap updatedState;
+
+ switch (command.type()) {
+ case View3DActionCommand::MoveTool:
+ updatedState.insert("groupTransform", 0);
+ break;
+ case View3DActionCommand::RotateTool:
+ updatedState.insert("groupTransform", 1);
+ break;
+ case View3DActionCommand::ScaleTool:
+ updatedState.insert("groupTransform", 2);
+ break;
+ case View3DActionCommand::FitToView:
+ QMetaObject::invokeMethod(m_editView3DRootItem, "fitToView");
+ break;
+ case View3DActionCommand::SelectionModeToggle:
+ updatedState.insert("groupSelect", command.isEnabled() ? 0 : 1);
+ break;
+ case View3DActionCommand::CameraToggle:
+ updatedState.insert("usePerspective", command.isEnabled());
+ break;
+ case View3DActionCommand::OrientationToggle:
+ updatedState.insert("globalOrientation", command.isEnabled());
+ break;
+ case View3DActionCommand::EditLightToggle:
+ updatedState.insert("showEditLight", command.isEnabled());
+ break;
+ default:
+ break;
+ }
+
+ if (!updatedState.isEmpty()) {
+ QMetaObject::invokeMethod(m_editView3DRootItem, "updateToolStates",
+ Q_ARG(QVariant, updatedState),
+ Q_ARG(QVariant, QVariant::fromValue(false)));
+ }
+
+ render3DEditView();
+}
+
+void Qt5InformationNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
+{
+ Qt5NodeInstanceServer::changeAuxiliaryValues(command);
+ render3DEditView();
}
// update 3D view window state when the main app window state change
void Qt5InformationNodeInstanceServer::update3DViewState(const Update3dViewStateCommand &command)
{
- auto window = qobject_cast(m_editView3D);
- if (window) {
+#ifdef QUICK3D_MODULE
+ if (command.type() == Update3dViewStateCommand::SizeChange) {
+ if (m_editView3DRootItem) {
+ m_editView3DRootItem->setSize(command.size());
+ auto helper = qobject_cast(m_3dHelper);
+ if (helper)
+ helper->storeToolState(helper->globalStateId(), "rootSize", QVariant(command.size()), 0);
+ render3DEditView();
+ }
+ } else if (m_editWindow3D) {
if (command.type() == Update3dViewStateCommand::StateChange) {
if (command.previousStates() & Qt::WindowMinimized) // main window expanded from minimize state
- window->show();
+ m_editWindow3D->show();
else if (command.currentStates() & Qt::WindowMinimized) // main window minimized
- window->hide();
+ m_editWindow3D->hide();
} else if (command.type() == Update3dViewStateCommand::ActiveChange) {
- window->setFlag(Qt::WindowStaysOnTopHint, command.isActive());
+ m_editWindow3D->setFlag(Qt::WindowStaysOnTopHint, command.isActive());
// main window has a popup open, lower the edit view 3D so that the pop up is visible
if (command.hasPopup())
- window->lower();
+ m_editWindow3D->lower();
}
}
-}
-
-void Qt5InformationNodeInstanceServer::enable3DView(const Enable3DViewCommand &command)
-{
- // TODO: this method is not currently in use as the 3D view is currently enabled by resetting the puppet.
- // It should however be implemented here.
-
- auto window = qobject_cast(m_editView3D);
- if (window && !command.isEnable()) {
- // TODO: remove the 3D view
- } else if (!window && command.isEnable()) {
- // TODO: create the 3D view
- }
+#else
+ Q_UNUSED(command)
+#endif
}
} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
index 12b2f12821a..1e4d70577b0 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
@@ -32,6 +32,7 @@
#include
#include
+#include
QT_BEGIN_NAMESPACE
class QDragMoveEvent;
@@ -49,7 +50,6 @@ public:
void reparentInstances(const ReparentInstancesCommand &command) override;
void clearScene(const ClearSceneCommand &command) override;
void update3DViewState(const Update3dViewStateCommand &command) override;
- void enable3DView(const Enable3DViewCommand &command) override;
void createScene(const CreateSceneCommand &command) override;
void completeComponent(const CompleteComponentCommand &command) override;
void token(const TokenCommand &command) override;
@@ -57,6 +57,9 @@ public:
void changeSelection(const ChangeSelectionCommand &command) override;
void changePropertyValues(const ChangeValuesCommand &command) override;
void removeInstances(const RemoveInstancesCommand &command) override;
+ void inputEvent(const InputEventCommand &command) override;
+ void view3DAction(const View3DActionCommand &command) override;
+ void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) override;
private slots:
void handleSelectionChanged(const QVariant &objs);
@@ -82,7 +85,7 @@ protected:
private:
void handleObjectPropertyChangeTimeout();
void handleSelectionChangeTimeout();
- QObject *createEditView3D(QQmlEngine *engine);
+ void createEditView3D();
void setup3DEditView(const QList &instanceList,
const QHash &toolStates);
void createCameraAndLightGizmos(const QList &instanceList) const;
@@ -104,8 +107,13 @@ private:
void removeNode3D(QObject *node);
void resolveSceneRoots();
ServerNodeInstance active3DSceneInstance() const;
+ void render3DEditView();
+ void doRender3DEditView();
- QObject *m_editView3D = nullptr;
+ QPointer m_editView3D;
+ QPointer m_editWindow3D;
+ QQuickItem *m_editView3DRootItem = nullptr;
+ QQuickItem *m_editView3DContentItem = nullptr;
QSet m_view3Ds;
QMultiHash m_3DSceneMap; // key: scene root, value: node
QObject *m_active3DView;
@@ -115,10 +123,12 @@ private:
QList m_tokenList;
QTimer m_propertyChangeTimer;
QTimer m_selectionChangeTimer;
+ QTimer m_renderTimer;
QVariant m_changedNode;
PropertyName m_changedProperty;
ChangeSelectionCommand m_pendingSelectionChangeCommand;
QObject *m_3dHelper = nullptr;
+ bool m_needRender = false;
};
} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp
index dbee5969be4..be54efd2c54 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp
@@ -70,8 +70,10 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) :
* because we want to be able to show the 3D Edit View
* as a normal QQuickView.
* The DesignerWindowManager prevents any window from actually being shown. */
- if (!qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE"))
+ if (!qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")
+ || !qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW")) {
DesignerSupport::activateDesignerWindowManager();
+ }
setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this));
initializeSocket();
} else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) {
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
index 39653af4129..b503afb655c 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
@@ -72,6 +72,7 @@ void Qt5NodeInstanceServer::initializeView()
DesignerSupport::createOpenGLContext(m_quickView.data());
if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")
+ && qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW")
&& QCoreApplication::arguments().at(2) == "editormode") {
/* In '3d editormode' we do not use the DesignerWindowManager
* and since we do not show the QQuickView we have to manually create the OpenGL context */
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
index b128161aeee..395b56e2416 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
@@ -627,16 +627,18 @@ QList ServerNodeInstance::allItemsRecursive() const
QString ServerNodeInstance::id() const
{
- return m_nodeInstance->id();
+ if (isValid())
+ return m_nodeInstance->id();
+
+ return {};
}
qint32 ServerNodeInstance::instanceId() const
{
- if (isValid()) {
+ if (isValid())
return m_nodeInstance->instanceId();
- } else {
- return -1;
- }
+
+ return -1;
}
QList ServerNodeInstance::stateInstances() const
diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc
index 79ffb4934f2..749517125f5 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc
+++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc
@@ -8,6 +8,7 @@
mockfiles/GenericBackend.qml
mockfiles/Dialog.qml
mockfiles/EditView3D.qml
+ mockfiles/EditWindow3D.qml
mockfiles/EditCameraController.qml
mockfiles/Arrow.qml
mockfiles/AutoScaleHelper.qml
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml
index bbc2444ac12..a353d9fec53 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml
@@ -146,6 +146,12 @@ Rectangle {
tooltip: qsTr("Toggles whether this item is exported as an alias property of the root item.")
}
}
+ Item { //dummy object to preserve layout in case of multiselection
+ Layout.preferredWidth: 20
+ Layout.preferredHeight: 20
+ enabled: modelNodeBackend.multiSelection
+ visible: enabled
+ }
}
Label {
@@ -154,13 +160,11 @@ Rectangle {
SecondColumnLayout {
enabled: !modelNodeBackend.multiSelection
- visible: enabled
spacing: 2
LineEdit {
id: annotationEdit
- enabled: annotationEditor.hasAuxData
- visible: enabled
+ visible: annotationEditor.hasAuxData
backendValue: backendValues.customId__AUX
placeholderText: qsTr("customId")
@@ -176,8 +180,8 @@ Rectangle {
StudioControls.AbstractButton {
id: editAnnotationButton
- enabled: annotationEditor.hasAuxData
- visible: enabled
+ visible: annotationEditor.hasAuxData
+
Layout.preferredWidth: 22
Layout.preferredHeight: 22
width: 22
@@ -185,14 +189,13 @@ Rectangle {
buttonIcon: StudioTheme.Constants.edit
onClicked: annotationEditor.showWidget()
-
onHoveredChanged: annotationEditor.checkAux()
}
StudioControls.AbstractButton {
id: removeAnnotationButton
- enabled: annotationEditor.hasAuxData
- visible: enabled
+ visible: annotationEditor.hasAuxData
+
Layout.preferredWidth: 22
Layout.preferredHeight: 22
width: 22
@@ -200,19 +203,18 @@ Rectangle {
buttonIcon: StudioTheme.Constants.closeCross
onClicked: annotationEditor.removeFullAnnotation()
-
onHoveredChanged: annotationEditor.checkAux()
}
StudioControls.AbstractButton {
id: addAnnotationButton
- enabled: !annotationEditor.hasAuxData
- visible: enabled
+ visible: !annotationEditor.hasAuxData
buttonIcon: qsTr("Add Annotation")
iconFont: StudioTheme.Constants.font
Layout.fillWidth: true
Layout.preferredWidth: 240
+ width: 240
onClicked: annotationEditor.showWidget()
@@ -222,8 +224,7 @@ Rectangle {
Item {
Layout.preferredWidth: 22
Layout.preferredHeight: 22
- enabled: !annotationEditor.hasAuxData
- visible: enabled
+ visible: !annotationEditor.hasAuxData
}
AnnotationEditor {
diff --git a/share/qtcreator/templates/wizards/classes/python/file.py b/share/qtcreator/templates/wizards/classes/python/file.py
index adcbc1ed2d0..5698022dd85 100644
--- a/share/qtcreator/templates/wizards/classes/python/file.py
+++ b/share/qtcreator/templates/wizards/classes/python/file.py
@@ -21,6 +21,7 @@ from PyQt5 import QtQuick
@endif
@endif
+
@if '%{Base}'
class %{Class}(%{Base}):
@else
@@ -29,11 +30,9 @@ class %{Class}:
def __init__(self):
@if '%{Base}' === 'QWidget'
QtWidgets.QWidget.__init__(self)
-@endif
-@if '%{Base}' === 'QMainWindow'
+@elif '%{Base}' === 'QMainWindow'
QtWidgets.QMainWindow.__init__(self)
-@if '%{Base}' === 'QQuickItem'
+@elif '%{Base}' === 'QQuickItem'
QtQuick.QQuickItem.__init__(self)
@endif
pass
-
diff --git a/share/qtcreator/templates/wizards/classes/python/wizard.json b/share/qtcreator/templates/wizards/classes/python/wizard.json
index 552c3f15a0e..aeebd1f2a30 100644
--- a/share/qtcreator/templates/wizards/classes/python/wizard.json
+++ b/share/qtcreator/templates/wizards/classes/python/wizard.json
@@ -46,7 +46,7 @@
"data":
{
"items": [ { "trKey": "", "value": "" },
- "QObject", "QWidget", "QMainWindow", "QDeclarativeItem" ]
+ "QObject", "QWidget", "QMainWindow", "QDeclarativeItem", "QQuickItem" ]
}
},
{
diff --git a/share/qtcreator/templates/wizards/files/python/file.py b/share/qtcreator/templates/wizards/files/python/file.py
index 003f8414973..fcb605f9f72 100644
--- a/share/qtcreator/templates/wizards/files/python/file.py
+++ b/share/qtcreator/templates/wizards/files/python/file.py
@@ -1,4 +1,4 @@
# This Python file uses the following encoding: utf-8
-# if__name__ == "__main__":
+# if __name__ == "__main__":
# pass
diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/empty/wizard.json b/share/qtcreator/templates/wizards/projects/qtquickapplication/empty/wizard.json
index 38f68550882..444f22d2de5 100644
--- a/share/qtcreator/templates/wizards/projects/qtquickapplication/empty/wizard.json
+++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/empty/wizard.json
@@ -83,9 +83,18 @@
"persistenceKey": "QtQuick.minimumQtVersion",
"data":
{
- "index": 2,
+ "index": 3,
"items":
[
+ {
+ "trKey": "Qt 5.15",
+ "value":
+ {
+ "QtQuickVersion": "2.15",
+ "QtQuickWindowVersion": "2.15",
+ "QtQuickVirtualKeyboardImport": "QtQuick.VirtualKeyboard 2.15"
+ }
+ },
{
"trKey": "Qt 5.14",
"value":
diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/scroll/wizard.json b/share/qtcreator/templates/wizards/projects/qtquickapplication/scroll/wizard.json
index 576e47d3e8a..1ad41e72302 100644
--- a/share/qtcreator/templates/wizards/projects/qtquickapplication/scroll/wizard.json
+++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/scroll/wizard.json
@@ -85,9 +85,18 @@
"persistenceKey": "QtQuick.minimumQtVersion",
"data":
{
- "index": 2,
+ "index": 3,
"items":
[
+ {
+ "trKey": "Qt 5.15",
+ "value":
+ {
+ "QtQuickVersion": "2.15",
+ "QtQuickControlsVersion": "2.15",
+ "QtQuickVirtualKeyboardImport": "QtQuick.VirtualKeyboard 2.15"
+ }
+ },
{
"trKey": "Qt 5.14",
"value":
diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/stack/wizard.json b/share/qtcreator/templates/wizards/projects/qtquickapplication/stack/wizard.json
index 34eca289d58..e3966ca5231 100644
--- a/share/qtcreator/templates/wizards/projects/qtquickapplication/stack/wizard.json
+++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/stack/wizard.json
@@ -85,9 +85,18 @@
"persistenceKey": "QtQuick.minimumQtVersion",
"data":
{
- "index": 2,
+ "index": 3,
"items":
[
+ {
+ "trKey": "Qt 5.15",
+ "value":
+ {
+ "QtQuickVersion": "2.15",
+ "QtQuickControlsVersion": "2.15",
+ "QtQuickVirtualKeyboardImport": "QtQuick.VirtualKeyboard 2.15"
+ }
+ },
{
"trKey": "Qt 5.14",
"value":
diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/swipe/wizard.json b/share/qtcreator/templates/wizards/projects/qtquickapplication/swipe/wizard.json
index 5f9a544cfc8..67dd9fb711a 100644
--- a/share/qtcreator/templates/wizards/projects/qtquickapplication/swipe/wizard.json
+++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/swipe/wizard.json
@@ -85,9 +85,18 @@
"persistenceKey": "QtQuick.minimumQtVersion",
"data":
{
- "index": 2,
+ "index": 3,
"items":
[
+ {
+ "trKey": "Qt 5.15",
+ "value":
+ {
+ "QtQuickVersion": "2.15",
+ "QtQuickControlsVersion": "2.15",
+ "QtQuickVirtualKeyboardImport": "QtQuick.VirtualKeyboard 2.15"
+ }
+ },
{
"trKey": "Qt 5.14",
"value":
diff --git a/share/qtcreator/templates/wizards/projects/qtquickuiprototype/wizard.json b/share/qtcreator/templates/wizards/projects/qtquickuiprototype/wizard.json
index c1a966b4b2b..ac39bb90be6 100644
--- a/share/qtcreator/templates/wizards/projects/qtquickuiprototype/wizard.json
+++ b/share/qtcreator/templates/wizards/projects/qtquickuiprototype/wizard.json
@@ -40,9 +40,18 @@
"type": "ComboBox",
"data":
{
- "index": 2,
+ "index": 3,
"items":
[
+ {
+ "trKey": "Qt 5.15",
+ "value":
+ {
+ "QtQuickVersion": "2.15",
+ "QtQuickWindowVersion": "2.15",
+ "QtQuickVirtualKeyboardImport": "QtQuick.VirtualKeyboard 2.15"
+ }
+ },
{
"trKey": "Qt 5.14",
"value":
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 0cd77cee29d..f2adb8b6206 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -546,6 +546,7 @@ int main(int argc, char **argv)
#endif
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
+ app.setAttribute(Qt::AA_DisableWindowContextHelpButton);
PluginManager pluginManager;
PluginManager::setPluginIID(QLatin1String("org.qt-project.Qt.QtCreatorPlugin"));
diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt
index ef261231f4d..4cb8e8d925f 100644
--- a/src/libs/CMakeLists.txt
+++ b/src/libs/CMakeLists.txt
@@ -1,5 +1,6 @@
add_subdirectory(3rdparty)
+add_subdirectory(advanceddockingsystem)
add_subdirectory(aggregation)
add_subdirectory(extensionsystem)
add_subdirectory(utils)
diff --git a/src/libs/advanceddockingsystem/CMakeLists.txt b/src/libs/advanceddockingsystem/CMakeLists.txt
new file mode 100644
index 00000000000..ba5deced265
--- /dev/null
+++ b/src/libs/advanceddockingsystem/CMakeLists.txt
@@ -0,0 +1,31 @@
+add_qtc_library(AdvancedDockingSystem
+ DEPENDS Qt5::Widgets Qt5::Core Qt5::Gui Utils
+ SOURCES
+ ads_globals.cpp ads_globals.h
+ dockareatabbar.cpp dockareatabbar.h
+ dockareatitlebar.cpp dockareatitlebar.h
+ dockareawidget.cpp dockareawidget.h
+ dockcomponentsfactory.cpp dockcomponentsfactory.h
+ dockcontainerwidget.cpp dockcontainerwidget.h
+ dockingstatereader.cpp dockingstatereader.h
+ dockmanager.cpp dockmanager.h
+ dockoverlay.cpp dockoverlay.h
+ docksplitter.cpp docksplitter.h
+ dockwidget.cpp dockwidget.h
+ dockwidgettab.cpp dockwidgettab.h
+ elidinglabel.cpp elidinglabel.h
+ floatingdockcontainer.cpp floatingdockcontainer.h
+ floatingdragpreview.cpp floatingdragpreview.h
+ iconprovider.cpp iconprovider.h
+ workspacedialog.cpp workspacedialog.h
+ workspacemodel.cpp workspacemodel.h
+ workspaceview.cpp workspaceview.h
+ workspacedialog.ui
+ resources.qrc
+)
+
+extend_qtc_target(AdvancedDockingSystem
+ INCLUDES linux
+ SOURCES
+ linux/floatingwidgettitlebar.cpp linux/floatingwidgettitlebar.h
+)
diff --git a/src/libs/advanceddockingsystem/LICENSE.LGPLv21 b/src/libs/advanceddockingsystem/LICENSE.LGPLv21
new file mode 100644
index 00000000000..dfcab5e29b7
--- /dev/null
+++ b/src/libs/advanceddockingsystem/LICENSE.LGPLv21
@@ -0,0 +1,514 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
+
+ You may use, distribute and copy the Qt Toolkit under the terms of
+ GNU Lesser General Public License version 2.1, which is displayed below.
+
+-------------------------------------------------------------------------
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/src/libs/advanceddockingsystem/ads_globals.cpp b/src/libs/advanceddockingsystem/ads_globals.cpp
new file mode 100644
index 00000000000..36df8ed869c
--- /dev/null
+++ b/src/libs/advanceddockingsystem/ads_globals.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "ads_globals.h"
+
+#include "dockmanager.h"
+#include "docksplitter.h"
+#include "iconprovider.h"
+
+#include
+#include
+#include
+
+namespace ADS {
+
+namespace internal {
+
+void replaceSplitterWidget(QSplitter *splitter, QWidget *from, QWidget *to)
+{
+ int index = splitter->indexOf(from);
+ from->setParent(nullptr);
+ splitter->insertWidget(index, to);
+}
+
+DockInsertParam dockAreaInsertParameters(DockWidgetArea area)
+{
+ switch (area) {
+ case TopDockWidgetArea:
+ return DockInsertParam(Qt::Vertical, false);
+ case RightDockWidgetArea:
+ return DockInsertParam(Qt::Horizontal, true);
+ case CenterDockWidgetArea:
+ case BottomDockWidgetArea:
+ return DockInsertParam(Qt::Vertical, true);
+ case LeftDockWidgetArea:
+ return DockInsertParam(Qt::Horizontal, false);
+ default:
+ DockInsertParam(Qt::Vertical, false);
+ }
+
+ return DockInsertParam(Qt::Vertical, false);
+}
+
+QPixmap createTransparentPixmap(const QPixmap &source, qreal opacity)
+{
+ QPixmap transparentPixmap(source.size());
+ transparentPixmap.fill(Qt::transparent);
+ QPainter painter(&transparentPixmap);
+ painter.setOpacity(opacity);
+ painter.drawPixmap(0, 0, source);
+ return transparentPixmap;
+}
+
+void hideEmptyParentSplitters(DockSplitter *splitter)
+{
+ while (splitter && splitter->isVisible()) {
+ if (!splitter->hasVisibleContent()) {
+ splitter->hide();
+ }
+ splitter = internal::findParent(splitter);
+ }
+}
+
+void setButtonIcon(QAbstractButton* button,
+ QStyle::StandardPixmap standarPixmap,
+ ADS::eIcon customIconId)
+{
+ // First we try to use custom icons if available
+ QIcon icon = DockManager::iconProvider().customIcon(customIconId);
+ if (!icon.isNull()) {
+ button->setIcon(icon);
+ return;
+ }
+
+ if (Utils::HostOsInfo::isLinuxHost()) {
+ button->setIcon(button->style()->standardIcon(standarPixmap));
+ } else {
+ // The standard icons does not look good on high DPI screens so we create
+ // our own "standard" icon here.
+ QPixmap normalPixmap = button->style()->standardPixmap(standarPixmap, nullptr, button);
+ icon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
+ icon.addPixmap(normalPixmap, QIcon::Normal);
+ button->setIcon(icon);
+ }
+}
+
+} // namespace internal
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/ads_globals.h b/src/libs/advanceddockingsystem/ads_globals.h
new file mode 100644
index 00000000000..4c0b8d6896a
--- /dev/null
+++ b/src/libs/advanceddockingsystem/ads_globals.h
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QSplitter;
+QT_END_NAMESPACE
+
+#ifndef ADS_STATIC
+#ifdef ADVANCEDDOCKINGSYSTEM_LIBRARY
+#define ADS_EXPORT Q_DECL_EXPORT
+#else
+#define ADS_EXPORT Q_DECL_IMPORT
+#endif
+#else
+#define ADS_EXPORT
+#endif
+
+//#define ADS_DEBUG_PRINT
+
+// Define ADS_DEBUG_PRINT to enable a lot of debug output
+#ifdef ADS_DEBUG_PRINT
+#define ADS_PRINT(s) qDebug() << s
+#else
+#define ADS_PRINT(s)
+#endif
+
+// Set ADS_DEBUG_LEVEL to enable additional debug output and to enable layout
+// dumps to qDebug and std::cout after layout changes
+#define ADS_DEBUG_LEVEL 0
+
+namespace ADS {
+
+enum eStateFileVersion { InitialVerison = 0, Version1 = 1, CurrentVersion = Version1 };
+
+class DockSplitter;
+
+enum DockWidgetArea {
+ NoDockWidgetArea = 0x00,
+ LeftDockWidgetArea = 0x01,
+ RightDockWidgetArea = 0x02,
+ TopDockWidgetArea = 0x04,
+ BottomDockWidgetArea = 0x08,
+ CenterDockWidgetArea = 0x10,
+
+ InvalidDockWidgetArea = NoDockWidgetArea,
+ OuterDockAreas = TopDockWidgetArea | LeftDockWidgetArea | RightDockWidgetArea
+ | BottomDockWidgetArea,
+ AllDockAreas = OuterDockAreas | CenterDockWidgetArea
+};
+Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)
+
+enum eTitleBarButton { TitleBarButtonTabsMenu, TitleBarButtonUndock, TitleBarButtonClose };
+
+/**
+ * The different dragging states
+ */
+enum eDragState {
+ DraggingInactive, //!< DraggingInactive
+ DraggingMousePressed, //!< DraggingMousePressed
+ DraggingTab, //!< DraggingTab
+ DraggingFloatingWidget //!< DraggingFloatingWidget
+};
+
+/**
+ * The different icons used in the UI
+ */
+enum eIcon {
+ TabCloseIcon, //!< TabCloseIcon
+ DockAreaMenuIcon, //!< DockAreaMenuIcon
+ DockAreaUndockIcon, //!< DockAreaUndockIcon
+ DockAreaCloseIcon, //!< DockAreaCloseIcon
+
+ IconCount, //!< just a delimiter for range checks
+};
+
+/**
+ * For bitwise combination of dock wdget features
+ */
+enum eBitwiseOperator
+{
+ BitwiseAnd,
+ BitwiseOr
+};
+
+namespace internal {
+const bool restoreTesting = true;
+const bool restore = false;
+const char *const closedProperty = "close";
+const char *const dirtyProperty = "dirty";
+
+/**
+ * Replace the from widget in the given splitter with the To widget
+ */
+void replaceSplitterWidget(QSplitter *splitter, QWidget *from, QWidget *to);
+
+/**
+ * This function walks the splitter tree upwards to hides all splitters
+ * that do not have visible content
+ */
+void hideEmptyParentSplitters(DockSplitter *firstParentSplitter);
+
+/**
+ * Convenience class for QPair to provide better naming than first and
+ * second
+ */
+class DockInsertParam : public QPair
+{
+public:
+ using QPair::QPair;
+ Qt::Orientation orientation() const { return this->first; }
+ bool append() const { return this->second; }
+ int insertOffset() const { return append() ? 1 : 0; }
+};
+
+/**
+ * Returns the insertion parameters for the given dock area
+ */
+DockInsertParam dockAreaInsertParameters(DockWidgetArea area);
+
+/**
+ * Searches for the parent widget of the given type.
+ * Returns the parent widget of the given widget or 0 if the widget is not
+ * child of any widget of type T
+ *
+ * It is not safe to use this function in in DockWidget because only
+ * the current dock widget has a parent. All dock widgets that are not the
+ * current dock widget in a dock area have no parent.
+ */
+template
+T findParent(const QWidget *widget)
+{
+ QWidget *parentWidget = widget->parentWidget();
+ while (parentWidget) {
+ T parentImpl = qobject_cast(parentWidget);
+ if (parentImpl) {
+ return parentImpl;
+ }
+ parentWidget = parentWidget->parentWidget();
+ }
+ return 0;
+}
+
+/**
+ * Creates a semi transparent pixmap from the given pixmap Source.
+ * The Opacity parameter defines the opacity from completely transparent (0.0)
+ * to completely opaque (1.0)
+ */
+QPixmap createTransparentPixmap(const QPixmap &source, qreal opacity);
+
+/**
+ * Helper function for settings flags in a QFlags instance.
+ */
+template
+void setFlag(T &flags, typename T::enum_type flag, bool on = true)
+{
+ flags.setFlag(flag, on);
+}
+
+/**
+ * Helper function for settings tooltips without cluttering the code with
+ * tests for preprocessor macros
+ */
+template
+void setToolTip(QObjectPtr obj, const QString &tip)
+{
+#ifndef QT_NO_TOOLTIP
+ obj->setToolTip(tip);
+#else
+ Q_UNUSED(obj);
+ Q_UNUSED(tip);
+#endif
+}
+
+/**
+ * Helper function to set the icon of a certain button.
+ * Use this function to set the icons for the dock area and dock widget buttons.
+ * The function first uses the CustomIconId to get an icon from the
+ * IconProvider. You can register your custom icons with the icon provider, if
+ * you do not want to use the default buttons and if you do not want to use
+ * stylesheets.
+ * If the IconProvider does not return a valid icon (icon is null), the function
+ * fetches the given standard pixmap from the QStyle.
+ * param[in] Button The button whose icons are to be set
+ * param[in] StandardPixmap The standard pixmap to be used for the button
+ * param[in] CustomIconId The identifier for the custom icon.
+ */
+void setButtonIcon(QAbstractButton *button, QStyle::StandardPixmap standarPixmap,
+ ADS::eIcon CustomIconId);
+
+} // namespace internal
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/advanceddockingsystem-lib.pri b/src/libs/advanceddockingsystem/advanceddockingsystem-lib.pri
new file mode 100644
index 00000000000..57526219853
--- /dev/null
+++ b/src/libs/advanceddockingsystem/advanceddockingsystem-lib.pri
@@ -0,0 +1,58 @@
+shared {
+ DEFINES += ADVANCEDDOCKINGSYSTEM_LIBRARY
+} else {
+ DEFINES += BUILD_ADVANCEDDOCKINGSYSTEM_STATIC_LIB
+}
+
+## Input
+RESOURCES += \
+ resources.qrc
+
+HEADERS += \
+ ads_globals.h \
+ dockareatabbar.h \
+ dockareatitlebar.h \
+ dockareawidget.h \
+ dockcomponentsfactory.h \
+ dockcontainerwidget.h \
+ dockingstatereader.h \
+ dockmanager.h \
+ dockoverlay.h \
+ docksplitter.h \
+ dockwidget.h \
+ dockwidgettab.h \
+ elidinglabel.h \
+ floatingdockcontainer.h \
+ floatingdragpreview.h \
+ iconprovider.h \
+ workspacedialog.h \
+ workspacemodel.h \
+ workspaceview.h
+
+SOURCES += \
+ ads_globals.cpp \
+ dockareatabbar.cpp \
+ dockareatitlebar.cpp \
+ dockareawidget.cpp \
+ dockcomponentsfactory.cpp \
+ dockcontainerwidget.cpp \
+ dockingstatereader.cpp \
+ dockmanager.cpp \
+ dockoverlay.cpp \
+ docksplitter.cpp \
+ dockwidget.cpp \
+ dockwidgettab.cpp \
+ elidinglabel.cpp \
+ floatingdockcontainer.cpp \
+ floatingdragpreview.cpp \
+ iconprovider.cpp \
+ workspacedialog.cpp \
+ workspacemodel.cpp \
+ workspaceview.cpp
+
+FORMS += \
+ workspacedialog.ui
+
+include(linux/linux.pri)
+
+DISTFILES += advanceddockingsystem.pri
diff --git a/src/libs/advanceddockingsystem/advanceddockingsystem.pro b/src/libs/advanceddockingsystem/advanceddockingsystem.pro
new file mode 100644
index 00000000000..30b4a3a77e8
--- /dev/null
+++ b/src/libs/advanceddockingsystem/advanceddockingsystem.pro
@@ -0,0 +1,6 @@
+unix:QMAKE_CXXFLAGS_DEBUG += -O3
+
+INCLUDEPATH += $$PWD $$PWD/linux
+
+include(../../qtcreatorlibrary.pri)
+include(advanceddockingsystem-lib.pri)
diff --git a/src/libs/advanceddockingsystem/advanceddockingsystem.qbs b/src/libs/advanceddockingsystem/advanceddockingsystem.qbs
new file mode 100644
index 00000000000..e2877556f0e
--- /dev/null
+++ b/src/libs/advanceddockingsystem/advanceddockingsystem.qbs
@@ -0,0 +1,48 @@
+import qbs 1.0
+
+QtcLibrary {
+ name: "AdvancedDockingSystem"
+
+ cpp.optimization: "fast"
+ cpp.defines: base.concat("ADVANCEDDOCKINGSYSTEM_LIBRARY")
+ cpp.includePaths: base.concat([".", linux.prefix])
+
+ Depends { name: "Qt"; submodules: ["widgets", "core", "gui"] }
+ Depends { name: "Utils" }
+
+ Group {
+ name: "General"
+ files: [
+ "ads_globals.cpp", "ads_globals.h",
+ "dockareatabbar.cpp", "dockareatabbar.h",
+ "dockareatitlebar.cpp", "dockareatitlebar.h",
+ "dockareawidget.cpp", "dockareawidget.h",
+ "dockcomponentsfactory.cpp", "dockcomponentsfactory.h",
+ "dockcontainerwidget.cpp", "dockcontainerwidget.h",
+ "dockingstatereader.cpp", "dockingstatereader.h",
+ "dockmanager.cpp", "dockmanager.h",
+ "dockoverlay.cpp", "dockoverlay.h",
+ "docksplitter.cpp", "docksplitter.h",
+ "dockwidget.cpp", "dockwidget.h",
+ "dockwidgettab.cpp", "dockwidgettab.h",
+ "elidinglabel.cpp", "elidinglabel.h",
+ "floatingdockcontainer.cpp", "floatingdockcontainer.h",
+ "floatingdragpreview.cpp", "floatingdragpreview.h",
+ "iconprovider.cpp", "iconprovider.h",
+ "workspacedialog.cpp", "workspacedialog.h",
+ "workspacemodel.cpp", "workspacemodel.h",
+ "workspaceview.cpp", "workspaceview.h",
+ "workspacedialog.ui",
+ "resources.qrc"
+ ]
+ }
+
+ Group {
+ name: "Linux"
+ id: linux
+ prefix: "linux/"
+ files: [
+ "floatingwidgettitlebar.cpp", "floatingwidgettitlebar.h"
+ ]
+ }
+}
diff --git a/src/libs/advanceddockingsystem/advanceddockingsystem_dependencies.pri b/src/libs/advanceddockingsystem/advanceddockingsystem_dependencies.pri
new file mode 100644
index 00000000000..df4563c7936
--- /dev/null
+++ b/src/libs/advanceddockingsystem/advanceddockingsystem_dependencies.pri
@@ -0,0 +1,3 @@
+QTC_LIB_NAME = AdvancedDockingSystem
+QTC_LIB_DEPENDS += utils
+INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/advanceddockingsystem
diff --git a/src/libs/advanceddockingsystem/dockareatabbar.cpp b/src/libs/advanceddockingsystem/dockareatabbar.cpp
new file mode 100644
index 00000000000..6c98ebe4fc0
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockareatabbar.cpp
@@ -0,0 +1,402 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockareatabbar.h"
+
+#include "dockareawidget.h"
+#include "dockmanager.h"
+#include "dockoverlay.h"
+#include "dockwidget.h"
+#include "dockwidgettab.h"
+#include "floatingdockcontainer.h"
+#include "floatingdragpreview.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+static Q_LOGGING_CATEGORY(adsLog, "qtc.qmldesigner.advanceddockingsystem", QtWarningMsg)
+
+namespace ADS
+{
+ /**
+ * Private data class of DockAreaTabBar class (pimpl)
+ */
+ struct DockAreaTabBarPrivate
+ {
+ DockAreaTabBar *q;
+ DockAreaWidget *m_dockArea;
+ QWidget *m_tabsContainerWidget;
+ QBoxLayout *m_tabsLayout;
+ int m_currentIndex = -1;
+
+ /**
+ * Private data constructor
+ */
+ DockAreaTabBarPrivate(DockAreaTabBar *parent);
+
+ /**
+ * Update tabs after current index changed or when tabs are removed.
+ * The function reassigns the stylesheet to update the tabs
+ */
+ void updateTabs();
+
+ /**
+ * Convenience function to access first tab
+ */
+ DockWidgetTab *firstTab() const {return q->tab(0);}
+
+ /**
+ * Convenience function to access last tab
+ */
+ DockWidgetTab *lastTab() const {return q->tab(q->count() - 1);}
+ };
+ // struct DockAreaTabBarPrivate
+
+ DockAreaTabBarPrivate::DockAreaTabBarPrivate(DockAreaTabBar *parent)
+ : q(parent)
+ {}
+
+ void DockAreaTabBarPrivate::updateTabs()
+ {
+ // Set active TAB and update all other tabs to be inactive
+ for (int i = 0; i < q->count(); ++i) {
+ auto tabWidget = q->tab(i);
+ if (!tabWidget)
+ continue;
+
+ if (i == m_currentIndex) {
+ tabWidget->show();
+ tabWidget->setActiveTab(true);
+ q->ensureWidgetVisible(tabWidget);
+ } else {
+ tabWidget->setActiveTab(false);
+ }
+ }
+ }
+
+ DockAreaTabBar::DockAreaTabBar(DockAreaWidget *parent)
+ : QScrollArea(parent)
+ , d(new DockAreaTabBarPrivate(this))
+ {
+ d->m_dockArea = parent;
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ setFrameStyle(QFrame::NoFrame);
+ setWidgetResizable(true);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ d->m_tabsContainerWidget = new QWidget();
+ d->m_tabsContainerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ d->m_tabsContainerWidget->setObjectName("tabsContainerWidget");
+ d->m_tabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
+ d->m_tabsLayout->setContentsMargins(0, 0, 0, 0);
+ d->m_tabsLayout->setSpacing(0);
+ d->m_tabsLayout->addStretch(1);
+ d->m_tabsContainerWidget->setLayout(d->m_tabsLayout);
+ setWidget(d->m_tabsContainerWidget);
+ }
+
+ DockAreaTabBar::~DockAreaTabBar() { delete d; }
+
+ void DockAreaTabBar::wheelEvent(QWheelEvent *event)
+ {
+ event->accept();
+ const int direction = event->angleDelta().y();
+ if (direction < 0) {
+ horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
+ } else {
+ horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
+ }
+ }
+
+ void DockAreaTabBar::setCurrentIndex(int index)
+ {
+ if (index == d->m_currentIndex)
+ return;
+
+ if (index < -1 || index > (count() - 1)) {
+ qWarning() << Q_FUNC_INFO << "Invalid index" << index;
+ return;
+ }
+
+ emit currentChanging(index);
+ d->m_currentIndex = index;
+ d->updateTabs();
+ updateGeometry();
+ emit currentChanged(index);
+ }
+
+ int DockAreaTabBar::count() const
+ {
+ // The tab bar contains a stretch item as last item
+ return d->m_tabsLayout->count() - 1;
+ }
+
+ void DockAreaTabBar::insertTab(int index, DockWidgetTab *dockWidgetTab)
+ {
+ d->m_tabsLayout->insertWidget(index, dockWidgetTab);
+ connect(dockWidgetTab, &DockWidgetTab::clicked, this, &DockAreaTabBar::onTabClicked);
+ connect(dockWidgetTab,
+ &DockWidgetTab::closeRequested,
+ this,
+ &DockAreaTabBar::onTabCloseRequested);
+ connect(dockWidgetTab,
+ &DockWidgetTab::closeOtherTabsRequested,
+ this,
+ &DockAreaTabBar::onCloseOtherTabsRequested);
+ connect(dockWidgetTab, &DockWidgetTab::moved, this, &DockAreaTabBar::onTabWidgetMoved);
+ connect(dockWidgetTab,
+ &DockWidgetTab::elidedChanged,
+ this,
+ &DockAreaTabBar::elidedChanged);
+ dockWidgetTab->installEventFilter(this);
+ emit tabInserted(index);
+ if (index <= d->m_currentIndex || d->m_currentIndex == -1) {
+ setCurrentIndex(d->m_currentIndex + 1);
+ }
+ updateGeometry();
+ }
+
+ void DockAreaTabBar::removeTab(DockWidgetTab *dockWidgetTab)
+ {
+ if (!count())
+ return;
+
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ int newCurrentIndex = currentIndex();
+ int removeIndex = d->m_tabsLayout->indexOf(dockWidgetTab);
+ if (count() == 1)
+ newCurrentIndex = -1;
+
+ if (newCurrentIndex > removeIndex) {
+ newCurrentIndex--;
+ } else if (newCurrentIndex == removeIndex) {
+ newCurrentIndex = -1;
+ // First we walk to the right to search for the next visible tab
+ for (int i = (removeIndex + 1); i < count(); ++i) {
+ if (tab(i)->isVisibleTo(this)) {
+ newCurrentIndex = i - 1;
+ break;
+ }
+ }
+
+ // If there is no visible tab right to this tab then we walk to
+ // the left to find a visible tab
+ if (newCurrentIndex < 0) {
+ for (int i = (removeIndex - 1); i >= 0; --i) {
+ if (tab(i)->isVisibleTo(this)) {
+ newCurrentIndex = i;
+ break;
+ }
+ }
+ }
+ }
+
+ emit removingTab(removeIndex);
+ d->m_tabsLayout->removeWidget(dockWidgetTab);
+ dockWidgetTab->disconnect(this);
+ dockWidgetTab->removeEventFilter(this);
+ qCInfo(adsLog) << "NewCurrentIndex " << newCurrentIndex;
+ if (newCurrentIndex != d->m_currentIndex) {
+ setCurrentIndex(newCurrentIndex);
+ } else {
+ d->updateTabs();
+ }
+ updateGeometry();
+ }
+
+ int DockAreaTabBar::currentIndex() const { return d->m_currentIndex; }
+
+ DockWidgetTab *DockAreaTabBar::currentTab() const
+ {
+ if (d->m_currentIndex < 0) {
+ return nullptr;
+ } else {
+ return qobject_cast(
+ d->m_tabsLayout->itemAt(d->m_currentIndex)->widget());
+ }
+ }
+
+ void DockAreaTabBar::onTabClicked()
+ {
+ DockWidgetTab *tab = qobject_cast(sender());
+ if (!tab)
+ return;
+
+ int index = d->m_tabsLayout->indexOf(tab);
+ if (index < 0)
+ return;
+
+ setCurrentIndex(index);
+ emit tabBarClicked(index);
+ }
+
+ void DockAreaTabBar::onTabCloseRequested()
+ {
+ DockWidgetTab *tab = qobject_cast(sender());
+ int index = d->m_tabsLayout->indexOf(tab);
+ closeTab(index);
+ }
+
+ void DockAreaTabBar::onCloseOtherTabsRequested()
+ {
+ auto senderTab = qobject_cast(sender());
+ for (int i = 0; i < count(); ++i) {
+ auto currentTab = tab(i);
+ if (currentTab->isClosable() && !currentTab->isHidden() && currentTab != senderTab) {
+ // If the dock widget is deleted with the closeTab() call, its tab it will no longer
+ // be in the layout, and thus the index needs to be updated to not skip any tabs
+ int offset = currentTab->dockWidget()->features().testFlag(
+ DockWidget::DockWidgetDeleteOnClose)
+ ? 1
+ : 0;
+ closeTab(i);
+ // If the the dock widget blocks closing, i.e. if the flag
+ // CustomCloseHandling is set, and the dock widget is still open,
+ // then we do not need to correct the index
+ if (currentTab->dockWidget()->isClosed()) {
+ i -= offset;
+ }
+ }
+ }
+ }
+
+ DockWidgetTab *DockAreaTabBar::tab(int index) const
+ {
+ if (index >= count() || index < 0)
+ return nullptr;
+
+ return qobject_cast(d->m_tabsLayout->itemAt(index)->widget());
+ }
+
+ void DockAreaTabBar::onTabWidgetMoved(const QPoint &globalPosition)
+ {
+ DockWidgetTab *movingTab = qobject_cast(sender());
+ if (!movingTab)
+ return;
+
+ int fromIndex = d->m_tabsLayout->indexOf(movingTab);
+ auto mousePos = mapFromGlobal(globalPosition);
+ mousePos.rx() = qMax(d->firstTab()->geometry().left(), mousePos.x());
+ mousePos.rx() = qMin(d->lastTab()->geometry().right(), mousePos.x());
+ int toIndex = -1;
+ // Find tab under mouse
+ for (int i = 0; i < count(); ++i) {
+ DockWidgetTab *dropTab = tab(i);
+ if (dropTab == movingTab || !dropTab->isVisibleTo(this)
+ || !dropTab->geometry().contains(mousePos))
+ continue;
+
+ toIndex = d->m_tabsLayout->indexOf(dropTab);
+ if (toIndex == fromIndex)
+ toIndex = -1;
+
+ break;
+ }
+
+ if (toIndex > -1) {
+ d->m_tabsLayout->removeWidget(movingTab);
+ d->m_tabsLayout->insertWidget(toIndex, movingTab);
+ qCInfo(adsLog) << "tabMoved from" << fromIndex << "to" << toIndex;
+ emit tabMoved(fromIndex, toIndex);
+ setCurrentIndex(toIndex);
+ } else {
+ // Ensure that the moved tab is reset to its start position
+ d->m_tabsLayout->update();
+ }
+ }
+
+ void DockAreaTabBar::closeTab(int index)
+ {
+ if (index < 0 || index >= count())
+ return;
+
+ auto dockWidgetTab = tab(index);
+ if (dockWidgetTab->isHidden())
+ return;
+
+ emit tabCloseRequested(index);
+ }
+
+ bool DockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
+ {
+ bool result = Super::eventFilter(watched, event);
+ DockWidgetTab *dockWidgetTab = qobject_cast(watched);
+ if (!dockWidgetTab)
+ return result;
+
+ switch (event->type()) {
+ case QEvent::Hide:
+ emit tabClosed(d->m_tabsLayout->indexOf(dockWidgetTab));
+ updateGeometry();
+ break;
+ case QEvent::Show:
+ emit tabOpened(d->m_tabsLayout->indexOf(dockWidgetTab));
+ updateGeometry();
+ break;
+ default:
+ break;
+ }
+
+ return result;
+ }
+
+ bool DockAreaTabBar::isTabOpen(int index) const
+ {
+ if (index < 0 || index >= count())
+ return false;
+
+ return !tab(index)->isHidden();
+ }
+
+ QSize DockAreaTabBar::minimumSizeHint() const
+ {
+ QSize size = sizeHint();
+ size.setWidth(10);
+ return size;
+ }
+
+ QSize DockAreaTabBar::sizeHint() const
+ {
+ return d->m_tabsContainerWidget->sizeHint();
+ }
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockareatabbar.h b/src/libs/advanceddockingsystem/dockareatabbar.h
new file mode 100644
index 00000000000..991286c45ee
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockareatabbar.h
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "ads_globals.h"
+
+#include
+
+namespace ADS {
+
+class DockAreaWidget;
+class DockWidgetTab;
+struct DockAreaTabBarPrivate;
+class DockAreaTitleBar;
+class FloatingDockContainer;
+class AbstractFloatingWidget;
+
+/**
+ * Custom tabbar implementation for tab area that is shown on top of a
+ * dock area widget.
+ * The tabbar displays the tab widgets of the contained dock widgets.
+ * We cannot use QTabBar here because it does a lot of fancy animations
+ * that will crash the application if a tab is removed while the animation
+ * has not finished. And we need to remove a tab, if the user drags a
+ * a dock widget out of a group of tabbed widgets
+ */
+class ADS_EXPORT DockAreaTabBar : public QScrollArea
+{
+ Q_OBJECT
+private:
+ DockAreaTabBarPrivate *d; ///< private data (pimpl)
+ friend struct DockAreaTabBarPrivate;
+ friend class DockAreaTitleBar;
+
+ void onTabClicked();
+ void onTabCloseRequested();
+ void onCloseOtherTabsRequested();
+ void onTabWidgetMoved(const QPoint &globalPos);
+
+protected:
+ virtual void wheelEvent(QWheelEvent *event) override;
+
+public:
+ using Super = QScrollArea;
+
+ /**
+ * Default Constructor
+ */
+ DockAreaTabBar(DockAreaWidget *parent);
+
+ /**
+ * Virtual Destructor
+ */
+ virtual ~DockAreaTabBar() override;
+
+ /**
+ * Inserts the given dock widget tab at the given position.
+ * Inserting a new tab at an index less than or equal to the current index
+ * will increment the current index, but keep the current tab.
+ */
+ void insertTab(int Index, DockWidgetTab *tab);
+
+ /**
+ * Removes the given DockWidgetTab from the tabbar
+ */
+ void removeTab(DockWidgetTab *tab);
+
+ /**
+ * Returns the number of tabs in this tabbar
+ */
+ int count() const;
+
+ /**
+ * Returns the current index or -1 if no tab is selected
+ */
+ int currentIndex() const;
+
+ /**
+ * Returns the current tab or a nullptr if no tab is selected.
+ */
+ DockWidgetTab *currentTab() const;
+
+ /**
+ * Returns the tab with the given index
+ */
+ DockWidgetTab *tab(int index) const;
+
+ /**
+ * Filters the tab widget events
+ */
+ virtual bool eventFilter(QObject *watched, QEvent *event) override;
+
+ /**
+ * This function returns true if the tab is open, that means if it is
+ * visible to the user. If the function returns false, the tab is
+ * closed
+ */
+ bool isTabOpen(int index) const;
+
+ /**
+ * Overrides the minimumSizeHint() function of QScrollArea
+ * The minimumSizeHint() is bigger than the sizeHint () for the scroll
+ * area because even if the scrollbars are invisible, the required speace
+ * is reserved in the minimumSizeHint(). This override simply returns
+ * sizeHint();
+ */
+ virtual QSize minimumSizeHint() const override;
+
+ /**
+ * The function provides a sizeHint that matches the height of the
+ * internal viewport.
+ */
+ virtual QSize sizeHint() const override;
+
+ /**
+ * This property sets the index of the tab bar's visible tab
+ */
+ void setCurrentIndex(int index);
+
+ /**
+ * This function will close the tab given in Index param.
+ * Closing a tab means, the tab will be hidden, it will not be removed
+ */
+ void closeTab(int index);
+
+signals:
+ /**
+ * This signal is emitted when the tab bar's current tab is about to be changed. The new
+ * current has the given index, or -1 if there isn't a new one.
+ */
+ void currentChanging(int index);
+
+ /**
+ * This signal is emitted when the tab bar's current tab changes. The new
+ * current has the given index, or -1 if there isn't a new one
+ */
+ void currentChanged(int index);
+
+ /**
+ * This signal is emitted when user clicks on a tab
+ */
+ void tabBarClicked(int index);
+
+ /**
+ * This signal is emitted when the close button on a tab is clicked.
+ * The index is the index that should be closed.
+ */
+ void tabCloseRequested(int index);
+
+ /**
+ * This signal is emitted if a tab has been closed
+ */
+ void tabClosed(int index);
+
+ /**
+ * This signal is emitted if a tab has been opened.
+ * A tab is opened if it has been made visible
+ */
+ void tabOpened(int index);
+
+ /**
+ * This signal is emitted when the tab has moved the tab at index position
+ * from to index position to.
+ */
+ void tabMoved(int from, int to);
+
+ /**
+ * This signal is emitted, just before the tab with the given index is
+ * removed
+ */
+ void removingTab(int index);
+
+ /**
+ * This signal is emitted if a tab has been inserted
+ */
+ void tabInserted(int index);
+
+ /**
+ * This signal is emitted when a tab title elide state has been changed
+ */
+ void elidedChanged(bool elided);
+}; // class DockAreaTabBar
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockareatitlebar.cpp b/src/libs/advanceddockingsystem/dockareatitlebar.cpp
new file mode 100644
index 00000000000..a24055d194f
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockareatitlebar.cpp
@@ -0,0 +1,577 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockareatitlebar.h"
+
+#include "ads_globals.h"
+#include "dockareatabbar.h"
+#include "dockareawidget.h"
+#include "dockmanager.h"
+#include "dockoverlay.h"
+#include "dockwidget.h"
+#include "dockwidgettab.h"
+#include "floatingdockcontainer.h"
+#include "floatingdragpreview.h"
+#include "iconprovider.h"
+#include "dockcomponentsfactory.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+static Q_LOGGING_CATEGORY(adsLog, "qtc.qmldesigner.advanceddockingsystem", QtWarningMsg)
+
+namespace ADS
+{
+ /**
+ * Private data class of DockAreaTitleBar class (pimpl)
+ */
+ struct DockAreaTitleBarPrivate
+ {
+ DockAreaTitleBar *q;
+ QPointer m_tabsMenuButton;
+ QPointer m_undockButton;
+ QPointer m_closeButton;
+ QBoxLayout *m_layout;
+ DockAreaWidget *m_dockArea;
+ DockAreaTabBar *m_tabBar;
+ bool m_menuOutdated = true;
+ QMenu *m_tabsMenu;
+ QList m_dockWidgetActionsButtons;
+
+ QPoint m_dragStartMousePos;
+ eDragState m_dragState = DraggingInactive;
+ AbstractFloatingWidget *m_floatingWidget = nullptr;
+
+ /**
+ * Private data constructor
+ */
+ DockAreaTitleBarPrivate(DockAreaTitleBar *parent);
+
+ /**
+ * Creates the title bar close and menu buttons
+ */
+ void createButtons();
+
+ /**
+ * Creates the internal TabBar
+ */
+ void createTabBar();
+
+ /**
+ * Convenience function for DockManager access
+ */
+ DockManager *dockManager() const { return m_dockArea->dockManager(); }
+
+ /**
+ * Returns true if the given config flag is set
+ */
+ static bool testConfigFlag(DockManager::eConfigFlag flag)
+ {
+ return DockManager::configFlags().testFlag(flag);
+ }
+
+ /**
+ * Test function for current drag state
+ */
+ bool isDraggingState(eDragState dragState) const { return this->m_dragState == dragState; }
+
+
+ /**
+ * Starts floating
+ */
+ void startFloating(const QPoint &offset);
+
+ /**
+ * Makes the dock area floating
+ */
+ AbstractFloatingWidget *makeAreaFloating(const QPoint &offset, eDragState dragState);
+ }; // struct DockAreaTitleBarPrivate
+
+
+ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(DockAreaTitleBar *parent)
+ : q(parent)
+ {}
+
+ void DockAreaTitleBarPrivate::createButtons()
+ {
+ QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+ // Tabs menu button
+ m_tabsMenuButton = new TitleBarButton(testConfigFlag(DockManager::DockAreaHasTabsMenuButton));
+ m_tabsMenuButton->setObjectName("tabsMenuButton");
+ m_tabsMenuButton->setAutoRaise(true);
+ m_tabsMenuButton->setPopupMode(QToolButton::InstantPopup);
+ internal::setButtonIcon(m_tabsMenuButton,
+ QStyle::SP_TitleBarUnshadeButton,
+ ADS::DockAreaMenuIcon);
+ QMenu *tabsMenu = new QMenu(m_tabsMenuButton);
+#ifndef QT_NO_TOOLTIP
+ tabsMenu->setToolTipsVisible(true);
+#endif
+ QObject::connect(tabsMenu, &QMenu::aboutToShow, q, &DockAreaTitleBar::onTabsMenuAboutToShow);
+ m_tabsMenuButton->setMenu(tabsMenu);
+ internal::setToolTip(m_tabsMenuButton, QObject::tr("List All Tabs"));
+ m_tabsMenuButton->setSizePolicy(sizePolicy);
+ m_layout->addWidget(m_tabsMenuButton, 0);
+ QObject::connect(m_tabsMenuButton->menu(),
+ &QMenu::triggered,
+ q,
+ &DockAreaTitleBar::onTabsMenuActionTriggered);
+
+ // Undock button
+ m_undockButton = new TitleBarButton(testConfigFlag(DockManager::DockAreaHasUndockButton));
+ m_undockButton->setObjectName("undockButton");
+ m_undockButton->setAutoRaise(true);
+ internal::setToolTip(m_undockButton, QObject::tr("Detach Group"));
+ internal::setButtonIcon(m_undockButton,
+ QStyle::SP_TitleBarNormalButton,
+ ADS::DockAreaUndockIcon);
+ m_undockButton->setSizePolicy(sizePolicy);
+ m_layout->addWidget(m_undockButton, 0);
+ QObject::connect(m_undockButton,
+ &QToolButton::clicked,
+ q,
+ &DockAreaTitleBar::onUndockButtonClicked);
+
+ // Close button
+ m_closeButton = new TitleBarButton(testConfigFlag(DockManager::DockAreaHasCloseButton));
+ m_closeButton->setObjectName("closeButton");
+ m_closeButton->setAutoRaise(true);
+ internal::setButtonIcon(m_closeButton,
+ QStyle::SP_TitleBarCloseButton,
+ ADS::DockAreaCloseIcon);
+ if (testConfigFlag(DockManager::DockAreaCloseButtonClosesTab)) {
+ internal::setToolTip(m_closeButton, QObject::tr("Close Active Tab"));
+ } else {
+ internal::setToolTip(m_closeButton, QObject::tr("Close Group"));
+ }
+ m_closeButton->setSizePolicy(sizePolicy);
+ m_closeButton->setIconSize(QSize(16, 16));
+ m_layout->addWidget(m_closeButton, 0);
+ QObject::connect(m_closeButton,
+ &QToolButton::clicked,
+ q,
+ &DockAreaTitleBar::onCloseButtonClicked);
+ }
+
+ void DockAreaTitleBarPrivate::createTabBar()
+ {
+ m_tabBar = componentsFactory()->createDockAreaTabBar(m_dockArea);
+ m_tabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
+ m_layout->addWidget(m_tabBar);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::tabClosed,
+ q,
+ &DockAreaTitleBar::markTabsMenuOutdated);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::tabOpened,
+ q,
+ &DockAreaTitleBar::markTabsMenuOutdated);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::tabInserted,
+ q,
+ &DockAreaTitleBar::markTabsMenuOutdated);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::removingTab,
+ q,
+ &DockAreaTitleBar::markTabsMenuOutdated);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::tabMoved,
+ q,
+ &DockAreaTitleBar::markTabsMenuOutdated);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::currentChanged,
+ q,
+ &DockAreaTitleBar::onCurrentTabChanged);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::tabBarClicked,
+ q,
+ &DockAreaTitleBar::tabBarClicked);
+ QObject::connect(m_tabBar,
+ &DockAreaTabBar::elidedChanged,
+ q,
+ &DockAreaTitleBar::markTabsMenuOutdated);
+ }
+
+ AbstractFloatingWidget *DockAreaTitleBarPrivate::makeAreaFloating(const QPoint &offset,
+ eDragState dragState)
+ {
+ QSize size = m_dockArea->size();
+ m_dragState = dragState;
+ bool opaqueUndocking = DockManager::configFlags().testFlag(DockManager::OpaqueUndocking)
+ || (DraggingFloatingWidget != dragState);
+ FloatingDockContainer *floatingDockContainer = nullptr;
+ AbstractFloatingWidget *floatingWidget;
+ if (opaqueUndocking) {
+ floatingWidget = floatingDockContainer = new FloatingDockContainer(m_dockArea);
+ } else {
+ auto w = new FloatingDragPreview(m_dockArea);
+ QObject::connect(w, &FloatingDragPreview::draggingCanceled, [=]() {
+ m_dragState = DraggingInactive;
+ });
+ floatingWidget = w;
+ }
+
+ floatingWidget->startFloating(offset, size, dragState, nullptr);
+ if (floatingDockContainer) {
+ auto topLevelDockWidget = floatingDockContainer->topLevelDockWidget();
+ if (topLevelDockWidget) {
+ topLevelDockWidget->emitTopLevelChanged(true);
+ }
+ }
+
+ return floatingWidget;
+ }
+
+ void DockAreaTitleBarPrivate::startFloating(const QPoint &offset)
+ {
+ m_floatingWidget = makeAreaFloating(offset, DraggingFloatingWidget);
+ }
+
+ TitleBarButton::TitleBarButton(bool visible, QWidget *parent)
+ : TitleBarButtonType(parent),
+ m_visible(visible),
+ m_hideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(DockManager::DockAreaHideDisabledButtons))
+ {}
+
+ void TitleBarButton::setVisible(bool visible)
+ {
+ // 'visible' can stay 'true' if and only if this button is configured to generaly visible:
+ visible = visible && m_visible;
+
+ // 'visible' can stay 'true' unless: this button is configured to be invisible when it
+ // is disabled and it is currently disabled:
+ if (visible && m_hideWhenDisabled) {
+ visible = isEnabled();
+ }
+
+ Super::setVisible(visible);
+ }
+
+ bool TitleBarButton::event(QEvent *event)
+ {
+ if (QEvent::EnabledChange == event->type() && m_hideWhenDisabled) {
+ // force setVisible() call
+ // Calling setVisible() directly here doesn't work well when button is expected to be shown first time
+ QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled()));
+ }
+
+ return Super::event(event);
+ }
+
+ SpacerWidget::SpacerWidget(QWidget *parent)
+ : QWidget(parent)
+ {
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ setStyleSheet("border: none; background: none;");
+ }
+
+ DockAreaTitleBar::DockAreaTitleBar(DockAreaWidget *parent)
+ : QFrame(parent)
+ , d(new DockAreaTitleBarPrivate(this))
+ {
+ d->m_dockArea = parent;
+
+ setObjectName("dockAreaTitleBar");
+ d->m_layout = new QBoxLayout(QBoxLayout::LeftToRight);
+ d->m_layout->setContentsMargins(0, 0, 0, 0);
+ d->m_layout->setSpacing(0);
+ setLayout(d->m_layout);
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+
+ d->createTabBar();
+ d->m_layout->addWidget(new SpacerWidget(this));
+ d->createButtons();
+ }
+
+ DockAreaTitleBar::~DockAreaTitleBar() {
+ if (!d->m_closeButton.isNull())
+ delete d->m_closeButton;
+
+ if (!d->m_tabsMenuButton.isNull())
+ delete d->m_tabsMenuButton;
+
+ if (!d->m_undockButton.isNull())
+ delete d->m_undockButton;
+
+ delete d;
+ }
+
+ DockAreaTabBar *DockAreaTitleBar::tabBar() const { return d->m_tabBar; }
+
+ void DockAreaTitleBar::markTabsMenuOutdated() {
+ if (DockAreaTitleBarPrivate::testConfigFlag(DockManager::DockAreaDynamicTabsMenuButtonVisibility)) {
+ bool hasElidedTabTitle = false;
+ for (int i = 0; i < d->m_tabBar->count(); ++i) {
+ if (!d->m_tabBar->isTabOpen(i))
+ continue;
+
+ DockWidgetTab* tab = d->m_tabBar->tab(i);
+ if (tab->isTitleElided()) {
+ hasElidedTabTitle = true;
+ break;
+ }
+ }
+ bool visible = (hasElidedTabTitle && (d->m_tabBar->count() > 1));
+ QMetaObject::invokeMethod(d->m_tabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
+ }
+ d->m_menuOutdated = true;
+ }
+
+ void DockAreaTitleBar::onTabsMenuAboutToShow()
+ {
+ if (!d->m_menuOutdated) {
+ return;
+ }
+
+ QMenu *menu = d->m_tabsMenuButton->menu();
+ menu->clear();
+ for (int i = 0; i < d->m_tabBar->count(); ++i) {
+ if (!d->m_tabBar->isTabOpen(i))
+ continue;
+
+ auto tab = d->m_tabBar->tab(i);
+ QAction *action = menu->addAction(tab->icon(), tab->text());
+ internal::setToolTip(action, tab->toolTip());
+ action->setData(i);
+ }
+
+ d->m_menuOutdated = false;
+ }
+
+ void DockAreaTitleBar::onCloseButtonClicked()
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ if (d->testConfigFlag(DockManager::DockAreaCloseButtonClosesTab)) {
+ d->m_tabBar->closeTab(d->m_tabBar->currentIndex());
+ } else {
+ d->m_dockArea->closeArea();
+ }
+ }
+
+ void DockAreaTitleBar::onUndockButtonClicked()
+ {
+ if (d->m_dockArea->features().testFlag(DockWidget::DockWidgetFloatable)) {
+ d->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
+ }
+ }
+
+ void DockAreaTitleBar::onTabsMenuActionTriggered(QAction *action)
+ {
+ int index = action->data().toInt();
+ d->m_tabBar->setCurrentIndex(index);
+ emit tabBarClicked(index);
+ }
+
+ void DockAreaTitleBar::updateDockWidgetActionsButtons()
+ {
+ DockWidget* dockWidget = d->m_tabBar->currentTab()->dockWidget();
+ if (!d->m_dockWidgetActionsButtons.isEmpty()) {
+ for (auto button : d->m_dockWidgetActionsButtons) {
+ d->m_layout->removeWidget(button);
+ delete button;
+ }
+ d->m_dockWidgetActionsButtons.clear();
+ }
+
+ auto actions = dockWidget->titleBarActions();
+ if (actions.isEmpty())
+ return;
+
+ int insertIndex = indexOf(d->m_tabsMenuButton);
+ for (auto action : actions) {
+ auto button = new TitleBarButton(true, this);
+ button->setDefaultAction(action);
+ button->setAutoRaise(true);
+ button->setPopupMode(QToolButton::InstantPopup);
+ button->setObjectName(action->objectName());
+ d->m_layout->insertWidget(insertIndex++, button, 0);
+ d->m_dockWidgetActionsButtons.append(button);
+ }
+ }
+
+ void DockAreaTitleBar::onCurrentTabChanged(int index)
+ {
+ if (index < 0)
+ return;
+
+ if (d->testConfigFlag(DockManager::DockAreaCloseButtonClosesTab)) {
+ DockWidget *dockWidget = d->m_tabBar->tab(index)->dockWidget();
+ d->m_closeButton->setEnabled(
+ dockWidget->features().testFlag(DockWidget::DockWidgetClosable));
+ }
+
+ updateDockWidgetActionsButtons();
+ }
+
+ QAbstractButton *DockAreaTitleBar::button(eTitleBarButton which) const
+ {
+ switch (which) {
+ case TitleBarButtonTabsMenu:
+ return d->m_tabsMenuButton;
+ case TitleBarButtonUndock:
+ return d->m_undockButton;
+ case TitleBarButtonClose:
+ return d->m_closeButton;
+ }
+ return nullptr;
+ }
+
+ void DockAreaTitleBar::setVisible(bool visible)
+ {
+ Super::setVisible(visible);
+ markTabsMenuOutdated();
+ }
+
+
+ void DockAreaTitleBar::mousePressEvent(QMouseEvent *event)
+ {
+ if (event->button() == Qt::LeftButton) {
+ event->accept();
+ d->m_dragStartMousePos = event->pos();
+ d->m_dragState = DraggingMousePressed;
+ return;
+ }
+ Super::mousePressEvent(event);
+ }
+
+ void DockAreaTitleBar::mouseReleaseEvent(QMouseEvent *event)
+ {
+ if (event->button() == Qt::LeftButton) {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ event->accept();
+ auto CurrentDragState = d->m_dragState;
+ d->m_dragStartMousePos = QPoint();
+ d->m_dragState = DraggingInactive;
+ if (DraggingFloatingWidget == CurrentDragState)
+ d->m_floatingWidget->finishDragging();
+
+ return;
+ }
+ Super::mouseReleaseEvent(event);
+ }
+
+ void DockAreaTitleBar::mouseMoveEvent(QMouseEvent *event)
+ {
+ Super::mouseMoveEvent(event);
+ if (!(event->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive)) {
+ d->m_dragState = DraggingInactive;
+ return;
+ }
+
+ // move floating window
+ if (d->isDraggingState(DraggingFloatingWidget)) {
+ d->m_floatingWidget->moveFloating();
+ return;
+ }
+
+ // If this is the last dock area in a dock container it does not make
+ // sense to move it to a new floating widget and leave this one empty
+ if (d->m_dockArea->dockContainer()->isFloating()
+ && d->m_dockArea->dockContainer()->visibleDockAreaCount() == 1) {
+ return;
+ }
+
+ // If one single dock widget in this area is not floatable then the whole
+ // area is not floatable
+ // If we do non opaque undocking, then we can create the floating drag
+ // preview if the dock widget is movable
+ auto features = d->m_dockArea->features();
+ if (!features.testFlag(DockWidget::DockWidgetFloatable)
+ && !(features.testFlag(DockWidget::DockWidgetMovable)
+ && !DockManager::testConfigFlag(DockManager::OpaqueUndocking))) {
+ return;
+ }
+
+ int dragDistance = (d->m_dragStartMousePos - event->pos()).manhattanLength();
+ if (dragDistance >= DockManager::startDragDistance()) {
+ qCInfo(adsLog) << "TabsScrollArea::startFloating";
+ d->startFloating(d->m_dragStartMousePos);
+ auto overlay = d->m_dockArea->dockManager()->containerOverlay();
+ overlay->setAllowedAreas(OuterDockAreas);
+ }
+
+ return;
+ }
+
+ void DockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
+ {
+ // If this is the last dock area in a dock container it does not make
+ // sense to move it to a new floating widget and leave this one empty
+ if (d->m_dockArea->dockContainer()->isFloating()
+ && d->m_dockArea->dockContainer()->dockAreaCount() == 1)
+ return;
+
+ if (!d->m_dockArea->features().testFlag(DockWidget::DockWidgetFloatable))
+ return;
+
+ d->makeAreaFloating(event->pos(), DraggingInactive);
+ }
+
+ void DockAreaTitleBar::contextMenuEvent(QContextMenuEvent *event)
+ {
+ event->accept();
+ if (d->isDraggingState(DraggingFloatingWidget))
+ return;
+
+ QMenu menu(this);
+ auto action = menu.addAction(tr("Detach Area"),
+ this,
+ &DockAreaTitleBar::onUndockButtonClicked);
+ action->setEnabled(d->m_dockArea->features().testFlag(DockWidget::DockWidgetFloatable));
+ menu.addSeparator();
+ action = menu.addAction(tr("Close Area"), this, &DockAreaTitleBar::onCloseButtonClicked);
+ action->setEnabled(d->m_dockArea->features().testFlag(DockWidget::DockWidgetClosable));
+ menu.addAction(tr("Close Other Areas"), d->m_dockArea, &DockAreaWidget::closeOtherAreas);
+ menu.exec(event->globalPos());
+ }
+
+ void DockAreaTitleBar::insertWidget(int index, QWidget *widget)
+ {
+ d->m_layout->insertWidget(index, widget);
+ }
+
+ int DockAreaTitleBar::indexOf(QWidget *widget) const
+ {
+ return d->m_layout->indexOf(widget);
+ }
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockareatitlebar.h b/src/libs/advanceddockingsystem/dockareatitlebar.h
new file mode 100644
index 00000000000..482816a34ee
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockareatitlebar.h
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "ads_globals.h"
+
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+QT_END_NAMESPACE
+
+namespace ADS {
+
+class DockAreaTabBar;
+class DockAreaWidget;
+struct DockAreaTitleBarPrivate;
+
+using TitleBarButtonType = QToolButton;
+
+/**
+ * Title bar button of a dock area that customizes TitleBarButtonType appearance/behavior
+ * according to various config flags such as:
+ * DockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible
+ * DockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled
+ */
+class TitleBarButton : public TitleBarButtonType
+{
+ Q_OBJECT
+ bool m_visible = true;
+ bool m_hideWhenDisabled = false;
+public:
+ using Super = TitleBarButtonType;
+ TitleBarButton(bool visible = true, QWidget *parent = nullptr);
+
+ /**
+ * Adjust this visibility change request with our internal settings:
+ */
+ virtual void setVisible(bool visible) override;
+
+protected:
+ /**
+ * Handle EnabledChanged signal to set button invisible if the configured
+ */
+ bool event(QEvent *event) override;
+};
+
+/**
+ * This spacer widget is here because of the following problem.
+ * The dock area title bar handles mouse dragging and moving the floating widget.
+ * The problem is, that if the title bar becomes invisible, i.e. if the dock
+ * area contains only one single dock widget and the dock area is moved
+ * into a floating widget, then mouse events are not handled anymore and dragging
+ * of the floating widget stops.
+ */
+class SpacerWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ SpacerWidget(QWidget *parent = nullptr);
+ virtual QSize sizeHint() const override {return QSize(0, 0);}
+ virtual QSize minimumSizeHint() const override {return QSize(0, 0);}
+};
+
+/**
+ * Title bar of a dock area.
+ * The title bar contains a tabbar with all tabs for a dock widget group and
+ * with a tabs menu button, a undock button and a close button.
+ */
+class ADS_EXPORT DockAreaTitleBar : public QFrame
+{
+ Q_OBJECT
+private:
+ DockAreaTitleBarPrivate *d; ///< private data (pimpl)
+ friend struct DockAreaTitleBarPrivate;
+
+ void onTabsMenuAboutToShow();
+ void onCloseButtonClicked();
+ void onUndockButtonClicked();
+ void onTabsMenuActionTriggered(QAction *action);
+ void onCurrentTabChanged(int index);
+
+protected:
+ /**
+ * Stores mouse position to detect dragging
+ */
+ virtual void mousePressEvent(QMouseEvent *event) override;
+
+ /**
+ * Stores mouse position to detect dragging
+ */
+ virtual void mouseReleaseEvent(QMouseEvent *event) override;
+
+ /**
+ * Starts floating the complete docking area including all dock widgets,
+ * if it is not the last dock area in a floating widget
+ */
+ virtual void mouseMoveEvent(QMouseEvent *event) override;
+
+ /**
+ * Double clicking the title bar also starts floating of the complete area
+ */
+ virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
+
+ /**
+ * Show context menu
+ */
+ virtual void contextMenuEvent(QContextMenuEvent *event) override;
+
+public:
+ /**
+ * Call this slot to tell the title bar that it should update the tabs menu
+ * the next time it is shown.
+ */
+ void markTabsMenuOutdated();
+
+ using Super = QFrame;
+ /**
+ * Default Constructor
+ */
+ DockAreaTitleBar(DockAreaWidget *parent);
+
+ /**
+ * Virtual Destructor
+ */
+ virtual ~DockAreaTitleBar() override;
+
+ /**
+ * Returns the pointer to the tabBar()
+ */
+ DockAreaTabBar *tabBar() const;
+
+ /**
+ * Returns the button corresponding to the given title bar button identifier
+ */
+ QAbstractButton *button(eTitleBarButton which) const;
+
+ /**
+ * Updates the visibility of the dock widget actions in the title bar
+ */
+ void updateDockWidgetActionsButtons();
+
+ /**
+ * Marks the tabs menu outdated before it calls its base class
+ * implementation
+ */
+ virtual void setVisible(bool visible) override;
+
+ /**
+ * Inserts a custom widget at position index into this title bar.
+ * If index is negative, the widget is added at the end.
+ * You can use this function to insert custom widgets into the title bar.
+ */
+ void insertWidget(int index, QWidget *widget);
+
+ /**
+ * Searches for widget widget in this title bar.
+ * You can use this function, to get the position of the default
+ * widget in the tile bar.
+ * \code
+ * int tabBarIndex = TitleBar->indexOf(TitleBar->tabBar());
+ * int closeButtonIndex = TitleBar->indexOf(TitleBar->button(TitleBarButtonClose));
+ * \endcode
+ */
+ int indexOf(QWidget *widget) const;
+
+signals:
+ /**
+ * This signal is emitted if a tab in the tab bar is clicked by the user
+ * or if the user clicks on a tab item in the title bar tab menu.
+ */
+ void tabBarClicked(int index);
+}; // class DockAreaTitleBar
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockareawidget.cpp b/src/libs/advanceddockingsystem/dockareawidget.cpp
new file mode 100644
index 00000000000..16bd88f5716
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockareawidget.cpp
@@ -0,0 +1,686 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockareawidget.h"
+
+#include "dockareatabbar.h"
+#include "dockareatitlebar.h"
+#include "dockcomponentsfactory.h"
+#include "dockcontainerwidget.h"
+#include "dockmanager.h"
+#include "dockoverlay.h"
+#include "docksplitter.h"
+#include "dockwidget.h"
+#include "dockwidgettab.h"
+#include "floatingdockcontainer.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+static Q_LOGGING_CATEGORY(adsLog, "qtc.qmldesigner.advanceddockingsystem", QtWarningMsg)
+
+namespace ADS
+{
+ static const char *const INDEX_PROPERTY = "index";
+ static const char *const ACTION_PROPERTY = "action";
+
+ /**
+ * Internal dock area layout mimics stack layout but only inserts the current
+ * widget into the internal QLayout object.
+ * \warning Only the current widget has a parent. All other widgets
+ * do not have a parent. That means, a widget that is in this layout may
+ * return nullptr for its parent() function if it is not the current widget.
+ */
+ class DockAreaLayout
+ {
+ private:
+ QBoxLayout *m_parentLayout;
+ QList m_widgets;
+ int m_currentIndex = -1;
+ QWidget *m_currentWidget = nullptr;
+
+ public:
+ /**
+ * Creates an instance with the given parent layout
+ */
+ DockAreaLayout(QBoxLayout *parentLayout)
+ : m_parentLayout(parentLayout)
+ {}
+
+ /**
+ * Returns the number of widgets in this layout
+ */
+ int count() const { return m_widgets.count(); }
+
+ /**
+ * Inserts the widget at the given index position into the internal widget
+ * list
+ */
+ void insertWidget(int index, QWidget *widget)
+ {
+ widget->setParent(nullptr);
+ if (index < 0) {
+ index = m_widgets.count();
+ }
+ m_widgets.insert(index, widget);
+ if (m_currentIndex < 0) {
+ setCurrentIndex(index);
+ } else {
+ if (index <= m_currentIndex) {
+ ++m_currentIndex;
+ }
+ }
+ }
+
+ /**
+ * Removes the given widget from the layout
+ */
+ void removeWidget(QWidget *widget)
+ {
+ if (currentWidget() == widget) {
+ auto layoutItem = m_parentLayout->takeAt(1);
+ if (layoutItem) {
+ layoutItem->widget()->setParent(nullptr);
+ }
+ m_currentWidget = nullptr;
+ m_currentIndex = -1;
+ }
+ m_widgets.removeOne(widget);
+ }
+
+ /**
+ * Returns the current selected widget
+ */
+ QWidget *currentWidget() const { return m_currentWidget; }
+
+ /**
+ * Activates the widget with the give index.
+ */
+ void setCurrentIndex(int index)
+ {
+ QWidget *prev = currentWidget();
+ QWidget *next = widget(index);
+ if (!next || (next == prev && !m_currentWidget)) {
+ return;
+ }
+
+ bool reenableUpdates = false;
+ QWidget *parent = m_parentLayout->parentWidget();
+
+ if (parent && parent->updatesEnabled()) {
+ reenableUpdates = true;
+ parent->setUpdatesEnabled(false);
+ }
+
+ // TODO
+ auto layoutItem = m_parentLayout->takeAt(1);
+ if (layoutItem) {
+ layoutItem->widget()->setParent(nullptr);
+ }
+
+ m_parentLayout->addWidget(next);
+ if (prev) {
+ prev->hide();
+ }
+ m_currentIndex = index;
+ m_currentWidget = next;
+
+ if (reenableUpdates) {
+ parent->setUpdatesEnabled(true);
+ }
+ }
+
+ /**
+ * Returns the index of the current active widget
+ */
+ int currentIndex() const { return m_currentIndex; }
+
+ /**
+ * Returns true if there are no widgets in the layout
+ */
+ bool isEmpty() const { return m_widgets.empty(); }
+
+ /**
+ * Returns the index of the given widget
+ */
+ int indexOf(QWidget *widget) const { return m_widgets.indexOf(widget); }
+
+ /**
+ * Returns the widget for the given index
+ */
+ QWidget *widget(int index) const
+ {
+ return (index < m_widgets.size()) ? m_widgets.at(index) : nullptr;
+ }
+
+ /**
+ * Returns the geometry of the current active widget
+ */
+ QRect geometry() const { return m_widgets.empty() ? QRect() : currentWidget()->geometry(); }
+ };
+
+ /**
+ * Private data class of DockAreaWidget class (pimpl)
+ */
+ struct DockAreaWidgetPrivate
+ {
+ DockAreaWidget *q = nullptr;
+ QBoxLayout *m_layout = nullptr;
+ DockAreaLayout *m_contentsLayout = nullptr;
+ DockAreaTitleBar *m_titleBar = nullptr;
+ DockManager *m_dockManager = nullptr;
+ bool m_updateTitleBarButtons = false;
+ DockWidgetAreas m_allowedAreas = AllDockAreas;
+
+ /**
+ * Private data constructor
+ */
+ DockAreaWidgetPrivate(DockAreaWidget *parent);
+
+ /**
+ * Creates the layout for top area with tabs and close button
+ */
+ void createTitleBar();
+
+ /**
+ * Returns the dock widget with the given index
+ */
+ DockWidget *dockWidgetAt(int index)
+ {
+ return qobject_cast(m_contentsLayout->widget(index));
+ }
+
+ /**
+ * Convenience function to ease title widget access by index
+ */
+ DockWidgetTab *tabWidgetAt(int index) { return dockWidgetAt(index)->tabWidget(); }
+
+ /**
+ * Returns the tab action of the given dock widget
+ */
+ QAction *dockWidgetTabAction(DockWidget *dockWidget) const
+ {
+ return qvariant_cast(dockWidget->property(ACTION_PROPERTY));
+ }
+
+ /**
+ * Returns the index of the given dock widget
+ */
+ int dockWidgetIndex(DockWidget *dockWidget) const
+ {
+ return dockWidget->property(INDEX_PROPERTY).toInt();
+ }
+
+ /**
+ * Convenience function for tabbar access
+ */
+ DockAreaTabBar *tabBar() const { return m_titleBar->tabBar(); }
+
+ /**
+ * Udpates the enable state of the close and detach button
+ */
+ void updateTitleBarButtonStates();
+ };
+ // struct DockAreaWidgetPrivate
+
+ DockAreaWidgetPrivate::DockAreaWidgetPrivate(DockAreaWidget *parent)
+ : q(parent)
+ {}
+
+ void DockAreaWidgetPrivate::createTitleBar()
+ {
+ m_titleBar = componentsFactory()->createDockAreaTitleBar(q);
+ m_layout->addWidget(m_titleBar);
+ QObject::connect(tabBar(),
+ &DockAreaTabBar::tabCloseRequested,
+ q,
+ &DockAreaWidget::onTabCloseRequested);
+ QObject::connect(m_titleBar,
+ &DockAreaTitleBar::tabBarClicked,
+ q,
+ &DockAreaWidget::setCurrentIndex);
+ QObject::connect(tabBar(), &DockAreaTabBar::tabMoved, q, &DockAreaWidget::reorderDockWidget);
+ }
+
+ void DockAreaWidgetPrivate::updateTitleBarButtonStates()
+ {
+ if (q->isHidden()) {
+ m_updateTitleBarButtons = true;
+ return;
+ }
+
+ m_titleBar->button(TitleBarButtonClose)
+ ->setEnabled(q->features().testFlag(DockWidget::DockWidgetClosable));
+ m_titleBar->button(TitleBarButtonUndock)
+ ->setEnabled(q->features().testFlag(DockWidget::DockWidgetFloatable));
+ m_titleBar->updateDockWidgetActionsButtons();
+ m_updateTitleBarButtons = false;
+ }
+
+ DockAreaWidget::DockAreaWidget(DockManager *dockManager, DockContainerWidget *parent)
+ : QFrame(parent)
+ , d(new DockAreaWidgetPrivate(this))
+ {
+ d->m_dockManager = dockManager;
+ d->m_layout = new QBoxLayout(QBoxLayout::TopToBottom);
+ d->m_layout->setContentsMargins(0, 0, 0, 0);
+ d->m_layout->setSpacing(0);
+ setLayout(d->m_layout);
+
+ d->createTitleBar();
+ d->m_contentsLayout = new DockAreaLayout(d->m_layout);
+ if (d->m_dockManager) {
+ emit d->m_dockManager->dockAreaCreated(this);
+ }
+ }
+
+ DockAreaWidget::~DockAreaWidget()
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ delete d->m_contentsLayout;
+ delete d;
+ }
+
+ DockManager *DockAreaWidget::dockManager() const { return d->m_dockManager; }
+
+ DockContainerWidget *DockAreaWidget::dockContainer() const
+ {
+ return internal::findParent(this);
+ }
+
+ void DockAreaWidget::addDockWidget(DockWidget *dockWidget)
+ {
+ insertDockWidget(d->m_contentsLayout->count(), dockWidget);
+ }
+
+ void DockAreaWidget::insertDockWidget(int index, DockWidget *dockWidget, bool activate)
+ {
+ d->m_contentsLayout->insertWidget(index, dockWidget);
+ dockWidget->tabWidget()->setDockAreaWidget(this);
+ auto tabWidget = dockWidget->tabWidget();
+ // Inserting the tab will change the current index which in turn will
+ // make the tab widget visible in the slot
+ d->tabBar()->blockSignals(true);
+ d->tabBar()->insertTab(index, tabWidget);
+ d->tabBar()->blockSignals(false);
+ tabWidget->setVisible(!dockWidget->isClosed());
+ dockWidget->setProperty(INDEX_PROPERTY, index);
+ if (activate) {
+ setCurrentIndex(index);
+ }
+ dockWidget->setDockArea(this);
+ d->updateTitleBarButtonStates();
+ }
+
+ void DockAreaWidget::removeDockWidget(DockWidget *dockWidget)
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ auto nextOpen = nextOpenDockWidget(dockWidget);
+
+ d->m_contentsLayout->removeWidget(dockWidget);
+ auto tabWidget = dockWidget->tabWidget();
+ tabWidget->hide();
+ d->tabBar()->removeTab(tabWidget);
+ DockContainerWidget *dockContainerWidget = dockContainer();
+ if (nextOpen) {
+ setCurrentDockWidget(nextOpen);
+ } else if (d->m_contentsLayout->isEmpty() && dockContainerWidget->dockAreaCount() > 1) {
+ qCInfo(adsLog) << "Dock Area empty";
+ dockContainerWidget->removeDockArea(this);
+ this->deleteLater();
+ } else {
+ // if contents layout is not empty but there are no more open dock
+ // widgets, then we need to hide the dock area because it does not
+ // contain any visible content
+ hideAreaWithNoVisibleContent();
+ }
+
+ d->updateTitleBarButtonStates();
+ updateTitleBarVisibility();
+ auto topLevelDockWidget = dockContainerWidget->topLevelDockWidget();
+ if (topLevelDockWidget) {
+ topLevelDockWidget->emitTopLevelChanged(true);
+ }
+
+#if (ADS_DEBUG_LEVEL > 0)
+ dockContainerWidget->dumpLayout();
+#endif
+ }
+
+ void DockAreaWidget::hideAreaWithNoVisibleContent()
+ {
+ this->toggleView(false);
+
+ // Hide empty parent splitters
+ auto splitter = internal::findParent(this);
+ internal::hideEmptyParentSplitters(splitter);
+
+ //Hide empty floating widget
+ DockContainerWidget *container = this->dockContainer();
+ if (!container->isFloating()) {
+ return;
+ }
+
+ updateTitleBarVisibility();
+ auto topLevelWidget = container->topLevelDockWidget();
+ auto floatingWidget = container->floatingWidget();
+ if (topLevelWidget) {
+ floatingWidget->updateWindowTitle();
+ DockWidget::emitTopLevelEventForWidget(topLevelWidget, true);
+ } else if (container->openedDockAreas().isEmpty()) {
+ floatingWidget->hide();
+ }
+ }
+
+ void DockAreaWidget::onTabCloseRequested(int index)
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO << "index" << index;
+ auto *currentDockWidget = dockWidget(index);
+ if (currentDockWidget->features().testFlag(DockWidget::DockWidgetDeleteOnClose)) {
+ currentDockWidget->closeDockWidgetInternal();
+ } else {
+ currentDockWidget->toggleView(false);
+ }
+ }
+
+ DockWidget *DockAreaWidget::currentDockWidget() const
+ {
+ int currentIdx = currentIndex();
+ if (currentIdx < 0) {
+ return nullptr;
+ }
+
+ return dockWidget(currentIdx);
+ }
+
+ void DockAreaWidget::setCurrentDockWidget(DockWidget *dockWidget)
+ {
+ if (dockManager()->isRestoringState()) {
+ return;
+ }
+
+ internalSetCurrentDockWidget(dockWidget);
+ }
+
+ void DockAreaWidget::internalSetCurrentDockWidget(DockWidget *dockWidget)
+ {
+ int index = indexOf(dockWidget);
+ if (index < 0) {
+ return;
+ }
+
+ setCurrentIndex(index);
+ }
+
+ void DockAreaWidget::setCurrentIndex(int index)
+ {
+ auto currentTabBar = d->tabBar();
+ if (index < 0 || index > (currentTabBar->count() - 1)) {
+ qWarning() << Q_FUNC_INFO << "Invalid index" << index;
+ return;
+ }
+
+ auto cw = d->m_contentsLayout->currentWidget();
+ auto nw = d->m_contentsLayout->widget(index);
+ if (cw == nw && !nw->isHidden()) {
+ return;
+ }
+
+ emit currentChanging(index);
+ currentTabBar->setCurrentIndex(index);
+ d->m_contentsLayout->setCurrentIndex(index);
+ d->m_contentsLayout->currentWidget()->show();
+ emit currentChanged(index);
+ }
+
+ int DockAreaWidget::currentIndex() const { return d->m_contentsLayout->currentIndex(); }
+
+ QRect DockAreaWidget::titleBarGeometry() const { return d->m_titleBar->geometry(); }
+
+ QRect DockAreaWidget::contentAreaGeometry() const { return d->m_contentsLayout->geometry(); }
+
+ int DockAreaWidget::indexOf(DockWidget *dockWidget)
+ {
+ return d->m_contentsLayout->indexOf(dockWidget);
+ }
+
+ QList DockAreaWidget::dockWidgets() const
+ {
+ QList dockWidgetList;
+ for (int i = 0; i < d->m_contentsLayout->count(); ++i) {
+ dockWidgetList.append(dockWidget(i));
+ }
+ return dockWidgetList;
+ }
+
+ int DockAreaWidget::openDockWidgetsCount() const
+ {
+ int count = 0;
+ for (int i = 0; i < d->m_contentsLayout->count(); ++i) {
+ if (!dockWidget(i)->isClosed()) {
+ ++count;
+ }
+ }
+ return count;
+ }
+
+ QList DockAreaWidget::openedDockWidgets() const
+ {
+ QList dockWidgetList;
+ for (int i = 0; i < d->m_contentsLayout->count(); ++i) {
+ DockWidget *currentDockWidget = dockWidget(i);
+ if (!currentDockWidget->isClosed()) {
+ dockWidgetList.append(dockWidget(i));
+ }
+ }
+ return dockWidgetList;
+ }
+
+ int DockAreaWidget::indexOfFirstOpenDockWidget() const
+ {
+ for (int i = 0; i < d->m_contentsLayout->count(); ++i) {
+ if (!dockWidget(i)->isClosed()) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ int DockAreaWidget::dockWidgetsCount() const { return d->m_contentsLayout->count(); }
+
+ DockWidget *DockAreaWidget::dockWidget(int index) const
+ {
+ return qobject_cast(d->m_contentsLayout->widget(index));
+ }
+
+ void DockAreaWidget::reorderDockWidget(int fromIndex, int toIndex)
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ if (fromIndex >= d->m_contentsLayout->count() || fromIndex < 0
+ || toIndex >= d->m_contentsLayout->count() || toIndex < 0 || fromIndex == toIndex) {
+ qCInfo(adsLog) << "Invalid index for tab movement" << fromIndex << toIndex;
+ return;
+ }
+
+ auto widget = d->m_contentsLayout->widget(fromIndex);
+ d->m_contentsLayout->removeWidget(widget);
+ d->m_contentsLayout->insertWidget(toIndex, widget);
+ setCurrentIndex(toIndex);
+ }
+
+ void DockAreaWidget::toggleDockWidgetView(DockWidget *dockWidget, bool open)
+ {
+ Q_UNUSED(dockWidget)
+ Q_UNUSED(open)
+ updateTitleBarVisibility();
+ }
+
+ void DockAreaWidget::updateTitleBarVisibility()
+ {
+ DockContainerWidget *container = dockContainer();
+ if (!container) {
+ return;
+ }
+
+ if (DockManager::configFlags().testFlag(DockManager::AlwaysShowTabs)) {
+ return;
+ }
+
+ if (d->m_titleBar) {
+ d->m_titleBar->setVisible(!container->isFloating() || !container->hasTopLevelDockWidget());
+ }
+ }
+
+ void DockAreaWidget::markTitleBarMenuOutdated()
+ {
+ if (d->m_titleBar) {
+ d->m_titleBar->markTabsMenuOutdated();
+ }
+ }
+
+ void DockAreaWidget::saveState(QXmlStreamWriter &stream) const
+ {
+ stream.writeStartElement("area");
+ stream.writeAttribute("tabs", QString::number(d->m_contentsLayout->count()));
+ auto localDockWidget = currentDockWidget();
+ QString name = localDockWidget ? localDockWidget->objectName() : "";
+ stream.writeAttribute("current", name);
+ qCInfo(adsLog) << Q_FUNC_INFO << "TabCount: " << d->m_contentsLayout->count()
+ << " Current: " << name;
+ for (int i = 0; i < d->m_contentsLayout->count(); ++i) {
+ dockWidget(i)->saveState(stream);
+ }
+ stream.writeEndElement();
+ }
+
+ DockWidget *DockAreaWidget::nextOpenDockWidget(DockWidget *dockWidget) const
+ {
+ auto openDockWidgets = openedDockWidgets();
+ if (openDockWidgets.count() > 1
+ || (openDockWidgets.count() == 1 && openDockWidgets[0] != dockWidget)) {
+ DockWidget *nextDockWidget;
+ if (openDockWidgets.last() == dockWidget) {
+ nextDockWidget = openDockWidgets[openDockWidgets.count() - 2];
+ } else {
+ int nextIndex = openDockWidgets.indexOf(dockWidget) + 1;
+ nextDockWidget = openDockWidgets[nextIndex];
+ }
+
+ return nextDockWidget;
+ } else {
+ return nullptr;
+ }
+ }
+
+ DockWidget::DockWidgetFeatures DockAreaWidget::features(eBitwiseOperator mode) const
+ {
+ if (BitwiseAnd == mode) {
+ DockWidget::DockWidgetFeatures features(DockWidget::AllDockWidgetFeatures);
+ for (const auto dockWidget : dockWidgets()) {
+ features &= dockWidget->features();
+ }
+ return features;
+ } else {
+ DockWidget::DockWidgetFeatures features(DockWidget::NoDockWidgetFeatures);
+ for (const auto dockWidget : dockWidgets()) {
+ features |= dockWidget->features();
+ }
+ return features;
+ }
+ }
+
+ void DockAreaWidget::toggleView(bool open)
+ {
+ setVisible(open);
+
+ emit viewToggled(open);
+ }
+
+ void DockAreaWidget::setVisible(bool visible)
+ {
+ Super::setVisible(visible);
+ if (d->m_updateTitleBarButtons) {
+ d->updateTitleBarButtonStates();
+ }
+ }
+
+ void DockAreaWidget::setAllowedAreas(DockWidgetAreas areas)
+ {
+ d->m_allowedAreas = areas;
+ }
+
+ DockWidgetAreas DockAreaWidget::allowedAreas() const
+ {
+ return d->m_allowedAreas;
+ }
+
+ QAbstractButton *DockAreaWidget::titleBarButton(eTitleBarButton which) const
+ {
+ return d->m_titleBar->button(which);
+ }
+
+ void DockAreaWidget::closeArea()
+ {
+ // If there is only one single dock widget and this widget has the
+ // DeleteOnClose feature, then we delete the dock widget now
+ auto openDockWidgets = openedDockWidgets();
+ if (openDockWidgets.count() == 1
+ && openDockWidgets[0]->features().testFlag(DockWidget::DockWidgetDeleteOnClose)) {
+ openDockWidgets[0]->closeDockWidgetInternal();
+ } else {
+ for (auto dockWidget : openedDockWidgets()) {
+ dockWidget->toggleView(false);
+ }
+ }
+ }
+
+ void DockAreaWidget::closeOtherAreas() { dockContainer()->closeOtherAreas(this); }
+
+ DockAreaTitleBar *DockAreaWidget::titleBar() const { return d->m_titleBar; }
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockareawidget.h b/src/libs/advanceddockingsystem/dockareawidget.h
new file mode 100644
index 00000000000..fab47e94769
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockareawidget.h
@@ -0,0 +1,321 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "ads_globals.h"
+#include "dockwidget.h"
+
+#include
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QXmlStreamWriter;
+QT_END_NAMESPACE
+
+namespace ADS {
+
+struct DockAreaWidgetPrivate;
+class DockManager;
+class DockContainerWidget;
+class DockContainerWidgetPrivate;
+class DockAreaTitleBar;
+
+/**
+ * DockAreaWidget manages multiple instances of DockWidgets.
+ * It displays a title tab, which is clickable and will switch to
+ * the contents associated to the title when clicked.
+ */
+class ADS_EXPORT DockAreaWidget : public QFrame
+{
+ Q_OBJECT
+private:
+ DockAreaWidgetPrivate *d; ///< private data (pimpl)
+ friend struct DockAreaWidgetPrivate;
+ friend class DockContainerWidget;
+ friend class DockContainerWidgetPrivate;
+ friend class DockWidgetTab;
+ friend struct DockWidgetPrivate;
+ friend class DockWidget;
+ friend struct DockManagerPrivate;
+ friend class DockManager;
+
+ void onTabCloseRequested(int index);
+
+ /**
+ * Reorder the index position of DockWidget at fromIndx to toIndex
+ * if a tab in the tabbar is dragged from one index to another one
+ */
+ void reorderDockWidget(int fromIndex, int toIndex);
+
+protected:
+ /**
+ * Inserts a dock widget into dock area.
+ * All dockwidgets in the dock area tabified in a stacked layout with tabs.
+ * The index indicates the index of the new dockwidget in the tabbar and
+ * in the stacked layout. If the Activate parameter is true, the new
+ * DockWidget will be the active one in the stacked layout
+ */
+ void insertDockWidget(int index, DockWidget *dockWidget, bool activate = true);
+
+ /**
+ * Add a new dock widget to dock area.
+ * All dockwidgets in the dock area tabified in a stacked layout with tabs
+ */
+ void addDockWidget(DockWidget *dockWidget);
+
+ /**
+ * Removes the given dock widget from the dock area
+ */
+ void removeDockWidget(DockWidget *dockWidget);
+
+ /**
+ * Called from dock widget if it is opened or closed
+ */
+ void toggleDockWidgetView(DockWidget *dockWidget, bool open);
+
+ /**
+ * This is a helper function to get the next open dock widget to activate
+ * if the given DockWidget will be closed or removed.
+ * The function returns the next widget that should be activated or
+ * nullptr in case there are no more open widgets in this area.
+ */
+ DockWidget *nextOpenDockWidget(DockWidget *dockWidget) const;
+
+ /**
+ * Returns the index of the given DockWidget in the internal layout
+ */
+ int indexOf(DockWidget *dockWidget);
+
+ /**
+ * Call this function, if you already know, that the dock does not
+ * contain any visible content (any open dock widgets).
+ */
+ void hideAreaWithNoVisibleContent();
+
+ /**
+ * Updates the dock area layout and components visibility
+ */
+ void updateTitleBarVisibility();
+
+ /**
+ * This is the internal private function for setting the current widget.
+ * This function is called by the public setCurrentDockWidget() function
+ * and by the dock manager when restoring the state
+ */
+ void internalSetCurrentDockWidget(DockWidget *dockWidget);
+
+ /**
+ * Marks tabs menu to update
+ */
+ void markTitleBarMenuOutdated();
+
+ void toggleView(bool open);
+
+public:
+ using Super = QFrame;
+
+ /**
+ * Default Constructor
+ */
+ DockAreaWidget(DockManager *dockManager, DockContainerWidget *parent);
+
+ /**
+ * Virtual Destructor
+ */
+ virtual ~DockAreaWidget() override;
+
+ /**
+ * Returns the dock manager object this dock area belongs to
+ */
+ DockManager *dockManager() const;
+
+ /**
+ * Returns the dock container widget this dock area widget belongs to or 0
+ * if there is no
+ */
+ DockContainerWidget *dockContainer() const;
+
+ /**
+ * Returns the rectangle of the title area
+ */
+ QRect titleBarGeometry() const;
+
+ /**
+ * Returns the rectangle of the content
+ */
+ QRect contentAreaGeometry() const;
+
+ /**
+ * Returns the number of dock widgets in this area
+ */
+ int dockWidgetsCount() const;
+
+ /**
+ * Returns a list of all dock widgets in this dock area.
+ * This list contains open and closed dock widgets.
+ */
+ QList dockWidgets() const;
+
+ /**
+ * Returns the number of open dock widgets in this area
+ */
+ int openDockWidgetsCount() const;
+
+ /**
+ * Returns a list of dock widgets that are not closed.
+ */
+ QList openedDockWidgets() const;
+
+ /**
+ * Returns a dock widget by its index
+ */
+ DockWidget *dockWidget(int indexOf) const;
+
+ /**
+ * Returns the index of the current active dock widget or -1 if there
+ * are is no active dock widget (ie.e if all dock widgets are closed)
+ */
+ int currentIndex() const;
+
+ /**
+ * Returns the index of the first open dock widgets in the list of
+ * dock widgets.
+ * This function is here for performance reasons. Normally it would
+ * be possible to take the first dock widget from the list returned by
+ * openedDockWidgets() function. But that function enumerates all
+ * dock widgets while this functions stops after the first open dock widget.
+ * If there are no open dock widgets, the function returns -1.
+ */
+ int indexOfFirstOpenDockWidget() const;
+
+ /**
+ * Returns the current active dock widget or a nullptr if there is no
+ * active dock widget (i.e. if all dock widgets are closed)
+ */
+ DockWidget *currentDockWidget() const;
+
+ /**
+ * Shows the tab with the given dock widget
+ */
+ void setCurrentDockWidget(DockWidget *dockWidget);
+
+ /**
+ * Saves the state into the given stream
+ */
+ void saveState(QXmlStreamWriter &stream) const;
+
+ /**
+ * This functions returns the dock widget features of all dock widget in
+ * this area.
+ * A bitwise and is used to combine the flags of all dock widgets. That
+ * means, if only one single dock widget does not support a certain flag,
+ * the whole dock are does not support the flag. I.e. if one single
+ * dock widget in this area is not closable, the whole dock are is not
+ * closable.
+ */
+ DockWidget::DockWidgetFeatures features(eBitwiseOperator mode = BitwiseAnd) const;
+
+ /**
+ * Returns the title bar button corresponding to the given title bar
+ * button identifier
+ */
+ QAbstractButton *titleBarButton(eTitleBarButton which) const;
+
+ /**
+ * Update the close button if visibility changed
+ */
+ virtual void setVisible(bool visible) override;
+
+ /**
+ * Configures the areas of this particular dock area that are allowed for docking
+ */
+ void setAllowedAreas(DockWidgetAreas areas);
+
+ /**
+ * Returns flags with all allowed drop areas of this particular dock area
+ */
+ DockWidgetAreas allowedAreas() const;
+
+ /**
+ * Returns the title bar of this dock area
+ */
+ DockAreaTitleBar *titleBar() const;
+
+ /**
+ * This activates the tab for the given tab index.
+ * If the dock widget for the given tab is not visible, the this function
+ * call will make it visible.
+ */
+ void setCurrentIndex(int indexOf);
+
+ /**
+ * Closes the dock area and all dock widgets in this area
+ */
+ void closeArea();
+
+ /**
+ * This function closes all other areas except of this area
+ */
+ void closeOtherAreas();
+
+signals:
+ /**
+ * This signal is emitted when user clicks on a tab at an index.
+ */
+ void tabBarClicked(int indexOf);
+
+ /**
+ * This signal is emitted when the tab bar's current tab is about to be changed. The new
+ * current has the given index, or -1 if there isn't a new one.
+ * @param index
+ */
+ void currentChanging(int indexOf);
+
+ /**
+ * This signal is emitted when the tab bar's current tab changes. The new
+ * current has the given index, or -1 if there isn't a new one
+ * @param index
+ */
+ void currentChanged(int indexOf);
+
+ /**
+ * This signal is emitted if the visibility of this dock area is toggled
+ * via toggle view function
+ */
+ void viewToggled(bool open);
+}; // class DockAreaWidget
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockcomponentsfactory.cpp b/src/libs/advanceddockingsystem/dockcomponentsfactory.cpp
new file mode 100644
index 00000000000..1b5a0933c2a
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockcomponentsfactory.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockcomponentsfactory.h"
+
+#include "dockwidgettab.h"
+#include "dockareatabbar.h"
+#include "dockareatitlebar.h"
+#include "dockwidget.h"
+#include "dockareawidget.h"
+
+#include
+
+namespace ADS
+{
+ static std::unique_ptr g_defaultFactory(new DockComponentsFactory());
+
+ DockWidgetTab *DockComponentsFactory::createDockWidgetTab(DockWidget *dockWidget) const
+ {
+ return new DockWidgetTab(dockWidget);
+ }
+
+ DockAreaTabBar *DockComponentsFactory::createDockAreaTabBar(DockAreaWidget *dockArea) const
+ {
+ return new DockAreaTabBar(dockArea);
+ }
+
+ DockAreaTitleBar *DockComponentsFactory::createDockAreaTitleBar(DockAreaWidget *dockArea) const
+ {
+ return new DockAreaTitleBar(dockArea);
+ }
+
+ const DockComponentsFactory *DockComponentsFactory::factory()
+ {
+ return g_defaultFactory.get();
+ }
+
+ void DockComponentsFactory::setFactory(DockComponentsFactory *factory)
+ {
+ g_defaultFactory.reset(factory);
+ }
+
+ void DockComponentsFactory::resetDefaultFactory()
+ {
+ g_defaultFactory.reset(new DockComponentsFactory());
+ }
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockcomponentsfactory.h b/src/libs/advanceddockingsystem/dockcomponentsfactory.h
new file mode 100644
index 00000000000..8e1019a9312
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockcomponentsfactory.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "ads_globals.h"
+
+namespace ADS {
+
+class DockWidgetTab;
+class DockAreaTitleBar;
+class DockAreaTabBar;
+class DockAreaWidget;
+class DockWidget;
+
+/**
+ * Factory for creation of certain GUI elements for the docking framework.
+ * A default unique instance provided by DockComponentsFactory is used for
+ * creation of all supported components. To inject your custom components,
+ * you can create your own derived dock components factory and register
+ * it via setDefaultFactory() function.
+ * \code
+ * CDockComponentsFactory::setDefaultFactory(new MyComponentsFactory()));
+ * \endcode
+ */
+class ADS_EXPORT DockComponentsFactory
+{
+public:
+ /**
+ * Force virtual destructor
+ */
+ virtual ~DockComponentsFactory() {}
+
+ /**
+ * This default implementation just creates a dock widget tab with
+ * new DockWidgetTab(dockWidget).
+ */
+ virtual DockWidgetTab *createDockWidgetTab(DockWidget *dockWidget) const;
+
+ /**
+ * This default implementation just creates a dock area tab bar with
+ * new DockAreaTabBar(dockArea).
+ */
+ virtual DockAreaTabBar *createDockAreaTabBar(DockAreaWidget *dockArea) const;
+
+ /**
+ * This default implementation just creates a dock area title bar with
+ * new DockAreaTitleBar(dockArea).
+ */
+ virtual DockAreaTitleBar *createDockAreaTitleBar(DockAreaWidget *dockArea) const;
+
+ /**
+ * Returns the default components factory
+ */
+ static const DockComponentsFactory *factory();
+
+ /**
+ * Sets a new default factory for creation of GUI elements.
+ * This function takes ownership of the given Factory.
+ */
+ static void setFactory(DockComponentsFactory* factory);
+
+ /**
+ * Resets the current factory to the
+ */
+ static void resetDefaultFactory();
+};
+
+/**
+ * Convenience function to ease factory instance access
+ */
+inline const DockComponentsFactory *componentsFactory()
+{
+ return DockComponentsFactory::factory();
+}
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockcontainerwidget.cpp b/src/libs/advanceddockingsystem/dockcontainerwidget.cpp
new file mode 100644
index 00000000000..10fdc8cde25
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockcontainerwidget.cpp
@@ -0,0 +1,1459 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockcontainerwidget.h"
+
+#include "ads_globals.h"
+#include "dockareawidget.h"
+#include "dockingstatereader.h"
+#include "dockmanager.h"
+#include "dockoverlay.h"
+#include "docksplitter.h"
+#include "dockwidget.h"
+#include "floatingdockcontainer.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+static Q_LOGGING_CATEGORY(adsLog, "qtc.qmldesigner.advanceddockingsystem", QtWarningMsg)
+
+namespace ADS
+{
+ static unsigned int zOrderCounter = 0;
+
+ enum eDropMode {
+ DropModeIntoArea, ///< drop widget into a dock area
+ DropModeIntoContainer, ///< drop into container
+ DropModeInvalid ///< invalid mode - do not drop
+ };
+
+ /**
+ * Converts dock area ID to an index for array access
+ */
+ static int areaIdToIndex(DockWidgetArea area)
+ {
+ switch (area) {
+ case LeftDockWidgetArea:
+ return 0;
+ case RightDockWidgetArea:
+ return 1;
+ case TopDockWidgetArea:
+ return 2;
+ case BottomDockWidgetArea:
+ return 3;
+ case CenterDockWidgetArea:
+ return 4;
+ default:
+ return 4;
+ }
+ }
+
+ /**
+ * Helper function to ease insertion of dock area into splitter
+ */
+ static void insertWidgetIntoSplitter(QSplitter *splitter, QWidget *widget, bool append)
+ {
+ if (append) {
+ splitter->addWidget(widget);
+ } else {
+ splitter->insertWidget(0, widget);
+ }
+ }
+
+ /**
+ * Private data class of DockContainerWidget class (pimpl)
+ */
+ class DockContainerWidgetPrivate
+ {
+ public:
+ DockContainerWidget *q;
+ QPointer m_dockManager;
+ unsigned int m_zOrderIndex = 0;
+ QList m_dockAreas;
+ QGridLayout *m_layout = nullptr;
+ QSplitter *m_rootSplitter = nullptr;
+ bool m_isFloating = false;
+ DockAreaWidget *m_lastAddedAreaCache[5];
+ int m_visibleDockAreaCount = -1;
+ DockAreaWidget *m_topLevelDockArea = nullptr;
+
+ /**
+ * Private data constructor
+ */
+ DockContainerWidgetPrivate(DockContainerWidget *parent);
+
+ /**
+ * Adds dock widget to container and returns the dock area that contains
+ * the inserted dock widget
+ */
+ DockAreaWidget *dockWidgetIntoContainer(DockWidgetArea area, DockWidget *dockWidget);
+
+ /**
+ * Adds dock widget to a existing DockWidgetArea
+ */
+ DockAreaWidget *dockWidgetIntoDockArea(DockWidgetArea area,
+ DockWidget *dockWidget,
+ DockAreaWidget *targetDockArea);
+
+ /**
+ * Add dock area to this container
+ */
+ void addDockArea(DockAreaWidget *newDockWidget, DockWidgetArea area = CenterDockWidgetArea);
+
+ /**
+ * Drop floating widget into container
+ */
+ void dropIntoContainer(FloatingDockContainer *floatingWidget, DockWidgetArea area);
+
+ /**
+ * Drop floating widget into dock area
+ */
+ void dropIntoSection(FloatingDockContainer *floatingWidget,
+ DockAreaWidget *targetArea,
+ DockWidgetArea area);
+
+ /**
+ * Moves the dock widget or dock area given in Widget parameter to a
+ * new dock widget area
+ */
+ void moveToNewSection(QWidget *widget, DockAreaWidget *targetArea, DockWidgetArea area);
+
+ /**
+ * Moves the dock widget or dock area given in Widget parameter to a
+ * a dock area in container
+ */
+ void moveToContainer(QWidget *widget, DockWidgetArea area);
+
+ /**
+ * Creates a new tab for a widget dropped into the center of a section
+ */
+ void dropIntoCenterOfSection(FloatingDockContainer *floatingWidget,
+ DockAreaWidget *targetArea);
+
+ /**
+ * Creates a new tab for a widget dropped into the center of a section
+ */
+ void moveIntoCenterOfSection(QWidget *widget, DockAreaWidget *targetArea);
+
+ /**
+ * Adds new dock areas to the internal dock area list
+ */
+ void addDockAreasToList(const QList newDockAreas);
+
+ /**
+ * Wrapper function for DockAreas append, that ensures that dock area signals
+ * are properly connected to dock container slots
+ */
+ void appendDockAreas(const QList newDockAreas);
+
+ /**
+ * Save state of child nodes
+ */
+ void saveChildNodesState(QXmlStreamWriter &stream, QWidget *widget);
+
+ /**
+ * Restore state of child nodes.
+ * \param[in] Stream The data stream that contains the serialized state
+ * \param[out] CreatedWidget The widget created from parsed data or 0 if
+ * the parsed widget was an empty splitter
+ * \param[in] Testing If Testing is true, only the stream data is
+ * parsed without modifiying anything.
+ */
+ bool restoreChildNodes(DockingStateReader &stateReader,
+ QWidget *&createdWidget,
+ bool testing);
+
+ /**
+ * Restores a splitter.
+ * \see restoreChildNodes() for details
+ */
+ bool restoreSplitter(DockingStateReader &stateReader, QWidget *&createdWidget, bool testing);
+
+ /**
+ * Restores a dock area.
+ * \see restoreChildNodes() for details
+ */
+ bool restoreDockArea(DockingStateReader &stateReader, QWidget *&createdWidget, bool testing);
+
+ /**
+ * Helper function for recursive dumping of layout
+ */
+ void dumpRecursive(int level, QWidget *widget) const;
+
+ /**
+ * Calculate the drop mode from the given target position
+ */
+ eDropMode getDropMode(const QPoint &targetPosition);
+
+ /**
+ * Initializes the visible dock area count variable if it is not initialized
+ * yet
+ */
+ void initVisibleDockAreaCount()
+ {
+ if (m_visibleDockAreaCount > -1) {
+ return;
+ }
+
+ m_visibleDockAreaCount = 0;
+ for (auto dockArea : m_dockAreas) {
+ m_visibleDockAreaCount += dockArea->isHidden() ? 0 : 1;
+ }
+ }
+
+ /**
+ * Access function for the visible dock area counter
+ */
+ int visibleDockAreaCount()
+ {
+ // Lazy initialization - we initialize the VisibleDockAreaCount variable
+ // on first use
+ initVisibleDockAreaCount();
+ return m_visibleDockAreaCount;
+ }
+
+ /**
+ * The visible dock area count changes, if dock areas are remove, added or
+ * when its view is toggled
+ */
+ void onVisibleDockAreaCountChanged();
+
+ void emitDockAreasRemoved()
+ {
+ onVisibleDockAreaCountChanged();
+ emit q->dockAreasRemoved();
+ }
+
+ void emitDockAreasAdded()
+ {
+ onVisibleDockAreaCountChanged();
+ emit q->dockAreasAdded();
+ }
+
+ /**
+ * Helper function for creation of new splitter
+ */
+ DockSplitter *createSplitter(Qt::Orientation orientation, QWidget *parent = nullptr)
+ {
+ auto *splitter = new DockSplitter(orientation, parent);
+ splitter->setOpaqueResize(
+ DockManager::configFlags().testFlag(DockManager::OpaqueSplitterResize));
+ splitter->setChildrenCollapsible(false);
+ return splitter;
+ }
+
+ void onDockAreaViewToggled(bool visible)
+ {
+ DockAreaWidget *dockArea = qobject_cast(q->sender());
+ m_visibleDockAreaCount += visible ? 1 : -1;
+ onVisibleDockAreaCountChanged();
+ emit q->dockAreaViewToggled(dockArea, visible);
+ }
+ }; // struct DockContainerWidgetPrivate
+
+ DockContainerWidgetPrivate::DockContainerWidgetPrivate(DockContainerWidget *parent)
+ : q(parent)
+ {
+ std::fill(std::begin(m_lastAddedAreaCache), std::end(m_lastAddedAreaCache), nullptr);
+ }
+
+ eDropMode DockContainerWidgetPrivate::getDropMode(const QPoint &targetPosition)
+ {
+ DockAreaWidget *dockArea = q->dockAreaAt(targetPosition);
+ auto dropArea = InvalidDockWidgetArea;
+ auto containerDropArea = m_dockManager->containerOverlay()->dropAreaUnderCursor();
+
+ if (dockArea) {
+ auto dropOverlay = m_dockManager->dockAreaOverlay();
+ dropOverlay->setAllowedAreas(dockArea->allowedAreas());
+ dropArea = dropOverlay->showOverlay(dockArea);
+ if (containerDropArea != InvalidDockWidgetArea && containerDropArea != dropArea) {
+ dropArea = InvalidDockWidgetArea;
+ }
+
+ if (dropArea != InvalidDockWidgetArea) {
+ qCInfo(adsLog) << "Dock Area Drop Content: " << dropArea;
+ return DropModeIntoArea;
+ }
+ }
+
+ // mouse is over container
+ if (InvalidDockWidgetArea == dropArea) {
+ dropArea = containerDropArea;
+ qCInfo(adsLog) << "Container Drop Content: " << dropArea;
+ if (dropArea != InvalidDockWidgetArea) {
+ return DropModeIntoContainer;
+ }
+ }
+
+ return DropModeInvalid;
+ }
+
+ void DockContainerWidgetPrivate::onVisibleDockAreaCountChanged()
+ {
+ auto topLevelDockArea = q->topLevelDockArea();
+
+ if (topLevelDockArea) {
+ this->m_topLevelDockArea = topLevelDockArea;
+ topLevelDockArea->titleBarButton(TitleBarButtonUndock)
+ ->setVisible(false || !q->isFloating());
+ topLevelDockArea->titleBarButton(TitleBarButtonClose)
+ ->setVisible(false || !q->isFloating());
+ } else if (this->m_topLevelDockArea) {
+ this->m_topLevelDockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
+ this->m_topLevelDockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
+ this->m_topLevelDockArea = nullptr;
+ }
+ }
+
+ void DockContainerWidgetPrivate::dropIntoContainer(FloatingDockContainer *floatingWidget,
+ DockWidgetArea area)
+ {
+ auto insertParam = internal::dockAreaInsertParameters(area);
+ DockContainerWidget *floatingDockContainer = floatingWidget->dockContainer();
+ auto newDockAreas = floatingDockContainer
+ ->findChildren(QString(),
+ Qt::FindChildrenRecursively);
+ QSplitter *splitter = m_rootSplitter;
+
+ if (m_dockAreas.count() <= 1) {
+ splitter->setOrientation(insertParam.orientation());
+ } else if (splitter->orientation() != insertParam.orientation()) {
+ QSplitter *newSplitter = createSplitter(insertParam.orientation());
+ QLayoutItem *layoutItem = m_layout->replaceWidget(splitter, newSplitter);
+ newSplitter->addWidget(splitter);
+ splitter = newSplitter;
+ delete layoutItem;
+ }
+
+ // Now we can insert the floating widget content into this container
+ auto floatingSplitter = floatingDockContainer->rootSplitter();
+ if (floatingSplitter->count() == 1) {
+ insertWidgetIntoSplitter(splitter, floatingSplitter->widget(0), insertParam.append());
+ } else if (floatingSplitter->orientation() == insertParam.orientation()) {
+ while (floatingSplitter->count()) {
+ insertWidgetIntoSplitter(splitter,
+ floatingSplitter->widget(0),
+ insertParam.append());
+ }
+ } else {
+ insertWidgetIntoSplitter(splitter, floatingSplitter, insertParam.append());
+ }
+
+ m_rootSplitter = splitter;
+ addDockAreasToList(newDockAreas);
+
+ // If we dropped the floating widget into the main dock container that does
+ // not contain any dock widgets, then splitter is invisible and we need to
+ // show it to display the docked widgets
+ if (!splitter->isVisible()) {
+ splitter->show();
+ }
+ q->dumpLayout();
+ }
+
+ void DockContainerWidgetPrivate::dropIntoCenterOfSection(FloatingDockContainer *floatingWidget,
+ DockAreaWidget *targetArea)
+ {
+ DockContainerWidget *floatingContainer = floatingWidget->dockContainer();
+ auto newDockWidgets = floatingContainer->dockWidgets();
+ auto topLevelDockArea = floatingContainer->topLevelDockArea();
+ int newCurrentIndex = -1;
+
+ // If the floating widget contains only one single dock are, then the
+ // current dock widget of the dock area will also be the future current
+ // dock widget in the drop area.
+ if (topLevelDockArea) {
+ newCurrentIndex = topLevelDockArea->currentIndex();
+ }
+
+ for (int i = 0; i < newDockWidgets.count(); ++i) {
+ DockWidget *dockWidget = newDockWidgets[i];
+ targetArea->insertDockWidget(i, dockWidget, false);
+ // If the floating widget contains multiple visible dock areas, then we
+ // simply pick the first visible open dock widget and make it
+ // the current one.
+ if (newCurrentIndex < 0 && !dockWidget->isClosed()) {
+ newCurrentIndex = i;
+ }
+ }
+ targetArea->setCurrentIndex(newCurrentIndex);
+ targetArea->updateTitleBarVisibility();
+ return;
+ }
+
+ void DockContainerWidgetPrivate::dropIntoSection(FloatingDockContainer *floatingWidget,
+ DockAreaWidget *targetArea,
+ DockWidgetArea area)
+ {
+ // Dropping into center means all dock widgets in the dropped floating
+ // widget will become tabs of the drop area
+ if (CenterDockWidgetArea == area) {
+ dropIntoCenterOfSection(floatingWidget, targetArea);
+ return;
+ }
+
+ auto insertParam = internal::dockAreaInsertParameters(area);
+ auto newDockAreas = floatingWidget->dockContainer()
+ ->findChildren(QString(),
+ Qt::FindChildrenRecursively);
+ QSplitter *targetAreaSplitter = internal::findParent(targetArea);
+
+ if (!targetAreaSplitter) {
+ QSplitter *splitter = createSplitter(insertParam.orientation());
+ m_layout->replaceWidget(targetArea, splitter);
+ splitter->addWidget(targetArea);
+ targetAreaSplitter = splitter;
+ }
+ int areaIndex = targetAreaSplitter->indexOf(targetArea);
+ auto widget = floatingWidget->dockContainer()
+ ->findChild(QString(), Qt::FindDirectChildrenOnly);
+ auto floatingSplitter = qobject_cast(widget);
+
+ if (targetAreaSplitter->orientation() == insertParam.orientation()) {
+ auto sizes = targetAreaSplitter->sizes();
+ int targetAreaSize = (insertParam.orientation() == Qt::Horizontal)
+ ? targetArea->width()
+ : targetArea->height();
+ bool adjustSplitterSizes = true;
+ if ((floatingSplitter->orientation() != insertParam.orientation())
+ && floatingSplitter->count() > 1) {
+ targetAreaSplitter->insertWidget(areaIndex + insertParam.insertOffset(), widget);
+ } else {
+ adjustSplitterSizes = (floatingSplitter->count() == 1);
+ int insertIndex = areaIndex + insertParam.insertOffset();
+ while (floatingSplitter->count()) {
+ targetAreaSplitter->insertWidget(insertIndex++, floatingSplitter->widget(0));
+ }
+ }
+
+ if (adjustSplitterSizes) {
+ int size = (targetAreaSize - targetAreaSplitter->handleWidth()) / 2;
+ sizes[areaIndex] = size;
+ sizes.insert(areaIndex, size);
+ targetAreaSplitter->setSizes(sizes);
+ }
+ } else {
+ QList newSplitterSizes;
+ QSplitter *newSplitter = createSplitter(insertParam.orientation());
+ int targetAreaSize = (insertParam.orientation() == Qt::Horizontal)
+ ? targetArea->width()
+ : targetArea->height();
+ bool adjustSplitterSizes = true;
+ if ((floatingSplitter->orientation() != insertParam.orientation())
+ && floatingSplitter->count() > 1) {
+ newSplitter->addWidget(widget);
+ } else {
+ adjustSplitterSizes = (floatingSplitter->count() == 1);
+ while (floatingSplitter->count()) {
+ newSplitter->addWidget(floatingSplitter->widget(0));
+ }
+ }
+
+ // Save the sizes before insertion and restore it later to prevent
+ // shrinking of existing area
+ auto sizes = targetAreaSplitter->sizes();
+ insertWidgetIntoSplitter(newSplitter, targetArea, !insertParam.append());
+ if (adjustSplitterSizes) {
+ int size = targetAreaSize / 2;
+ newSplitter->setSizes({size, size});
+ }
+ targetAreaSplitter->insertWidget(areaIndex, newSplitter);
+ targetAreaSplitter->setSizes(sizes);
+ }
+
+ addDockAreasToList(newDockAreas);
+ q->dumpLayout();
+ }
+
+ void DockContainerWidgetPrivate::moveIntoCenterOfSection(QWidget *widget,
+ DockAreaWidget *targetArea)
+ {
+ auto droppedDockWidget = qobject_cast(widget);
+ auto droppedArea = qobject_cast(widget);
+
+ if (droppedDockWidget) {
+ DockAreaWidget *oldDockArea = droppedDockWidget->dockAreaWidget();
+ if (oldDockArea) {
+ oldDockArea->removeDockWidget(droppedDockWidget);
+ }
+ targetArea->insertDockWidget(0, droppedDockWidget, true);
+ } else {
+ QList newDockWidgets = droppedArea->dockWidgets();
+ int newCurrentIndex = droppedArea->currentIndex();
+ for (int i = 0; i < newDockWidgets.count(); ++i) {
+ DockWidget *dockWidget = newDockWidgets[i];
+ targetArea->insertDockWidget(i, dockWidget, false);
+ }
+ targetArea->setCurrentIndex(newCurrentIndex);
+ droppedArea->dockContainer()->removeDockArea(droppedArea);
+ droppedArea->deleteLater();
+ }
+
+ targetArea->updateTitleBarVisibility();
+ return;
+ }
+
+ void DockContainerWidgetPrivate::moveToNewSection(QWidget *widget,
+ DockAreaWidget *targetArea,
+ DockWidgetArea area)
+ {
+ // Dropping into center means all dock widgets in the dropped floating
+ // widget will become tabs of the drop area
+ if (CenterDockWidgetArea == area) {
+ moveIntoCenterOfSection(widget, targetArea);
+ return;
+ }
+
+ DockWidget *droppedDockWidget = qobject_cast(widget);
+ DockAreaWidget *droppedDockArea = qobject_cast(widget);
+ DockAreaWidget *newDockArea;
+ if (droppedDockWidget) {
+ newDockArea = new DockAreaWidget(m_dockManager, q);
+ DockAreaWidget *oldDockArea = droppedDockWidget->dockAreaWidget();
+ if (oldDockArea) {
+ oldDockArea->removeDockWidget(droppedDockWidget);
+ }
+ newDockArea->addDockWidget(droppedDockWidget);
+ } else {
+ droppedDockArea->dockContainer()->removeDockArea(droppedDockArea);
+ newDockArea = droppedDockArea;
+ }
+
+ auto insertParam = internal::dockAreaInsertParameters(area);
+ QSplitter *targetAreaSplitter = internal::findParent(targetArea);
+ int areaIndex = targetAreaSplitter->indexOf(targetArea);
+ auto sizes = targetAreaSplitter->sizes();
+ if (targetAreaSplitter->orientation() == insertParam.orientation()) {
+ int targetAreaSize = (insertParam.orientation() == Qt::Horizontal)
+ ? targetArea->width()
+ : targetArea->height();
+ targetAreaSplitter->insertWidget(areaIndex + insertParam.insertOffset(), newDockArea);
+ int size = (targetAreaSize - targetAreaSplitter->handleWidth()) / 2;
+ sizes[areaIndex] = size;
+ sizes.insert(areaIndex, size);
+ } else {
+ auto sizes = targetAreaSplitter->sizes();
+ int targetAreaSize = (insertParam.orientation() == Qt::Horizontal)
+ ? targetArea->width()
+ : targetArea->height();
+ QSplitter *newSplitter = createSplitter(insertParam.orientation());
+ newSplitter->addWidget(targetArea);
+ insertWidgetIntoSplitter(newSplitter, newDockArea, insertParam.append());
+ int size = targetAreaSize / 2;
+ newSplitter->setSizes({size, size});
+ targetAreaSplitter->insertWidget(areaIndex, newSplitter);
+ }
+ targetAreaSplitter->setSizes(sizes);
+
+ addDockAreasToList({newDockArea});
+ }
+
+ void DockContainerWidgetPrivate::moveToContainer(QWidget *widget, DockWidgetArea area)
+ {
+ DockWidget *droppedDockWidget = qobject_cast(widget);
+ DockAreaWidget *droppedDockArea = qobject_cast(widget);
+ DockAreaWidget *newDockArea;
+
+ if (droppedDockWidget) {
+ newDockArea = new DockAreaWidget(m_dockManager, q);
+ DockAreaWidget *oldDockArea = droppedDockWidget->dockAreaWidget();
+ if (oldDockArea) {
+ oldDockArea->removeDockWidget(droppedDockWidget);
+ }
+ newDockArea->addDockWidget(droppedDockWidget);
+ } else {
+ droppedDockArea->dockContainer()->removeDockArea(droppedDockArea);
+ newDockArea = droppedDockArea;
+ }
+
+ addDockArea(newDockArea, area);
+ m_lastAddedAreaCache[areaIdToIndex(area)] = newDockArea;
+ }
+
+ void DockContainerWidgetPrivate::addDockAreasToList(const QList newDockAreas)
+ {
+ int countBefore = m_dockAreas.count();
+ int newAreaCount = newDockAreas.count();
+ appendDockAreas(newDockAreas);
+ // If the user dropped a floating widget that contains only one single
+ // visible dock area, then its title bar button TitleBarButtonUndock is
+ // likely hidden. We need to ensure, that it is visible
+ for (auto dockArea : newDockAreas) {
+ dockArea->titleBarButton(TitleBarButtonUndock)->setVisible(true);
+ dockArea->titleBarButton(TitleBarButtonClose)->setVisible(true);
+ }
+
+ // We need to ensure, that the dock area title bar is visible. The title bar
+ // is invisible, if the dock are is a single dock area in a floating widget.
+ if (1 == countBefore) {
+ m_dockAreas.at(0)->updateTitleBarVisibility();
+ }
+
+ if (1 == newAreaCount) {
+ m_dockAreas.last()->updateTitleBarVisibility();
+ }
+
+ emitDockAreasAdded();
+ }
+
+ void DockContainerWidgetPrivate::appendDockAreas(const QList newDockAreas)
+ {
+ m_dockAreas.append(newDockAreas);
+ for (auto dockArea : newDockAreas) {
+ QObject::connect(dockArea,
+ &DockAreaWidget::viewToggled,
+ q,
+ std::bind(&DockContainerWidgetPrivate::onDockAreaViewToggled,
+ this,
+ std::placeholders::_1));
+ }
+ }
+
+ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter &stream, QWidget *widget)
+ {
+ QSplitter *splitter = qobject_cast(widget);
+ if (splitter) {
+ stream.writeStartElement("splitter");
+ stream.writeAttribute("orientation",
+ QVariant::fromValue(splitter->orientation()).toString());
+ stream.writeAttribute("count", QString::number(splitter->count()));
+ qCInfo(adsLog) << "NodeSplitter orient: " << splitter->orientation()
+ << " WidgetCont: " << splitter->count();
+ for (int i = 0; i < splitter->count(); ++i) {
+ saveChildNodesState(stream, splitter->widget(i));
+ }
+
+ stream.writeStartElement("sizes");
+ QStringList sizes;
+ for (auto size : splitter->sizes()) {
+ sizes.append(QString::number(size));
+ }
+ stream.writeCharacters(sizes.join(" "));
+ stream.writeEndElement();
+ stream.writeEndElement();
+ } else {
+ DockAreaWidget *dockArea = qobject_cast(widget);
+ if (dockArea) {
+ dockArea->saveState(stream);
+ }
+ }
+ }
+
+ bool DockContainerWidgetPrivate::restoreSplitter(DockingStateReader &stateReader,
+ QWidget *&createdWidget,
+ bool testing)
+ {
+ QVariant orientationVar = QVariant(stateReader.attributes().value("orientation").toString());
+
+ // Check if the orientation string is convertable
+ if (!orientationVar.canConvert()) {
+ return false;
+ }
+ Qt::Orientation orientation = orientationVar.value();
+
+ bool ok;
+ int widgetCount = stateReader.attributes().value("count").toInt(&ok);
+ if (!ok) {
+ return false;
+ }
+ qCInfo(adsLog) << "Restore NodeSplitter Orientation: " << orientation
+ << " WidgetCount: " << widgetCount;
+ QSplitter *splitter = nullptr;
+ if (!testing) {
+ splitter = createSplitter(orientation);
+ }
+ bool visible = false;
+ QList sizes;
+ while (stateReader.readNextStartElement()) {
+ QWidget *childNode = nullptr;
+ bool result = true;
+ if (stateReader.name() == "splitter") {
+ result = restoreSplitter(stateReader, childNode, testing);
+ } else if (stateReader.name() == "area") {
+ result = restoreDockArea(stateReader, childNode, testing);
+ } else if (stateReader.name() == "sizes") {
+ QString size = stateReader.readElementText().trimmed();
+ qCInfo(adsLog) << "Size: " << size;
+ QTextStream textStream(&size);
+ while (!textStream.atEnd()) {
+ int value;
+ textStream >> value;
+ sizes.append(value);
+ }
+ } else {
+ stateReader.skipCurrentElement();
+ }
+
+ if (!result) {
+ return false;
+ }
+
+ if (testing || !childNode) {
+ continue;
+ }
+
+ qCInfo(adsLog) << "ChildNode isVisible " << childNode->isVisible() << " isVisibleTo "
+ << childNode->isVisibleTo(splitter);
+ splitter->addWidget(childNode);
+ visible |= childNode->isVisibleTo(splitter);
+ }
+
+ if (sizes.count() != widgetCount) {
+ return false;
+ }
+
+ if (!testing) {
+ if (!splitter->count()) {
+ delete splitter;
+ splitter = nullptr;
+ } else {
+ splitter->setSizes(sizes);
+ splitter->setVisible(visible);
+ }
+ createdWidget = splitter;
+ } else {
+ createdWidget = nullptr;
+ }
+
+ return true;
+ }
+
+ bool DockContainerWidgetPrivate::restoreDockArea(DockingStateReader &stateReader,
+ QWidget *&createdWidget,
+ bool testing)
+ {
+ QString currentDockWidget = stateReader.attributes().value("current").toString();
+
+#ifdef ADS_DEBUG_PRINT
+ bool ok;
+ int tabs = stateReader.attributes().value("tabs").toInt(&ok);
+ if (!ok) {
+ return false;
+ }
+ qCInfo(adsLog) << "Restore NodeDockArea Tabs: " << tabs
+ << " Current: " << currentDockWidget;
+#endif
+
+ DockAreaWidget *dockArea = nullptr;
+ if (!testing) {
+ dockArea = new DockAreaWidget(m_dockManager, q);
+ }
+
+ while (stateReader.readNextStartElement()) {
+ if (stateReader.name() != "widget") {
+ continue;
+ }
+
+ auto objectName = stateReader.attributes().value("name");
+ if (objectName.isEmpty()) {
+ qCInfo(adsLog) << "Error: Empty name!";
+ return false;
+ }
+
+ QVariant closedVar = QVariant(stateReader.attributes().value("closed").toString());
+ if (!closedVar.canConvert()) {
+ return false;
+ }
+ bool closed = closedVar.value();
+
+ stateReader.skipCurrentElement();
+ DockWidget *dockWidget = m_dockManager->findDockWidget(objectName.toString());
+ if (!dockWidget || testing) {
+ continue;
+ }
+
+ qCInfo(adsLog) << "Dock Widget found - parent " << dockWidget->parent();
+ // We hide the DockArea here to prevent the short display (the flashing)
+ // of the dock areas during application startup
+ dockArea->hide();
+ dockArea->addDockWidget(dockWidget);
+ dockWidget->setToggleViewActionChecked(!closed);
+ dockWidget->setClosedState(closed);
+ dockWidget->setProperty(internal::closedProperty, closed);
+ dockWidget->setProperty(internal::dirtyProperty, false);
+ }
+
+ if (testing) {
+ return true;
+ }
+
+ if (!dockArea->dockWidgetsCount()) {
+ delete dockArea;
+ dockArea = nullptr;
+ } else {
+ dockArea->setProperty("currentDockWidget", currentDockWidget);
+ appendDockAreas({dockArea});
+ }
+
+ createdWidget = dockArea;
+ return true;
+ }
+
+ bool DockContainerWidgetPrivate::restoreChildNodes(DockingStateReader &stateReader,
+ QWidget *&createdWidget,
+ bool testing)
+ {
+ bool result = true;
+ while (stateReader.readNextStartElement()) {
+ if (stateReader.name() == "splitter") {
+ result = restoreSplitter(stateReader, createdWidget, testing);
+ qCInfo(adsLog) << "Splitter";
+ } else if (stateReader.name() == "area") {
+ result = restoreDockArea(stateReader, createdWidget, testing);
+ qCInfo(adsLog) << "DockAreaWidget";
+ } else {
+ stateReader.skipCurrentElement();
+ qCInfo(adsLog) << "Unknown element" << stateReader.name();
+ }
+ }
+
+ return result;
+ }
+
+ DockAreaWidget *DockContainerWidgetPrivate::dockWidgetIntoContainer(DockWidgetArea area,
+ DockWidget *dockWidget)
+ {
+ DockAreaWidget *newDockArea = new DockAreaWidget(m_dockManager, q);
+ newDockArea->addDockWidget(dockWidget);
+ addDockArea(newDockArea, area);
+ newDockArea->updateTitleBarVisibility();
+ m_lastAddedAreaCache[areaIdToIndex(area)] = newDockArea;
+ return newDockArea;
+ }
+
+ void DockContainerWidgetPrivate::addDockArea(DockAreaWidget *newDockArea, DockWidgetArea area)
+ {
+ auto insertParam = internal::dockAreaInsertParameters(area);
+ // As long as we have only one dock area in the splitter we can adjust its orientation
+ if (m_dockAreas.count() <= 1) {
+ m_rootSplitter->setOrientation(insertParam.orientation());
+ }
+
+ QSplitter *splitter = m_rootSplitter;
+ if (splitter->orientation() == insertParam.orientation()) {
+ insertWidgetIntoSplitter(splitter, newDockArea, insertParam.append());
+ } else {
+ QSplitter *newSplitter = createSplitter(insertParam.orientation());
+ if (insertParam.append()) {
+ QLayoutItem *layoutItem = m_layout->replaceWidget(splitter, newSplitter);
+ newSplitter->addWidget(splitter);
+ newSplitter->addWidget(newDockArea);
+ delete layoutItem;
+ } else {
+ newSplitter->addWidget(newDockArea);
+ QLayoutItem *layoutItem = m_layout->replaceWidget(splitter, newSplitter);
+ newSplitter->addWidget(splitter);
+ delete layoutItem;
+ }
+ m_rootSplitter = newSplitter;
+ }
+
+ addDockAreasToList({newDockArea});
+ }
+
+ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget *widget) const
+ {
+#if defined(QT_DEBUG)
+ QSplitter *splitter = qobject_cast(widget);
+ QByteArray buf;
+ buf.fill(' ', level * 4);
+ if (splitter) {
+#ifdef ADS_DEBUG_PRINT
+ qDebug("%sSplitter %s v: %s c: %s",
+ buf.data(),
+ (splitter->orientation() == Qt::Vertical) ? "--" : "|",
+ splitter->isHidden() ? " " : "v",
+ QString::number(splitter->count()).toStdString().c_str());
+ std::cout << buf.data() << "Splitter "
+ << ((splitter->orientation() == Qt::Vertical) ? "--" : "|") << " "
+ << (splitter->isHidden() ? " " : "v") << " "
+ << QString::number(splitter->count()).toStdString() << std::endl;
+#endif
+ for (int i = 0; i < splitter->count(); ++i) {
+ dumpRecursive(level + 1, splitter->widget(i));
+ }
+ } else {
+ DockAreaWidget *dockArea = qobject_cast(widget);
+ if (!dockArea) {
+ return;
+ }
+#ifdef ADS_DEBUG_PRINT
+ qDebug("%sDockArea", buf.data());
+ std::cout << buf.data() << (dockArea->isHidden() ? " " : "v")
+ << (dockArea->openDockWidgetsCount() > 0 ? " " : "c") << " DockArea"
+ << std::endl;
+ buf.fill(' ', (level + 1) * 4);
+ for (int i = 0; i < dockArea->dockWidgetsCount(); ++i) {
+ std::cout << buf.data() << (i == dockArea->currentIndex() ? "*" : " ");
+ DockWidget *dockWidget = dockArea->dockWidget(i);
+ std::cout << (dockWidget->isHidden() ? " " : "v");
+ std::cout << (dockWidget->isClosed() ? "c" : " ") << " ";
+ std::cout << dockWidget->windowTitle().toStdString() << std::endl;
+ }
+#endif
+ }
+#else
+ Q_UNUSED(level)
+ Q_UNUSED(widget)
+#endif
+ }
+
+ DockAreaWidget *DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetArea area,
+ DockWidget *dockWidget,
+ DockAreaWidget
+ *targetDockArea)
+ {
+ if (CenterDockWidgetArea == area) {
+ targetDockArea->addDockWidget(dockWidget);
+ targetDockArea->updateTitleBarVisibility();
+ return targetDockArea;
+ }
+
+ DockAreaWidget *newDockArea = new DockAreaWidget(m_dockManager, q);
+ newDockArea->addDockWidget(dockWidget);
+ auto insertParam = internal::dockAreaInsertParameters(area);
+
+ QSplitter *targetAreaSplitter = internal::findParent(targetDockArea);
+ int index = targetAreaSplitter->indexOf(targetDockArea);
+ if (targetAreaSplitter->orientation() == insertParam.orientation()) {
+ qCInfo(adsLog) << "TargetAreaSplitter->orientation() == InsertParam.orientation()";
+ targetAreaSplitter->insertWidget(index + insertParam.insertOffset(), newDockArea);
+ } else {
+ qCInfo(adsLog) << "TargetAreaSplitter->orientation() != InsertParam.orientation()";
+ QSplitter *newSplitter = createSplitter(insertParam.orientation());
+ newSplitter->addWidget(targetDockArea);
+ insertWidgetIntoSplitter(newSplitter, newDockArea, insertParam.append());
+ targetAreaSplitter->insertWidget(index, newSplitter);
+ }
+
+ appendDockAreas({newDockArea});
+ emitDockAreasAdded();
+ return newDockArea;
+ }
+
+ DockContainerWidget::DockContainerWidget(DockManager *dockManager, QWidget *parent)
+ : QFrame(parent)
+ , d(new DockContainerWidgetPrivate(this))
+ {
+ d->m_dockManager = dockManager;
+ d->m_isFloating = floatingWidget() != nullptr;
+
+ d->m_layout = new QGridLayout();
+ d->m_layout->setContentsMargins(0, 1, 0, 1);
+ d->m_layout->setSpacing(0);
+ setLayout(d->m_layout);
+
+ // The function d->createSplitter() accesses the config flags from dock
+ // manager which in turn requires a properly constructed dock manager.
+ // If this dock container is the dock manager, then it is not properly
+ // constructed yet because this base class constructor is called before
+ // the constructor of the DockManager private class
+ if (dockManager != this) {
+ d->m_dockManager->registerDockContainer(this);
+ createRootSplitter();
+ }
+ }
+
+ DockContainerWidget::~DockContainerWidget()
+ {
+ if (d->m_dockManager) {
+ d->m_dockManager->removeDockContainer(this);
+ }
+ delete d;
+ }
+
+ DockAreaWidget *DockContainerWidget::addDockWidget(DockWidgetArea area,
+ DockWidget *dockWidget,
+ DockAreaWidget *dockAreaWidget)
+ {
+ DockAreaWidget *oldDockArea = dockWidget->dockAreaWidget();
+ if (oldDockArea) {
+ oldDockArea->removeDockWidget(dockWidget);
+ }
+
+ dockWidget->setDockManager(d->m_dockManager);
+ if (dockAreaWidget) {
+ return d->dockWidgetIntoDockArea(area, dockWidget, dockAreaWidget);
+ } else {
+ return d->dockWidgetIntoContainer(area, dockWidget);
+ }
+ }
+
+ void DockContainerWidget::removeDockWidget(DockWidget * dockWidget)
+ {
+ DockAreaWidget *area = dockWidget->dockAreaWidget();
+ if (area) {
+ area->removeDockWidget(dockWidget);
+ }
+ }
+
+ unsigned int DockContainerWidget::zOrderIndex() const { return d->m_zOrderIndex; }
+
+ bool DockContainerWidget::isInFrontOf(DockContainerWidget *other) const
+ {
+ return this->zOrderIndex() > other->zOrderIndex();
+ }
+
+ bool DockContainerWidget::event(QEvent *event)
+ {
+ bool result = QWidget::event(event);
+ if (event->type() == QEvent::WindowActivate) {
+ d->m_zOrderIndex = ++zOrderCounter;
+ } else if (event->type() == QEvent::Show && !d->m_zOrderIndex) {
+ d->m_zOrderIndex = ++zOrderCounter;
+ }
+
+ return result;
+ }
+
+ void DockContainerWidget::addDockArea(DockAreaWidget *dockAreaWidget, DockWidgetArea area)
+ {
+ DockContainerWidget *container = dockAreaWidget->dockContainer();
+ if (container && container != this) {
+ container->removeDockArea(dockAreaWidget);
+ }
+
+ d->addDockArea(dockAreaWidget, area);
+ }
+
+ void DockContainerWidget::removeDockArea(DockAreaWidget *area)
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ area->disconnect(this);
+ d->m_dockAreas.removeAll(area);
+ DockSplitter *splitter = internal::findParent(area);
+
+ // Remove area from parent splitter and recursively hide tree of parent
+ // splitters if it has no visible content
+ area->setParent(nullptr);
+ internal::hideEmptyParentSplitters(splitter);
+
+ // Remove this area from cached areas
+ const auto &cache = d->m_lastAddedAreaCache;
+ if (auto p = std::find(cache, cache + sizeof(cache) / sizeof(cache[0]), area)) {
+ d->m_lastAddedAreaCache[std::distance(cache, p)] = nullptr;
+ }
+
+ // If splitter has more than 1 widgets, we are finished and can leave
+ if (splitter->count() > 1) {
+ emitAndExit();
+ return;
+ }
+
+ // If this is the RootSplitter we need to remove empty splitters to
+ // avoid too many empty splitters
+ if (splitter == d->m_rootSplitter) {
+ qCInfo(adsLog) << "Removed from RootSplitter";
+ // If splitter is empty, we are finished
+ if (!splitter->count()) {
+ splitter->hide();
+ emitAndExit();
+ return;
+ }
+
+ QWidget *widget = splitter->widget(0);
+ QSplitter *childSplitter = qobject_cast(widget);
+ // If the one and only content widget of the splitter is not a splitter
+ // then we are finished
+ if (!childSplitter) {
+ emitAndExit();
+ return;
+ }
+
+ // We replace the superfluous RootSplitter with the ChildSplitter
+ childSplitter->setParent(nullptr);
+ QLayoutItem *layoutItem = d->m_layout->replaceWidget(splitter, childSplitter);
+ d->m_rootSplitter = childSplitter;
+ delete layoutItem;
+ qCInfo(adsLog) << "RootSplitter replaced by child splitter";
+ } else if (splitter->count() == 1) {
+ qCInfo(adsLog) << "Replacing splitter with content";
+ QSplitter *parentSplitter = internal::findParent(splitter);
+ auto sizes = parentSplitter->sizes();
+ QWidget *widget = splitter->widget(0);
+ widget->setParent(this);
+ internal::replaceSplitterWidget(parentSplitter, splitter, widget);
+ parentSplitter->setSizes(sizes);
+ }
+
+ delete splitter;
+ }
+
+ void DockContainerWidget::emitAndExit() const
+ {
+ DockWidget *topLevelWidget = topLevelDockWidget();
+
+ // Updated the title bar visibility of the dock widget if there is only
+ // one single visible dock widget
+ DockWidget::emitTopLevelEventForWidget(topLevelWidget, true);
+ dumpLayout();
+ d->emitDockAreasRemoved();
+ }
+
+ DockAreaWidget *DockContainerWidget::dockAreaAt(const QPoint &globalPosition) const
+ {
+ for (auto dockArea : d->m_dockAreas) {
+ if (dockArea->isVisible()
+ && dockArea->rect().contains(dockArea->mapFromGlobal(globalPosition))) {
+ return dockArea;
+ }
+ }
+
+ return nullptr;
+ }
+
+ DockAreaWidget *DockContainerWidget::dockArea(int index) const
+ {
+ return (index < dockAreaCount()) ? d->m_dockAreas[index] : nullptr;
+ }
+
+ bool DockContainerWidget::isFloating() const { return d->m_isFloating; }
+
+ int DockContainerWidget::dockAreaCount() const { return d->m_dockAreas.count(); }
+
+ int DockContainerWidget::visibleDockAreaCount() const
+ {
+ int result = 0;
+ for (auto dockArea : d->m_dockAreas) {
+ result += dockArea->isHidden() ? 0 : 1;
+ }
+
+ return result;
+
+ // TODO Cache or precalculate this to speed it up because it is used during
+ // movement of floating widget
+ //return d->visibleDockAreaCount();
+ }
+
+ void DockContainerWidget::dropFloatingWidget(FloatingDockContainer *floatingWidget,
+ const QPoint &targetPosition)
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ DockWidget *singleDroppedDockWidget = floatingWidget->topLevelDockWidget();
+ DockWidget *singleDockWidget = topLevelDockWidget();
+ DockAreaWidget *dockArea = dockAreaAt(targetPosition);
+ auto dropArea = InvalidDockWidgetArea;
+ auto containerDropArea = d->m_dockManager->containerOverlay()->dropAreaUnderCursor();
+ bool dropped = false;
+
+ if (dockArea) {
+ auto dropOverlay = d->m_dockManager->dockAreaOverlay();
+ dropOverlay->setAllowedAreas(dockArea->allowedAreas());
+ dropArea = dropOverlay->showOverlay(dockArea);
+ if (containerDropArea != InvalidDockWidgetArea && containerDropArea != dropArea) {
+ dropArea = InvalidDockWidgetArea;
+ }
+
+ if (dropArea != InvalidDockWidgetArea) {
+ qCInfo(adsLog) << "Dock Area Drop Content: " << dropArea;
+ d->dropIntoSection(floatingWidget, dockArea, dropArea);
+ dropped = true;
+ }
+ }
+
+ // mouse is over container
+ if (InvalidDockWidgetArea == dropArea) {
+ dropArea = containerDropArea;
+ qCInfo(adsLog) << "Container Drop Content: " << dropArea;
+ if (dropArea != InvalidDockWidgetArea) {
+ d->dropIntoContainer(floatingWidget, dropArea);
+ dropped = true;
+ }
+ }
+
+ if (dropped) {
+ floatingWidget->deleteLater();
+
+ // If we dropped a floating widget with only one single dock widget, then we
+ // drop a top level widget that changes from floating to docked now
+ DockWidget::emitTopLevelEventForWidget(singleDroppedDockWidget, false);
+
+ // If there was a top level widget before the drop, then it is not top
+ // level widget anymore
+ DockWidget::emitTopLevelEventForWidget(singleDockWidget, false);
+ }
+ }
+
+ void DockContainerWidget::dropWidget(QWidget *widget, const QPoint &targetPosition)
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO;
+ DockWidget *singleDockWidget = topLevelDockWidget();
+ DockAreaWidget *dockArea = dockAreaAt(targetPosition);
+ auto dropArea = InvalidDockWidgetArea;
+ auto containerDropArea = d->m_dockManager->containerOverlay()->dropAreaUnderCursor();
+
+ if (dockArea) {
+ auto dropOverlay = d->m_dockManager->dockAreaOverlay();
+ dropOverlay->setAllowedAreas(dockArea->allowedAreas());
+ dropArea = dropOverlay->showOverlay(dockArea);
+ if (containerDropArea != InvalidDockWidgetArea && containerDropArea != dropArea) {
+ dropArea = InvalidDockWidgetArea;
+ }
+
+ if (dropArea != InvalidDockWidgetArea) {
+ qCInfo(adsLog) << "Dock Area Drop Content: " << dropArea;
+ d->moveToNewSection(widget, dockArea, dropArea);
+ }
+ }
+
+ // mouse is over container
+ if (InvalidDockWidgetArea == dropArea) {
+ dropArea = containerDropArea;
+ qCInfo(adsLog) << "Container Drop Content: " << dropArea;
+ if (dropArea != InvalidDockWidgetArea) {
+ d->moveToContainer(widget, dropArea);
+ }
+ }
+
+ // If there was a top level widget before the drop, then it is not top
+ // level widget anymore
+ DockWidget::emitTopLevelEventForWidget(singleDockWidget, false);
+ }
+
+ QList DockContainerWidget::openedDockAreas() const
+ {
+ QList result;
+ for (auto dockArea : d->m_dockAreas) {
+ if (!dockArea->isHidden()) {
+ result.append(dockArea);
+ }
+ }
+
+ return result;
+ }
+
+ void DockContainerWidget::saveState(QXmlStreamWriter &stream) const
+ {
+ qCInfo(adsLog) << Q_FUNC_INFO << "isFloating " << isFloating();
+
+ stream.writeStartElement("container");
+ stream.writeAttribute("floating", QVariant::fromValue(isFloating()).toString());
+ if (isFloating()) {
+ FloatingDockContainer *floatingDockContainer = floatingWidget();
+ QByteArray geometry = floatingDockContainer->saveGeometry();
+ stream.writeTextElement("geometry", QString::fromLatin1(geometry.toBase64()));
+ }
+ d->saveChildNodesState(stream, d->m_rootSplitter);
+ stream.writeEndElement();
+ }
+
+ bool DockContainerWidget::restoreState(DockingStateReader &stateReader, bool testing)
+ {
+ QVariant floatingVar = QVariant(stateReader.attributes().value("floating").toString());
+ if (!floatingVar.canConvert()) {
+ return false;
+ }
+ bool isFloating = floatingVar.value();
+ qCInfo(adsLog) << "Restore DockContainerWidget Floating" << isFloating;
+
+ QWidget *newRootSplitter{};
+ if (!testing) {
+ d->m_visibleDockAreaCount = -1; // invalidate the dock area count
+ d->m_dockAreas.clear();
+ std::fill(std::begin(d->m_lastAddedAreaCache),
+ std::end(d->m_lastAddedAreaCache),
+ nullptr);
+ }
+
+ if (isFloating) {
+ qCInfo(adsLog) << "Restore floating widget";
+ if (!stateReader.readNextStartElement() || stateReader.name() != "geometry") {
+ return false;
+ }
+
+ QByteArray geometryString = stateReader
+ .readElementText(
+ DockingStateReader::ErrorOnUnexpectedElement)
+ .toLocal8Bit();
+ QByteArray geometry = QByteArray::fromBase64(geometryString);
+ if (geometry.isEmpty()) {
+ return false;
+ }
+
+ if (!testing) {
+ FloatingDockContainer *floatingDockContainer = floatingWidget();
+ floatingDockContainer->restoreGeometry(geometry);
+ }
+ }
+
+ if (!d->restoreChildNodes(stateReader, newRootSplitter, testing)) {
+ return false;
+ }
+
+ if (testing) {
+ return true;
+ }
+
+ // If the root splitter is empty, rostoreChildNodes returns a 0 pointer
+ // and we need to create a new empty root splitter
+ if (!newRootSplitter) {
+ newRootSplitter = d->createSplitter(Qt::Horizontal);
+ }
+
+ d->m_layout->replaceWidget(d->m_rootSplitter, newRootSplitter);
+ QSplitter *oldRoot = d->m_rootSplitter;
+ d->m_rootSplitter = qobject_cast(newRootSplitter);
+ oldRoot->deleteLater();
+
+ return true;
+ }
+
+ QSplitter *DockContainerWidget::rootSplitter() const { return d->m_rootSplitter; }
+
+ void DockContainerWidget::createRootSplitter()
+ {
+ if (d->m_rootSplitter) {
+ return;
+ }
+ d->m_rootSplitter = d->createSplitter(Qt::Horizontal);
+ d->m_layout->addWidget(d->m_rootSplitter);
+ }
+
+ void DockContainerWidget::dumpLayout() const
+ {
+#if (ADS_DEBUG_LEVEL > 0)
+ qDebug("\n\nDumping layout --------------------------");
+ std::cout << "\n\nDumping layout --------------------------" << std::endl;
+ d->dumpRecursive(0, d->m_rootSplitter);
+ qDebug("--------------------------\n\n");
+ std::cout << "--------------------------\n\n" << std::endl;
+#endif
+ }
+
+ DockAreaWidget *DockContainerWidget::lastAddedDockAreaWidget(DockWidgetArea area) const
+ {
+ return d->m_lastAddedAreaCache[areaIdToIndex(area)];
+ }
+
+ bool DockContainerWidget::hasTopLevelDockWidget() const
+ {
+ if (!isFloating()) {
+ return false;
+ }
+
+ auto dockAreas = openedDockAreas();
+ if (dockAreas.count() != 1) {
+ return false;
+ }
+
+ return dockAreas[0]->openDockWidgetsCount() == 1;
+ }
+
+ DockWidget *DockContainerWidget::topLevelDockWidget() const
+ {
+ auto dockArea = topLevelDockArea();
+ if (!dockArea) {
+ return nullptr;
+ }
+
+ auto dockWidgets = dockArea->openedDockWidgets();
+ if (dockWidgets.count() != 1) {
+ return nullptr;
+ }
+
+ return dockWidgets[0];
+ }
+
+ DockAreaWidget *DockContainerWidget::topLevelDockArea() const
+ {
+ if (!isFloating()) {
+ return nullptr;
+ }
+
+ auto dockAreas = openedDockAreas();
+ if (dockAreas.count() != 1) {
+ return nullptr;
+ }
+
+ return dockAreas[0];
+ }
+
+ QList DockContainerWidget::dockWidgets() const
+ {
+ QList result;
+ for (const auto dockArea : d->m_dockAreas) {
+ result.append(dockArea->dockWidgets());
+ }
+
+ return result;
+ }
+
+ DockWidget::DockWidgetFeatures DockContainerWidget::features() const
+ {
+ DockWidget::DockWidgetFeatures features(DockWidget::AllDockWidgetFeatures);
+ for (const auto dockArea : d->m_dockAreas) {
+ features &= dockArea->features();
+ }
+
+ return features;
+ }
+
+ FloatingDockContainer *DockContainerWidget::floatingWidget() const
+ {
+ return internal::findParent(this);
+ }
+
+ void DockContainerWidget::closeOtherAreas(DockAreaWidget *keepOpenArea)
+ {
+ for (const auto dockArea : d->m_dockAreas) {
+ if (dockArea == keepOpenArea) {
+ continue;
+ }
+
+ if (!dockArea->features(BitwiseAnd).testFlag(DockWidget::DockWidgetClosable)) {
+ continue;
+ }
+
+ // We do not close areas with widgets with custom close handling
+ if (dockArea->features(BitwiseOr).testFlag(DockWidget::CustomCloseHandling)) {
+ continue;
+ }
+
+ dockArea->closeArea();
+ }
+ }
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockcontainerwidget.h b/src/libs/advanceddockingsystem/dockcontainerwidget.h
new file mode 100644
index 00000000000..497b4caa194
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockcontainerwidget.h
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include "ads_globals.h"
+#include "dockwidget.h"
+
+#include
+
+QT_BEGIN_NAMESPACE
+class QXmlStreamWriter;
+QT_END_NAMESPACE
+
+namespace ADS {
+
+class DockContainerWidgetPrivate;
+class DockAreaWidget;
+class DockWidget;
+class DockManager;
+struct DockManagerPrivate;
+class FloatingDockContainer;
+struct FloatingDockContainerPrivate;
+class FloatingDragPreview;
+struct FloatingDragPreviewPrivate;
+class DockingStateReader;
+
+/**
+ * Container that manages a number of dock areas with single dock widgets
+ * or tabyfied dock widgets in each area.
+ * Each window that support docking has a DockContainerWidget. That means
+ * the main application window and all floating windows contain
+ * a DockContainerWidget.
+ */
+class ADS_EXPORT DockContainerWidget : public QFrame
+{
+ Q_OBJECT
+private:
+ DockContainerWidgetPrivate *d; ///< private data (pimpl)
+ friend class DockContainerWidgetPrivate;
+ friend class DockManager;
+ friend struct DockManagerPrivate;
+ friend class DockAreaWidget;
+ friend struct DockAreaWidgetPrivate;
+ friend class FloatingDockContainer;
+ friend struct FloatingDockContainerPrivate;
+ friend class DockWidget;
+ friend class FloatingDragPreview;
+ friend struct FloatingDragPreviewPrivate;
+
+protected:
+ /**
+ * Handles activation events to update zOrderIndex
+ */
+ virtual bool event(QEvent *event) override;
+
+public: // TODO temporary
+ /**
+ * Access function for the internal root splitter
+ */
+ QSplitter *rootSplitter() const;
+
+protected:
+ /**
+ * Helper function for creation of the root splitter
+ */
+ void createRootSplitter();
+
+ /**
+ * Drop floating widget into the container
+ */
+ void dropFloatingWidget(FloatingDockContainer *floatingWidget, const QPoint &targetPos);
+
+ /**
+ * Drop a dock area or a dock widget given in widget parameter
+ */
+ void dropWidget(QWidget *widget, const QPoint &targetPos);
+
+ /**
+ * Adds the given dock area to this container widget
+ */
+ void addDockArea(DockAreaWidget *dockAreaWidget, DockWidgetArea area = CenterDockWidgetArea);
+
+ /**
+ * Removes the given dock area from this container
+ */
+ void removeDockArea(DockAreaWidget *area);
+
+ /**
+ * This function replaces the goto construct. Still need to write a good description.
+ */
+ void emitAndExit() const; // TODO rename
+
+ /**
+ * Saves the state into the given stream
+ */
+ void saveState(QXmlStreamWriter &stream) const;
+
+ /**
+ * Restores the state from given stream.
+ * If Testing is true, the function only parses the data from the given
+ * stream but does not restore anything. You can use this check for
+ * faulty files before you start restoring the state
+ */
+ bool restoreState(DockingStateReader &stream, bool testing);
+
+ /**
+ * This function returns the last added dock area widget for the given
+ * area identifier or 0 if no dock area widget has been added for the given
+ * area
+ */
+ DockAreaWidget *lastAddedDockAreaWidget(DockWidgetArea area) const;
+
+ /**
+ * If hasSingleVisibleDockWidget() returns true, this function returns the
+ * one and only visible dock widget. Otherwise it returns a nullptr.
+ */
+ DockWidget *topLevelDockWidget() const;
+
+ /**
+ * Returns the top level dock area.
+ */
+ DockAreaWidget *topLevelDockArea() const;
+
+ /**
+ * This function returns a list of all dock widgets in this floating widget.
+ * It may be possible, depending on the implementation, that dock widgets,
+ * that are not visible to the user have no parent widget. Therefore simply
+ * calling findChildren() would not work here. Therefore this function
+ * iterates over all dock areas and creates a list that contains all
+ * dock widgets returned from all dock areas.
+ */
+ QList dockWidgets() const;
+
+public:
+ /**
+ * Default Constructor
+ */
+ DockContainerWidget(DockManager *dockManager, QWidget *parent = nullptr);
+
+ /**
+ * Virtual Destructor
+ */
+ virtual ~DockContainerWidget() override;
+
+ /**
+ * Adds dockwidget into the given area.
+ * If DockAreaWidget is not null, then the area parameter indicates the area
+ * into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will
+ * be dropped into the container.
+ * \return Returns the dock area widget that contains the new DockWidget
+ */
+ DockAreaWidget *addDockWidget(DockWidgetArea area,
+ DockWidget *dockWidget,
+ DockAreaWidget *dockAreaWidget = nullptr);
+
+ /**
+ * Removes dockwidget
+ */
+ void removeDockWidget(DockWidget *dockWidget);
+
+ /**
+ * Returns the current zOrderIndex
+ */
+ virtual unsigned int zOrderIndex() const;
+
+ /**
+ * This function returns true if this container widgets z order index is
+ * higher than the index of the container widget given in Other parameter
+ */
+ bool isInFrontOf(DockContainerWidget *other) const;
+
+ /**
+ * Returns the dock area at the given global position or 0 if there is no
+ * dock area at this position
+ */
+ DockAreaWidget *dockAreaAt(const QPoint &globalPos) const;
+
+ /**
+ * Returns the dock area at the given Index or 0 if the index is out of
+ * range
+ */
+ DockAreaWidget *dockArea(int index) const;
+
+ /**
+ * Returns the list of dock areas that are not closed
+ * If all dock widgets in a dock area are closed, the dock area will be closed
+ */
+ QList openedDockAreas() const;
+
+ /**
+ * This function returns true if this dock area has only one single
+ * visible dock widget.
+ * A top level widget is a real floating widget. Only the isFloating()
+ * function of top level widgets may returns true.
+ */
+ bool hasTopLevelDockWidget() const;
+
+ /**
+ * Returns the number of dock areas in this container
+ */
+ int dockAreaCount() const;
+
+ /**
+ * Returns the number of visible dock areas
+ */
+ int visibleDockAreaCount() const;
+
+ /**
+ * This function returns true, if this container is in a floating widget
+ */
+ bool isFloating() const;
+
+ /**
+ * Dumps the layout for debugging purposes
+ */
+ void dumpLayout() const;
+
+ /**
+ * This functions returns the dock widget features of all dock widget in
+ * this container.
+ * A bitwise and is used to combine the flags of all dock widgets. That
+ * means, if only dock widget does not support a certain flag, the whole
+ * dock are does not support the flag.
+ */
+ DockWidget::DockWidgetFeatures features() const;
+
+ /**
+ * If this dock container is in a floating widget, this function returns
+ * the floating widget.
+ * Else, it returns a nullptr.
+ */
+ FloatingDockContainer *floatingWidget() const;
+
+ /**
+ * Call this function to close all dock areas except the KeepOpenArea
+ */
+ void closeOtherAreas(DockAreaWidget *keepOpenArea);
+
+signals:
+ /**
+ * This signal is emitted if one or multiple dock areas has been added to
+ * the internal list of dock areas.
+ * If multiple dock areas are inserted, this signal is emitted only once
+ */
+ void dockAreasAdded();
+
+ /**
+ * This signal is emitted if one or multiple dock areas has been removed
+ */
+ void dockAreasRemoved();
+
+ /**
+ * This signal is emitted if a dock area is opened or closed via
+ * toggleView() function
+ */
+ void dockAreaViewToggled(DockAreaWidget *dockArea, bool open);
+}; // class DockContainerWidget
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockingstatereader.cpp b/src/libs/advanceddockingsystem/dockingstatereader.cpp
new file mode 100644
index 00000000000..3802a608502
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockingstatereader.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockingstatereader.h"
+
+namespace ADS {
+
+void DockingStateReader::setFileVersion(int fileVersion)
+{
+ m_fileVersion = fileVersion;
+}
+
+int DockingStateReader::fileVersion() const
+{
+ return m_fileVersion;
+}
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockingstatereader.h b/src/libs/advanceddockingsystem/dockingstatereader.h
new file mode 100644
index 00000000000..00141496edb
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockingstatereader.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include
+
+namespace ADS {
+
+/**
+ * Extends QXmlStreamReader with file version information
+ */
+class DockingStateReader : public QXmlStreamReader
+{
+private:
+ int m_fileVersion;
+
+public:
+ using QXmlStreamReader::QXmlStreamReader;
+
+ /**
+ * Set the file version for this state reader
+ */
+ void setFileVersion(int fileVersion);
+
+ /**
+ * Returns the file version set via setFileVersion
+ */
+ int fileVersion() const;
+};
+
+} // namespace ADS
diff --git a/src/libs/advanceddockingsystem/dockmanager.cpp b/src/libs/advanceddockingsystem/dockmanager.cpp
new file mode 100644
index 00000000000..4e1554dff22
--- /dev/null
+++ b/src/libs/advanceddockingsystem/dockmanager.cpp
@@ -0,0 +1,820 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Uwe Kindler
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or (at your option) any later version.
+** The licenses are as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPLv21 included in the packaging
+** of this file. Please review the following information to ensure
+** the GNU Lesser General Public License version 2.1 requirements
+** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "dockmanager.h"
+
+#include "ads_globals.h"
+#include "dockareawidget.h"
+#include "dockingstatereader.h"
+#include "dockoverlay.h"
+#include "dockwidget.h"
+#include "dockwidgettab.h"
+#include "floatingdockcontainer.h"
+#include "iconprovider.h"
+
+#include "workspacedialog.h"
+
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include